From 6439fa44655732fbf26069feac70836fbc441644 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 24 Nov 2020 12:24:19 +0100 Subject: [PATCH] monitortags: removing monidx function in favour of mon->num --- dwm/dwm-monitortags-6.2.diff | 69 ++++++------------------------------ 1 file changed, 11 insertions(+), 58 deletions(-) diff --git a/dwm/dwm-monitortags-6.2.diff b/dwm/dwm-monitortags-6.2.diff index 346baf6..2e598d0 100644 --- a/dwm/dwm-monitortags-6.2.diff +++ b/dwm/dwm-monitortags-6.2.diff @@ -1,4 +1,4 @@ -From e92b0373f8ebb59121cbb9f514f7bc977f7c5066 Mon Sep 17 00:00:00 2001 +From 5387680b1ff596ec7376ae03075411072ce08360 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 26 Apr 2020 14:38:59 +0200 Subject: [PATCH] Monitor tags patch @@ -6,13 +6,12 @@ Subject: [PATCH] Monitor tags patch This patch allows you to have different tags icons on a per-monitor basis. This patch will conflict with a series of other patches, but it should be more or less straightforward to sort out: - - the monitor index is retrieved via monidx when needed - LENGTH(tags) is replaced with TAGLENGTH - - tags[i] is replaced with tags[mi][i] + - tags[i] is replaced with tags[m->mon][i] --- config.def.h | 6 +++++- - dwm.c | 31 ++++++++++++++++++++++--------- - 2 files changed, 27 insertions(+), 10 deletions(-) + dwm.c | 16 ++++++++-------- + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 1c0b587..5858e96 100644 @@ -32,7 +31,7 @@ index 1c0b587..5858e96 100644 static const Rule rules[] = { /* xprop(1): diff --git a/dwm.c b/dwm.c -index 4465af1..54b346a 100644 +index 4465af1..109932c 100644 --- a/dwm.c +++ b/dwm.c @@ -54,7 +54,7 @@ @@ -44,15 +43,7 @@ index 4465af1..54b346a 100644 #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) /* enums */ -@@ -180,6 +180,7 @@ static void killclient(const Arg *arg); - static void manage(Window w, XWindowAttributes *wa); - static void mappingnotify(XEvent *e); - static void maprequest(XEvent *e); -+static int monidx(Monitor *m); - static void monocle(Monitor *m); - static void motionnotify(XEvent *e); - static void movemouse(const Arg *arg); -@@ -272,7 +273,7 @@ static Window root, wmcheckwin; +@@ -272,7 +272,7 @@ static Window root, wmcheckwin; #include "config.h" /* compile-time check if all tags fit into an unsigned int bit array. */ @@ -61,71 +52,33 @@ index 4465af1..54b346a 100644 /* function implementations */ void -@@ -421,7 +422,7 @@ buttonpress(XEvent *e) - Client *c; - Monitor *m; - XButtonPressedEvent *ev = &e->xbutton; -- -+ int mi; - click = ClkRootWin; - /* focus monitor if necessary */ - if ((m = wintomon(ev->window)) && m != selmon) { -@@ -429,12 +430,14 @@ buttonpress(XEvent *e) - selmon = m; - focus(NULL); - } -+ mi = monidx(m); -+ +@@ -432,9 +432,9 @@ buttonpress(XEvent *e) if (ev->window == selmon->barwin) { i = x = 0; do - x += TEXTW(tags[i]); - while (ev->x >= x && ++i < LENGTH(tags)); - if (i < LENGTH(tags)) { -+ x += TEXTW(tags[mi][i]); ++ x += TEXTW(tags[selmon->num][i]); + while (ev->x >= x && ++i < TAGLENGTH); + if (i < TAGLENGTH) { click = ClkTagBar; arg.ui = 1 << i; } else if (ev->x < x + blw) -@@ -699,6 +702,7 @@ drawbar(Monitor *m) - int boxs = drw->fonts->h / 9; - int boxw = drw->fonts->h / 6 + 2; - unsigned int i, occ = 0, urg = 0; -+ int mi = monidx(m); - Client *c; - - /* draw status first so it can be overdrawn by tags later */ -@@ -714,10 +718,10 @@ drawbar(Monitor *m) +@@ -714,10 +714,10 @@ drawbar(Monitor *m) urg |= c->tags; } x = 0; - for (i = 0; i < LENGTH(tags); i++) { - w = TEXTW(tags[i]); + for (i = 0; i < TAGLENGTH; i++) { -+ w = TEXTW(tags[mi][i]); ++ w = TEXTW(tags[m->num][i]); 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, lrpad / 2, tags[mi][i], urg & 1 << i); ++ drw_text(drw, x, 0, w, bh, lrpad / 2, tags[m->num][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, -@@ -1670,6 +1674,15 @@ tagmon(const Arg *arg) - sendmon(selmon->sel, dirtomon(arg->i)); - } - -+int -+monidx(Monitor *mon) -+{ -+ unsigned int i; -+ Monitor *m; -+ for (i = 0, m = mons; m && m->next && m != mon; m = m->next, i++); -+ return i; -+} -+ - void - tile(Monitor *m) - { -- 2.19.1