diff options
author | Brian Ashworth <RedSoxFan@users.noreply.github.com> | 2018-07-25 12:07:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 12:07:35 -0400 |
commit | c8dc9b3b3094c9b2778309855114b9495518c2d4 (patch) | |
tree | fbe2ecd9c36e7e1d954853f76d813ecdcd1a2e57 /sway/input | |
parent | 6a8d1e5044086a8dce121bd1f405b342e17a1301 (diff) | |
parent | 76ece5788bffe27b32c85968886f3738d244abf9 (diff) |
Merge pull request #2330 from progandy/set-modifier-locks
Configure initial state for numlock/capslock
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/keyboard.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 49241db8..643ff510 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,31 @@ 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); + uint32_t leds = 0; + for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) { + if (xkb_state_led_index_is_active(wlr_device->keyboard->xkb_state, + wlr_device->keyboard->led_indexes[i])) { + leds |= (1 << i); + } + } + wlr_keyboard_led_update(wlr_device->keyboard, leds); + } + if (input_config && input_config->repeat_delay != INT_MIN && input_config->repeat_rate != INT_MIN) { wlr_keyboard_set_repeat_info(wlr_device->keyboard, |