en-keycodes: update to 0.8

This commit is contained in:
Nikita Ivanov 2026-03-16 21:06:48 +01:00
parent 36439e54ba
commit 05895bbe1b
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
3 changed files with 77 additions and 2 deletions

View File

@ -2,8 +2,8 @@
Always use the English keymap to get keycodes, so key bindings work even when using a non-English keyboard layout. Always use the English keymap to get keycodes, so key bindings work even when using a non-English keyboard layout.
### Download ### Download
- [git branch](https://codeberg.org/ForzCross/dwl/src/branch/en-keycodes.patch) - [0.8](/dwl/dwl-patches/raw/branch/main/patches/en-keycodes/en-keycodes-0.8.patch)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/en-keycodes/en-keycodes.patch) - [0.7](/dwl/dwl-patches/raw/branch/main/patches/en-keycodes/en-keycodes-0.7.patch)
### Authors ### Authors
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV)) - [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))

View File

@ -0,0 +1,75 @@
From cde0921304c11c2e1341539a5ada4f7b9715b178 Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Sun, 30 Nov 2025 23:22:42 +0100
Subject: [PATCH] Always use the English keymap to get keycodes
---
dwl.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/dwl.c b/dwl.c
index 44f3ad9..97ba897 100644
--- a/dwl.c
+++ b/dwl.c
@@ -436,6 +436,11 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
+static struct xkb_rule_names en_rules;
+static struct xkb_context *en_context;
+static struct xkb_keymap *en_keymap;
+static struct xkb_state *en_state;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -718,6 +723,9 @@ cleanup(void)
wlr_backend_destroy(backend);
wl_display_destroy(dpy);
+ xkb_state_unref(en_state);
+ xkb_keymap_unref(en_keymap);
+ xkb_context_unref(en_context);
/* Destroy after the wayland display (when the monitors are already destroyed)
to avoid destroying them with an invalid scene output. */
wlr_scene_node_destroy(&scene->tree.node);
@@ -1632,16 +1640,19 @@ keypress(struct wl_listener *listener, void *data)
/* This event is raised when a key is pressed or released. */
KeyboardGroup *group = wl_container_of(listener, group, key);
struct wlr_keyboard_key_event *event = data;
+ int nsyms, handled;
/* Translate libinput keycode -> xkbcommon */
uint32_t keycode = event->keycode + 8;
/* Get a list of keysyms based on the keymap for this keyboard */
const xkb_keysym_t *syms;
- int nsyms = xkb_state_key_get_syms(
- group->wlr_group->keyboard.xkb_state, keycode, &syms);
-
- int handled = 0;
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
+ xkb_state_update_key(en_state, keycode,
+ (event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
+ ? XKB_KEY_DOWN : XKB_KEY_UP);
+ nsyms = xkb_state_key_get_syms(en_state, keycode, &syms);
+
+ handled = 0;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -2624,6 +2635,12 @@ setup(void)
* pointer, touch, and drawing tablet device. We also rig up a listener to
* let us know when new input devices are available on the backend.
*/
+ en_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ en_rules = xkb_rules;
+ en_rules.layout = "us";
+ en_keymap = xkb_keymap_new_from_names(en_context, &en_rules,
+ XKB_KEYMAP_COMPILE_NO_FLAGS);
+ en_state = xkb_state_new(en_keymap);
wl_signal_add(&backend->events.new_input, &new_input_device);
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
--
2.53.0