mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 17:31:28 +00:00
input/keyboard: don't reset layout for same keymap
In sway_keyboard_config, do not change the keymap when the new keymap is unchanged, unless this is during a config reload. The reasoning for this is to prevent the effective layout from being reset to index 0 for input config changes unrelated to the keymap.
This commit is contained in:
parent
f567a40d59
commit
14562fdbee
|
@ -622,34 +622,42 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
|
||||||
keymap_changed = true;
|
keymap_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
xkb_keymap_unref(keyboard->keymap);
|
if (keymap_changed || config->reloading) {
|
||||||
keyboard->keymap = keymap;
|
xkb_keymap_unref(keyboard->keymap);
|
||||||
keyboard->effective_layout = 0;
|
keyboard->keymap = keymap;
|
||||||
wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap);
|
keyboard->effective_layout = 0;
|
||||||
|
wlr_keyboard_set_keymap(wlr_device->keyboard, keyboard->keymap);
|
||||||
|
|
||||||
xkb_mod_mask_t locked_mods = 0;
|
xkb_mod_mask_t locked_mods = 0;
|
||||||
if (input_config && input_config->xkb_numlock > 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);
|
xkb_mod_index_t mod_index = xkb_map_mod_get_index(keymap,
|
||||||
if (mod_index != XKB_MOD_INVALID) {
|
XKB_MOD_NAME_NUM);
|
||||||
locked_mods |= (uint32_t)1 << mod_index;
|
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->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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
}
|
}
|
||||||
|
|
||||||
int repeat_rate = 25;
|
int repeat_rate = 25;
|
||||||
|
|
Loading…
Reference in a new issue