fix heuristics for focusing windows after hiding or deleting current
This commit is contained in:
parent
1f72f88bde
commit
4ad722c1aa
4 changed files with 68 additions and 13 deletions
21
client.c
21
client.c
|
@ -415,3 +415,24 @@ void ensureactiveonmonitor(int monitor) {
|
|||
if (!current)
|
||||
shuffleonmonitor(monitor);
|
||||
}
|
||||
|
||||
Window getrevert(Client* c) {
|
||||
int m;
|
||||
Client* cc;
|
||||
|
||||
if (!c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (c->trans) {
|
||||
return c->trans;
|
||||
} else {
|
||||
m = getmonitorbyclient(c);
|
||||
for (cc = c->revert; cc && cc->revert; cc = cc->revert) {
|
||||
if (getmonitorbyclient(cc) == m) {
|
||||
return cc->window;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
32
event.c
32
event.c
|
@ -255,14 +255,15 @@ void mapreq(XMapRequestEvent* e) {
|
|||
}
|
||||
|
||||
void unmap(XUnmapEvent* e) {
|
||||
Client* c;
|
||||
int monitor;
|
||||
Client *c, *revertc;
|
||||
Window revert;
|
||||
int m;
|
||||
|
||||
curtime = CurrentTime;
|
||||
c = getclient(e->window, 0);
|
||||
|
||||
if (c) {
|
||||
monitor = getmonitorbyclient(c);
|
||||
m = getmonitorbyclient(c);
|
||||
switch (c->state) {
|
||||
case IconicState:
|
||||
if (e->send_event) {
|
||||
|
@ -271,8 +272,14 @@ void unmap(XUnmapEvent* e) {
|
|||
}
|
||||
break;
|
||||
case NormalState:
|
||||
if (c == current)
|
||||
shuffleonmonitor(monitor);
|
||||
if (c == current) {
|
||||
if (revertc = getclient(getrevert(c), 0)) {
|
||||
top(revertc);
|
||||
active(revertc);
|
||||
} else {
|
||||
shuffleonmonitor(m);
|
||||
}
|
||||
}
|
||||
if (!c->reparenting)
|
||||
withdraw(c);
|
||||
break;
|
||||
|
@ -345,7 +352,8 @@ void newwindow(XCreateWindowEvent* e) {
|
|||
|
||||
void destroy(Window w) {
|
||||
int i;
|
||||
Client* c;
|
||||
Client *c, *revertc;
|
||||
Window revert;
|
||||
int monitor;
|
||||
|
||||
curtime = CurrentTime;
|
||||
|
@ -353,14 +361,20 @@ void destroy(Window w) {
|
|||
if (c == 0)
|
||||
return;
|
||||
|
||||
revert = getrevert(c);
|
||||
monitor = getmonitorbyclient(c);
|
||||
|
||||
if (numvirtuals > 1)
|
||||
for (i = 0; i < numvirtuals; i++)
|
||||
if (currents[i] == c)
|
||||
currents[i] = 0;
|
||||
|
||||
rmclient(c);
|
||||
ensureactiveonmonitor(monitor);
|
||||
|
||||
if (!current && (revertc = getclient(revert, 0))) {
|
||||
top(revertc);
|
||||
active(revertc);
|
||||
}
|
||||
|
||||
/* flush any errors generated by the window's sudden demise */
|
||||
ignore_badwindow = 1;
|
||||
|
@ -383,8 +397,10 @@ void clientmesg(XClientMessageEvent* e) {
|
|||
perror("ryudo: exec failed");
|
||||
exit(1);
|
||||
}
|
||||
if (e->message_type == wm_protocols)
|
||||
|
||||
if (e->message_type == wm_protocols) {
|
||||
return;
|
||||
}
|
||||
if (e->message_type == wm_change_state) {
|
||||
c = getclient(e->window, 0);
|
||||
if (e->format == 32 && e->data.l[0] == IconicState && c != 0) {
|
||||
|
|
1
fns.h
1
fns.h
|
@ -103,6 +103,7 @@ int isterminalwindow(Client* c);
|
|||
void ensureactive();
|
||||
void ensureactiveonmonitor(int);
|
||||
void shuffleonmonitor(int);
|
||||
Window getrevert(Client*);
|
||||
|
||||
/* grab.c */
|
||||
int menuhit();
|
||||
|
|
25
menu.c
25
menu.c
|
@ -310,19 +310,30 @@ void move(Client* c, int but) {
|
|||
}
|
||||
|
||||
void delete (Client* c, int shift) {
|
||||
// int v;
|
||||
Client* revertc;
|
||||
|
||||
if (c == 0)
|
||||
return;
|
||||
// v = c->virt;
|
||||
|
||||
if (c == current) {
|
||||
if (revertc = getclient(getrevert(c), 0)) {
|
||||
top(revertc);
|
||||
active(revertc);
|
||||
} else {
|
||||
nofocus();
|
||||
}
|
||||
}
|
||||
|
||||
if ((c->proto & Pdelete) && !shift)
|
||||
sendcmessage(c->window, wm_protocols, wm_delete, 0, 0);
|
||||
else
|
||||
XKillClient(dpy, c->window); /* let event clean up */
|
||||
ensureactive();
|
||||
}
|
||||
|
||||
void hide(Client* c) {
|
||||
int monitor;
|
||||
Client* revertc;
|
||||
|
||||
if (c == 0 || numhidden == MAXHIDDEN)
|
||||
return;
|
||||
if (hidden(c)) {
|
||||
|
@ -333,8 +344,14 @@ void hide(Client* c) {
|
|||
XUnmapWindow(dpy, c->parent);
|
||||
XUnmapWindow(dpy, c->window);
|
||||
setstate(c, IconicState);
|
||||
if (c == current)
|
||||
if (c == current) {
|
||||
if (revertc = getclient(getrevert(c), 0)) {
|
||||
top(revertc);
|
||||
active(revertc);
|
||||
} else {
|
||||
nofocus();
|
||||
}
|
||||
}
|
||||
if (reversehide) {
|
||||
memmove(hiddenc + 1, hiddenc, numhidden * sizeof hiddenc[0]);
|
||||
memmove(
|
||||
|
|
Loading…
Reference in a new issue