[mutter] wayland/keyboard: preserve layout index
- From: Olivier Fourdan <ofourdan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland/keyboard: preserve layout index
- Date: Wed, 20 Dec 2017 09:03:01 +0000 (UTC)
commit 7f5f5eb8473649f19357b45baa925a1de8b8a683
Author: Olivier Fourdan <ofourdan redhat com>
Date: Tue Dec 19 16:32:32 2017 +0100
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
.../clutter/evdev/clutter-device-manager-evdev.c | 14 +++++++++-----
clutter/clutter/evdev/clutter-seat-evdev.h | 1 +
src/wayland/meta-wayland-keyboard.c | 6 ++++--
3 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.c
b/clutter/clutter/evdev/clutter-device-manager-evdev.c
index c1c933e..44e3ddd 100644
--- a/clutter/clutter/evdev/clutter-device-manager-evdev.c
+++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c
@@ -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;
}
/**
diff --git a/clutter/clutter/evdev/clutter-seat-evdev.h b/clutter/clutter/evdev/clutter-seat-evdev.h
index 38c9c7a..61a2acd 100644
--- a/clutter/clutter/evdev/clutter-seat-evdev.h
+++ b/clutter/clutter/evdev/clutter-seat-evdev.h
@@ -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];
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index c069df8..5b90b2a 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]