Fix modifiers support with backend != wayland
This commit is contained in:
parent
d3d9aca40c
commit
d71344bcdd
|
@ -24,3 +24,9 @@ geometry = 2500x800
|
|||
map-to-output = VGA-1
|
||||
# Restrict cursor movements for this mouse to concrete rectangle
|
||||
geometry = 2500x800
|
||||
|
||||
# Keybindings
|
||||
# Maps key combinations with commands to execute
|
||||
# The special command "exit" stops the compositor
|
||||
[bindings]
|
||||
Logo+q=exit
|
||||
|
|
|
@ -21,22 +21,39 @@ static void keyboard_led_update(struct wlr_keyboard *keyboard) {
|
|||
wlr_keyboard_led_update(keyboard, leds);
|
||||
}
|
||||
|
||||
void wlr_keyboard_update_modifiers(struct wlr_keyboard *keyboard,
|
||||
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
||||
uint32_t group) {
|
||||
if (mods_depressed == keyboard->modifiers.depressed &&
|
||||
mods_latched == keyboard->modifiers.latched &&
|
||||
mods_locked == keyboard->modifiers.locked &&
|
||||
group == keyboard->modifiers.group) {
|
||||
return;
|
||||
}
|
||||
keyboard->modifiers.depressed = mods_depressed;
|
||||
keyboard->modifiers.latched = mods_latched;
|
||||
keyboard->modifiers.locked = mods_locked;
|
||||
keyboard->modifiers.group = group;
|
||||
}
|
||||
|
||||
void wlr_keyboard_update_state(struct wlr_keyboard *keyboard,
|
||||
struct wlr_event_keyboard_key *event) {
|
||||
uint32_t keycode = event->keycode + 8;
|
||||
xkb_state_update_key(keyboard->xkb_state, keycode,
|
||||
event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP);
|
||||
keyboard_led_update(keyboard);
|
||||
wl_signal_emit(&keyboard->events.key, event);
|
||||
}
|
||||
|
||||
void wlr_keyboard_update_modifiers(struct wlr_keyboard *keyboard,
|
||||
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
||||
uint32_t group) {
|
||||
keyboard->modifiers.depressed = mods_depressed;
|
||||
keyboard->modifiers.latched = mods_latched;
|
||||
keyboard->modifiers.locked = mods_locked;
|
||||
keyboard->modifiers.group = group;
|
||||
xkb_mod_mask_t depressed = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_DEPRESSED);
|
||||
xkb_mod_mask_t latched = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_LATCHED);
|
||||
xkb_mod_mask_t locked = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_LOCKED);
|
||||
xkb_mod_mask_t group = xkb_state_serialize_layout(keyboard->xkb_state,
|
||||
XKB_STATE_LAYOUT_EFFECTIVE);
|
||||
wlr_keyboard_update_modifiers(keyboard, depressed, latched, locked, group);
|
||||
|
||||
wl_signal_emit(&keyboard->events.key, event);
|
||||
}
|
||||
|
||||
void wlr_keyboard_init(struct wlr_keyboard *kb,
|
||||
|
|
|
@ -402,28 +402,10 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
|
|||
handle->seat_keyboard = seat_kb;
|
||||
}
|
||||
|
||||
xkb_mod_mask_t depressed = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_DEPRESSED);
|
||||
xkb_mod_mask_t latched = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_LATCHED);
|
||||
xkb_mod_mask_t locked = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_LOCKED);
|
||||
xkb_mod_mask_t group = xkb_state_serialize_layout(keyboard->xkb_state,
|
||||
XKB_STATE_LAYOUT_EFFECTIVE);
|
||||
if (depressed != keyboard->modifiers.depressed ||
|
||||
latched != keyboard->modifiers.latched ||
|
||||
locked != keyboard->modifiers.locked ||
|
||||
group != keyboard->modifiers.group) {
|
||||
keyboard->modifiers.depressed = depressed;
|
||||
keyboard->modifiers.latched = latched;
|
||||
keyboard->modifiers.locked = locked;
|
||||
keyboard->modifiers.group = group;
|
||||
|
||||
uint32_t modifiers_serial = wl_display_next_serial(seat->display);
|
||||
wl_keyboard_send_modifiers(handle->keyboard, modifiers_serial, depressed,
|
||||
latched, locked, group);
|
||||
}
|
||||
|
||||
wl_keyboard_send_modifiers(handle->keyboard, modifiers_serial,
|
||||
keyboard->modifiers.depressed, keyboard->modifiers.latched,
|
||||
keyboard->modifiers.locked, keyboard->modifiers.group);
|
||||
uint32_t key_serial = wl_display_next_serial(seat->display);
|
||||
wl_keyboard_send_key(handle->keyboard, key_serial,
|
||||
(uint32_t)event->time_usec, event->keycode, key_state);
|
||||
|
|
Loading…
Reference in New Issue