aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-07-24 16:21:12 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-07-24 16:21:12 +0100
commit7c67af1e810d549c9a85525498217fc40bd92e27 (patch)
tree9e155e70695ef02ffb597dfcb84c8355ba2ff494
parenta5ef1a0a857849164ac300520050810e13615f7b (diff)
downloaddwm-7c67af1e810d549c9a85525498217fc40bd92e27.tar.gz
dwm-7c67af1e810d549c9a85525498217fc40bd92e27.tar.bz2
dwm-7c67af1e810d549c9a85525498217fc40bd92e27.zip
Defer focusing on sticky windows on switching tags
focus(NULL) is called when switching to a new tag or monitor. I don't want sticky windows to get first focus in this situation, hence this code. Shamelessly stolen from https://github.com/LukeSmithxyz/dwm/issues/152.
-rw-r--r--dwm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/dwm.c b/dwm.c
index 1a88bf2..0445327 100644
--- a/dwm.c
+++ b/dwm.c
@@ -906,8 +906,14 @@ expose(XEvent *e)
void
focus(Client *c)
{
- if (!c || !ISVISIBLE(c))
- for (c = selmon->stack; c && !ISVISIBLE(c); 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) {