From 60646c2a2f1e16aaa121c00001937a7a79c25f91 Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 12 Nov 2022 14:02:56 +0100 Subject: [PATCH] Add toggle for focusonnetactive --- docs/example.Xresources | 1 + options.h | 1 + speedwm.c | 5 +++++ xresources.h | 1 + 4 files changed, 8 insertions(+) diff --git a/docs/example.Xresources b/docs/example.Xresources index 938e8f2..db1bd45 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -44,6 +44,7 @@ !! Client options !@ - speedwm.client.allowurgent: 1 ! Allow windows to have the 'urgent' status (0/1) + - speedwm.client.autofocus: 0 ! Allow windows to focus themselves on demand. This may be annoying depending on what software you use and is disabled by default for this reason (0/1) - speedwm.client.autoresize: 0 ! Allow windows to resize themselves on demand (0/1) - speedwm.client.decorhints: 1 ! Respect decoration hints for windows (0/1) - speedwm.client.fade.inactive: 1 ! Fade inactive windows (windows that are not focused) (0/1) diff --git a/options.h b/options.h index a2504c2..d69cabd 100644 --- a/options.h +++ b/options.h @@ -128,6 +128,7 @@ static int centerfloating = 1; /* Center floating windows by static int startontag = 1; /* Start on a tag or not? */ static int floatscratchpad = 0; /* Float the scratchpad window on hide (1/0) */ static int focusspawn = 0; /* Automatically focus the next spawned window. If warp is enabled, this is useless and will be disabled. (1/0) */ +static int autofocus = 0; /* Allow clients to automatically be focused when they request it. This comes with the side effect of potentially being annoying */ static int autoresize = 0; /* Allow resizing clients automatically when they request it. */ /* Font options diff --git a/speedwm.c b/speedwm.c index cdf5c40..2081da5 100644 --- a/speedwm.c +++ b/speedwm.c @@ -1541,6 +1541,10 @@ clientmessage(XEvent *e) setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); } else if (cme->message_type == netatom[NetActiveWindow]) { + if (!autofocus) { + if (c != selmon->sel && !c->isurgent) + seturgent(c, 1); + } else { for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); if (i < LENGTH(tags)) { const Arg a = {.ui = 1 << i}; @@ -1549,6 +1553,7 @@ clientmessage(XEvent *e) focus(c); restack(selmon); } + } } } diff --git a/xresources.h b/xresources.h index d7c00f6..bb408f8 100644 --- a/xresources.h +++ b/xresources.h @@ -124,6 +124,7 @@ ResourcePref resources[] = { { "focus.spawned", INTEGER, &focusspawn }, { "client.floatscratchpad", INTEGER, &floatscratchpad }, { "bar.altbar", INTEGER, &altbar }, + { "client.autofocus", INTEGER, &autofocus }, { "client.autoresize", INTEGER, &autoresize }, { "mfact", FLOAT, &mfact }, { "mfact.lowest", FLOAT, &lowestmfact },