mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
wayland/keyboard: preserve layout index
On VT switch, the xkb state layout index is lost and reset to the first group, so if the first layout is not the last one being used, the xkb state used in both meta-wayland-keyboard.c and clutter/evdev will be desynchronized with the keyboard source indicator in the gnome-shell UI. Save the effective layout chosen along with the seat so it can be restored when reclaiming devices. Use the saved layout index from the clutter/evdev's seat to restore the layout in meta-wayland-keyboard, so that switching VT doesn't reset the layout and causes further discrepancies with the layout indicator in the gnome-shell UI. https://bugzilla.gnome.org/show_bug.cgi?id=791383
This commit is contained in:
parent
44269e6a1d
commit
7f5f5eb847
@ -2317,7 +2317,7 @@ clutter_evdev_update_xkb_state (ClutterDeviceManagerEvdev *manager_evdev)
|
||||
0, /* depressed */
|
||||
latched_mods,
|
||||
locked_mods,
|
||||
0, 0, 0);
|
||||
0, 0, seat->layout_idx);
|
||||
|
||||
seat->caps_lock_led = xkb_keymap_led_get_index (priv->keymap, XKB_LED_NAME_CAPS);
|
||||
seat->num_lock_led = xkb_keymap_led_get_index (priv->keymap, XKB_LED_NAME_NUM);
|
||||
@ -2465,6 +2465,7 @@ clutter_evdev_set_keyboard_layout_index (ClutterDeviceManager *evdev,
|
||||
xkb_mod_mask_t latched_mods;
|
||||
xkb_mod_mask_t locked_mods;
|
||||
struct xkb_state *state;
|
||||
GSList *l;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER_EVDEV (evdev));
|
||||
|
||||
@ -2476,6 +2477,12 @@ clutter_evdev_set_keyboard_layout_index (ClutterDeviceManager *evdev,
|
||||
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);
|
||||
for (l = manager_evdev->priv->seats; l; l = l->next)
|
||||
{
|
||||
ClutterSeatEvdev *seat = l->data;
|
||||
|
||||
seat->layout_idx = idx;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2485,12 +2492,9 @@ xkb_layout_index_t
|
||||
clutter_evdev_get_keyboard_layout_index (ClutterDeviceManager *evdev)
|
||||
{
|
||||
ClutterDeviceManagerEvdev *manager_evdev;
|
||||
struct xkb_state *state;
|
||||
|
||||
manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (evdev);
|
||||
state = manager_evdev->priv->main_seat->xkb;
|
||||
|
||||
return xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_LOCKED);
|
||||
return manager_evdev->priv->main_seat->layout_idx;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,6 +58,7 @@ struct _ClutterSeatEvdev
|
||||
xkb_led_index_t caps_lock_led;
|
||||
xkb_led_index_t num_lock_led;
|
||||
xkb_led_index_t scroll_lock_led;
|
||||
xkb_layout_index_t layout_idx;
|
||||
uint32_t button_state;
|
||||
int button_count[KEY_CNT];
|
||||
|
||||
|
@ -508,6 +508,8 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
|
||||
{
|
||||
MetaWaylandXkbInfo *xkb_info = &keyboard->xkb_info;
|
||||
xkb_mod_mask_t latched, locked;
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
xkb_layout_index_t layout_idx;
|
||||
|
||||
/* Preserve latched/locked modifiers state */
|
||||
if (xkb_info->state)
|
||||
@ -523,8 +525,8 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
|
||||
|
||||
xkb_info->state = xkb_state_new (xkb_info->keymap);
|
||||
|
||||
if (latched || locked)
|
||||
xkb_state_update_mask (xkb_info->state, 0, latched, locked, 0, 0, 0);
|
||||
layout_idx = meta_backend_get_keymap_layout_group (backend);
|
||||
xkb_state_update_mask (xkb_info->state, 0, latched, locked, 0, 0, layout_idx);
|
||||
|
||||
kbd_a11y_apply_mask (keyboard);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user