aboutsummaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/XF86keysym.patch41
-rw-r--r--patches/alwayscenter.patch35
-rw-r--r--patches/attachbottom.patch26
-rw-r--r--patches/autostart.patch154
-rw-r--r--patches/gaps.patch127
-rw-r--r--patches/naturalscrolltrackpad.patch27
-rw-r--r--patches/pertag.patch170
7 files changed, 580 insertions, 0 deletions
diff --git a/patches/XF86keysym.patch b/patches/XF86keysym.patch
new file mode 100644
index 0000000..9255b9a
--- /dev/null
+++ b/patches/XF86keysym.patch
@@ -0,0 +1,41 @@
+From 7182343aaf6c1fed1f5802aff948cfb4f3c82e69 Mon Sep 17 00:00:00 2001
+From: 917Wolf <none>
+Date: Thu, 6 May 2021 11:04:23 +0200
+Subject: [PATCH] Found this in my old dwm config, moved it into dwl ... It
+ made my volum keys work again :)
+
+---
+ config.def.h | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 089aa3795..29a6d624f 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -1,3 +1,4 @@
++#include <X11/XF86keysym.h>
+ /* appearance */
+ static const int sloppyfocus = 1; /* focus follows mouse */
+ static const unsigned int borderpx = 1; /* border pixel of windows */
+@@ -62,6 +63,11 @@ static const int natural_scrolling = 0;
+ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+
+ /* commands */
++// for cahnging the volume via alsa amixer //
++static const char *upvol[] = { "amixer", "-q", "-c", "0", "set", "Master", "2+", NULL };
++static const char *downvol[] = { "amixer", "-q", "-c", "0", "set", "Master", "2-", NULL };
++// for muting/unmuting //
++static const char *mute[] = { "amixer", "-q", "set", "Master", "toggle", NULL };
+ static const char *termcmd[] = { "alacritty", NULL };
+ static const char *menucmd[] = { "bemenu-run", NULL };
+
+@@ -107,6 +113,9 @@ static const Key keys[] = {
+ #define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
+ CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
+ CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
++ { 0,XF86XK_AudioRaiseVolume, spawn,{.v = upvol } },
++ { 0,XF86XK_AudioLowerVolume, spawn,{.v = downvol } },
++ { 0,XF86XK_AudioMute,spawn,{.v = mute } },
+ };
+
+ static const Button buttons[] = {
diff --git a/patches/alwayscenter.patch b/patches/alwayscenter.patch
new file mode 100644
index 0000000..0aa717f
--- /dev/null
+++ b/patches/alwayscenter.patch
@@ -0,0 +1,35 @@
+From 6616470ef135019ef4c767003a66df76df45f53e Mon Sep 17 00:00:00 2001
+From: Guido Cella <guido@guidocella.xyz>
+Date: Wed, 5 Jun 2024 12:05:16 +0200
+Subject: [PATCH] center floating windows
+
+---
+ dwl.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/dwl.c b/dwl.c
+index 6f041a0..79ace52 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -472,6 +472,10 @@ applyrules(Client *c)
+ }
+ }
+ }
++ if (mon) {
++ c->geom.x = (mon->w.width - c->geom.width) / 2 + mon->m.x;
++ c->geom.y = (mon->w.height - c->geom.height) / 2 + mon->m.y;
++ }
+ setmon(c, mon, newtags);
+ }
+
+@@ -1677,6 +1681,10 @@ mapnotify(struct wl_listener *listener, void *data)
+ * try to apply rules for them */
+ if ((p = client_get_parent(c))) {
+ c->isfloating = 1;
++ if (p->mon) {
++ c->geom.x = (p->mon->w.width - c->geom.width) / 2 + p->mon->m.x;
++ c->geom.y = (p->mon->w.height - c->geom.height) / 2 + p->mon->m.y;
++ }
+ setmon(c, p->mon, p->tags);
+ } else {
+ applyrules(c);
diff --git a/patches/attachbottom.patch b/patches/attachbottom.patch
new file mode 100644
index 0000000..d7fdb43
--- /dev/null
+++ b/patches/attachbottom.patch
@@ -0,0 +1,26 @@
+From 0dda3ed8634154fd3887b71133b451d66a11b61d Mon Sep 17 00:00:00 2001
+From: Ben Collerson <benc@benc.cc>
+Date: Thu, 4 Jan 2024 23:31:41 +1000
+Subject: [PATCH] attachbottom
+
+---
+ dwl.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/dwl.c b/dwl.c
+index bf763df..12e08e2 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -1605,7 +1605,11 @@ mapnotify(struct wl_listener *listener, void *data)
+ c->geom.height += 2 * c->bw;
+
+ /* Insert this client into client lists. */
+- wl_list_insert(&clients, &c->link);
++ if (clients.prev)
++ // tile at the bottom
++ wl_list_insert(clients.prev, &c->link);
++ else
++ wl_list_insert(&clients, &c->link);
+ wl_list_insert(&fstack, &c->flink);
+
+ /* Set initial monitor, tags, floating status, and focus:
diff --git a/patches/autostart.patch b/patches/autostart.patch
new file mode 100644
index 0000000..0350380
--- /dev/null
+++ b/patches/autostart.patch
@@ -0,0 +1,154 @@
+From d2829ed5c970c7e7692e39c451526b3860dabb2f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
+ <leohdz172@proton.me>
+Date: Sat, 8 Jul 2023 17:11:36 -0600
+Subject: [PATCH] port autostart patch from dwm
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+https://dwm.suckless.org/patches/cool_autostart/
+Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
+---
+ config.def.h | 7 +++++++
+ dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++-----
+ 2 files changed, 61 insertions(+), 5 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 22d2171..1d0f935 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -20,6 +20,13 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
+ /* logging */
+ static int log_level = WLR_ERROR;
+
++/* Autostart */
++static const char *const autostart[] = {
++ "wbg", "/path/to/your/image", NULL,
++ NULL /* terminate */
++};
++
++
+ /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
+ static const Rule rules[] = {
+ /* app_id title tags mask isfloating monitor */
+diff --git a/dwl.c b/dwl.c
+index 00e9cc1e..5de32831 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -249,6 +249,7 @@ static void arrange(Monitor *m);
+ static void arrangelayer(Monitor *m, struct wl_list *list,
+ struct wlr_box *usable_area, int exclusive);
+ static void arrangelayers(Monitor *m);
++static void autostartexec(void);
+ static void axisnotify(struct wl_listener *listener, void *data);
+ static void buttonpress(struct wl_listener *listener, void *data);
+ static void chvt(const Arg *arg);
+@@ -429,6 +430,9 @@ static xcb_atom_t netatom[NetLast];
+ /* attempt to encapsulate suck into one file */
+ #include "client.h"
+
++static pid_t *autostart_pids;
++static size_t autostart_len;
++
+ /* function implementations */
+ void
+ applybounds(Client *c, struct wlr_box *bbox)
+@@ -577,6 +581,27 @@ arrangelayers(Monitor *m)
+ }
+ }
+
++void
++autostartexec(void) {
++ const char *const *p;
++ size_t i = 0;
++
++ /* count entries */
++ for (p = autostart; *p; autostart_len++, p++)
++ while (*++p);
++
++ autostart_pids = calloc(autostart_len, sizeof(pid_t));
++ for (p = autostart; *p; i++, p++) {
++ if ((autostart_pids[i] = fork()) == 0) {
++ setsid();
++ execvp(*p, (char *const *)p);
++ die("dwl: execvp %s:", *p);
++ }
++ /* skip arguments */
++ while (*++p);
++ }
++}
++
+ void
+ axisnotify(struct wl_listener *listener, void *data)
+ {
+@@ -672,11 +697,21 @@ checkidleinhibitor(struct wlr_surface *exclude)
+ void
+ cleanup(void)
+ {
++ size_t i;
+ #ifdef XWAYLAND
+ wlr_xwayland_destroy(xwayland);
+ xwayland = NULL;
+ #endif
+ wl_display_destroy_clients(dpy);
++
++ /* kill child processes */
++ for (i = 0; i < autostart_len; i++) {
++ if (0 < autostart_pids[i]) {
++ kill(autostart_pids[i], SIGTERM);
++ waitpid(autostart_pids[i], NULL, 0);
++ }
++ }
++
+ if (child_pid > 0) {
+ kill(-child_pid, SIGTERM);
+ waitpid(child_pid, NULL, 0);
+@@ -1438,18 +1473,31 @@ void
+ handlesig(int signo)
+ {
+ if (signo == SIGCHLD) {
+-#ifdef XWAYLAND
+ siginfo_t in;
+ /* wlroots expects to reap the XWayland process itself, so we
+ * use WNOWAIT to keep the child waitable until we know it's not
+ * XWayland.
+ */
+ while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
+- && (!xwayland || in.si_pid != xwayland->server->pid))
+- waitpid(in.si_pid, NULL, 0);
+-#else
+- while (waitpid(-1, NULL, WNOHANG) > 0);
++#ifdef XWAYLAND
++ && (!xwayland || in.si_pid != xwayland->server->pid)
+ #endif
++ ) {
++ pid_t *p, *lim;
++ waitpid(in.si_pid, NULL, 0);
++ if (in.si_pid == child_pid)
++ child_pid = -1;
++ if (!(p = autostart_pids))
++ continue;
++ lim = &p[autostart_len];
++
++ for (; p < lim; p++) {
++ if (*p == in.si_pid) {
++ *p = -1;
++ break;
++ }
++ }
++ }
+ } else if (signo == SIGINT || signo == SIGTERM) {
+ quit(NULL);
+ }
+@@ -2169,6 +2217,7 @@ run(char *startup_cmd)
+ die("startup: backend_start");
+
+ /* Now that the socket exists and the backend is started, run the startup command */
++ autostartexec();
+ if (startup_cmd) {
+ int piperw[2];
+ if (pipe(piperw) < 0)
+--
+2.45.2
+
diff --git a/patches/gaps.patch b/patches/gaps.patch
new file mode 100644
index 0000000..c025baf
--- /dev/null
+++ b/patches/gaps.patch
@@ -0,0 +1,127 @@
+From 50e3dd4746b6cb719efb9f8213b94ac52a5320d9 Mon Sep 17 00:00:00 2001
+From: peesock <kcormn@gmail.com>
+Date: Mon, 24 Jun 2024 20:06:42 -0700
+Subject: [PATCH] gaps!
+
+Co-authored-by: sewn <sewn@disroot.org>
+Co-authored-by: serenevoid <ajuph9224@gmail.com>
+---
+ config.def.h | 4 ++++
+ dwl.c | 34 ++++++++++++++++++++++++++--------
+ 2 files changed, 30 insertions(+), 8 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 22d2171..b388b4e 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -6,6 +6,9 @@
+ /* appearance */
+ static const int sloppyfocus = 1; /* focus follows mouse */
+ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
++static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
++static int gaps = 1; /* 1 means gaps between windows are added */
++static const unsigned int gappx = 10; /* gap pixel between windows */
+ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const float rootcolor[] = COLOR(0x222222ff);
+ static const float bordercolor[] = COLOR(0x444444ff);
+@@ -135,6 +138,7 @@ static const Key keys[] = {
+ { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
+ { MODKEY, XKB_KEY_Return, zoom, {0} },
+ { MODKEY, XKB_KEY_Tab, view, {0} },
++ { MODKEY, XKB_KEY_g, togglegaps, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
+ { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
+diff --git a/dwl.c b/dwl.c
+index dc0437e..dc851df 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -199,6 +199,7 @@ struct Monitor {
+ struct wlr_box w; /* window area, layout-relative */
+ struct wl_list layers[4]; /* LayerSurface.link */
+ const Layout *lt[2];
++ int gaps;
+ unsigned int seltags;
+ unsigned int sellt;
+ uint32_t tagset[2];
+@@ -336,6 +337,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *m);
+ static void togglefloating(const Arg *arg);
+ static void togglefullscreen(const Arg *arg);
++static void togglegaps(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unlocksession(struct wl_listener *listener, void *data);
+@@ -949,6 +951,8 @@ createmon(struct wl_listener *listener, void *data)
+
+ wlr_output_state_init(&state);
+ /* Initialize monitor state using configured rules */
++ m->gaps = gaps;
++
+ m->tagset[0] = m->tagset[1] = 1;
+ for (r = monrules; r < END(monrules); r++) {
+ if (!r->name || strstr(wlr_output->name, r->name)) {
+@@ -2638,7 +2642,7 @@ tagmon(const Arg *arg)
+ void
+ tile(Monitor *m)
+ {
+- unsigned int mw, my, ty;
++ unsigned int h, r, e = m->gaps, mw, my, ty;
+ int i, n = 0;
+ Client *c;
+
+@@ -2647,23 +2651,30 @@ tile(Monitor *m)
+ n++;
+ if (n == 0)
+ return;
++ if (smartgaps == n)
++ e = 0;
+
+ if (n > m->nmaster)
+- mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
++ mw = m->nmaster ? (int)roundf((m->w.width + gappx*e) * m->mfact) : 0;
+ else
+ mw = m->w.width;
+- i = my = ty = 0;
++ i = 0;
++ my = ty = gappx*e;
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ if (i < m->nmaster) {
+- resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
+- .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
+- my += c->geom.height;
++ r = MIN(n, m->nmaster) - i;
++ h = (m->w.height - my - gappx*e - gappx*e * (r - 1)) / r;
++ resize(c, (struct wlr_box){.x = m->w.x + gappx*e, .y = m->w.y + my,
++ .width = mw - 2*gappx*e, .height = h}, 0);
++ my += c->geom.height + gappx*e;
+ } else {
++ r = n - i;
++ h = (m->w.height - ty - gappx*e - gappx*e * (r - 1)) / r;
+ resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
+- .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
+- ty += c->geom.height;
++ .width = m->w.width - mw - gappx*e, .height = h}, 0);
++ ty += c->geom.height + gappx*e;
+ }
+ i++;
+ }
+@@ -2686,6 +2697,13 @@ togglefullscreen(const Arg *arg)
+ setfullscreen(sel, !sel->isfullscreen);
+ }
+
++void
++togglegaps(const Arg *arg)
++{
++ selmon->gaps = !selmon->gaps;
++ arrange(selmon);
++}
++
+ void
+ toggletag(const Arg *arg)
+ {
+--
+2.45.2
+
diff --git a/patches/naturalscrolltrackpad.patch b/patches/naturalscrolltrackpad.patch
new file mode 100644
index 0000000..5cd3742
--- /dev/null
+++ b/patches/naturalscrolltrackpad.patch
@@ -0,0 +1,27 @@
+From 8b523453aefdc9d2920c8f9a52de009da251fbb0 Mon Sep 17 00:00:00 2001
+From: neuromagus <neuromagus@mail.ru>
+Date: Sun, 7 Jan 2024 05:11:24 +0300
+Subject: [PATCH] apply patch naturalscrolltrackpad
+
+---
+ dwl.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/dwl.c b/dwl.c
+index 4d19357..26f394b 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -974,11 +974,10 @@ createpointer(struct wlr_pointer *pointer)
+ libinput_device_config_tap_set_drag_enabled(device, tap_and_drag);
+ libinput_device_config_tap_set_drag_lock_enabled(device, drag_lock);
+ libinput_device_config_tap_set_button_map(device, button_map);
++ if (libinput_device_config_scroll_has_natural_scroll(device))
++ libinput_device_config_scroll_set_natural_scroll_enabled(device, natural_scrolling);
+ }
+
+- if (libinput_device_config_scroll_has_natural_scroll(device))
+- libinput_device_config_scroll_set_natural_scroll_enabled(device, natural_scrolling);
+-
+ if (libinput_device_config_dwt_is_available(device))
+ libinput_device_config_dwt_set_enabled(device, disable_while_typing);
+
diff --git a/patches/pertag.patch b/patches/pertag.patch
new file mode 100644
index 0000000..971732a
--- /dev/null
+++ b/patches/pertag.patch
@@ -0,0 +1,170 @@
+From d3b551ffe3ec85e16341962e322150b81af6722f Mon Sep 17 00:00:00 2001
+From: wochap <gean.marroquin@gmail.com>
+Date: Wed, 31 Jul 2024 08:27:26 -0500
+Subject: [PATCH] makes layout, mwfact and nmaster individual for every tag
+
+inspiration: https://github.com/djpohly/dwl/wiki/pertag
+---
+ dwl.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 70 insertions(+), 5 deletions(-)
+
+diff --git a/dwl.c b/dwl.c
+index 145fd01..2f364bc 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -102,6 +102,7 @@ typedef struct {
+ const Arg arg;
+ } Button;
+
++typedef struct Pertag Pertag;
+ typedef struct Monitor Monitor;
+ typedef struct {
+ /* Must keep these three elements in this order */
+@@ -199,6 +200,7 @@ struct Monitor {
+ struct wlr_box w; /* window area, layout-relative */
+ struct wl_list layers[4]; /* LayerSurface.link */
+ const Layout *lt[2];
++ Pertag *pertag;
+ unsigned int seltags;
+ unsigned int sellt;
+ uint32_t tagset[2];
+@@ -427,6 +429,14 @@ static xcb_atom_t netatom[NetLast];
+ /* attempt to encapsulate suck into one file */
+ #include "client.h"
+
++struct Pertag {
++ unsigned int curtag, prevtag; /* current and previous tag */
++ int nmasters[TAGCOUNT + 1]; /* number of windows in master area */
++ float mfacts[TAGCOUNT + 1]; /* mfacts per tag */
++ unsigned int sellts[TAGCOUNT + 1]; /* selected layouts */
++ const Layout *ltidxs[TAGCOUNT + 1][2]; /* matrix of tags and layouts indexes */
++};
++
+ /* function implementations */
+ void
+ applybounds(Client *c, struct wlr_box *bbox)
+@@ -712,6 +722,7 @@ cleanupmon(struct wl_listener *listener, void *data)
+ wlr_output_layout_remove(output_layout, m->wlr_output);
+ wlr_scene_output_destroy(m->scene_output);
+
++ free(m->pertag);
+ closemon(m);
+ wlr_scene_node_destroy(&m->fullscreen_bg->node);
+ free(m);
+@@ -983,6 +994,18 @@ createmon(struct wl_listener *listener, void *data)
+ wl_list_insert(&mons, &m->link);
+ printstatus();
+
++ m->pertag = calloc(1, sizeof(Pertag));
++ m->pertag->curtag = m->pertag->prevtag = 1;
++
++ for (i = 0; i <= TAGCOUNT; i++) {
++ m->pertag->nmasters[i] = m->nmaster;
++ m->pertag->mfacts[i] = m->mfact;
++
++ m->pertag->ltidxs[i][0] = m->lt[0];
++ m->pertag->ltidxs[i][1] = m->lt[1];
++ m->pertag->sellts[i] = m->sellt;
++ }
++
+ /* The xdg-protocol specifies:
+ *
+ * If the fullscreened surface is not opaque, the compositor must make
+@@ -1472,7 +1495,7 @@ incnmaster(const Arg *arg)
+ {
+ if (!arg || !selmon)
+ return;
+- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
+ arrange(selmon);
+ }
+
+@@ -2305,9 +2328,9 @@ setlayout(const Arg *arg)
+ if (!selmon)
+ return;
+ if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+- selmon->sellt ^= 1;
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
+ if (arg && arg->v)
+- selmon->lt[selmon->sellt] = (Layout *)arg->v;
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
+ strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol));
+ arrange(selmon);
+ printstatus();
+@@ -2324,7 +2347,7 @@ setmfact(const Arg *arg)
+ f = arg->f < 1.0f ? arg->f + selmon->mfact : arg->f - 1.0f;
+ if (f < 0.1 || f > 0.9)
+ return;
+- selmon->mfact = f;
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
+ arrange(selmon);
+ }
+
+@@ -2701,9 +2724,29 @@ void
+ toggleview(const Arg *arg)
+ {
+ uint32_t newtagset;
++ size_t i;
+ if (!(newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0))
+ return;
+
++ if (newtagset == (uint32_t)~0) {
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ selmon->pertag->curtag = 0;
++ }
++
++ /* test if the user did not select the same tag */
++ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ for (i = 0; !(newtagset & 1 << i); i++) ;
++ selmon->pertag->curtag = i + 1;
++ }
++
++ /* apply settings for this view */
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
++
+ selmon->tagset[selmon->seltags] = newtagset;
+ focusclient(focustop(selmon), 1);
+ arrange(selmon);
+@@ -2892,11 +2935,33 @@ urgent(struct wl_listener *listener, void *data)
+ void
+ view(const Arg *arg)
+ {
++ size_t i, tmptag;
++
+ if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ return;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+- if (arg->ui & TAGMASK)
++ if (arg->ui & ~0) {
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++
++ if (arg->ui == TAGMASK)
++ selmon->pertag->curtag = 0;
++ else {
++ for (i = 0; !(arg->ui & 1 << i); i++) ;
++ selmon->pertag->curtag = i + 1;
++ }
++ } else {
++ tmptag = selmon->pertag->prevtag;
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ selmon->pertag->curtag = tmptag;
++ }
++
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
++
+ focusclient(focustop(selmon), 1);
+ arrange(selmon);
+ printstatus();
+--
+2.45.2
+