From 526a0bf71173c42b71a34e5a787fb086a84b3c5c Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Fri, 2 Dec 2022 22:39:46 -0500 Subject: 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 --- dwm.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'dwm.c') 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) { -- cgit v1.2.3