[hackers] [dwm][PATCH] miscalculation of status text width at buttonpress()

From: Petros Pateros <petratman_AT_gmail.com>
Date: Thu, 29 Apr 2021 11:24:58 +0300

This resulted in mistakenly recognizing ClkWinTitle clicks
as ClkStatusText. The problem is that TEXTW(stext) does not
return the width of the status text.
---
 dwm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dwm.c b/dwm.c
index b0b3466..025be5b 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -56,6 +56,7 @@
 #define HEIGHT(X)               ((X)->h + 2 * (X)->bw)
 #define TAGMASK                 ((1 << LENGTH(tags)) - 1)
 #define TEXTW(X)                (drw_fontset_getwidth(drw, (X)) + lrpad)
+#define STEXTW                  (TEXTW(stext) - lrpad + 2) /* 2px right padding */
 
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
_AT_@ -440,7 +441,7 @@ buttonpress(XEvent *e)
 			arg.ui = 1 << i;
 		} else if (ev->x < x + blw)
 			click = ClkLtSymbol;
-		else if (ev->x > selmon->ww - (int)TEXTW(stext))
+		else if (ev->x > selmon->ww - (int)STEXTW)
 			click = ClkStatusText;
 		else
 			click = ClkWinTitle;
_AT_@ -705,7 +706,7 @@ drawbar(Monitor *m)
 	/* draw status first so it can be overdrawn by tags later */
 	if (m == selmon) { /* status is only drawn on selected monitor */
 		drw_setscheme(drw, scheme[SchemeNorm]);
-		tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+		tw = STEXTW;
 		drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
 	}
 
-- 
2.31.1
Received on Thu Apr 29 2021 - 10:24:58 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 29 2021 - 11:36:37 CEST