Compare commits

...

2 Commits

Author SHA1 Message Date
nullsystem
46021333a1 update perinputconfig patch for main dwl
Now split into two patches, keyboard and pointer
2025-11-19 23:12:30 +00:00
nullsystem
5493b6dd94 update primaryselection patch for main dwl 2025-11-19 22:41:14 +00:00
7 changed files with 402 additions and 19 deletions

View File

@ -3,9 +3,14 @@ Replace the singular keyboard and pointer input configuration with an array allo
Tip to find the names: Grep for `device_name` and add a line after it to print to stdout. Then run EX: `dwl > /tmp/print_device_names.log`, exit dwl, and should see the names.
Since 2025-11-19, this has been split into two patches, one for pointer and one for keyboard.
### Download
- [git branch](https://codeberg.org/nullsystem/dwl/src/branch/main_perinputconfig)
- [2024-06-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig.patch)
- [git branch (pointer)](https://codeberg.org/nullsystem/dwl/src/branch/main_perinputconfig-pointer)
- [git branch (keyboard)](https://codeberg.org/nullsystem/dwl/src/branch/main_perinputconfig-keyboard)
- [2025-11-19 (pointer)](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig-pointer.patch)
- [2025-11-19 (keyboard)](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig-keyboard.patch)
- [2024-06-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig-2024-06-08.patch)
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig-v0.5.patch)
### Authors

View File

@ -0,0 +1,223 @@
From 9d9670103c59937d4f59843baea284b6750486dc Mon Sep 17 00:00:00 2001
From: nullsystem <nullsystem@noreply.codeberg.org>
Date: Wed, 19 Nov 2025 23:08:00 +0000
Subject: [PATCH] [PATCH] perinputconfig-keyboard - 2025-11-19 Update
* Array replaced singular variables for configuration
* Like EX: Rules, requires NULL/default set at the end
* 2025-11-19: Split keyboard and pointer into two patches
---
config.def.h | 9 ++++---
dwl.c | 70 +++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 64 insertions(+), 15 deletions(-)
diff --git a/config.def.h b/config.def.h
index 95c2afa..83c38a9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -52,12 +52,13 @@ static const MonitorRule monrules[] = {
};
/* keyboard */
-static const struct xkb_rule_names xkb_rules = {
- /* can specify fields: rules, model, layout, variant, options */
+/* NOTE: Always include a fallback rule at the end (name as NULL) */
+static const KeyboardRule kbrules[] = {
+ /* name rules model layout variant options */
/* example:
- .options = "ctrl:nocaps",
+ { "keyboard", NULL, NULL, "us,de", NULL, "ctrl:nocaps" },
*/
- .options = NULL,
+ { NULL, NULL, NULL, NULL, NULL, NULL },
};
static const int repeat_rate = 25;
diff --git a/dwl.c b/dwl.c
index 12f441e..9aa1681 100644
--- a/dwl.c
+++ b/dwl.c
@@ -159,6 +159,8 @@ typedef struct {
struct wl_listener modifiers;
struct wl_listener key;
struct wl_listener destroy;
+
+ struct wl_list link;
} KeyboardGroup;
typedef struct {
@@ -239,6 +241,15 @@ typedef struct {
struct wl_listener destroy;
} SessionLock;
+typedef struct {
+ const char *name;
+ const char *rules;
+ const char *model;
+ const char *layout;
+ const char *variant;
+ const char *options;
+} KeyboardRule;
+
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -260,7 +271,7 @@ static void commitpopup(struct wl_listener *listener, void *data);
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);
-static KeyboardGroup *createkeyboardgroup(void);
+static KeyboardGroup *createkeyboardgroup(struct xkb_rule_names *new_xkb_rules);
static void createlayersurface(struct wl_listener *listener, void *data);
static void createlocksurface(struct wl_listener *listener, void *data);
static void createmon(struct wl_listener *listener, void *data);
@@ -396,7 +407,7 @@ static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock;
static struct wlr_seat *seat;
-static KeyboardGroup *kb_group;
+static struct wl_list kb_groups;
static unsigned int cursor_mode;
static Client *grabc;
static int grabcx, grabcy; /* client-relative */
@@ -699,6 +710,8 @@ checkidleinhibitor(struct wlr_surface *exclude)
void
cleanup(void)
{
+ KeyboardGroup *kb_group;
+
cleanuplisteners();
#ifdef XWAYLAND
wlr_xwayland_destroy(xwayland);
@@ -711,7 +724,8 @@ cleanup(void)
}
wlr_xcursor_manager_destroy(cursor_mgr);
- destroykeyboardgroup(&kb_group->destroy, NULL);
+ wl_list_for_each(kb_group, &kb_groups, link)
+ destroykeyboardgroup(&kb_group->destroy, NULL);
/* If it's not destroyed manually, it will cause a use-after-free of wlr_seat.
* Destroy it until it's fixed on the wlroots side */
@@ -940,6 +954,30 @@ createidleinhibitor(struct wl_listener *listener, void *data)
void
createkeyboard(struct wlr_keyboard *keyboard)
{
+ KeyboardGroup *kb_group;
+ const char *device_name = "";
+ const KeyboardRule *krule = NULL;
+ struct libinput_device *device = NULL;
+
+ if (wlr_input_device_is_libinput(&keyboard->base)
+ && (device = wlr_libinput_get_device_handle(&keyboard->base))) {
+ device_name = libinput_device_get_name(device);
+ }
+ for (krule = kbrules; krule < END(kbrules); krule++) {
+ if (!krule->name || strstr(device_name, krule->name))
+ break;
+ }
+ if (krule) {
+ struct xkb_rule_names xkb_rules;
+ xkb_rules.rules = krule->rules;
+ xkb_rules.model = krule->model;
+ xkb_rules.layout = krule->layout;
+ xkb_rules.variant = krule->variant;
+ xkb_rules.options = krule->options;
+ kb_group = createkeyboardgroup(&xkb_rules);
+ } else
+ wl_list_for_each(kb_group, &kb_groups, link);
+
/* Set the keymap to match the group keymap */
wlr_keyboard_set_keymap(keyboard, kb_group->wlr_group->keyboard.keymap);
@@ -948,11 +986,16 @@ createkeyboard(struct wlr_keyboard *keyboard)
}
KeyboardGroup *
-createkeyboardgroup(void)
+createkeyboardgroup(struct xkb_rule_names *new_xkb_rules)
{
KeyboardGroup *group = ecalloc(1, sizeof(*group));
struct xkb_context *context;
struct xkb_keymap *keymap;
+ struct xkb_rule_names xkb_rules;
+
+ memset(&xkb_rules, 0, sizeof(struct xkb_rule_names));
+ if (new_xkb_rules)
+ xkb_rules = *new_xkb_rules;
group->wlr_group = wlr_keyboard_group_create();
group->wlr_group->data = group;
@@ -981,6 +1024,9 @@ createkeyboardgroup(void)
* all of them. Set this combined wlr_keyboard as the seat keyboard.
*/
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
+
+ wl_list_init(&group->destroy.link);
+ wl_list_insert(&kb_groups, &group->link);
return group;
}
@@ -1380,7 +1426,6 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
wl_list_remove(&group->modifiers.link);
wl_list_remove(&group->destroy.link);
wlr_keyboard_group_destroy(group->wlr_group);
- free(group);
}
Monitor *
@@ -1582,6 +1627,7 @@ inputdevice(struct wl_listener *listener, void *data)
* available. */
struct wlr_input_device *device = data;
uint32_t caps;
+ KeyboardGroup *group;
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:
@@ -1600,8 +1646,11 @@ inputdevice(struct wl_listener *listener, void *data)
* there are no pointer devices, so we always include that capability. */
/* TODO do we actually require a cursor? */
caps = WL_SEAT_CAPABILITY_POINTER;
- if (!wl_list_empty(&kb_group->wlr_group->devices))
- caps |= WL_SEAT_CAPABILITY_KEYBOARD;
+ wl_list_for_each(group, &kb_groups, link)
+ if (!wl_list_empty(&group->wlr_group->devices)) {
+ caps |= WL_SEAT_CAPABILITY_KEYBOARD;
+ break;
+ }
wlr_seat_set_capabilities(seat, caps);
}
@@ -2553,6 +2602,7 @@ setup(void)
*/
wl_list_init(&clients);
wl_list_init(&fstack);
+ wl_list_init(&kb_groups);
xdg_shell = wlr_xdg_shell_create(dpy, 6);
wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel);
@@ -2638,8 +2688,7 @@ setup(void)
wl_signal_add(&seat->events.request_start_drag, &request_start_drag);
wl_signal_add(&seat->events.start_drag, &start_drag);
- kb_group = createkeyboardgroup();
- wl_list_init(&kb_group->destroy.link);
+ createkeyboardgroup(NULL);
output_mgr = wlr_output_manager_v1_create(dpy);
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
@@ -2983,10 +3032,9 @@ virtualkeyboard(struct wl_listener *listener, void *data)
{
struct wlr_virtual_keyboard_v1 *kb = data;
/* virtual keyboards shouldn't share keyboard group */
- KeyboardGroup *group = createkeyboardgroup();
+ KeyboardGroup *group = createkeyboardgroup(NULL);
/* Set the keymap to match the group keymap */
wlr_keyboard_set_keymap(&kb->keyboard, group->wlr_group->keyboard.keymap);
- LISTEN(&kb->keyboard.base.events.destroy, &group->destroy, destroykeyboardgroup);
/* Add the new keyboard to the group */
wlr_keyboard_group_add_keyboard(group->wlr_group, &kb->keyboard);
--
2.52.0

View File

@ -0,0 +1,103 @@
From 0287678092e5ed076d417c2241244c0211798e9d Mon Sep 17 00:00:00 2001
From: nullsystem <nullsystem.aongp@slmail.me>
Date: Wed, 19 Nov 2025 00:01:54 +0000
Subject: [PATCH] [PATCH] perinputconfig-pointer - 2025-11-19 Update
* Array replaced singular variables for configuration
* Only applies to enable-state, acceleration profile, and speed
* Like EX: Rules, requires NULL/default set at the end
* 2025-11-19: Split keyboard and pointer into two patches
---
config.def.h | 19 +++++++++++++------
dwl.c | 19 ++++++++++++++++---
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/config.def.h b/config.def.h
index 95c2afa..81ba5a2 100644
--- a/config.def.h
+++ b/config.def.h
@@ -86,19 +86,26 @@ LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
*/
static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
-/* You can choose between:
+/*
+send_events_mode: You can choose between:
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE
-*/
-static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
-/* You can choose between:
+accel_profile: You can choose between:
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
+
+NOTE: Always include a fallback rule at the end (name as NULL)
*/
-static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
-static const double accel_speed = 0.0;
+static const InputRule inputrules[] = {
+ /* name send_events_mode accel_profile accel_speed */
+ /* examples:
+ { "SynPS/2 Synaptics TouchPad", LIBINPUT_CONFIG_SEND_EVENTS_DISABLED, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT, 0.0 },
+ { "TPPS/2 IBM TrackPoint", LIBINPUT_CONFIG_SEND_EVENTS_ENABLED, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE, 0.0 },
+ */
+ { NULL, LIBINPUT_CONFIG_SEND_EVENTS_ENABLED, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE, 0.0 },
+};
/* You can choose between:
LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle
diff --git a/dwl.c b/dwl.c
index 12f441e..47240b6 100644
--- a/dwl.c
+++ b/dwl.c
@@ -239,6 +239,13 @@ typedef struct {
struct wl_listener destroy;
} SessionLock;
+typedef struct {
+ const char *name;
+ uint32_t send_events_mode;
+ enum libinput_config_accel_profile accel_profile;
+ double accel_speed;
+} InputRule;
+
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -1140,9 +1147,15 @@ createnotify(struct wl_listener *listener, void *data)
void
createpointer(struct wlr_pointer *pointer)
{
+ const InputRule *irule;
struct libinput_device *device;
if (wlr_input_device_is_libinput(&pointer->base)
&& (device = wlr_libinput_get_device_handle(&pointer->base))) {
+ const char *device_name = libinput_device_get_name(device);
+ for (irule = inputrules; irule < END(inputrules); irule++) {
+ if (!irule->name || strstr(device_name, irule->name))
+ break;
+ }
if (libinput_device_config_tap_get_finger_count(device)) {
libinput_device_config_tap_set_enabled(device, tap_to_click);
@@ -1170,11 +1183,11 @@ createpointer(struct wlr_pointer *pointer)
libinput_device_config_click_set_method(device, click_method);
if (libinput_device_config_send_events_get_modes(device))
- libinput_device_config_send_events_set_mode(device, send_events_mode);
+ libinput_device_config_send_events_set_mode(device, irule->send_events_mode);
if (libinput_device_config_accel_is_available(device)) {
- libinput_device_config_accel_set_profile(device, accel_profile);
- libinput_device_config_accel_set_speed(device, accel_speed);
+ libinput_device_config_accel_set_profile(device, irule->accel_profile);
+ libinput_device_config_accel_set_speed(device, irule->accel_speed);
}
}
--
2.52.0

View File

@ -3,7 +3,8 @@ Adds a config option to disable/enable primary selection (middle-click paste).
### Download
- [git branch](https://codeberg.org/nullsystem/dwl/src/branch/main_primaryselection)
- [2024-04-06](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/primaryselection/primaryselection.patch)
- [2025-11-19](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/primaryselection/primaryselection.patch)
- [2024-04-06](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/primaryselection/primaryselection-2024-04-06.patch)
### Authors
- [nullsystem](https://codeberg.org/nullsystem)

View File

@ -0,0 +1,50 @@
From 4fc77fde2f6015564544e029f9905fc1678fcb59 Mon Sep 17 00:00:00 2001
From: nullsystem <nullsystem.aongp@slmail.me>
Date: Sat, 6 Apr 2024 14:19:44 +0100
Subject: [PATCH] primaryselection - disable/enable primary selection
* Just simply adds a config to disable/enable primary selection
---
config.def.h | 1 +
dwl.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8847e58..057e1c3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -66,6 +66,7 @@ static const int natural_scrolling = 0;
static const int disable_while_typing = 1;
static const int left_handed = 0;
static const int middle_button_emulation = 0;
+static const int enable_primary_selection = 0;
/* You can choose between:
LIBINPUT_CONFIG_SCROLL_NO_SCROLL
LIBINPUT_CONFIG_SCROLL_2FG
diff --git a/dwl.c b/dwl.c
index bf763df..7e8d8f2 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2339,7 +2339,8 @@ setup(void)
wlr_export_dmabuf_manager_v1_create(dpy);
wlr_screencopy_manager_v1_create(dpy);
wlr_data_control_manager_v1_create(dpy);
- wlr_primary_selection_v1_device_manager_create(dpy);
+ if (enable_primary_selection)
+ wlr_primary_selection_v1_device_manager_create(dpy);
wlr_viewporter_create(dpy);
wlr_single_pixel_buffer_manager_v1_create(dpy);
wlr_fractional_scale_manager_v1_create(dpy, 1);
@@ -2449,7 +2450,8 @@ setup(void)
seat = wlr_seat_create(dpy, "seat0");
LISTEN_STATIC(&seat->events.request_set_cursor, setcursor);
LISTEN_STATIC(&seat->events.request_set_selection, setsel);
- LISTEN_STATIC(&seat->events.request_set_primary_selection, setpsel);
+ if (enable_primary_selection)
+ LISTEN_STATIC(&seat->events.request_set_primary_selection, setpsel);
LISTEN_STATIC(&seat->events.request_start_drag, requeststartdrag);
LISTEN_STATIC(&seat->events.start_drag, startdrag);
--
2.44.0

View File

@ -1,19 +1,20 @@
From 4fc77fde2f6015564544e029f9905fc1678fcb59 Mon Sep 17 00:00:00 2001
From: nullsystem <nullsystem.aongp@slmail.me>
Date: Sat, 6 Apr 2024 14:19:44 +0100
Subject: [PATCH] primaryselection - disable/enable primary selection
From 57d50147a2ffd91e6c10c12162dd4a55c451485c Mon Sep 17 00:00:00 2001
From: nullsystem <nullsystem@noreply.codeberg.org>
Date: Wed, 19 Nov 2025 22:35:24 +0000
Subject: [PATCH] [PATCH] primaryselection - disable/enable primary selection
* Just simply adds a config to disable/enable primary selection
* 2025-11-19 update
---
config.def.h | 1 +
dwl.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8847e58..057e1c3 100644
index 95c2afa..1d143db 100644
--- a/config.def.h
+++ b/config.def.h
@@ -66,6 +66,7 @@ static const int natural_scrolling = 0;
@@ -71,6 +71,7 @@ static const int natural_scrolling = 0;
static const int disable_while_typing = 1;
static const int left_handed = 0;
static const int middle_button_emulation = 0;
@ -22,10 +23,10 @@ index 8847e58..057e1c3 100644
LIBINPUT_CONFIG_SCROLL_NO_SCROLL
LIBINPUT_CONFIG_SCROLL_2FG
diff --git a/dwl.c b/dwl.c
index bf763df..7e8d8f2 100644
index 12f441e..3a026b4 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2339,7 +2339,8 @@ setup(void)
@@ -2517,7 +2517,8 @@ setup(void)
wlr_export_dmabuf_manager_v1_create(dpy);
wlr_screencopy_manager_v1_create(dpy);
wlr_data_control_manager_v1_create(dpy);
@ -35,16 +36,16 @@ index bf763df..7e8d8f2 100644
wlr_viewporter_create(dpy);
wlr_single_pixel_buffer_manager_v1_create(dpy);
wlr_fractional_scale_manager_v1_create(dpy, 1);
@@ -2449,7 +2450,8 @@ setup(void)
@@ -2634,7 +2635,8 @@ setup(void)
seat = wlr_seat_create(dpy, "seat0");
LISTEN_STATIC(&seat->events.request_set_cursor, setcursor);
LISTEN_STATIC(&seat->events.request_set_selection, setsel);
- LISTEN_STATIC(&seat->events.request_set_primary_selection, setpsel);
wl_signal_add(&seat->events.request_set_cursor, &request_cursor);
wl_signal_add(&seat->events.request_set_selection, &request_set_sel);
- wl_signal_add(&seat->events.request_set_primary_selection, &request_set_psel);
+ if (enable_primary_selection)
+ LISTEN_STATIC(&seat->events.request_set_primary_selection, setpsel);
LISTEN_STATIC(&seat->events.request_start_drag, requeststartdrag);
LISTEN_STATIC(&seat->events.start_drag, startdrag);
+ wl_signal_add(&seat->events.request_set_primary_selection, &request_set_psel);
wl_signal_add(&seat->events.request_start_drag, &request_start_drag);
wl_signal_add(&seat->events.start_drag, &start_drag);
--
2.44.0
2.52.0