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
|
@ -414,4 +414,25 @@ void ensureactive() {
|
||||||
void ensureactiveonmonitor(int monitor) {
|
void ensureactiveonmonitor(int monitor) {
|
||||||
if (!current)
|
if (!current)
|
||||||
shuffleonmonitor(monitor);
|
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) {
|
void unmap(XUnmapEvent* e) {
|
||||||
Client* c;
|
Client *c, *revertc;
|
||||||
int monitor;
|
Window revert;
|
||||||
|
int m;
|
||||||
|
|
||||||
curtime = CurrentTime;
|
curtime = CurrentTime;
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
monitor = getmonitorbyclient(c);
|
m = getmonitorbyclient(c);
|
||||||
switch (c->state) {
|
switch (c->state) {
|
||||||
case IconicState:
|
case IconicState:
|
||||||
if (e->send_event) {
|
if (e->send_event) {
|
||||||
|
@ -271,8 +272,14 @@ void unmap(XUnmapEvent* e) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NormalState:
|
case NormalState:
|
||||||
if (c == current)
|
if (c == current) {
|
||||||
shuffleonmonitor(monitor);
|
if (revertc = getclient(getrevert(c), 0)) {
|
||||||
|
top(revertc);
|
||||||
|
active(revertc);
|
||||||
|
} else {
|
||||||
|
shuffleonmonitor(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!c->reparenting)
|
if (!c->reparenting)
|
||||||
withdraw(c);
|
withdraw(c);
|
||||||
break;
|
break;
|
||||||
|
@ -345,7 +352,8 @@ void newwindow(XCreateWindowEvent* e) {
|
||||||
|
|
||||||
void destroy(Window w) {
|
void destroy(Window w) {
|
||||||
int i;
|
int i;
|
||||||
Client* c;
|
Client *c, *revertc;
|
||||||
|
Window revert;
|
||||||
int monitor;
|
int monitor;
|
||||||
|
|
||||||
curtime = CurrentTime;
|
curtime = CurrentTime;
|
||||||
|
@ -353,14 +361,20 @@ void destroy(Window w) {
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
revert = getrevert(c);
|
||||||
monitor = getmonitorbyclient(c);
|
monitor = getmonitorbyclient(c);
|
||||||
|
|
||||||
if (numvirtuals > 1)
|
if (numvirtuals > 1)
|
||||||
for (i = 0; i < numvirtuals; i++)
|
for (i = 0; i < numvirtuals; i++)
|
||||||
if (currents[i] == c)
|
if (currents[i] == c)
|
||||||
currents[i] = 0;
|
currents[i] = 0;
|
||||||
|
|
||||||
rmclient(c);
|
rmclient(c);
|
||||||
ensureactiveonmonitor(monitor);
|
|
||||||
|
if (!current && (revertc = getclient(revert, 0))) {
|
||||||
|
top(revertc);
|
||||||
|
active(revertc);
|
||||||
|
}
|
||||||
|
|
||||||
/* flush any errors generated by the window's sudden demise */
|
/* flush any errors generated by the window's sudden demise */
|
||||||
ignore_badwindow = 1;
|
ignore_badwindow = 1;
|
||||||
|
@ -383,8 +397,10 @@ void clientmesg(XClientMessageEvent* e) {
|
||||||
perror("ryudo: exec failed");
|
perror("ryudo: exec failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (e->message_type == wm_protocols)
|
|
||||||
|
if (e->message_type == wm_protocols) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (e->message_type == wm_change_state) {
|
if (e->message_type == wm_change_state) {
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (e->format == 32 && e->data.l[0] == IconicState && c != 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 ensureactive();
|
||||||
void ensureactiveonmonitor(int);
|
void ensureactiveonmonitor(int);
|
||||||
void shuffleonmonitor(int);
|
void shuffleonmonitor(int);
|
||||||
|
Window getrevert(Client*);
|
||||||
|
|
||||||
/* grab.c */
|
/* grab.c */
|
||||||
int menuhit();
|
int menuhit();
|
||||||
|
|
27
menu.c
27
menu.c
|
@ -310,19 +310,30 @@ void move(Client* c, int but) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete (Client* c, int shift) {
|
void delete (Client* c, int shift) {
|
||||||
// int v;
|
Client* revertc;
|
||||||
|
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
return;
|
return;
|
||||||
// v = c->virt;
|
|
||||||
|
if (c == current) {
|
||||||
|
if (revertc = getclient(getrevert(c), 0)) {
|
||||||
|
top(revertc);
|
||||||
|
active(revertc);
|
||||||
|
} else {
|
||||||
|
nofocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((c->proto & Pdelete) && !shift)
|
if ((c->proto & Pdelete) && !shift)
|
||||||
sendcmessage(c->window, wm_protocols, wm_delete, 0, 0);
|
sendcmessage(c->window, wm_protocols, wm_delete, 0, 0);
|
||||||
else
|
else
|
||||||
XKillClient(dpy, c->window); /* let event clean up */
|
XKillClient(dpy, c->window); /* let event clean up */
|
||||||
ensureactive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hide(Client* c) {
|
void hide(Client* c) {
|
||||||
int monitor;
|
int monitor;
|
||||||
|
Client* revertc;
|
||||||
|
|
||||||
if (c == 0 || numhidden == MAXHIDDEN)
|
if (c == 0 || numhidden == MAXHIDDEN)
|
||||||
return;
|
return;
|
||||||
if (hidden(c)) {
|
if (hidden(c)) {
|
||||||
|
@ -333,8 +344,14 @@ void hide(Client* c) {
|
||||||
XUnmapWindow(dpy, c->parent);
|
XUnmapWindow(dpy, c->parent);
|
||||||
XUnmapWindow(dpy, c->window);
|
XUnmapWindow(dpy, c->window);
|
||||||
setstate(c, IconicState);
|
setstate(c, IconicState);
|
||||||
if (c == current)
|
if (c == current) {
|
||||||
nofocus();
|
if (revertc = getclient(getrevert(c), 0)) {
|
||||||
|
top(revertc);
|
||||||
|
active(revertc);
|
||||||
|
} else {
|
||||||
|
nofocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (reversehide) {
|
if (reversehide) {
|
||||||
memmove(hiddenc + 1, hiddenc, numhidden * sizeof hiddenc[0]);
|
memmove(hiddenc + 1, hiddenc, numhidden * sizeof hiddenc[0]);
|
||||||
memmove(
|
memmove(
|
||||||
|
|
Loading…
Reference in a new issue