diff options
author | Joshua Yun <joshua@joshuayun.com> | 2025-03-31 23:21:12 -0500 |
---|---|---|
committer | Joshua Yun <joshua@joshuayun.com> | 2025-03-31 23:21:12 -0500 |
commit | b38b5e28d9f28a9382a290461fb12c7a58d19256 (patch) | |
tree | 11a9b33b29383d5e543b49b9cc36c2c8a74d989b | |
parent | c0d1ed7d19021f451b2dd3f7d7bcb5c0818b26be (diff) | |
download | dwl-b38b5e28d9f28a9382a290461fb12c7a58d19256.tar.gz |
feat: added numlock patch
-rw-r--r-- | config.def.h | 4 | ||||
-rw-r--r-- | dwl.c | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 143bee1..54f4c42 100644 --- a/config.def.h +++ b/config.def.h @@ -80,6 +80,10 @@ static const struct xkb_rule_names xkb_rules = { .options = NULL, }; +/* numlock and capslock */ +static const int numlock = 1; +static const int capslock = 0; + static const int repeat_rate = 50; static const int repeat_delay = 300; @@ -16,6 +16,7 @@ #include <wayland-server-core.h> #include <wlr/backend.h> #include <wlr/backend/libinput.h> +#include <wlr/interfaces/wlr_keyboard.h> #include <wlr/render/allocator.h> #include <wlr/render/wlr_renderer.h> #include <wlr/types/wlr_alpha_modifier_v1.h> @@ -399,6 +400,7 @@ static void zoom(const Arg *arg); /* variables */ static pid_t child_pid = -1; static int locked; +static uint32_t locked_mods = 0; static void *exclusive_focus; static struct wl_display *dpy; static struct wl_event_loop *event_loop; @@ -1172,6 +1174,8 @@ createkeyboard(struct wlr_keyboard *keyboard) /* Set the keymap to match the group keymap */ wlr_keyboard_set_keymap(keyboard, kb_group->wlr_group->keyboard.keymap); + wlr_keyboard_notify_modifiers(keyboard, 0, 0, locked_mods, 0); + /* Add the new keyboard to the group */ wlr_keyboard_group_add_keyboard(kb_group->wlr_group, keyboard); } @@ -1193,6 +1197,21 @@ createkeyboardgroup(void) die("failed to compile keymap"); wlr_keyboard_set_keymap(&group->wlr_group->keyboard, keymap); + if (numlock) { + xkb_mod_index_t mod_index = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_NUM); + if (mod_index != XKB_MOD_INVALID) + locked_mods |= (uint32_t)1 << mod_index; + } + + if (capslock) { + xkb_mod_index_t mod_index = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CAPS); + if (mod_index != XKB_MOD_INVALID) + locked_mods |= (uint32_t)1 << mod_index; + } + + if (locked_mods) + wlr_keyboard_notify_modifiers(&group->wlr_group->keyboard, 0, 0, locked_mods, 0); + xkb_keymap_unref(keymap); xkb_context_unref(context); |