Created
May 8, 2025 08:31
-
-
Save Yappaholic/9478701e99f583cbd45f215542dbc638 to your computer and use it in GitHub Desktop.
Patch for Colemak-dh-wide-iso keycodes in DWL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 54b5d3413748c610fd5e5367ac6595faf09f079f Mon Sep 17 00:00:00 2001 | |
| From: Yappaholic <[email protected]> | |
| Date: Thu, 8 May 2025 11:26:36 +0300 | |
| Subject: [PATCH] En-keycodes | |
| --- | |
| dwl.c | 20 +++++++++++++++++--- | |
| 1 file changed, 17 insertions(+), 3 deletions(-) | |
| diff --git a/dwl.c b/dwl.c | |
| index cf3ef70..2d525f7 100644 | |
| --- a/dwl.c | |
| +++ b/dwl.c | |
| @@ -361,6 +361,10 @@ static const char broken[] = "broken"; | |
| static pid_t child_pid = -1; | |
| static int locked; | |
| static void *exclusive_focus; | |
| +static struct xkb_rule_names en_rules = {.layout = "us", .variant = "colemak_dh_wide_iso"}; | |
| +static struct xkb_context *en_context; | |
| +static struct xkb_keymap *en_keymap; | |
| +static struct xkb_state *en_state; | |
| static struct wl_display *dpy; | |
| static struct wl_event_loop *event_loop; | |
| static struct wlr_backend *backend; | |
| @@ -694,6 +698,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); | |
| @@ -1581,15 +1588,18 @@ 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); | |
| + 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); | |
| - int handled = 0; | |
| + handled = 0; | |
| uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard); | |
| wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); | |
| @@ -2606,6 +2616,10 @@ 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_keymap = xkb_keymap_new_from_names(en_context, &en_rules, | |
| + XKB_KEYMAP_COMPILE_NO_FLAGS); | |
| + en_state = xkb_state_new(en_keymap); | |
| LISTEN_STATIC(&backend->events.new_input, inputdevice); | |
| virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy); | |
| LISTEN_STATIC(&virtual_keyboard_mgr->events.new_virtual_keyboard, virtualkeyboard); | |
| -- | |
| 2.49.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment