simple_scratchpad: update

- Updated to current main
This commit is contained in:
julmajustus
2026-09-20 03:27:16 +03:00
parent 0d41b75737
commit d5bbf841c2
2 changed files with 60 additions and 45 deletions
+6 -6
View File
@@ -1,10 +1,10 @@
### Description ### Description
# simple_scratchpad A very simple scratchpad utility. # simple_scratchpad - A very simple scratchpad utility.
Adds functions to add, toggle and remove clients to/from scratchpad client lists. Adds functions to add, toggle and remove clients to/from scratchpad client lists.
![scratchpad in action](https://codeberg.org/julmajustus/my-dwl-patches/raw/branch/main/demos/simple_scratchpad_demo.gif?raw=true) ![scratchpad in action](https://codeberg.org/julmajustus/my-dwl-patches/raw/branch/main/demos/simple_scratchpad_demo.gif?raw=true)
--- ---
1. **addscratchpad** 1. **addscratchpad**
@@ -18,12 +18,12 @@ Adds functions to add, toggle and remove clients to/from scratchpad client lists
4. **setscratchpad** 4. **setscratchpad**
- Sets current scratchpad number - Sets current scratchpad number
### Download ### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/simple_scratchpad) - [git branch](https://codeberg.org/julmajustus/dwl/src/branch/simple_scratchpad-0.9)
- [scratchpad-wlroots-next-d41ecb7.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-wlroots-next-d41ecb7.patch) - [main-d16036e](./simple_scratchpad-d16036e.patch)
- [scratchpad-v0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-v0.8.patch) - [scratchpad-v0.8.patch](./simple_scratchpad-v0.8.patch)
### Authors ### Authors
- [julmajustus](https://codeberg.org/julmajustus) - [julmajustus](https://codeberg.org/julmajustus)
@@ -1,21 +1,35 @@
From be4f7488eac6ea502e0e9d1cc5595e01d97cb345 Mon Sep 17 00:00:00 2001 From da5b4335fab5ca589ac6a9e569aa99aaa091eae9 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com> From: julmajustus <julmajustus@tutanota.com>
Date: Thu, 21 May 2026 00:28:41 +0300 Date: Sun, 20 Sep 2026 02:23:44 +0300
Subject: [PATCH] simple_scratchpad: Spring update scratchpad V2 Subject: [PATCH] simple_scratchpad d16036e refactor
- Added support for multiple scratchpads
--- ---
Makefile | 3 +-
config.def.h | 7 ++++ config.def.h | 7 ++++
dwl.c | 43 +++++++++++++++++++++-- dwl.c | 40 +++++++++++++++++++-
simple_scratchpad.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ simple_scratchpad.h | 89 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 133 insertions(+), 2 deletions(-) 4 files changed, 136 insertions(+), 3 deletions(-)
create mode 100644 simple_scratchpad.c create mode 100644 simple_scratchpad.h
diff --git a/Makefile b/Makefile
index 8304245..4592dff 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,8 @@ all: dwl
dwl: dwl.c client.h config.h ime.h util.h config.mk cursor-shape-v1-protocol.h \
ext-image-copy-capture-v1-protocol.h \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
+ simple_scratchpad.h
$(CC) dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
# wayland-scanner is a tool which generates C headers and rigging for Wayland
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
index 8a6eda0..a527e09 100644 index 13c5322..acd44d9 100644
--- a/config.def.h --- a/config.def.h
+++ b/config.def.h +++ b/config.def.h
@@ -14,6 +14,7 @@ static const float urgentcolor[] = COLOR(0xff0000ff); @@ -15,6 +15,7 @@ static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ /* 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 */ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
@@ -35,27 +49,27 @@ index 8a6eda0..a527e09 100644
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
@@ -144,6 +148,9 @@ static const Key keys[] = { @@ -144,6 +148,9 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} }, { 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_comma, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_period, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_1, setscratchpad, {.i = 0} }, + { 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_2, setscratchpad, {.i = 1} },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_3, setscratchpad, {.i = 2} }, + { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_3, setscratchpad, {.i = 2} },
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), TAGKEYS( XKB_KEY_1, 0),
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), TAGKEYS( XKB_KEY_2, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), TAGKEYS( XKB_KEY_3, 2),
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index 8101ffa..1c858a8 100644 index 4cfd0fd..91a7628 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -143,6 +143,7 @@ typedef struct { @@ -159,6 +159,7 @@ typedef struct {
unsigned int bw;
uint32_t tags; uint32_t tags;
int isfloating, isurgent, isfullscreen; int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
+ struct wl_list link_temp; + struct wl_list link_temp;
} Client; } Client;
typedef struct { typedef struct {
@@ -244,6 +245,7 @@ typedef struct { @@ -260,6 +261,7 @@ typedef struct {
} SessionLock; } SessionLock;
/* function declarations */ /* function declarations */
@@ -63,7 +77,7 @@ index 8101ffa..1c858a8 100644
static void applybounds(Client *c, struct wlr_box *bbox); static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c); static void applyrules(Client *c);
static void arrange(Monitor *m); static void arrange(Monitor *m);
@@ -318,6 +320,7 @@ static void printstatus(void); @@ -335,6 +337,7 @@ static void printstatus(void);
static void powermgrsetmode(struct wl_listener *listener, void *data); static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg); static void quit(const Arg *arg);
static void rendermon(struct wl_listener *listener, void *data); static void rendermon(struct wl_listener *listener, void *data);
@@ -71,7 +85,7 @@ index 8101ffa..1c858a8 100644
static void requestdecorationmode(struct wl_listener *listener, void *data); static void requestdecorationmode(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data); static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(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); @@ -348,6 +351,7 @@ static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags); static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data); static void setpsel(struct wl_listener *listener, void *data);
@@ -79,7 +93,7 @@ index 8101ffa..1c858a8 100644
static void setsel(struct wl_listener *listener, void *data); static void setsel(struct wl_listener *listener, void *data);
static void setup(void); static void setup(void);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
@@ -340,6 +344,7 @@ static void tagmon(const Arg *arg); @@ -357,6 +361,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m); static void tile(Monitor *m);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg); static void togglefullscreen(const Arg *arg);
@@ -87,19 +101,16 @@ index 8101ffa..1c858a8 100644
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg); static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data); static void unlocksession(struct wl_listener *listener, void *data);
@@ -459,6 +464,11 @@ static struct wlr_xwayland *xwayland; @@ -484,6 +489,8 @@ static struct wlr_xwayland *xwayland;
/* attempt to encapsulate suck into one file */
#include "client.h"
+static struct wl_list scratchpad_clients[SCRATCHPAD_COUNT]; #include "ime.h"
+static int scratchpad_visible[SCRATCHPAD_COUNT];
+static int scratchpad_sel = 0; +#include "simple_scratchpad.h"
+#include "simple_scratchpad.c"
+ +
/* function implementations */ /* function implementations */
void void
applybounds(Client *c, struct wlr_box *bbox) applybounds(Client *c, struct wlr_box *bbox)
@@ -1332,10 +1342,21 @@ void @@ -1427,10 +1434,21 @@ void
destroynotify(struct wl_listener *listener, void *data) destroynotify(struct wl_listener *listener, void *data)
{ {
/* Called when the xdg_toplevel is destroyed. */ /* Called when the xdg_toplevel is destroyed. */
@@ -122,7 +133,7 @@ index 8101ffa..1c858a8 100644
#ifdef XWAYLAND #ifdef XWAYLAND
if (c->type != XDGShell) { if (c->type != XDGShell) {
wl_list_remove(&c->activate.link); wl_list_remove(&c->activate.link);
@@ -2337,11 +2358,24 @@ setcursorshape(struct wl_listener *listener, void *data) @@ -2490,11 +2508,24 @@ setcursorshape(struct wl_listener *listener, void *data)
void void
setfloating(Client *c, int floating) setfloating(Client *c, int floating)
{ {
@@ -148,7 +159,7 @@ index 8101ffa..1c858a8 100644
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen || wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
(p && p->isfullscreen) ? LyrFS (p && p->isfullscreen) ? LyrFS
: c->isfloating ? LyrFloat : LyrTile]); : c->isfloating ? LyrFloat : LyrTile]);
@@ -2561,6 +2595,11 @@ setup(void) @@ -2714,6 +2745,11 @@ setup(void)
*/ */
wl_list_init(&clients); wl_list_init(&clients);
wl_list_init(&fstack); wl_list_init(&fstack);
@@ -160,26 +171,30 @@ index 8101ffa..1c858a8 100644
xdg_shell = wlr_xdg_shell_create(dpy, 6); xdg_shell = wlr_xdg_shell_create(dpy, 6);
wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel); wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel);
diff --git a/simple_scratchpad.c b/simple_scratchpad.c diff --git a/simple_scratchpad.h b/simple_scratchpad.h
new file mode 100644 new file mode 100644
index 0000000..0e23ddd index 0000000..36a564e
--- /dev/null --- /dev/null
+++ b/simple_scratchpad.c +++ b/simple_scratchpad.h
@@ -0,0 +1,85 @@ @@ -0,0 +1,89 @@
+/* ************************************************************************** */ +/* ************************************************************************** */
+/* @@@ @@@@@@@@ */ +/* @@@ @@@@@@@@ */
+/* @@@ @@@@@@@@@@ */ +/* @@@ @@@@@@@@@@ */
+/* @@! @@! @@@@ */ +/* @@! @@! @@@@ */
+/* !@! !@! @!@!@ */ +/* !@! !@! @!@!@ */
+/* simple_scratchpad.c @!! @!@ @! !@! */ +/* simple_scratchpad.h @!! @!@ @! !@! */
+/* !!! !@!!! !!! */ +/* !!! !@!!! !!! */
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */ +/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
+/* ::! :!: !:! */ +/* ::! :!: !:! */
+/* Created: 2024/12/19 19:35:02 by jmakkone :: ::::::: :: */ +/* Created: 2024/12/19 19:35:02 by jmakkone :: ::::::: :: */
+/* Updated: 2026/05/20 23:56:35 by julmajustus : : : : : : */ +/* Updated: 2026/09/20 02:14:02 by julmajustus : : : : : : */
+/* */ +/* */
+/* ************************************************************************** */ +/* ************************************************************************** */
+ +
+static struct wl_list scratchpad_clients[SCRATCHPAD_COUNT];
+static int scratchpad_visible[SCRATCHPAD_COUNT];
+static int scratchpad_sel = 0;
+
+void +void
+addscratchpad(const Arg *arg) +addscratchpad(const Arg *arg)
+{ +{
@@ -252,5 +267,5 @@ index 0000000..0e23ddd
+ scratchpad_sel = idx; + scratchpad_sel = idx;
+} +}
-- --
2.53.0 2.55.0