wayland-keyboard: Handle keymap-layout-group-changed signal
We need to send a modifiers event to wayland clients when the layout group changes. https://bugzilla.gnome.org/show_bug.cgi?id=736433
This commit is contained in:
parent
59c5ac0cb5
commit
656573c5d2
1 changed files with 38 additions and 20 deletions
|
@ -62,9 +62,7 @@
|
|||
#include "meta-wayland-private.h"
|
||||
|
||||
static void meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard);
|
||||
static void notify_modifiers (MetaWaylandKeyboard *keyboard, uint32_t serial,
|
||||
uint32_t mods_depressed, uint32_t mods_latched,
|
||||
uint32_t mods_locked, uint32_t group);
|
||||
static void notify_modifiers (MetaWaylandKeyboard *keyboard);
|
||||
|
||||
static void
|
||||
unbind_resource (struct wl_resource *resource)
|
||||
|
@ -190,12 +188,8 @@ meta_wayland_keyboard_take_keymap (MetaWaylandKeyboard *keyboard,
|
|||
|
||||
inform_clients_of_new_keymap (keyboard);
|
||||
|
||||
notify_modifiers (keyboard,
|
||||
wl_display_next_serial (keyboard->display),
|
||||
xkb_state_serialize_mods (xkb_info->state, XKB_STATE_MODS_DEPRESSED),
|
||||
xkb_state_serialize_mods (xkb_info->state, XKB_STATE_MODS_LATCHED),
|
||||
xkb_state_serialize_mods (xkb_info->state, XKB_STATE_MODS_LOCKED),
|
||||
xkb_state_serialize_layout (xkb_info->state, XKB_STATE_LAYOUT_EFFECTIVE));
|
||||
notify_modifiers (keyboard);
|
||||
|
||||
return;
|
||||
|
||||
err_dev_zero:
|
||||
|
@ -215,6 +209,28 @@ on_keymap_changed (MetaBackend *backend,
|
|||
meta_wayland_keyboard_take_keymap (keyboard, meta_backend_get_keymap (backend));
|
||||
}
|
||||
|
||||
static void
|
||||
on_keymap_layout_group_changed (MetaBackend *backend,
|
||||
guint idx,
|
||||
gpointer data)
|
||||
{
|
||||
MetaWaylandKeyboard *keyboard = data;
|
||||
xkb_mod_mask_t depressed_mods;
|
||||
xkb_mod_mask_t latched_mods;
|
||||
xkb_mod_mask_t locked_mods;
|
||||
struct xkb_state *state;
|
||||
|
||||
state = keyboard->xkb_info.state;
|
||||
|
||||
depressed_mods = xkb_state_serialize_mods (state, XKB_STATE_MODS_DEPRESSED);
|
||||
latched_mods = xkb_state_serialize_mods (state, XKB_STATE_MODS_LATCHED);
|
||||
locked_mods = xkb_state_serialize_mods (state, XKB_STATE_MODS_LOCKED);
|
||||
|
||||
xkb_state_update_mask (state, depressed_mods, latched_mods, locked_mods, 0, 0, idx);
|
||||
|
||||
notify_modifiers (keyboard);
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_handle_focus_surface_destroy (struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
@ -248,18 +264,23 @@ notify_key (MetaWaylandKeyboard *keyboard,
|
|||
}
|
||||
|
||||
static void
|
||||
notify_modifiers (MetaWaylandKeyboard *keyboard, uint32_t serial,
|
||||
uint32_t mods_depressed, uint32_t mods_latched,
|
||||
uint32_t mods_locked, uint32_t group)
|
||||
notify_modifiers (MetaWaylandKeyboard *keyboard)
|
||||
{
|
||||
struct xkb_state *state;
|
||||
struct wl_resource *resource;
|
||||
struct wl_list *l;
|
||||
|
||||
state = keyboard->xkb_info.state;
|
||||
|
||||
l = &keyboard->focus_resource_list;
|
||||
wl_resource_for_each (resource, l)
|
||||
{
|
||||
wl_keyboard_send_modifiers (resource, serial, mods_depressed,
|
||||
mods_latched, mods_locked, group);
|
||||
wl_keyboard_send_modifiers (resource,
|
||||
wl_display_next_serial (keyboard->display),
|
||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_DEPRESSED),
|
||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_LATCHED),
|
||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_LOCKED),
|
||||
xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,6 +388,8 @@ meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
|
|||
|
||||
g_signal_connect (backend, "keymap-changed",
|
||||
G_CALLBACK (on_keymap_changed), keyboard);
|
||||
g_signal_connect (backend, "keymap-layout-group-changed",
|
||||
G_CALLBACK (on_keymap_layout_group_changed), keyboard);
|
||||
meta_wayland_keyboard_take_keymap (keyboard, meta_backend_get_keymap (backend));
|
||||
}
|
||||
|
||||
|
@ -454,12 +477,7 @@ meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard,
|
|||
if (changed_state == 0)
|
||||
return;
|
||||
|
||||
notify_modifiers (keyboard,
|
||||
wl_display_next_serial (keyboard->display),
|
||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_DEPRESSED),
|
||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_LATCHED),
|
||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_LOCKED),
|
||||
xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE));
|
||||
notify_modifiers (keyboard);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
Loading…
Reference in a new issue