diff options
| -rw-r--r-- | config.def.h | 93 | ||||
| -rw-r--r-- | dwl.c | 171 | ||||
| -rw-r--r-- | patches/XF86keysym.patch | 41 | ||||
| -rw-r--r-- | patches/alwayscenter.patch | 35 | ||||
| -rw-r--r-- | patches/attachbottom.patch | 26 | ||||
| -rw-r--r-- | patches/autostart.patch | 154 | ||||
| -rw-r--r-- | patches/gaps.patch | 127 | ||||
| -rw-r--r-- | patches/naturalscrolltrackpad.patch | 27 | ||||
| -rw-r--r-- | patches/pertag.patch | 170 |
9 files changed, 792 insertions, 52 deletions
diff --git a/config.def.h b/config.def.h index 95c2afa..6aa97a6 100644 --- a/config.def.h +++ b/config.def.h @@ -1,3 +1,5 @@ +#include <X11/XF86keysym.h> + /* Taken from https://github.com/djpohly/dwl/issues/466 */ #define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \ ((hex >> 16) & 0xFF) / 255.0f, \ @@ -6,11 +8,14 @@ /* 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 unsigned int borderpx = 1; /* border pixel of windows */ -static const float rootcolor[] = COLOR(0x222222ff); -static const float bordercolor[] = COLOR(0x444444ff); -static const float focuscolor[] = COLOR(0x005577ff); -static const float urgentcolor[] = COLOR(0xff0000ff); +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 = 8; /* gap pixel between windows */ +static const unsigned int borderpx = 4; /* border pixel of windows */ +static const float rootcolor[] = COLOR(0x0f1212ff); +static const float bordercolor[] = COLOR(0x0f1212ff); +static const float focuscolor[] = COLOR(0x607767ff); +static const float urgentcolor[] = COLOR(0x202222ff); /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */ @@ -20,12 +25,23 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca /* logging */ static int log_level = WLR_ERROR; +/* Autostart */ +static const char *const autostart[] = { + "/config/dist/bar.sh", NULL, + "way-displays", NULL, + "dunst", NULL, + "swayidle", "before-sleep", "swaylock", "lock", "swaylock", NULL, + "nm-applet", NULL, + "blueman-applet", NULL, + "systemctl", "--user", "import-environment", "DISPLAY", "WAYLAND_DISPLAY", NULL, + NULL +}; + + /* 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 */ - /* examples: */ - { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */ - { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */ + { NULL, "float", (unsigned int) NULL, 1, -1 } }; /* layout(s) */ @@ -44,20 +60,13 @@ static const Layout layouts[] = { /* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */ static const MonitorRule monrules[] = { /* name mfact nmaster scale layout rotate/reflect x y */ - /* example of a HiDPI laptop monitor: - { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, - */ - /* defaults */ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, }; /* keyboard */ static const struct xkb_rule_names xkb_rules = { /* can specify fields: rules, model, layout, variant, options */ - /* example: - .options = "ctrl:nocaps", - */ - .options = NULL, + /* .options = "ctrl:nocaps", */ }; static const int repeat_rate = 25; @@ -67,10 +76,10 @@ static const int repeat_delay = 600; static const int tap_to_click = 1; static const int tap_and_drag = 1; static const int drag_lock = 1; -static const int natural_scrolling = 0; +static const int natural_scrolling = 1; static const int disable_while_typing = 1; static const int left_handed = 0; -static const int middle_button_emulation = 0; +static const int middle_button_emulation = 1; /* You can choose between: LIBINPUT_CONFIG_SCROLL_NO_SCROLL LIBINPUT_CONFIG_SCROLL_2FG @@ -84,7 +93,7 @@ LIBINPUT_CONFIG_CLICK_METHOD_NONE LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER */ -static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; +static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; /* You can choose between: LIBINPUT_CONFIG_SEND_EVENTS_ENABLED @@ -107,7 +116,7 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM; /* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */ -#define MODKEY WLR_MODIFIER_ALT +#define MODKEY WLR_MODIFIER_LOGO #define TAGKEYS(KEY,SKEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ @@ -119,14 +128,29 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ -static const char *termcmd[] = { "foot", NULL }; -static const char *menucmd[] = { "wmenu-run", NULL }; +static const char *upvol[] = { "pamixer", "-i", "5", NULL }; +static const char *downvol[] = { "pamixer", "-d", "5", NULL }; +static const char *mute[] = { "pamixer", "-t", NULL }; + +static const char *upbrightness[] = { "brightnessctl", "set", "+5%", NULL }; +static const char *downbrightness[] = { "brightnessctl", "set", "5%-", NULL }; + +static const char *termcmd[] = { "alacritty", NULL }; +static const char *menucmd[] = { "/config/dist/run.sh", NULL }; +static const char *vmcmd[] = { "/config/dist/vm.sh", NULL }; +static const char *lgcmd[] = { "looking-glass-client", "-m", "97", NULL }; +static const char *filemanagercmd[] = { "pcmanfm", NULL }; +static const char *lockcmd[] = { "swaylock", NULL }; static const Key keys[] = { /* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */ /* modifier key function argument */ - { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, + { MODKEY, XKB_KEY_space, spawn, {.v = menucmd} }, + { MODKEY, XKB_KEY_v, spawn, {.v = vmcmd} }, + { MODKEY, XKB_KEY_g, spawn, {.v = lgcmd} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, + { MODKEY, XKB_KEY_x, spawn, {.v = lockcmd} }, + { MODKEY, XKB_KEY_e, spawn, {.v = filemanagercmd} }, { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, @@ -135,19 +159,16 @@ 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|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, killclient, {0} }, { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XKB_KEY_space, setlayout, {0} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, - { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, + { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[2]} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_F, togglefloating, {0} }, { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} }, { MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} }, - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, tagmon, {.i = WLR_DIRECTION_LEFT} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L, tagmon, {.i = WLR_DIRECTION_RIGHT} }, TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), @@ -157,7 +178,12 @@ static const Key keys[] = { TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6), TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7), TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8), - { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, quit, {0} }, + { 0, XF86XK_AudioRaiseVolume,spawn, {.v = upvol } }, + { 0, XF86XK_AudioLowerVolume,spawn, {.v = downvol } }, + { 0, XF86XK_AudioMute, spawn, {.v = mute } }, + { 0, XF86XK_MonBrightnessUp,spawn, {.v = upbrightness } }, + { 0, XF86XK_MonBrightnessDown,spawn, {.v = downbrightness } }, /* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */ { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} }, @@ -167,6 +193,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[] = { @@ -100,6 +100,7 @@ typedef struct { const Arg arg; } Button; +typedef struct Pertag Pertag; typedef struct Monitor Monitor; typedef struct { /* Must keep this field first */ @@ -197,6 +198,8 @@ struct Monitor { struct wlr_box w; /* window area, layout-relative */ struct wl_list layers[4]; /* LayerSurface.link */ const Layout *lt[2]; + int gaps; + Pertag *pertag; unsigned int seltags; unsigned int sellt; uint32_t tagset[2]; @@ -246,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); @@ -336,6 +340,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); @@ -455,6 +460,17 @@ static struct wlr_xwayland *xwayland; /* attempt to encapsulate suck into one file */ #include "client.h" +static pid_t *autostart_pids; +static size_t autostart_len; + +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) @@ -498,6 +514,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; + } c->isfloating |= client_is_float_type(c); setmon(c, mon, newtags); @@ -604,6 +624,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) { /* This event is forwarded by the cursor when a pointer emits an axis event, @@ -699,12 +740,22 @@ checkidleinhibitor(struct wlr_surface *exclude) void cleanup(void) { + size_t i; cleanuplisteners(); #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); @@ -746,6 +797,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); @@ -1057,6 +1109,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)) { @@ -1091,6 +1145,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 @@ -1149,11 +1215,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); @@ -1561,7 +1626,8 @@ void handlesig(int signo) { if (signo == SIGCHLD) - while (waitpid(-1, NULL, WNOHANG) > 0); + while (waitpid(-1, NULL, WNOHANG) > 0) + ; else if (signo == SIGINT || signo == SIGTERM) quit(NULL); } @@ -1571,7 +1637,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); } @@ -1778,7 +1844,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: @@ -1787,6 +1857,10 @@ mapnotify(struct wl_listener *listener, void *data) * If there is no parent, apply rules */ 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); @@ -2249,6 +2323,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) @@ -2373,9 +2448,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(); @@ -2392,7 +2467,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); } @@ -2595,8 +2670,8 @@ setup(void) * Xcursor themes to source cursor images from and makes sure that cursor * images are available at all scale factors on the screen (necessary for * HiDPI support). Scaled cursors will be loaded with each output. */ - cursor_mgr = wlr_xcursor_manager_create(NULL, 24); - setenv("XCURSOR_SIZE", "24", 1); + cursor_mgr = wlr_xcursor_manager_create(NULL, 16); + setenv("XCURSOR_SIZE", "16", 1); /* * wlr_cursor *only* displays an image on screen. It does not move around @@ -2711,7 +2786,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; @@ -2720,23 +2795,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++; } @@ -2760,6 +2842,13 @@ togglefullscreen(const Arg *arg) } void +togglegaps(const Arg *arg) +{ + selmon->gaps = !selmon->gaps; + arrange(selmon); +} + +void toggletag(const Arg *arg) { uint32_t newtags; @@ -2777,9 +2866,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); @@ -2968,11 +3077,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(); 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 + |
