conformal / spectrwm

A small dynamic tiling window manager for X11.
ISC License
1.33k stars 96 forks source link

fix focusing urgent windows on current workspace #575

Closed vqns closed 3 months ago

vqns commented 3 months ago

Fix focus_urgent not focusing previous urgent windows in the current workspace.

Alternative patch, which prioritizes previous urgent windows in the current workspace over urgent windows in the next workspaces:

diff --git a/spectrwm.c b/spectrwm.c
index 282ca0a..ad6017a 100644
--- a/spectrwm.c
+++ b/spectrwm.c
@@ -7569,6 +7569,21 @@ focus(struct swm_screen *s, struct binding *bp, union arg *args)
                head = TAILQ_NEXT(head, entry);
            }

+           if (i == 0 && !winfocus) {
+               head = TAILQ_FIRST(&(cws ? cws : ws)->winlist);
+               while (head) {
+                   if (head == cur_focus) {
+                       head = NULL;
+                       break;
+                   } else if (win_urgent(head)) {
+                       winfocus = head;
+                       break;
+                   }
+
+                   head = TAILQ_NEXT(head, entry);
+               }
+           }
+
            if (winfocus)
                break;
        }
LordReg commented 3 months ago

Nice catch

The issue with searching for previous urgent windows before continuing to the next workspace is that a program may not actually clear the urgency bit when it gets focused. It is possible to get stuck when invoking focus_urgent repeatedly to search through all the urgent windows.