dwm - Custom fork of dwm
ssh://anon@thyssentishman.com/dwm
Log | Files | Refs | Feed | Contribute | README | LICENSE

Commit: 07e6317b84e5e836c4e9ed0e2bda0a00d154ed12
Parent: 3ccd4068d8062de80e4d81123ee9a7b98eaccb03
Author: Johannes Thyssen Tishman
Date:   Tue,  9 Apr 2024 12:04:29 +0000

Use pointer arithmetic for getting desktop number

Diffstat:
M dwm.c | 16 ++++++----------

1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/dwm.c b/dwm.c
@@ -2086,11 +2086,9 @@ void
 updateclientdesktop(Client *c)
 {
 	long rawdata[] = { c->tags };
-	int i = 0;
-	while(*rawdata >> (i + 1)){
-		i++;
-	}
-	long data[] = { i + 1 };
+	long data[] = { 1 };
+	while (*rawdata >> *data)
+		(*data)++;
 	XChangeProperty(dpy, c->win, netatom[NetWMDesktop], XA_CARDINAL, 32,
 			PropModeReplace, (unsigned char *)data, 1);
 }
@@ -2113,11 +2111,9 @@ void
 updatecurrentdesktop(void)
 {
 	long rawdata[] = { selmon->tagset[selmon->seltags] };
-	int i = 0;
-	while(*rawdata >> (i + 1)){
-		i++;
-	}
-	long data[] = { i + 1 };
+	long data[] = { 1 };
+	while (*rawdata >> *data)
+		(*data)++;
 	XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32,
 		PropModeReplace, (unsigned char *)data, 1);
 }