mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-25 06:59:42 -05:00
compositor modifier hook
This commit is contained in:
parent
c8b9c0ad0e
commit
0ef2df21f2
6 changed files with 51 additions and 34 deletions
|
|
@ -30,17 +30,17 @@ static void keyboard_modifier_update(struct wlr_keyboard *keyboard) {
|
|||
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) {
|
||||
if (depressed == keyboard->modifiers->depressed &&
|
||||
latched == keyboard->modifiers->latched &&
|
||||
locked == keyboard->modifiers->locked &&
|
||||
group == keyboard->modifiers->group) {
|
||||
return;
|
||||
}
|
||||
|
||||
keyboard->modifiers.depressed = depressed;
|
||||
keyboard->modifiers.latched = latched;
|
||||
keyboard->modifiers.locked = locked;
|
||||
keyboard->modifiers.group = group;
|
||||
keyboard->modifiers->depressed = depressed;
|
||||
keyboard->modifiers->latched = latched;
|
||||
keyboard->modifiers->locked = locked;
|
||||
keyboard->modifiers->group = group;
|
||||
|
||||
wl_signal_emit(&keyboard->events.modifiers, keyboard);
|
||||
}
|
||||
|
|
@ -117,6 +117,7 @@ void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard,
|
|||
void wlr_keyboard_init(struct wlr_keyboard *kb,
|
||||
struct wlr_keyboard_impl *impl) {
|
||||
kb->impl = impl;
|
||||
kb->modifiers = calloc(1, sizeof(struct wlr_keyboard_modifiers));
|
||||
wl_signal_init(&kb->events.key);
|
||||
wl_signal_init(&kb->events.modifiers);
|
||||
wl_signal_init(&kb->events.keymap);
|
||||
|
|
@ -139,6 +140,7 @@ void wlr_keyboard_destroy(struct wlr_keyboard *kb) {
|
|||
xkb_state_unref(kb->xkb_state);
|
||||
xkb_keymap_unref(kb->keymap);
|
||||
close(kb->keymap_fd);
|
||||
free(kb->modifiers);
|
||||
free(kb);
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +224,7 @@ void wlr_keyboard_set_repeat_info(struct wlr_keyboard *kb, int32_t rate,
|
|||
}
|
||||
|
||||
uint32_t wlr_keyboard_get_modifiers(struct wlr_keyboard *kb) {
|
||||
xkb_mod_mask_t mask = kb->modifiers.depressed | kb->modifiers.latched;
|
||||
xkb_mod_mask_t mask = kb->modifiers->depressed | kb->modifiers->latched;
|
||||
uint32_t modifiers = 0;
|
||||
for (size_t i = 0; i < WLR_MODIFIER_COUNT; ++i) {
|
||||
if (kb->mod_indexes[i] != XKB_MOD_INVALID &&
|
||||
|
|
|
|||
|
|
@ -291,8 +291,9 @@ static void default_keyboard_key(struct wlr_seat_keyboard_grab *grab,
|
|||
wlr_seat_keyboard_send_key(grab->seat, time, key, state);
|
||||
}
|
||||
|
||||
static void default_keyboard_modifiers(struct wlr_seat_keyboard_grab *grab) {
|
||||
wlr_seat_keyboard_send_modifiers(grab->seat);
|
||||
static void default_keyboard_modifiers(struct wlr_seat_keyboard_grab *grab,
|
||||
struct wlr_keyboard_modifiers *modifiers) {
|
||||
wlr_seat_keyboard_send_modifiers(grab->seat, modifiers);
|
||||
}
|
||||
|
||||
static void default_keyboard_cancel(struct wlr_seat_keyboard_grab *grab) {
|
||||
|
|
@ -796,6 +797,10 @@ void wlr_seat_set_keyboard(struct wlr_seat *seat,
|
|||
seat->keyboard_state.keyboard = keyboard;
|
||||
}
|
||||
|
||||
struct wlr_keyboard *wlr_seat_get_keyboard(struct wlr_seat *seat) {
|
||||
return seat->keyboard_state.keyboard;
|
||||
}
|
||||
|
||||
void wlr_seat_keyboard_start_grab(struct wlr_seat *wlr_seat,
|
||||
struct wlr_seat_keyboard_grab *grab) {
|
||||
grab->seat = wlr_seat;
|
||||
|
|
@ -834,23 +839,19 @@ static void keyboard_resource_destroy_notify(struct wl_listener *listener,
|
|||
wlr_seat_keyboard_clear_focus(state->seat);
|
||||
}
|
||||
|
||||
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat) {
|
||||
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
||||
struct wlr_keyboard_modifiers *modifiers) {
|
||||
struct wlr_seat_client *client = seat->keyboard_state.focused_client;
|
||||
if (client == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_keyboard *keyboard = seat->keyboard_state.keyboard;
|
||||
if (keyboard == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t serial = wl_display_next_serial(seat->display);
|
||||
struct wl_resource *resource;
|
||||
wl_resource_for_each(resource, &client->keyboards) {
|
||||
wl_keyboard_send_modifiers(resource, serial,
|
||||
keyboard->modifiers.depressed, keyboard->modifiers.latched,
|
||||
keyboard->modifiers.locked, keyboard->modifiers.group);
|
||||
modifiers->depressed, modifiers->latched,
|
||||
modifiers->locked, modifiers->group);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -930,7 +931,8 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
|||
if (client != NULL && seat->keyboard_state.keyboard != NULL) {
|
||||
// tell new client about any modifier change last,
|
||||
// as it targets seat->keyboard_state.focused_client
|
||||
wlr_seat_keyboard_send_modifiers(seat);
|
||||
wlr_seat_keyboard_send_modifiers(seat,
|
||||
seat->keyboard_state.keyboard->modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -950,10 +952,11 @@ bool wlr_seat_keyboard_has_grab(struct wlr_seat *seat) {
|
|||
return seat->keyboard_state.grab->interface != &default_keyboard_grab_impl;
|
||||
}
|
||||
|
||||
void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat) {
|
||||
void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat,
|
||||
struct wlr_keyboard_modifiers *modifiers) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
||||
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
||||
grab->interface->modifiers(grab);
|
||||
grab->interface->modifiers(grab, modifiers);
|
||||
}
|
||||
|
||||
void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
|
||||
|
|
|
|||
|
|
@ -112,8 +112,9 @@ static void xdg_keyboard_grab_key(struct wlr_seat_keyboard_grab *grab, uint32_t
|
|||
wlr_seat_keyboard_send_key(grab->seat, time, key, state);
|
||||
}
|
||||
|
||||
static void xdg_keyboard_grab_modifiers(struct wlr_seat_keyboard_grab *grab) {
|
||||
wlr_seat_keyboard_send_modifiers(grab->seat);
|
||||
static void xdg_keyboard_grab_modifiers(struct wlr_seat_keyboard_grab *grab,
|
||||
struct wlr_keyboard_modifiers *modifiers) {
|
||||
wlr_seat_keyboard_send_modifiers(grab->seat, modifiers);
|
||||
}
|
||||
|
||||
static void xdg_keyboard_grab_cancel(struct wlr_seat_keyboard_grab *grab) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue