From 125a12548fec6560579a9586178804ba0cfad2f0 Mon Sep 17 00:00:00 2001 From: Ethan Marshall Date: Sun, 5 Dec 2021 16:55:06 +0000 Subject: [PATCH 1/2] Initial fix for sticky switching --- dwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 929f878..adafb3c 100644 --- a/dwm.c +++ b/dwm.c @@ -952,7 +952,7 @@ void focus(Client *c) { if (!c || !ISVISIBLE(c)) - for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); + for (c = selmon->stack; c && (!ISVISIBLE(c) || c->issticky); c = c->snext); if (selmon->sel && selmon->sel != c) unfocus(selmon->sel, 0); if (c) { From 7e843c47ba573ab03a62f06638c297b9da7e5e75 Mon Sep 17 00:00:00 2001 From: Ethan Marshall Date: Sun, 5 Dec 2021 17:01:20 +0000 Subject: [PATCH 2/2] Fix small edge cases Fix case where only windows available are sticky Fix case where stack is empty sometimes segfaulting --- dwm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dwm.c b/dwm.c index adafb3c..d752216 100644 --- a/dwm.c +++ b/dwm.c @@ -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) {