diff options
author | ProgAndy <code@progandy.de> | 2018-07-22 21:16:19 +0200 |
---|---|---|
committer | ProgAndy <code@progandy.de> | 2018-07-25 17:24:45 +0200 |
commit | 2166dbe2e49fc5eeb345d744424db360ee63f508 (patch) | |
tree | fcb9cd6632e0e6b907ae046f94288617230a3688 /sway/input | |
parent | 6a8d1e5044086a8dce121bd1f405b342e17a1301 (diff) |
Implement setting NumLock and CapsLock status
After setting the keymap, try to enable NumLock and disable CapsLock.
This only works if sway has the xkb master state and controls the keyboard.
Prepare configuration settings for later use as well.
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/keyboard.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 49241db8..36c5a064 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -3,6 +3,7 @@ #include <wlr/backend/multi.h> #include <wlr/backend/session.h> #include <wlr/types/wlr_idle.h> +#include <wlr/interfaces/wlr_keyboard.h> #include "sway/commands.h" #include "sway/desktop/transaction.h" #include "sway/input/input-manager.h" @@ -385,6 +386,23 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { keyboard->keymap = keymap; wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap); + xkb_mod_mask_t locked_mods = 0; + if (!input_config || input_config->xkb_numlock != 0) { + xkb_mod_index_t mod_index = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_NUM); + if (mod_index != XKB_MOD_INVALID) { + locked_mods |= (uint32_t)1 << mod_index; + } + } + if (input_config && input_config->xkb_capslock > 0) { + xkb_mod_index_t mod_index = xkb_map_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(wlr_device->keyboard, 0, 0, locked_mods, 0); + } + if (input_config && input_config->repeat_delay != INT_MIN && input_config->repeat_rate != INT_MIN) { wlr_keyboard_set_repeat_info(wlr_device->keyboard, |