mirror of https://github.com/bakkeby/patches
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
3.9 KiB
Diff
132 lines
3.9 KiB
Diff
From e92b0373f8ebb59121cbb9f514f7bc977f7c5066 Mon Sep 17 00:00:00 2001
|
|
From: bakkeby <bakkeby@gmail.com>
|
|
Date: Sun, 26 Apr 2020 14:38:59 +0200
|
|
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]
|
|
---
|
|
config.def.h | 6 +++++-
|
|
dwm.c | 31 ++++++++++++++++++++++---------
|
|
2 files changed, 27 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/config.def.h b/config.def.h
|
|
index 1c0b587..5858e96 100644
|
|
--- a/config.def.h
|
|
+++ b/config.def.h
|
|
@@ -19,7 +19,11 @@ static const char *colors[][3] = {
|
|
};
|
|
|
|
/* tagging */
|
|
-static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
+#define TAGLENGTH 9
|
|
+static const char *tags[][TAGLENGTH] = {
|
|
+ { "1", "2", "3", "4", "5", "6", "7", "8", "9" },
|
|
+ { "A", "B", "C", "D", "E", "F", "G", "H", "I"},
|
|
+};
|
|
|
|
static const Rule rules[] = {
|
|
/* xprop(1):
|
|
diff --git a/dwm.c b/dwm.c
|
|
index 4465af1..54b346a 100644
|
|
--- a/dwm.c
|
|
+++ b/dwm.c
|
|
@@ -54,7 +54,7 @@
|
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
|
-#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
|
+#define TAGMASK ((1 << TAGLENGTH) - 1)
|
|
#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;
|
|
#include "config.h"
|
|
|
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
|
-struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
|
+struct NumTags { char limitexceeded[TAGLENGTH > 31 ? -1 : 1]; };
|
|
|
|
/* 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);
|
|
+
|
|
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]);
|
|
+ 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)
|
|
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]);
|
|
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);
|
|
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
|
|
|