On Tue, Jan 21, 2025 at 08:27:53PM +0100, Hiltjo Posthuma wrote:
> 
> Thanks for the patch, at a glance it looks good.
> 
> Can anyone confirm this makes sense. I do not use gnome-shell myself.
 
Hi,

I made following patch to tabbed.c:

diff --git a/Makefile b/Makefile
index dda3cdb..964ef86 100644
diff --git a/tabbed.c b/tabbed.c
index e5664aa..40b31db 100644
--- a/tabbed.c
+++ b/tabbed.c
@@ -482,6 +482,9 @@ focus(int c)
                XFree(wmh);
        }
 
+       XWMHints *win_wmh = XGetWMHints(dpy, win);
+       printf("%s: win_wmh->flags=0x%lx\n", __func__, win_wmh->flags);
+
        drawbar();
        XSync(dpy, False);
 }

It prints hint flags for the parent window on every focus() call, then I
launched ./tabbed in a terminal and opened two tabs, in one of them
executed "sleep 2 && printf '\a'", then quickly switched to another tab.

When the bell has rung, urgency hint has been displayed on the tab,
switching to it cleared the tab color notification as expected, but on
the another switch back to the first tab, and on every further switches
between the tabs, in the console I can see:

focus: win_wmh->flags=0x100

(1 << 8) is the urgency hint.

I tested openbsd-current/cwm, debian-testing/xfce, and ubuntu/gnome - on
each of them urgency hint for the container window had been set on the
first urgency notification and not cleared afterwards, the result of it
is indefinite blinking and twitching of the tabbed icon/window button in
XFCE and Gnome, which can't be stopped by switching to the urgency tab,
the only was to stop it - tabbed restart.

I'm sorry for all that back and forth for such simple patch, I should
have tested more OS'es/DEs and present the results right in the first
mail and state the problem more clearly, also the patch I made in the
beginning was the one I sent second, without memory leak, late
simplification and over engineering always causes mistakes. Not my day,
definitely.

Here is the same patch with better commit message, I hope it's now clear
the problem I'm trying to fix and this way it can be easier for the
maintainers to decide.

>From e3355c4fcc4f8e9d7c6835067505b6db2c1ba006 Mon Sep 17 00:00:00 2001
From: Mikhail Pchelin <mi...@freebsd.org>
Date: Tue, 21 Jan 2025 19:01:13 +0300
Subject: [PATCH] focus(): clear XUrgencyHint from the container window

When urgency hint is cleared from the child window, it's not being
cleared for the parent (container) one and this bit is left uncleared
for the time of the whole tabbed session.

The result of the previous behavior was that it wasn't possible to clear
urgency alarm (blinking and twitching of the icon/window button on the
taskbar) in DE's like XFCE and Gnome - when the user hit urgency event
and switched to the tab, the DE continued to issue the alarms, the only
way to stop this was to restart tabbed.
---
 tabbed.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tabbed.c b/tabbed.c
index e5664aa..aa45716 100644
--- a/tabbed.c
+++ b/tabbed.c
@@ -447,6 +447,7 @@ focus(int c)
        char buf[BUFSIZ] = "tabbed-"VERSION" ::";
        size_t i, n;
        XWMHints* wmh;
+       XWMHints* win_wmh;
 
        /* If c, sel and clients are -1, raise tabbed-win itself */
        if (nclients == 0) {
@@ -480,6 +481,17 @@ focus(int c)
                XSetWMHints(dpy, clients[c]->win, wmh);
                clients[c]->urgent = False;
                XFree(wmh);
+
+               /*
+                * gnome-shell will not stop notifying us about urgency,
+                * if we clear only the client hint and don't clear the
+                * hint from the main container window
+                */
+               if ((win_wmh = XGetWMHints(dpy, win))) {
+                       win_wmh->flags &= ~XUrgencyHint;
+                       XSetWMHints(dpy, win, win_wmh);
+                       XFree(win_wmh);
+               }
        }
 
        drawbar();
-- 
2.45.2


Reply via email to