From 30c33ed26ca9f733316b692d6782f73b58b17780 Mon Sep 17 00:00:00 2001 From: julmajustus Date: Thu, 21 May 2026 01:05:17 +0300 Subject: [PATCH] simple_scratchpad: Spring update scratchpad V2 - Added support for multiple scratchpads --- patches/simple_scratchpad/README.md | 9 +- .../simple_scratchpad-0.8.patch | 211 --------------- .../simple_scratchpad-v0.8.patch | 256 ++++++++++++++++++ ...mple_scratchpad-wlroots-next-d41ecb7.patch | 256 ++++++++++++++++++ ...mple_scratchpad-wlroots-next-f4249db.patch | 219 --------------- 5 files changed, 518 insertions(+), 433 deletions(-) delete mode 100644 patches/simple_scratchpad/simple_scratchpad-0.8.patch create mode 100644 patches/simple_scratchpad/simple_scratchpad-v0.8.patch create mode 100644 patches/simple_scratchpad/simple_scratchpad-wlroots-next-d41ecb7.patch delete mode 100644 patches/simple_scratchpad/simple_scratchpad-wlroots-next-f4249db.patch diff --git a/patches/simple_scratchpad/README.md b/patches/simple_scratchpad/README.md index d7918bb..2227fd6 100644 --- a/patches/simple_scratchpad/README.md +++ b/patches/simple_scratchpad/README.md @@ -2,7 +2,7 @@ # simple_scratchpad — A very simple scratchpad utility. -Adds functions to add, toggle and remove clients to/from scratchpad client list. +Adds functions to add, toggle and remove clients to/from scratchpad client lists. ![scratchpad in action](https://github.com/julmajustus/dwl-patches/blob/main/demos/simple_scratchpad_demo.gif?raw=true) --- @@ -15,12 +15,15 @@ Adds functions to add, toggle and remove clients to/from scratchpad client list. 3. **removescratchpad** - Removes client from scratchpad client list. + +4. **setscratchpad** + - Sets current scratchpad number ### Download - [git branch](https://codeberg.org/julmajustus/dwl/src/branch/simple_scratchpad) -- [scratchpad-wlroots-next-f4249db.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-f4249db.patch) -- [scratchpad-0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-0.8.patch) +- [scratchpad-wlroots-next-d41ecb7.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-wlroots-next-d41ecb7.patch) +- [scratchpad-v0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-v0.8.patch) ### Authors - [julmajustus](https://codeberg.org/julmajustus) diff --git a/patches/simple_scratchpad/simple_scratchpad-0.8.patch b/patches/simple_scratchpad/simple_scratchpad-0.8.patch deleted file mode 100644 index 0d8af99..0000000 --- a/patches/simple_scratchpad/simple_scratchpad-0.8.patch +++ /dev/null @@ -1,211 +0,0 @@ -From 0d603b179ccccbb4270fd202a14a2db18d0a5413 Mon Sep 17 00:00:00 2001 -From: A Frederick Christensen -Date: Thu, 26 Feb 2026 17:09:28 -0600 -Subject: [PATCH] Apply simple_scratchpad patch - ---- - config.def.h | 3 ++ - dwl.c | 34 +++++++++++++++++++++-- - simple_scratchpad.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 103 insertions(+), 2 deletions(-) - create mode 100644 simple_scratchpad.c - -diff --git a/config.def.h b/config.def.h -index 8a6eda0..6254fc9 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -132,6 +132,9 @@ static const Key keys[] = { - { 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_z, addscratchpad, {0} }, -+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_z, togglescratchpad, {0} }, -+ { MODKEY, XKB_KEY_z, removescratchpad, {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]} }, -diff --git a/dwl.c b/dwl.c -index 44f3ad9..215f630 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -139,6 +139,7 @@ typedef struct { - uint32_t tags; - int isfloating, isurgent, isfullscreen; - uint32_t resize; /* configure serial of a pending resize */ -+ struct wl_list link_temp; - } Client; - - typedef struct { -@@ -240,6 +241,7 @@ typedef struct { - } SessionLock; - - /* function declarations */ -+static void addscratchpad(const Arg *arg); - static void applybounds(Client *c, struct wlr_box *bbox); - static void applyrules(Client *c); - static void arrange(Monitor *m); -@@ -314,6 +316,7 @@ static void printstatus(void); - static void powermgrsetmode(struct wl_listener *listener, void *data); - static void quit(const Arg *arg); - static void rendermon(struct wl_listener *listener, void *data); -+static void removescratchpad(const Arg *arg); - static void requestdecorationmode(struct wl_listener *listener, void *data); - static void requeststartdrag(struct wl_listener *listener, void *data); - static void requestmonstate(struct wl_listener *listener, void *data); -@@ -336,6 +339,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 togglescratchpad(const Arg *arg); - static void toggletag(const Arg *arg); - static void toggleview(const Arg *arg); - static void unlocksession(struct wl_listener *listener, void *data); -@@ -406,6 +410,9 @@ static struct wlr_box sgeom; - static struct wl_list mons; - static Monitor *selmon; - -+static struct wl_list scratchpad_clients; -+static int scratchpad_visible = 1; -+ - /* global event handlers */ - static struct wl_listener cursor_axis = {.notify = axisnotify}; - static struct wl_listener cursor_button = {.notify = buttonpress}; -@@ -455,6 +462,8 @@ static struct wlr_xwayland *xwayland; - /* attempt to encapsulate suck into one file */ - #include "client.h" - -+#include "simple_scratchpad.c" -+ - /* function implementations */ - void - applybounds(Client *c, struct wlr_box *bbox) -@@ -1328,10 +1337,20 @@ void - destroynotify(struct wl_listener *listener, void *data) - { - /* Called when the xdg_toplevel is destroyed. */ -- Client *c = wl_container_of(listener, c, destroy); -+ Client *sc, *c = wl_container_of(listener, c, destroy); - wl_list_remove(&c->destroy.link); - wl_list_remove(&c->set_title.link); - wl_list_remove(&c->fullscreen.link); -+ /* Check if destroyed client was part of scratchpad_clients -+ * and clean it from the list if so. */ -+ if (c && wl_list_length(&scratchpad_clients) > 0) { -+ wl_list_for_each(sc, &scratchpad_clients, link_temp) { -+ if (sc == c) { -+ wl_list_remove(&c->link_temp); -+ break; -+ } -+ } -+ } - #ifdef XWAYLAND - if (c->type != XDGShell) { - wl_list_remove(&c->activate.link); -@@ -2333,11 +2352,21 @@ setcursorshape(struct wl_listener *listener, void *data) - void - setfloating(Client *c, int floating) - { -- Client *p = client_get_parent(c); -+ Client *sc, *p = client_get_parent(c); - c->isfloating = floating; - /* If in floating layout do not change the client's layer */ - if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange) - return; -+ /* Check if unfloated client was part of scratchpad_clients -+ * and remove it from scratchpad_clients list if so */ -+ if (!floating && wl_list_length(&scratchpad_clients) > 0) { -+ wl_list_for_each(sc, &scratchpad_clients, link_temp) { -+ if (sc == c) { -+ wl_list_remove(&c->link_temp); -+ break; -+ } -+ } -+ } - wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || - (p && p->isfullscreen) ? LyrFS - : c->isfloating ? LyrFloat : LyrTile]); -@@ -2554,6 +2583,7 @@ setup(void) - */ - wl_list_init(&clients); - wl_list_init(&fstack); -+ wl_list_init(&scratchpad_clients); - - xdg_shell = wlr_xdg_shell_create(dpy, 6); - wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel); -diff --git a/simple_scratchpad.c b/simple_scratchpad.c -new file mode 100644 -index 0000000..26d6b66 ---- /dev/null -+++ b/simple_scratchpad.c -@@ -0,0 +1,68 @@ -+/* ************************************************************************** */ -+/* */ -+/* ::: :::::::: */ -+/* simple_scratchpad.c :+: :+: :+: */ -+/* +:+ +:+ +:+ */ -+/* By: jmakkone +#+ +:+ +#+ */ -+/* +#+#+#+#+#+ +#+ */ -+/* Created: 2024/12/19 19:35:02 by jmakkone #+# #+# */ -+/* Updated: 2025/01/04 13:35:50 by jmakkone ### ########.fr */ -+/* */ -+/* ************************************************************************** */ -+ -+void -+addscratchpad(const Arg *arg) -+{ -+ Client *cc, *c = focustop(selmon); -+ -+ if (!c) -+ return; -+ /* Check if the added client is already a scratchpad client */ -+ wl_list_for_each(cc, &scratchpad_clients, link_temp) { -+ if (cc == c) -+ return; -+ } -+ if (!c->isfloating) { -+ setfloating(c, 1); -+ } -+ wl_list_insert(&scratchpad_clients, &c->link_temp); -+} -+ -+void -+togglescratchpad(const Arg *arg) -+{ -+ Client *c; -+ Monitor *m = selmon; -+ -+ scratchpad_visible = !scratchpad_visible; -+ if (scratchpad_visible) { -+ wl_list_for_each(c, &scratchpad_clients, link_temp) { -+ c->mon = m; -+ c->tags = m->tagset[m->seltags]; -+ arrange(m); -+ focusclient(c, 1); -+ } -+ } else { -+ wl_list_for_each(c, &scratchpad_clients, link_temp) { -+ c->tags = 0; -+ focusclient(focustop(m), 1); -+ arrange(m); -+ } -+ } -+} -+ -+void -+removescratchpad(const Arg *arg) -+{ -+ Client *sc, *c = focustop(selmon); -+ -+ if (c && wl_list_length(&scratchpad_clients) > 0) { -+ /* Check if c is in scratchpad_clients */ -+ wl_list_for_each(sc, &scratchpad_clients, link_temp) { -+ if (sc == c) { -+ wl_list_remove(&c->link_temp); -+ break; -+ } -+ } -+ } -+} --- -2.52.0 - diff --git a/patches/simple_scratchpad/simple_scratchpad-v0.8.patch b/patches/simple_scratchpad/simple_scratchpad-v0.8.patch new file mode 100644 index 0000000..8a6cca8 --- /dev/null +++ b/patches/simple_scratchpad/simple_scratchpad-v0.8.patch @@ -0,0 +1,256 @@ +From 09c708876afe3675f68f7b35c3f17263b134ceee Mon Sep 17 00:00:00 2001 +From: julmajustus +Date: Thu, 21 May 2026 00:28:15 +0300 +Subject: [PATCH] simple_scratchpad: Spring update scratchpad V2 + +- Added support for multiple scratchpads +--- + config.def.h | 7 ++++ + dwl.c | 43 +++++++++++++++++++++-- + simple_scratchpad.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 133 insertions(+), 2 deletions(-) + create mode 100644 simple_scratchpad.c + +diff --git a/config.def.h b/config.def.h +index 8a6eda0..a527e09 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -14,6 +14,7 @@ static const float urgentcolor[] = COLOR(0xff0000ff); + /* 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 */ + ++#define SCRATCHPAD_COUNT 3 + /* tagging - TAGCOUNT must be no greater than 31 */ + #define TAGCOUNT (9) + +@@ -132,6 +133,9 @@ static const Key keys[] = { + { 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_z, addscratchpad, {0} }, ++ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_z, togglescratchpad, {0} }, ++ { MODKEY, XKB_KEY_z, removescratchpad, {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]} }, +@@ -144,6 +148,9 @@ static const Key keys[] = { + { 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_LOGO, XKB_KEY_1, setscratchpad, {.i = 0} }, ++ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_2, setscratchpad, {.i = 1} }, ++ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_3, setscratchpad, {.i = 2} }, + TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), + TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), + TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), +diff --git a/dwl.c b/dwl.c +index 44f3ad9..f54bbda 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -139,6 +139,7 @@ typedef struct { + uint32_t tags; + int isfloating, isurgent, isfullscreen; + uint32_t resize; /* configure serial of a pending resize */ ++ struct wl_list link_temp; + } Client; + + typedef struct { +@@ -240,6 +241,7 @@ typedef struct { + } SessionLock; + + /* function declarations */ ++static void addscratchpad(const Arg *arg); + static void applybounds(Client *c, struct wlr_box *bbox); + static void applyrules(Client *c); + static void arrange(Monitor *m); +@@ -314,6 +316,7 @@ static void printstatus(void); + static void powermgrsetmode(struct wl_listener *listener, void *data); + static void quit(const Arg *arg); + static void rendermon(struct wl_listener *listener, void *data); ++static void removescratchpad(const Arg *arg); + static void requestdecorationmode(struct wl_listener *listener, void *data); + static void requeststartdrag(struct wl_listener *listener, void *data); + static void requestmonstate(struct wl_listener *listener, void *data); +@@ -327,6 +330,7 @@ static void setlayout(const Arg *arg); + static void setmfact(const Arg *arg); + static void setmon(Client *c, Monitor *m, uint32_t newtags); + static void setpsel(struct wl_listener *listener, void *data); ++static void setscratchpad(const Arg *arg); + static void setsel(struct wl_listener *listener, void *data); + static void setup(void); + static void spawn(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 togglescratchpad(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,11 @@ static struct wlr_xwayland *xwayland; + /* attempt to encapsulate suck into one file */ + #include "client.h" + ++static struct wl_list scratchpad_clients[SCRATCHPAD_COUNT]; ++static int scratchpad_visible[SCRATCHPAD_COUNT]; ++static int scratchpad_sel = 0; ++#include "simple_scratchpad.c" ++ + /* function implementations */ + void + applybounds(Client *c, struct wlr_box *bbox) +@@ -1328,10 +1338,21 @@ void + destroynotify(struct wl_listener *listener, void *data) + { + /* Called when the xdg_toplevel is destroyed. */ +- Client *c = wl_container_of(listener, c, destroy); ++ Client *sc, *c = wl_container_of(listener, c, destroy); + wl_list_remove(&c->destroy.link); + wl_list_remove(&c->set_title.link); + wl_list_remove(&c->fullscreen.link); ++ /* Check if destroyed client was part of any scratchpad slot ++ * and clean it from the list if so. */ ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ wl_list_for_each(sc, &scratchpad_clients[i], link_temp) { ++ if (sc == c) { ++ wl_list_remove(&c->link_temp); ++ goto scratchpad_destroy_done; ++ } ++ } ++ } ++scratchpad_destroy_done:; + #ifdef XWAYLAND + if (c->type != XDGShell) { + wl_list_remove(&c->activate.link); +@@ -2333,11 +2354,24 @@ setcursorshape(struct wl_listener *listener, void *data) + void + setfloating(Client *c, int floating) + { +- Client *p = client_get_parent(c); ++ Client *sc, *p = client_get_parent(c); + c->isfloating = floating; + /* If in floating layout do not change the client's layer */ + if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange) + return; ++ /* Check if unfloated client was part of any scratchpad slot ++ * and remove it from that slot if so */ ++ if (!floating) { ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ wl_list_for_each(sc, &scratchpad_clients[i], link_temp) { ++ if (sc == c) { ++ wl_list_remove(&c->link_temp); ++ goto scratchpad_float_done; ++ } ++ } ++ } ++scratchpad_float_done:; ++ } + wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || + (p && p->isfullscreen) ? LyrFS + : c->isfloating ? LyrFloat : LyrTile]); +@@ -2554,6 +2588,11 @@ setup(void) + */ + wl_list_init(&clients); + wl_list_init(&fstack); ++ wl_list_init(&fstack); ++ for (int j = 0; j < SCRATCHPAD_COUNT; j++) { ++ wl_list_init(&scratchpad_clients[j]); ++ scratchpad_visible[j] = 1; ++ } + + xdg_shell = wlr_xdg_shell_create(dpy, 6); + wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel); +diff --git a/simple_scratchpad.c b/simple_scratchpad.c +new file mode 100644 +index 0000000..cd62d83 +--- /dev/null ++++ b/simple_scratchpad.c +@@ -0,0 +1,85 @@ ++/* ************************************************************************** */ ++/* @@@ @@@@@@@@ */ ++/* @@@ @@@@@@@@@@ */ ++/* @@! @@! @@@@ */ ++/* !@! !@! @!@!@ */ ++/* simple_scratchpad.c @!! @!@ @! !@! */ ++/* !!! !@!!! !!! */ ++/* By: julmajustus !!: !!:! !!! */ ++/* ::! :!: !:! */ ++/* Created: 2024/12/19 19:35:02 by jmakkone :: ::::::: :: */ ++/* Updated: 2026/05/20 23:58:16 by julmajustus : : : : : : */ ++/* */ ++/* ************************************************************************** */ ++ ++void ++addscratchpad(const Arg *arg) ++{ ++ Client *cc, *c = focustop(selmon); ++ ++ if (!c) ++ return; ++ /* Check if the added client is already a scratchpad client */ ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ wl_list_for_each(cc, &scratchpad_clients[i], link_temp) { ++ if (cc == c) ++ return; ++ } ++ } ++ if (!c->isfloating) { ++ setfloating(c, 1); ++ } ++ wl_list_insert(&scratchpad_clients[scratchpad_sel], &c->link_temp); ++} ++ ++void ++togglescratchpad(const Arg *arg) ++{ ++ Client *c; ++ Monitor *m = selmon; ++ ++ scratchpad_visible[scratchpad_sel] = !scratchpad_visible[scratchpad_sel]; ++ if (scratchpad_visible[scratchpad_sel]) { ++ wl_list_for_each(c, &scratchpad_clients[scratchpad_sel], link_temp) { ++ c->mon = m; ++ c->tags = m->tagset[m->seltags]; ++ arrange(m); ++ focusclient(c, 1); ++ } ++ } else { ++ wl_list_for_each(c, &scratchpad_clients[scratchpad_sel], link_temp) { ++ c->tags = 0; ++ focusclient(focustop(m), 1); ++ arrange(m); ++ } ++ } ++} ++ ++void ++removescratchpad(const Arg *arg) ++{ ++ Client *sc, *c = focustop(selmon); ++ if (!c) ++ return; ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ /* Check if c is in scratchpad_clients */ ++ wl_list_for_each(sc, &scratchpad_clients[i], link_temp) { ++ if (sc == c) { ++ wl_list_remove(&c->link_temp); ++ return; ++ } ++ } ++ } ++} ++ ++void ++setscratchpad(const Arg *arg) ++{ ++ int idx = arg->i; ++ ++ if (idx < 0) ++ idx = 0; ++ else if (idx >= SCRATCHPAD_COUNT) ++ idx = SCRATCHPAD_COUNT - 1; ++ scratchpad_sel = idx; ++} +-- +2.53.0 + diff --git a/patches/simple_scratchpad/simple_scratchpad-wlroots-next-d41ecb7.patch b/patches/simple_scratchpad/simple_scratchpad-wlroots-next-d41ecb7.patch new file mode 100644 index 0000000..ff5fd66 --- /dev/null +++ b/patches/simple_scratchpad/simple_scratchpad-wlroots-next-d41ecb7.patch @@ -0,0 +1,256 @@ +From be4f7488eac6ea502e0e9d1cc5595e01d97cb345 Mon Sep 17 00:00:00 2001 +From: julmajustus +Date: Thu, 21 May 2026 00:28:41 +0300 +Subject: [PATCH] simple_scratchpad: Spring update scratchpad V2 + +- Added support for multiple scratchpads +--- + config.def.h | 7 ++++ + dwl.c | 43 +++++++++++++++++++++-- + simple_scratchpad.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 133 insertions(+), 2 deletions(-) + create mode 100644 simple_scratchpad.c + +diff --git a/config.def.h b/config.def.h +index 8a6eda0..a527e09 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -14,6 +14,7 @@ static const float urgentcolor[] = COLOR(0xff0000ff); + /* 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 */ + ++#define SCRATCHPAD_COUNT 3 + /* tagging - TAGCOUNT must be no greater than 31 */ + #define TAGCOUNT (9) + +@@ -132,6 +133,9 @@ static const Key keys[] = { + { 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_z, addscratchpad, {0} }, ++ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_z, togglescratchpad, {0} }, ++ { MODKEY, XKB_KEY_z, removescratchpad, {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]} }, +@@ -144,6 +148,9 @@ static const Key keys[] = { + { 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_LOGO, XKB_KEY_1, setscratchpad, {.i = 0} }, ++ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_2, setscratchpad, {.i = 1} }, ++ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_3, setscratchpad, {.i = 2} }, + TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), + TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), + TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), +diff --git a/dwl.c b/dwl.c +index 8101ffa..1c858a8 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -143,6 +143,7 @@ typedef struct { + uint32_t tags; + int isfloating, isurgent, isfullscreen; + uint32_t resize; /* configure serial of a pending resize */ ++ struct wl_list link_temp; + } Client; + + typedef struct { +@@ -244,6 +245,7 @@ typedef struct { + } SessionLock; + + /* function declarations */ ++static void addscratchpad(const Arg *arg); + static void applybounds(Client *c, struct wlr_box *bbox); + static void applyrules(Client *c); + static void arrange(Monitor *m); +@@ -318,6 +320,7 @@ static void printstatus(void); + static void powermgrsetmode(struct wl_listener *listener, void *data); + static void quit(const Arg *arg); + static void rendermon(struct wl_listener *listener, void *data); ++static void removescratchpad(const Arg *arg); + static void requestdecorationmode(struct wl_listener *listener, void *data); + static void requeststartdrag(struct wl_listener *listener, void *data); + static void requestmonstate(struct wl_listener *listener, void *data); +@@ -331,6 +334,7 @@ static void setlayout(const Arg *arg); + static void setmfact(const Arg *arg); + static void setmon(Client *c, Monitor *m, uint32_t newtags); + static void setpsel(struct wl_listener *listener, void *data); ++static void setscratchpad(const Arg *arg); + static void setsel(struct wl_listener *listener, void *data); + static void setup(void); + static void spawn(const Arg *arg); +@@ -340,6 +344,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 togglescratchpad(const Arg *arg); + static void toggletag(const Arg *arg); + static void toggleview(const Arg *arg); + static void unlocksession(struct wl_listener *listener, void *data); +@@ -459,6 +464,11 @@ static struct wlr_xwayland *xwayland; + /* attempt to encapsulate suck into one file */ + #include "client.h" + ++static struct wl_list scratchpad_clients[SCRATCHPAD_COUNT]; ++static int scratchpad_visible[SCRATCHPAD_COUNT]; ++static int scratchpad_sel = 0; ++#include "simple_scratchpad.c" ++ + /* function implementations */ + void + applybounds(Client *c, struct wlr_box *bbox) +@@ -1332,10 +1342,21 @@ void + destroynotify(struct wl_listener *listener, void *data) + { + /* Called when the xdg_toplevel is destroyed. */ +- Client *c = wl_container_of(listener, c, destroy); ++ Client *sc, *c = wl_container_of(listener, c, destroy); + wl_list_remove(&c->destroy.link); + wl_list_remove(&c->set_title.link); + wl_list_remove(&c->fullscreen.link); ++ /* Check if destroyed client was part of any scratchpad slot ++ * and clean it from the list if so. */ ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ wl_list_for_each(sc, &scratchpad_clients[i], link_temp) { ++ if (sc == c) { ++ wl_list_remove(&c->link_temp); ++ goto scratchpad_destroy_done; ++ } ++ } ++ } ++scratchpad_destroy_done:; + #ifdef XWAYLAND + if (c->type != XDGShell) { + wl_list_remove(&c->activate.link); +@@ -2337,11 +2358,24 @@ setcursorshape(struct wl_listener *listener, void *data) + void + setfloating(Client *c, int floating) + { +- Client *p = client_get_parent(c); ++ Client *sc, *p = client_get_parent(c); + c->isfloating = floating; + /* If in floating layout do not change the client's layer */ + if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange) + return; ++ /* Check if unfloated client was part of any scratchpad slot ++ * and remove it from that slot if so */ ++ if (!floating) { ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ wl_list_for_each(sc, &scratchpad_clients[i], link_temp) { ++ if (sc == c) { ++ wl_list_remove(&c->link_temp); ++ goto scratchpad_float_done; ++ } ++ } ++ } ++scratchpad_float_done:; ++ } + wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || + (p && p->isfullscreen) ? LyrFS + : c->isfloating ? LyrFloat : LyrTile]); +@@ -2561,6 +2595,11 @@ setup(void) + */ + wl_list_init(&clients); + wl_list_init(&fstack); ++ wl_list_init(&fstack); ++ for (int j = 0; j < SCRATCHPAD_COUNT; j++) { ++ wl_list_init(&scratchpad_clients[j]); ++ scratchpad_visible[j] = 1; ++ } + + xdg_shell = wlr_xdg_shell_create(dpy, 6); + wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel); +diff --git a/simple_scratchpad.c b/simple_scratchpad.c +new file mode 100644 +index 0000000..0e23ddd +--- /dev/null ++++ b/simple_scratchpad.c +@@ -0,0 +1,85 @@ ++/* ************************************************************************** */ ++/* @@@ @@@@@@@@ */ ++/* @@@ @@@@@@@@@@ */ ++/* @@! @@! @@@@ */ ++/* !@! !@! @!@!@ */ ++/* simple_scratchpad.c @!! @!@ @! !@! */ ++/* !!! !@!!! !!! */ ++/* By: julmajustus !!: !!:! !!! */ ++/* ::! :!: !:! */ ++/* Created: 2024/12/19 19:35:02 by jmakkone :: ::::::: :: */ ++/* Updated: 2026/05/20 23:56:35 by julmajustus : : : : : : */ ++/* */ ++/* ************************************************************************** */ ++ ++void ++addscratchpad(const Arg *arg) ++{ ++ Client *cc, *c = focustop(selmon); ++ ++ if (!c) ++ return; ++ /* Check if the added client is already a scratchpad client */ ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ wl_list_for_each(cc, &scratchpad_clients[i], link_temp) { ++ if (cc == c) ++ return; ++ } ++ } ++ if (!c->isfloating) { ++ setfloating(c, 1); ++ } ++ wl_list_insert(&scratchpad_clients[scratchpad_sel], &c->link_temp); ++} ++ ++void ++togglescratchpad(const Arg *arg) ++{ ++ Client *c; ++ Monitor *m = selmon; ++ ++ scratchpad_visible[scratchpad_sel] = !scratchpad_visible[scratchpad_sel]; ++ if (scratchpad_visible[scratchpad_sel]) { ++ wl_list_for_each(c, &scratchpad_clients[scratchpad_sel], link_temp) { ++ c->mon = m; ++ c->tags = m->tagset[m->seltags]; ++ arrange(m); ++ focusclient(c, 1); ++ } ++ } else { ++ wl_list_for_each(c, &scratchpad_clients[scratchpad_sel], link_temp) { ++ c->tags = 0; ++ focusclient(focustop(m), 1); ++ arrange(m); ++ } ++ } ++} ++ ++void ++removescratchpad(const Arg *arg) ++{ ++ Client *sc, *c = focustop(selmon); ++ if (!c) ++ return; ++ for (int i = 0; i < SCRATCHPAD_COUNT; i++) { ++ /* Check if c is in scratchpad_clients */ ++ wl_list_for_each(sc, &scratchpad_clients[i], link_temp) { ++ if (sc == c) { ++ wl_list_remove(&c->link_temp); ++ return; ++ } ++ } ++ } ++} ++ ++void ++setscratchpad(const Arg *arg) ++{ ++ int idx = arg->i; ++ ++ if (idx < 0) ++ idx = 0; ++ else if (idx >= SCRATCHPAD_COUNT) ++ idx = SCRATCHPAD_COUNT - 1; ++ scratchpad_sel = idx; ++} +-- +2.53.0 + diff --git a/patches/simple_scratchpad/simple_scratchpad-wlroots-next-f4249db.patch b/patches/simple_scratchpad/simple_scratchpad-wlroots-next-f4249db.patch deleted file mode 100644 index 690fa99..0000000 --- a/patches/simple_scratchpad/simple_scratchpad-wlroots-next-f4249db.patch +++ /dev/null @@ -1,219 +0,0 @@ -From 94e649317328c7af091516fe3441ea80a814d1e4 Mon Sep 17 00:00:00 2001 -From: A Frederick Christensen -Date: Thu, 26 Feb 2026 17:18:17 -0600 -Subject: [PATCH] Apply simple_scratchpad patch - ---- - config.def.h | 4 ++- - dwl.c | 34 +++++++++++++++++++++-- - simple_scratchpad.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 103 insertions(+), 3 deletions(-) - create mode 100644 simple_scratchpad.c - -diff --git a/config.def.h b/config.def.h -index 8a6eda0..bd6cb40 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -132,6 +132,9 @@ static const Key keys[] = { - { 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_z, addscratchpad, {0} }, -+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_z, togglescratchpad, {0} }, -+ { MODKEY, XKB_KEY_z, removescratchpad, {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]} }, -@@ -154,7 +157,6 @@ static const Key keys[] = { - 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} }, -- - /* 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} }, - /* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is -diff --git a/dwl.c b/dwl.c -index 8a9715d..6ae7707 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -141,6 +141,7 @@ typedef struct { - uint32_t tags; - int isfloating, isurgent, isfullscreen; - uint32_t resize; /* configure serial of a pending resize */ -+ struct wl_list link_temp; - } Client; - - typedef struct { -@@ -242,6 +243,7 @@ typedef struct { - } SessionLock; - - /* function declarations */ -+static void addscratchpad(const Arg *arg); - static void applybounds(Client *c, struct wlr_box *bbox); - static void applyrules(Client *c); - static void arrange(Monitor *m); -@@ -316,6 +318,7 @@ static void printstatus(void); - static void powermgrsetmode(struct wl_listener *listener, void *data); - static void quit(const Arg *arg); - static void rendermon(struct wl_listener *listener, void *data); -+static void removescratchpad(const Arg *arg); - static void requestdecorationmode(struct wl_listener *listener, void *data); - static void requeststartdrag(struct wl_listener *listener, void *data); - static void requestmonstate(struct wl_listener *listener, void *data); -@@ -338,6 +341,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 togglescratchpad(const Arg *arg); - static void toggletag(const Arg *arg); - static void toggleview(const Arg *arg); - static void unlocksession(struct wl_listener *listener, void *data); -@@ -408,6 +412,9 @@ static struct wlr_box sgeom; - static struct wl_list mons; - static Monitor *selmon; - -+static struct wl_list scratchpad_clients; -+static int scratchpad_visible = 1; -+ - /* global event handlers */ - static struct wl_listener cursor_axis = {.notify = axisnotify}; - static struct wl_listener cursor_button = {.notify = buttonpress}; -@@ -457,6 +464,8 @@ static struct wlr_xwayland *xwayland; - /* attempt to encapsulate suck into one file */ - #include "client.h" - -+#include "simple_scratchpad.c" -+ - /* function implementations */ - void - applybounds(Client *c, struct wlr_box *bbox) -@@ -1330,10 +1339,20 @@ void - destroynotify(struct wl_listener *listener, void *data) - { - /* Called when the xdg_toplevel is destroyed. */ -- Client *c = wl_container_of(listener, c, destroy); -+ Client *sc, *c = wl_container_of(listener, c, destroy); - wl_list_remove(&c->destroy.link); - wl_list_remove(&c->set_title.link); - wl_list_remove(&c->fullscreen.link); -+ /* Check if destroyed client was part of scratchpad_clients -+ * and clean it from the list if so. */ -+ if (c && wl_list_length(&scratchpad_clients) > 0) { -+ wl_list_for_each(sc, &scratchpad_clients, link_temp) { -+ if (sc == c) { -+ wl_list_remove(&c->link_temp); -+ break; -+ } -+ } -+ } - #ifdef XWAYLAND - if (c->type != XDGShell) { - wl_list_remove(&c->activate.link); -@@ -2335,11 +2354,21 @@ setcursorshape(struct wl_listener *listener, void *data) - void - setfloating(Client *c, int floating) - { -- Client *p = client_get_parent(c); -+ Client *sc, *p = client_get_parent(c); - c->isfloating = floating; - /* If in floating layout do not change the client's layer */ - if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange) - return; -+ /* Check if unfloated client was part of scratchpad_clients -+ * and remove it from scratchpad_clients list if so */ -+ if (!floating && wl_list_length(&scratchpad_clients) > 0) { -+ wl_list_for_each(sc, &scratchpad_clients, link_temp) { -+ if (sc == c) { -+ wl_list_remove(&c->link_temp); -+ break; -+ } -+ } -+ } - wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || - (p && p->isfullscreen) ? LyrFS - : c->isfloating ? LyrFloat : LyrTile]); -@@ -2557,6 +2586,7 @@ setup(void) - */ - wl_list_init(&clients); - wl_list_init(&fstack); -+ wl_list_init(&scratchpad_clients); - - xdg_shell = wlr_xdg_shell_create(dpy, 6); - wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel); -diff --git a/simple_scratchpad.c b/simple_scratchpad.c -new file mode 100644 -index 0000000..26d6b66 ---- /dev/null -+++ b/simple_scratchpad.c -@@ -0,0 +1,68 @@ -+/* ************************************************************************** */ -+/* */ -+/* ::: :::::::: */ -+/* simple_scratchpad.c :+: :+: :+: */ -+/* +:+ +:+ +:+ */ -+/* By: jmakkone +#+ +:+ +#+ */ -+/* +#+#+#+#+#+ +#+ */ -+/* Created: 2024/12/19 19:35:02 by jmakkone #+# #+# */ -+/* Updated: 2025/01/04 13:35:50 by jmakkone ### ########.fr */ -+/* */ -+/* ************************************************************************** */ -+ -+void -+addscratchpad(const Arg *arg) -+{ -+ Client *cc, *c = focustop(selmon); -+ -+ if (!c) -+ return; -+ /* Check if the added client is already a scratchpad client */ -+ wl_list_for_each(cc, &scratchpad_clients, link_temp) { -+ if (cc == c) -+ return; -+ } -+ if (!c->isfloating) { -+ setfloating(c, 1); -+ } -+ wl_list_insert(&scratchpad_clients, &c->link_temp); -+} -+ -+void -+togglescratchpad(const Arg *arg) -+{ -+ Client *c; -+ Monitor *m = selmon; -+ -+ scratchpad_visible = !scratchpad_visible; -+ if (scratchpad_visible) { -+ wl_list_for_each(c, &scratchpad_clients, link_temp) { -+ c->mon = m; -+ c->tags = m->tagset[m->seltags]; -+ arrange(m); -+ focusclient(c, 1); -+ } -+ } else { -+ wl_list_for_each(c, &scratchpad_clients, link_temp) { -+ c->tags = 0; -+ focusclient(focustop(m), 1); -+ arrange(m); -+ } -+ } -+} -+ -+void -+removescratchpad(const Arg *arg) -+{ -+ Client *sc, *c = focustop(selmon); -+ -+ if (c && wl_list_length(&scratchpad_clients) > 0) { -+ /* Check if c is in scratchpad_clients */ -+ wl_list_for_each(sc, &scratchpad_clients, link_temp) { -+ if (sc == c) { -+ wl_list_remove(&c->link_temp); -+ break; -+ } -+ } -+ } -+} --- -2.52.0 -