commit f1a5d8d56cbae1e78f759549c0ad740b24220ad9
parent 46e9c77094cc03c416cbebd557bfe3a616d0a0cb
Author: Tom Schwindl <schwindl@posteo.de>
Date: Sun, 18 Sep 2022 19:00:28 +0200
[dwm][patch][alternativetags] Port to 6.3
Diffstat:
2 files changed, 132 insertions(+), 0 deletions(-)
diff --git a/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-6.3.diff b/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-6.3.diff
@@ -0,0 +1,130 @@
+From 937130c8ea4884f54eb71357bfa99233e6c3e556 Mon Sep 17 00:00:00 2001
+From: Tom Schwindl <schwindl@posteo.de>
+Date: Sun, 18 Sep 2022 18:44:29 +0200
+Subject: [PATCH] 6.3 alternativetags patch
+
+---
+ config.def.h | 3 +++
+ dwm.c | 35 +++++++++++++++++++++++++++++++++--
+ 2 files changed, 36 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 061ad662f82a..e912edd557cf 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -20,6 +20,8 @@ static const char *colors[][3] = {
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
++static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
++static const int momentaryalttags = 0; /* 1 means alttags will show only when key is held down*/
+
+ static const Rule rules[] = {
+ /* xprop(1):
+@@ -84,6 +86,7 @@ static const Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY, XK_n, togglealttag, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff --git a/dwm.c b/dwm.c
+index e5efb6a22806..12ff3f0768bc 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -130,6 +130,7 @@ struct Monitor {
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
++ unsigned int alttag;
+ };
+
+ typedef struct {
+@@ -177,6 +178,7 @@ static void grabbuttons(Client *c, int focused);
+ static void grabkeys(void);
+ static void incnmaster(const Arg *arg);
+ static void keypress(XEvent *e);
++static void keyrelease(XEvent *e);
+ static void killclient(const Arg *arg);
+ static void manage(Window w, XWindowAttributes *wa);
+ static void mappingnotify(XEvent *e);
+@@ -210,6 +212,7 @@ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *m);
++static void togglealttag(const Arg *arg);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+@@ -254,6 +257,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
+ [Expose] = expose,
+ [FocusIn] = focusin,
+ [KeyPress] = keypress,
++ [KeyRelease] = keyrelease,
+ [MappingNotify] = mappingnotify,
+ [MapRequest] = maprequest,
+ [MotionNotify] = motionnotify,
+@@ -699,7 +703,7 @@ dirtomon(int dir)
+ void
+ drawbar(Monitor *m)
+ {
+- int x, w, tw = 0;
++ int x, w, wdelta, tw = 0;
+ int boxs = drw->fonts->h / 9;
+ int boxw = drw->fonts->h / 6 + 2;
+ unsigned int i, occ = 0, urg = 0;
+@@ -723,8 +727,9 @@ drawbar(Monitor *m)
+ x = 0;
+ for (i = 0; i < LENGTH(tags); i++) {
+ w = TEXTW(tags[i]);
++ wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0;
+ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
++ drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), urg & 1 << i);
+ if (occ & 1 << i)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw,
+ m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+@@ -1003,6 +1008,25 @@ keypress(XEvent *e)
+ keys[i].func(&(keys[i].arg));
+ }
+
++void
++keyrelease(XEvent *e)
++{
++ unsigned int i;
++ KeySym keysym;
++ XKeyEvent *ev;
++
++ ev = &e->xkey;
++ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
++
++ for (i = 0; i < LENGTH(keys); i++)
++ if (momentaryalttags
++ && keys[i].func && keys[i].func == togglealttag
++ && selmon->alttag
++ && (keysym == keys[i].keysym
++ || CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)))
++ keys[i].func(&(keys[i].arg));
++}
++
+ void
+ killclient(const Arg *arg)
+ {
+@@ -1694,6 +1718,13 @@ tile(Monitor *m)
+ }
+ }
+
++void
++togglealttag(const Arg *arg)
++{
++ selmon->alttag = !selmon->alttag;
++ drawbar(selmon);
++}
++
+ void
+ togglebar(const Arg *arg)
+ {
+--
+2.37.3
+
diff --git a/dwm.suckless.org/patches/alternativetags/index.md b/dwm.suckless.org/patches/alternativetags/index.md
@@ -17,6 +17,7 @@ Alternative tags
Download
--------
+* [dwm-alternativetags-6.3.diff](dwm-alternativetags-6.3.diff) (2022-09-19)
* [dwm-alternativetags-6.2.diff](dwm-alternativetags-6.2.diff) (2021-08-29)
* [dwm-alternativetags-20210829-ed3ab6b4.diff](dwm-alternativetags-20210829-ed3ab6b4.diff) (2021-08-29)
@@ -24,3 +25,4 @@ Author
-------
* Piyush Pangtey <gokuvsvegita@gmail.com>
* Jack Bird <jack.bird@dur.ac.uk> (momentary switch)
+* Tom Schwindl <schwindl@posteo.de> (6.3 port, cleanup)