dwm-notags-20250618-cfb8627.diff - sites - public wiki contents of suckless.org
HTML git clone git://git.suckless.org/sites
DIR Log
DIR Files
DIR Refs
---
dwm-notags-20250618-cfb8627.diff (14480B)
---
1 From dad55f720cc88c239253e52690c22d0797961a72 Mon Sep 17 00:00:00 2001
2 From: Farlado <stultasergalo@gmail.com>
3 Date: Wed, 18 Jun 2025 22:12:13 -0400
4 Subject: [PATCH] Remove client tagging
5
6 ---
7 config.def.h | 30 ++----------
8 dwm.c | 135 ++++++---------------------------------------------
9 2 files changed, 19 insertions(+), 146 deletions(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index 9efa774..fbfa63f 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -18,17 +18,14 @@ static const char *colors[][3] = {
16 [SchemeSel] = { col_gray4, col_cyan, col_cyan },
17 };
18
19 -/* tagging */
20 -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
21 -
22 static const Rule rules[] = {
23 /* xprop(1):
24 * WM_CLASS(STRING) = instance, class
25 * WM_NAME(STRING) = title
26 */
27 - /* class instance title tags mask isfloating monitor */
28 - { "Gimp", NULL, NULL, 0, 1, -1 },
29 - { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
30 + /* class instance title isfloating monitor */
31 + { "Gimp", NULL, NULL, 1, -1 },
32 + { "Firefox", NULL, NULL, 0, -1 },
33 };
34
35 /* layout(s) */
36 @@ -46,11 +43,6 @@ static const Layout layouts[] = {
37
38 /* key definitions */
39 #define MODKEY Mod1Mask
40 -#define TAGKEYS(KEY,TAG) \
41 - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
42 - { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
43 - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
44 - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
45
46 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
47 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
48 @@ -72,28 +64,16 @@ static const Key keys[] = {
49 { MODKEY, XK_h, setmfact, {.f = -0.05} },
50 { MODKEY, XK_l, setmfact, {.f = +0.05} },
51 { MODKEY, XK_Return, zoom, {0} },
52 - { MODKEY, XK_Tab, view, {0} },
53 { MODKEY|ShiftMask, XK_c, killclient, {0} },
54 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
55 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
56 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
57 { MODKEY, XK_space, setlayout, {0} },
58 { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
59 - { MODKEY, XK_0, view, {.ui = ~0 } },
60 - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
61 { MODKEY, XK_comma, focusmon, {.i = -1 } },
62 { MODKEY, XK_period, focusmon, {.i = +1 } },
63 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
64 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
65 - TAGKEYS( XK_1, 0)
66 - TAGKEYS( XK_2, 1)
67 - TAGKEYS( XK_3, 2)
68 - TAGKEYS( XK_4, 3)
69 - TAGKEYS( XK_5, 4)
70 - TAGKEYS( XK_6, 5)
71 - TAGKEYS( XK_7, 6)
72 - TAGKEYS( XK_8, 7)
73 - TAGKEYS( XK_9, 8)
74 { MODKEY|ShiftMask, XK_q, quit, {0} },
75 };
76
77 @@ -108,9 +88,5 @@ static const Button buttons[] = {
78 { ClkClientWin, MODKEY, Button1, movemouse, {0} },
79 { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
80 { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
81 - { ClkTagBar, 0, Button1, view, {0} },
82 - { ClkTagBar, 0, Button3, toggleview, {0} },
83 - { ClkTagBar, MODKEY, Button1, tag, {0} },
84 - { ClkTagBar, MODKEY, Button3, toggletag, {0} },
85 };
86
87 diff --git a/dwm.c b/dwm.c
88 index 1443802..ace2a3b 100644
89 --- a/dwm.c
90 +++ b/dwm.c
91 @@ -13,10 +13,9 @@
92 * Each child of the root window is called a client, except windows which have
93 * set the override_redirect flag. Clients are organized in a linked client
94 * list on each monitor, the focus history is remembered through a stack list
95 - * on each monitor. Each client contains a bit array to indicate the tags of a
96 - * client.
97 + * on each monitor.
98 *
99 - * Keys and tagging rules are organized as arrays and defined in config.h.
100 + * Keys are organized as arrays and defined in config.h.
101 *
102 * To understand everything else, start reading main().
103 */
104 @@ -49,11 +48,10 @@
105 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
106 #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
107 * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
108 -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
109 +#define ISVISIBLE(C) 1 /* FIXME: I am lazy and for now this isn't causing unexpected behavior on my end */
110 #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
111 #define WIDTH(X) ((X)->w + 2 * (X)->bw)
112 #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
113 -#define TAGMASK ((1 << LENGTH(tags)) - 1)
114 #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
115
116 /* enums */
117 @@ -90,7 +88,6 @@ struct Client {
118 int oldx, oldy, oldw, oldh;
119 int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
120 int bw, oldbw;
121 - unsigned int tags;
122 int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
123 Client *next;
124 Client *snext;
125 @@ -118,9 +115,7 @@ struct Monitor {
126 int by; /* bar geometry */
127 int mx, my, mw, mh; /* screen size */
128 int wx, wy, ww, wh; /* window area */
129 - unsigned int seltags;
130 unsigned int sellt;
131 - unsigned int tagset[2];
132 int showbar;
133 int topbar;
134 Client *clients;
135 @@ -135,7 +130,6 @@ typedef struct {
136 const char *class;
137 const char *instance;
138 const char *title;
139 - unsigned int tags;
140 int isfloating;
141 int monitor;
142 } Rule;
143 @@ -205,13 +199,10 @@ static void setup(void);
144 static void seturgent(Client *c, int urg);
145 static void showhide(Client *c);
146 static void spawn(const Arg *arg);
147 -static void tag(const Arg *arg);
148 static void tagmon(const Arg *arg);
149 static void tile(Monitor *m);
150 static void togglebar(const Arg *arg);
151 static void togglefloating(const Arg *arg);
152 -static void toggletag(const Arg *arg);
153 -static void toggleview(const Arg *arg);
154 static void unfocus(Client *c, int setfocus);
155 static void unmanage(Client *c, int destroyed);
156 static void unmapnotify(XEvent *e);
157 @@ -225,7 +216,6 @@ static void updatestatus(void);
158 static void updatetitle(Client *c);
159 static void updatewindowtype(Client *c);
160 static void updatewmhints(Client *c);
161 -static void view(const Arg *arg);
162 static Client *wintoclient(Window w);
163 static Monitor *wintomon(Window w);
164 static int xerror(Display *dpy, XErrorEvent *ee);
165 @@ -270,9 +260,6 @@ static Window root, wmcheckwin;
166 /* configuration, allows nested code to access above variables */
167 #include "config.h"
168
169 -/* compile-time check if all tags fit into an unsigned int bit array. */
170 -struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
171 -
172 /* function implementations */
173 void
174 applyrules(Client *c)
175 @@ -285,7 +272,6 @@ applyrules(Client *c)
176
177 /* rule matching */
178 c->isfloating = 0;
179 - c->tags = 0;
180 XGetClassHint(dpy, c->win, &ch);
181 class = ch.res_class ? ch.res_class : broken;
182 instance = ch.res_name ? ch.res_name : broken;
183 @@ -297,7 +283,6 @@ applyrules(Client *c)
184 && (!r->instance || strstr(instance, r->instance)))
185 {
186 c->isfloating = r->isfloating;
187 - c->tags |= r->tags;
188 for (m = mons; m && m->num != r->monitor; m = m->next);
189 if (m)
190 c->mon = m;
191 @@ -307,7 +292,6 @@ applyrules(Client *c)
192 XFree(ch.res_class);
193 if (ch.res_name)
194 XFree(ch.res_name);
195 - c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
196 }
197
198 int
199 @@ -417,7 +401,7 @@ attachstack(Client *c)
200 void
201 buttonpress(XEvent *e)
202 {
203 - unsigned int i, x, click;
204 + unsigned int i, click;
205 Arg arg = {0};
206 Client *c;
207 Monitor *m;
208 @@ -431,14 +415,7 @@ buttonpress(XEvent *e)
209 focus(NULL);
210 }
211 if (ev->window == selmon->barwin) {
212 - i = x = 0;
213 - do
214 - x += TEXTW(tags[i]);
215 - while (ev->x >= x && ++i < LENGTH(tags));
216 - if (i < LENGTH(tags)) {
217 - click = ClkTagBar;
218 - arg.ui = 1 << i;
219 - } else if (ev->x < x + TEXTW(selmon->ltsymbol))
220 + if (ev->x < TEXTW(selmon->ltsymbol))
221 click = ClkLtSymbol;
222 else if (ev->x > selmon->ww - (int)TEXTW(stext))
223 click = ClkStatusText;
224 @@ -470,12 +447,10 @@ checkotherwm(void)
225 void
226 cleanup(void)
227 {
228 - Arg a = {.ui = ~0};
229 Layout foo = { "", NULL };
230 Monitor *m;
231 size_t i;
232
233 - view(&a);
234 selmon->lt[selmon->sellt] = &foo;
235 for (m = mons; m; m = m->next)
236 while (m->stack)
237 @@ -612,8 +587,7 @@ configurerequest(XEvent *e)
238 c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */
239 if ((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
240 configure(c);
241 - if (ISVISIBLE(c))
242 - XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
243 + XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
244 } else
245 configure(c);
246 } else {
247 @@ -635,7 +609,6 @@ createmon(void)
248 Monitor *m;
249
250 m = ecalloc(1, sizeof(Monitor));
251 - m->tagset[0] = m->tagset[1] = 1;
252 m->mfact = mfact;
253 m->nmaster = nmaster;
254 m->showbar = showbar;
255 @@ -700,35 +673,18 @@ drawbar(Monitor *m)
256 int x, w, tw = 0;
257 int boxs = drw->fonts->h / 9;
258 int boxw = drw->fonts->h / 6 + 2;
259 - unsigned int i, occ = 0, urg = 0;
260 - Client *c;
261
262 if (!m->showbar)
263 return;
264
265 - /* draw status first so it can be overdrawn by tags later */
266 + /* draw status first so it can be overdrawn later */
267 if (m == selmon) { /* status is only drawn on selected monitor */
268 drw_setscheme(drw, scheme[SchemeNorm]);
269 tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
270 drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
271 }
272
273 - for (c = m->clients; c; c = c->next) {
274 - occ |= c->tags;
275 - if (c->isurgent)
276 - urg |= c->tags;
277 - }
278 x = 0;
279 - for (i = 0; i < LENGTH(tags); i++) {
280 - w = TEXTW(tags[i]);
281 - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
282 - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
283 - if (occ & 1 << i)
284 - drw_rect(drw, x + boxs, boxs, boxw, boxw,
285 - m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
286 - urg & 1 << i);
287 - x += w;
288 - }
289 w = TEXTW(m->ltsymbol);
290 drw_setscheme(drw, scheme[SchemeNorm]);
291 x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
292 @@ -851,8 +807,7 @@ focusstack(const Arg *arg)
293 c = i;
294 if (!c)
295 for (; i; i = i->next)
296 - if (ISVISIBLE(i))
297 - c = i;
298 + c = i;
299 }
300 if (c) {
301 focus(c);
302 @@ -1046,7 +1001,6 @@ manage(Window w, XWindowAttributes *wa)
303 updatetitle(c);
304 if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
305 c->mon = t->mon;
306 - c->tags = t->tags;
307 } else {
308 c->mon = selmon;
309 applyrules(c);
310 @@ -1116,8 +1070,7 @@ monocle(Monitor *m)
311 Client *c;
312
313 for (c = m->clients; c; c = c->next)
314 - if (ISVISIBLE(c))
315 - n++;
316 + n++;
317 if (n > 0) /* override layout symbol */
318 snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
319 for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
320 @@ -1204,7 +1157,7 @@ movemouse(const Arg *arg)
321 Client *
322 nexttiled(Client *c)
323 {
324 - for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
325 + for (; c && c->isfloating; c = c->next);
326 return c;
327 }
328
329 @@ -1369,7 +1322,7 @@ restack(Monitor *m)
330 wc.stack_mode = Below;
331 wc.sibling = m->barwin;
332 for (c = m->stack; c; c = c->snext)
333 - if (!c->isfloating && ISVISIBLE(c)) {
334 + if (!c->isfloating) {
335 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
336 wc.sibling = c->win;
337 }
338 @@ -1425,7 +1378,6 @@ sendmon(Client *c, Monitor *m)
339 detach(c);
340 detachstack(c);
341 c->mon = m;
342 - c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
343 attach(c);
344 attachstack(c);
345 focus(NULL);
346 @@ -1630,17 +1582,11 @@ showhide(Client *c)
347 {
348 if (!c)
349 return;
350 - if (ISVISIBLE(c)) {
351 - /* show clients top down */
352 - XMoveWindow(dpy, c->win, c->x, c->y);
353 - if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
354 - resize(c, c->x, c->y, c->w, c->h, 0);
355 - showhide(c->snext);
356 - } else {
357 - /* hide clients bottom up */
358 - showhide(c->snext);
359 - XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
360 - }
361 + /* show clients top down */
362 + XMoveWindow(dpy, c->win, c->x, c->y);
363 + if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
364 + resize(c, c->x, c->y, c->w, c->h, 0);
365 + showhide(c->snext);
366 }
367
368 void
369 @@ -1665,16 +1611,6 @@ spawn(const Arg *arg)
370 }
371 }
372
373 -void
374 -tag(const Arg *arg)
375 -{
376 - if (selmon->sel && arg->ui & TAGMASK) {
377 - selmon->sel->tags = arg->ui & TAGMASK;
378 - focus(NULL);
379 - arrange(selmon);
380 - }
381 -}
382 -
383 void
384 tagmon(const Arg *arg)
385 {
386 @@ -1734,33 +1670,6 @@ togglefloating(const Arg *arg)
387 arrange(selmon);
388 }
389
390 -void
391 -toggletag(const Arg *arg)
392 -{
393 - unsigned int newtags;
394 -
395 - if (!selmon->sel)
396 - return;
397 - newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
398 - if (newtags) {
399 - selmon->sel->tags = newtags;
400 - focus(NULL);
401 - arrange(selmon);
402 - }
403 -}
404 -
405 -void
406 -toggleview(const Arg *arg)
407 -{
408 - unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
409 -
410 - if (newtagset) {
411 - selmon->tagset[selmon->seltags] = newtagset;
412 - focus(NULL);
413 - arrange(selmon);
414 - }
415 -}
416 -
417 void
418 unfocus(Client *c, int setfocus)
419 {
420 @@ -2049,18 +1958,6 @@ updatewmhints(Client *c)
421 }
422 }
423
424 -void
425 -view(const Arg *arg)
426 -{
427 - if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
428 - return;
429 - selmon->seltags ^= 1; /* toggle sel tagset */
430 - if (arg->ui & TAGMASK)
431 - selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
432 - focus(NULL);
433 - arrange(selmon);
434 -}
435 -
436 Client *
437 wintoclient(Window w)
438 {
439 --
440 2.49.0
441