Fix small edge cases
Fix case where only windows available are sticky
Fix case where stack is empty sometimes segfaulting
@@ -951,8 +951,13 @@ expose(XEvent *e)
void
focus(Client *c)
{
- if (!c || !ISVISIBLE(c))
- for (c = selmon->stack; c && (!ISVISIBLE(c) || c->issticky); c = c->snext);
+ if (!c || !ISVISIBLE(c)) {
+ for (c = selmon->stack; c && (!ISVISIBLE(c) || (c->issticky && !selmon->sel->issticky)); c = c->snext);
+
+ if (!c) /* No windows found; check for available stickies */
+ for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
+ }
+
if (selmon->sel && selmon->sel != c)
unfocus(selmon->sel, 0);
if (c) {
