Compare commits

..

2 Commits

Author SHA1 Message Date
A Frederick Christensen c9f31f29ea simpleborders: Update for 0.8 and for wlroots-next-f4249db
Abandoned simpleborders patch updated by @fauxmight
2026-07-16 06:09:31 +02:00
Viktor Woloszczuk 8085c4759f inputdevicerules: update for v0.8 dwl
addresses issue #623
2026-07-12 20:19:16 +01:00
5 changed files with 205 additions and 32 deletions
+2 -1
View File
@@ -10,9 +10,10 @@ Examples provided:
- exclude certain keyboards (eg ydotool) from keyboard group
### Download
- [git branch](https://codeberg.org/bencc/dwl/src/branch/inputdevicerules)
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.8.patch)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.7.patch)
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.6.patch)
### Authors
- [Viktor Woloszczuk](https://codeberg.org/vwoloszczuk)
- [Ben Collerson](https://codeberg.org/bencc)
@@ -0,0 +1,173 @@
From 31c8493d7f2a863949a91cd14769e28894f259e7 Mon Sep 17 00:00:00 2001
From: Viktor Woloszczuk <viktor@woloszcz.uk>
Date: Wed, 11 Mar 2026 19:41:02 +0000
Subject: [PATCH] input device rules (v0.8)
* customise input device handling
* ignore unwanted input devices
* configure a toggle for an input device
---
config.def.h | 13 ++++++++++
dwl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..4dbcfd1 100644
--- a/config.def.h
+++ b/config.def.h
@@ -56,6 +56,18 @@ static const struct xkb_rule_names xkb_rules = {
.options = NULL,
};
+/* input devices */
+static const InputRule inputrules[] = {
+ /* name kbcreate ptrcreate */
+ /* ignore bad device - like a touchpad ;) */
+ { "BAD DEVICE", NULL, NULL },
+ /* ungroup ydotool device - fixes a bug */
+ { "ydotoold virtual device", createungroupedkeyboard, createpointer },
+ /* put your touchpad name here to enable toggle touchpad */
+ { "Elan Touchpad", createkeyboard, createtogglepointer },
+ { NULL, createkeyboard, createpointer },
+};
+
static const int repeat_rate = 25;
static const int repeat_delay = 600;
@@ -138,6 +150,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_u, togglepointer, {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} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..42557fe 100644
--- a/dwl.c
+++ b/dwl.c
@@ -141,6 +141,12 @@ typedef struct {
uint32_t resize; /* configure serial of a pending resize */
} Client;
+typedef struct {
+ const char *name;
+ void (*kbcreate)(struct wlr_keyboard *);
+ void (*ptrcreate)(struct wlr_pointer *);
+} InputRule;
+
typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
@@ -268,6 +274,8 @@ static void createnotify(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_pointer *pointer);
static void createpointerconstraint(struct wl_listener *listener, void *data);
static void createpopup(struct wl_listener *listener, void *data);
+static void createtogglepointer(struct wlr_pointer *pointer);
+static void createungroupedkeyboard(struct wlr_keyboard *keyboard);
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
@@ -336,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 togglepointer(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 +415,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static struct libinput_device *togglepointerdevice = NULL;
+
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
static struct wl_listener cursor_button = {.notify = buttonpress};
@@ -1199,6 +1210,33 @@ createpopup(struct wl_listener *listener, void *data)
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
}
+void
+createtogglepointer(struct wlr_pointer *pointer)
+{
+ struct libinput_device *device;
+
+ createpointer(pointer);
+
+ if (wlr_input_device_is_libinput(&pointer->base)
+ && (device = wlr_libinput_get_device_handle(&pointer->base))) {
+ togglepointerdevice = device;
+ }
+}
+
+void
+createungroupedkeyboard(struct wlr_keyboard *keyboard)
+{
+ /* for keyboards that need their own keyboard group */
+ KeyboardGroup *group = createkeyboardgroup();
+
+ /* Set the keymap to match the group keymap */
+ wlr_keyboard_set_keymap(keyboard, group->wlr_group->keyboard.keymap);
+ LISTEN(&keyboard->base.events.destroy, &group->destroy, destroykeyboardgroup);
+
+ /* Add the new keyboard to the group */
+ wlr_keyboard_group_add_keyboard(group->wlr_group, keyboard);
+}
+
void
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
{
@@ -1582,13 +1620,27 @@ inputdevice(struct wl_listener *listener, void *data)
* available. */
struct wlr_input_device *device = data;
uint32_t caps;
+ const InputRule *r;
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:
- createkeyboard(wlr_keyboard_from_input_device(device));
+ for (r = inputrules; r < END(inputrules); r++) {
+ if (!r->name || strstr(device->name, r->name)) {
+ if (r->kbcreate)
+ r->kbcreate(wlr_keyboard_from_input_device(device));
+ break;
+ }
+ }
+
break;
case WLR_INPUT_DEVICE_POINTER:
- createpointer(wlr_pointer_from_input_device(device));
+ for (r = inputrules; r < END(inputrules); r++) {
+ if (!r->name || strstr(device->name, r->name)) {
+ if (r->ptrcreate)
+ r->ptrcreate(wlr_pointer_from_input_device(device));
+ break;
+ }
+ }
break;
default:
/* TODO handle other input device types */
@@ -2760,6 +2812,18 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
+void
+togglepointer(const Arg *arg)
+{
+ if (!togglepointerdevice)
+ return;
+
+ libinput_device_config_send_events_set_mode(
+ togglepointerdevice,
+ libinput_device_config_send_events_get_mode(togglepointerdevice) ^ LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
+ );
+}
+
void
toggletag(const Arg *arg)
{
--
2.53.0
+4 -5
View File
@@ -2,12 +2,11 @@
Like smartborders. Don't put borders when there is only one window on the screen.
The patch for tag v0.7 below appears to apply cleanly to the current HEAD of
upstream/main as at 2024-10-11.
### Download
- [git branch](https://codeberg.org/bencc/dwl/src/branch/simpleborders)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders-v0.7.patch)
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders-v0.6.patch)
- [simpleborders-wlroots-next-f4249db](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders-wlroots-next-f4249db.patch)
- [simpleborders-0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simpleborders/simpleborders-v0.8.patch)
### Authors
- [A Frederick Christensen](https://codeberg.org/fauxmight)
- [Ben Collerson](https://codeberg.org/bencc)
@@ -1,34 +1,34 @@
From 681e520deaeee460647de36f5312af3cb0c31f4a Mon Sep 17 00:00:00 2001
From: Ben Collerson <benc@benc.cc>
Date: Sat, 30 Dec 2023 13:39:31 +1000
Subject: [PATCH] simpleborders
From 41eb0c0d196d302790ae87a5ca1a4da660864f10 Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Wed, 25 Feb 2026 20:11:56 -0600
Subject: [PATCH] Apply simpleborders patch
---
dwl.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/dwl.c b/dwl.c
index 4d19357..900e651 100644
index 44f3ad9..defe2a8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -245,6 +245,7 @@ static void cleanupmon(struct wl_listener *listener, void *data);
static void closemon(Monitor *m);
@@ -257,6 +257,7 @@ static void closemon(Monitor *m);
static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data);
static void commitpopup(struct wl_listener *listener, void *data);
+static int countclients(Monitor *m);
static void createdecoration(struct wl_listener *listener, void *data);
static void createidleinhibitor(struct wl_listener *listener, void *data);
static void createkeyboard(struct wlr_keyboard *keyboard);
@@ -286,6 +287,7 @@ static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time);
@@ -305,6 +306,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
double sy, double sx_unaccel, double sy_unaccel);
static void motionrelative(struct wl_listener *listener, void *data);
static void moveresize(const Arg *arg);
+static int needsborder(Client *c);
static void outputmgrapply(struct wl_listener *listener, void *data);
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
static void outputmgrtest(struct wl_listener *listener, void *data);
@@ -739,6 +741,17 @@ commitnotify(struct wl_listener *listener, void *data)
c->resize = 0;
@@ -915,6 +917,17 @@ commitpopup(struct wl_listener *listener, void *data)
free(listener);
}
+int
@@ -45,7 +45,7 @@ index 4d19357..900e651 100644
void
createdecoration(struct wl_listener *listener, void *data)
{
@@ -1697,6 +1710,14 @@ moveresize(const Arg *arg)
@@ -1980,6 +1993,14 @@ moveresize(const Arg *arg)
}
}
@@ -60,8 +60,8 @@ index 4d19357..900e651 100644
void
outputmgrapply(struct wl_listener *listener, void *data)
{
@@ -1930,6 +1951,7 @@ resize(Client *c, struct wlr_box geo, int interact)
struct wlr_box clip;
@@ -2215,6 +2236,7 @@ resize(Client *c, struct wlr_box geo, int interact)
client_set_bounds(c, geo.width, geo.height);
c->geom = geo;
+ c->bw = needsborder(c) ? borderpx : 0;
@@ -69,5 +69,5 @@ index 4d19357..900e651 100644
/* Update scene-graph, including borders */
--
2.43.0
2.52.0
@@ -1,14 +1,14 @@
From 09759c3ef75158c366e9fc63814485fbb31a3ccf Mon Sep 17 00:00:00 2001
From: Ben Collerson <benc@benc.cc>
Date: Sat, 30 Dec 2023 13:39:31 +1000
Subject: [PATCH] simpleborders
From 33364ee84f8063813fbdb8b319965a87f63e2694 Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Wed, 25 Feb 2026 20:14:28 -0600
Subject: [PATCH] Apply simpleborders patch
---
dwl.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/dwl.c b/dwl.c
index a2711f67..415fe1a0 100644
index 8a9715d..a3caac8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -259,6 +259,7 @@ static void closemon(Monitor *m);
@@ -19,7 +19,7 @@ index a2711f67..415fe1a0 100644
static void createdecoration(struct wl_listener *listener, void *data);
static void createidleinhibitor(struct wl_listener *listener, void *data);
static void createkeyboard(struct wlr_keyboard *keyboard);
@@ -308,6 +309,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
@@ -307,6 +308,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
double sy, double sx_unaccel, double sy_unaccel);
static void motionrelative(struct wl_listener *listener, void *data);
static void moveresize(const Arg *arg);
@@ -27,8 +27,8 @@ index a2711f67..415fe1a0 100644
static void outputmgrapply(struct wl_listener *listener, void *data);
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
static void outputmgrtest(struct wl_listener *listener, void *data);
@@ -849,6 +851,17 @@ commitpopup(struct wl_listener *listener, void *data)
wl_list_remove(&listener->link);
@@ -917,6 +919,17 @@ commitpopup(struct wl_listener *listener, void *data)
free(listener);
}
+int
@@ -45,7 +45,7 @@ index a2711f67..415fe1a0 100644
void
createdecoration(struct wl_listener *listener, void *data)
{
@@ -1927,6 +1940,14 @@ moveresize(const Arg *arg)
@@ -1982,6 +1995,14 @@ moveresize(const Arg *arg)
}
}
@@ -60,7 +60,7 @@ index a2711f67..415fe1a0 100644
void
outputmgrapply(struct wl_listener *listener, void *data)
{
@@ -2190,6 +2211,7 @@ resize(Client *c, struct wlr_box geo, int interact)
@@ -2217,6 +2238,7 @@ resize(Client *c, struct wlr_box geo, int interact)
client_set_bounds(c, geo.width, geo.height);
c->geom = geo;
@@ -69,5 +69,5 @@ index a2711f67..415fe1a0 100644
/* Update scene-graph, including borders */
--
2.45.2
2.52.0