From 46021333a10ecb9179c8477588fafd75c7cc7a05 Mon Sep 17 00:00:00 2001 From: nullsystem Date: Wed, 19 Nov 2025 23:12:30 +0000 Subject: [PATCH] update perinputconfig patch for main dwl Now split into two patches, keyboard and pointer --- patches/perinputconfig/README.md | 9 +- ....patch => perinputconfig-2024-06-08.patch} | 0 .../perinputconfig-keyboard.patch | 223 ++++++++++++++++++ .../perinputconfig-pointer.patch | 103 ++++++++ 4 files changed, 333 insertions(+), 2 deletions(-) rename patches/perinputconfig/{perinputconfig.patch => perinputconfig-2024-06-08.patch} (100%) create mode 100644 patches/perinputconfig/perinputconfig-keyboard.patch create mode 100644 patches/perinputconfig/perinputconfig-pointer.patch diff --git a/patches/perinputconfig/README.md b/patches/perinputconfig/README.md index ab1602c..b240a45 100644 --- a/patches/perinputconfig/README.md +++ b/patches/perinputconfig/README.md @@ -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 diff --git a/patches/perinputconfig/perinputconfig.patch b/patches/perinputconfig/perinputconfig-2024-06-08.patch similarity index 100% rename from patches/perinputconfig/perinputconfig.patch rename to patches/perinputconfig/perinputconfig-2024-06-08.patch diff --git a/patches/perinputconfig/perinputconfig-keyboard.patch b/patches/perinputconfig/perinputconfig-keyboard.patch new file mode 100644 index 0000000..82abf2b --- /dev/null +++ b/patches/perinputconfig/perinputconfig-keyboard.patch @@ -0,0 +1,223 @@ +From 9d9670103c59937d4f59843baea284b6750486dc Mon Sep 17 00:00:00 2001 +From: nullsystem +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 + diff --git a/patches/perinputconfig/perinputconfig-pointer.patch b/patches/perinputconfig/perinputconfig-pointer.patch new file mode 100644 index 0000000..f0ee253 --- /dev/null +++ b/patches/perinputconfig/perinputconfig-pointer.patch @@ -0,0 +1,103 @@ +From 0287678092e5ed076d417c2241244c0211798e9d Mon Sep 17 00:00:00 2001 +From: nullsystem +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 +