mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-21 22:52:20 +00:00
wlr-seat: keyboard modifiers
This commit is contained in:
parent
cef1f60522
commit
30b5d76426
@ -343,6 +343,17 @@ static void handle_keyboard_key(struct keyboard_state *keyboard,
|
||||
struct compositor_state *state = keyboard->compositor;
|
||||
struct sample_state *sample = state->data;
|
||||
|
||||
uint32_t depressed = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_DEPRESSED);
|
||||
uint32_t latched = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_LATCHED);
|
||||
uint32_t locked = xkb_state_serialize_mods(keyboard->xkb_state,
|
||||
XKB_STATE_MODS_LOCKED);
|
||||
uint32_t group = xkb_state_serialize_layout(keyboard->xkb_state,
|
||||
XKB_STATE_LAYOUT_EFFECTIVE);
|
||||
|
||||
wlr_seat_keyboard_send_modifiers(sample->wl_seat, depressed, latched,
|
||||
locked, group);
|
||||
wlr_seat_keyboard_send_key(sample->wl_seat, (uint32_t)time_usec, keycode,
|
||||
key_state);
|
||||
|
||||
|
@ -142,4 +142,12 @@ void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat);
|
||||
uint32_t wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time,
|
||||
uint32_t key, uint32_t state);
|
||||
|
||||
/**
|
||||
* Send the modifiers event to the surface with keyboard focus. Also sends the
|
||||
* event to the surface with pointer focus.
|
||||
*/
|
||||
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *wlr_seat,
|
||||
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
||||
uint32_t group);
|
||||
|
||||
#endif
|
||||
|
@ -481,3 +481,30 @@ uint32_t wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time,
|
||||
|
||||
return serial;
|
||||
}
|
||||
|
||||
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *wlr_seat,
|
||||
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
||||
uint32_t group) {
|
||||
uint32_t serial = 0;
|
||||
struct wl_resource *keyboard;
|
||||
|
||||
if (wlr_seat_keyboard_has_focus_resource(wlr_seat)) {
|
||||
serial = wl_display_next_serial(wlr_seat->display);
|
||||
keyboard = wlr_seat->keyboard_state.focused_handle->keyboard;
|
||||
wl_keyboard_send_modifiers(keyboard, serial, mods_depressed,
|
||||
mods_latched, mods_locked, group);
|
||||
}
|
||||
|
||||
if (wlr_seat_pointer_has_focus_resource(wlr_seat) &&
|
||||
wlr_seat->pointer_state.focused_handle->keyboard &&
|
||||
wlr_seat->pointer_state.focused_handle !=
|
||||
wlr_seat->keyboard_state.focused_handle) {
|
||||
if (serial == 0) {
|
||||
serial = wl_display_next_serial(wlr_seat->display);
|
||||
}
|
||||
keyboard = wlr_seat->pointer_state.focused_handle->keyboard;
|
||||
|
||||
wl_keyboard_send_modifiers(keyboard, serial, mods_depressed,
|
||||
mods_latched, mods_locked, group);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user