]> Skullheadx's Git Forge - dwm.git/commitdiff
buttonpress: fix status text click area mismatch
authorRuben Gonzalez <gonzaru@sdf.org>
Fri, 13 Mar 2026 13:23:24 +0000 (15:23 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 13 Mar 2026 17:27:18 +0000 (18:27 +0100)
The status bar in drawbar() calculates the text width as TEXTW(stext)
- lrpad + 2. However, the click detection in buttonpress() used
TEXTW(stext) without adjusting for that padding.

This created an "extra" clickable area of some pixels to the left of
the status text that would incorrectly trigger ClkStatusText actions
instead of ClkWinTitle.

Steps to reproduce:
1. Set a status text: xsetroot -name "HELLO"
2. Move the mouse to the empty space with some pixels close to the
left of the word "HELLO" but in the title area.
3. Middle-click (or any binding for ClkStatusText).
4. You can see that the status bar action is triggered (default a
terminal spawns), even though you clicked in the window title area.

This fix ensures that the clickable area matches the visual text.

dwm.c

diff --git a/dwm.c b/dwm.c
index 6fe226f3dff5800cea8689e5b326d3f03345aa2f..ab3a84c007fd68b9a8db620256971cd1c82e92de 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -440,7 +440,7 @@ buttonpress(XEvent *e)
                        arg.ui = 1 << i;
                } else if (ev->x < x + TEXTW(selmon->ltsymbol))
                        click = ClkLtSymbol;
-               else if (ev->x > selmon->ww - (int)TEXTW(stext))
+               else if (ev->x > selmon->ww - (int)TEXTW(stext) + lrpad - 2)
                        click = ClkStatusText;
                else
                        click = ClkWinTitle;