Fix for focustack not being able to focus past hidden windows.

Also focusstack +2/-2 allow hidden windows to be selected using
keyboard shortcuts in order to unhide them via showhideclient.

Ref.
https://www.reddit.com/r/suckless/comments/i1c66t/how_to_make_awesomebar_patch_more_keyboard_centric/
This commit is contained in:
bakkeby 2020-08-01 16:58:43 +02:00
parent d85dc0404f
commit f87bd6c86e

22
dwm.c
View File

@ -1048,7 +1048,6 @@ clientmessage(XEvent *e)
c->next = systray->icons; c->next = systray->icons;
systray->icons = c; systray->icons = c;
XGetWindowAttributes(dpy, c->win, &wa); XGetWindowAttributes(dpy, c->win, &wa);
c->x = c->oldx = c->y = c->oldy = 0; c->x = c->oldx = c->y = c->oldy = 0;
c->w = c->oldw = wa.width; c->w = c->oldw = wa.width;
c->h = c->oldh = wa.height; c->h = c->oldh = wa.height;
@ -1609,13 +1608,8 @@ expose(XEvent *e)
void void
focus(Client *c) focus(Client *c)
{ {
#if BAR_AWESOMEBAR_PATCH
if (!c || !ISVISIBLE(c) || HIDDEN(c))
for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext);
#else
if (!c || !ISVISIBLE(c)) if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
#endif // BAR_AWESOMEBAR_PATCH
if (selmon->sel && selmon->sel != c) if (selmon->sel && selmon->sel != c)
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0);
if (c) { if (c) {
@ -1682,6 +1676,21 @@ focusstack(const Arg *arg)
if (selmon->sel->isfullscreen) if (selmon->sel->isfullscreen)
return; return;
#endif // ALWAYSFULLSCREEN_PATCH #endif // ALWAYSFULLSCREEN_PATCH
#if BAR_AWESOMEBAR_PATCH
if (arg->i > 0) {
for (c = selmon->sel->next; c && (!ISVISIBLE(c) || (arg->i == 1 && HIDDEN(c))); c = c->next);
if (!c)
for (c = selmon->clients; c && (!ISVISIBLE(c) || (arg->i == 1 && HIDDEN(c))); c = c->next);
} else {
for (i = selmon->clients; i != selmon->sel; i = i->next)
if (ISVISIBLE(i) && !(arg->i == -1 && HIDDEN(i)))
c = i;
if (!c)
for (; i; i = i->next)
if (ISVISIBLE(i) && !(arg->i == -1 && HIDDEN(i)))
c = i;
}
#else
if (arg->i > 0) { if (arg->i > 0) {
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
if (!c) if (!c)
@ -1695,6 +1704,7 @@ focusstack(const Arg *arg)
if (ISVISIBLE(i)) if (ISVISIBLE(i))
c = i; c = i;
} }
#endif // BAR_AWESOMEBAR_PATCH
if (c) { if (c) {
focus(c); focus(c);
restack(selmon); restack(selmon);