summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorDouglas Rumbaugh <doug@douglasrumbaugh.com>2022-12-02 22:39:46 -0500
committerDouglas Rumbaugh <doug@douglasrumbaugh.com>2022-12-05 15:35:35 -0500
commit526a0bf71173c42b71a34e5a787fb086a84b3c5c (patch)
tree27e00f5fd6364335cb4696188ad75625ca3ba15a /dwm.c
parent7ae4961c62c2f620bd8f141b70389a3d099094a9 (diff)
downloaddwm-526a0bf71173c42b71a34e5a787fb086a84b3c5c.tar.gz
Improved tag-0 behavior
Displaying tag 0 now triggers on all attached monitors, and leaving it on any monitor reverts all other back to their original configuration
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/dwm.c b/dwm.c
index 5046d2d..694c772 100644
--- a/dwm.c
+++ b/dwm.c
@@ -268,6 +268,7 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
+static void view_t0(const Arg *arg);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
@@ -2449,16 +2450,30 @@ view(const Arg *arg)
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
+
+
+ if (selmon->pertag->curtag == 0 && arg->ui != 0) {
+ Monitor *oldmon = selmon;
+ for (Monitor *m = mons; m; m = m->next) {
+ if (m != oldmon) {
+ selmon = m;
+ Arg tmp = {0};
+ view(&tmp);
+ }
+ }
+
+ selmon = oldmon;
+ }
+
selmon->seltags ^= 1; /* toggle sel tagset */
if (arg->ui & TAGMASK) {
- selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
- selmon->pertag->prevtag = selmon->pertag->curtag;
if (arg->ui == ~0) {
- selmon->pertag->curtag = 0;
- selmon->tagset[selmon->seltags] ^= SPTAGMASK;
+ view_t0(arg);
}
else {
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->pertag->prevtag = selmon->pertag->curtag;
for (i = 0; !(arg->ui & 1 << i); i++) ;
selmon->pertag->curtag = i + 1;
}
@@ -2481,6 +2496,26 @@ view(const Arg *arg)
arrange(selmon);
}
+void
+view_t0(const Arg *arg)
+{
+ Monitor *oldmon = selmon;
+ for (Monitor *m = mons; m; m = m->next) {
+ selmon = m;
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->pertag->prevtag = selmon->pertag->curtag;
+ selmon->pertag->curtag = 0;
+ selmon->tagset[selmon->seltags] ^= SPTAGMASK;
+ // Force set the layout to grid when viewing
+ // all tags
+ Arg tmp;
+ tmp.v = &layouts[7];
+ setlayout(&tmp);
+ }
+
+ selmon = oldmon;
+}
+
pid_t
winpid(Window w)
{