fix en-keycodes patch

This commit is contained in:
ForzCross 2024-01-10 00:14:55 +03:00
parent 4cf16ae5c5
commit 2e85f37f39

View File

@ -1,6 +1,6 @@
From eceb8adcd3321e6bc71b45f54b1a78b6183e92f2 Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Sun, 12 Nov 2023 23:34:25 +0100
From 52114aecd94813ba5abf8f6b4dcc59bdafadbfe0 Mon Sep 17 00:00:00 2001
From: ForzCross <forzcross@gmail.com>
Date: Wed, 10 Jan 2024 00:16:55 +0300
Subject: [PATCH] Always use the English keymap to get keycodes
---
@ -8,10 +8,10 @@ Subject: [PATCH] Always use the English keymap to get keycodes
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index a7d41b085..4978cfac5 100644
index 632dabf..858318a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -367,6 +367,12 @@ static struct wlr_box sgeom;
@@ -384,6 +384,12 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
@ -21,36 +21,36 @@ index a7d41b085..4978cfac5 100644
+static struct xkb_state *en_state, *en_state_shift;
+static xkb_mod_index_t en_shift;
+
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
static struct wl_listener cursor_button = {.notify = buttonpress};
@@ -669,6 +675,10 @@ cleanup(void)
wlr_output_layout_destroy(output_layout);
wlr_seat_destroy(seat);
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -647,6 +653,10 @@ cleanup(void)
wl_event_source_remove(vkb_group.key_repeat_source);
wl_display_destroy(dpy);
+ xkb_state_unref(en_state);
+ xkb_state_unref(en_state_shift);
+ xkb_keymap_unref(en_keymap);
+ xkb_context_unref(en_context);
}
void
@@ -1419,8 +1429,10 @@ keypress(struct wl_listener *listener, void *data)
/* 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);
@@ -1381,8 +1391,10 @@ keypress(struct wl_listener *listener, void *data)
uint32_t keycode = event->keycode + 8;
/* Get a list of keysyms based on the keymap for this keyboard */
const xkb_keysym_t *syms;
+ int shift = xkb_state_mod_index_is_active(
+ kb->wlr_keyboard->xkb_state, en_shift, XKB_STATE_MODS_EFFECTIVE);
+ group->wlr_group->keyboard.xkb_state, en_shift, XKB_STATE_MODS_EFFECTIVE);
int nsyms = xkb_state_key_get_syms(
- kb->wlr_keyboard->xkb_state, keycode, &syms);
- group->wlr_group->keyboard.xkb_state, keycode, &syms);
+ shift ? en_state_shift : en_state, keycode, &syms);
int handled = 0;
uint32_t mods = wlr_keyboard_get_modifiers(kb->wlr_keyboard);
@@ -2279,6 +2291,13 @@ setup(void)
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
@@ -2323,6 +2335,13 @@ 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.
*/
wl_list_init(&keyboards);
+ en_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ en_keymap = xkb_keymap_new_from_names(en_context, &en_rules,
+ XKB_KEYMAP_COMPILE_NO_FLAGS);
@ -58,6 +58,9 @@ index a7d41b085..4978cfac5 100644
+ en_state_shift = xkb_state_new(en_keymap);
+ en_shift = xkb_keymap_mod_get_index(en_keymap, XKB_MOD_NAME_SHIFT);
+ xkb_state_update_mask(en_state_shift, 1 << en_shift, 0, 0, 0, 0, 0);
wl_signal_add(&backend->events.new_input, &new_input);
LISTEN_STATIC(&backend->events.new_input, inputdevice);
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
LISTEN_STATIC(&virtual_keyboard_mgr->events.new_virtual_keyboard, virtualkeyboard);
--
2.43.0