backends/native: Shuffle xkb_keymap creation

Push it a little bit down to the MetaSeatNative. As both the UI thread
and the input thread are interested in dealing with the xkb_keymap and
it is not meant to be used in different threads, keep 2 separate copies
around.

The keyboard map will always be set from the UI thread, so the xkb_keymap
owned by the MetaSeatNative (owned by the UI thread) can be considered
canonical.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho
2020-08-12 12:47:07 +02:00
committed by Marge Bot
parent 40665b0fb1
commit 23f95348fd
5 changed files with 74 additions and 71 deletions

View File

@@ -2826,19 +2826,23 @@ meta_seat_impl_set_device_callbacks (MetaOpenDeviceCallback open_callback,
void
meta_seat_impl_update_xkb_state (MetaSeatImpl *seat_impl)
{
xkb_mod_mask_t latched_mods;
xkb_mod_mask_t locked_mods;
xkb_mod_mask_t latched_mods = 0;
xkb_mod_mask_t locked_mods = 0;
struct xkb_keymap *xkb_keymap;
g_rw_lock_writer_lock (&seat_impl->state_lock);
xkb_keymap = meta_keymap_native_get_keyboard_map (seat_impl->keymap);
latched_mods = xkb_state_serialize_mods (seat_impl->xkb,
XKB_STATE_MODS_LATCHED);
locked_mods = xkb_state_serialize_mods (seat_impl->xkb,
XKB_STATE_MODS_LOCKED);
xkb_state_unref (seat_impl->xkb);
if (seat_impl->xkb)
{
latched_mods = xkb_state_serialize_mods (seat_impl->xkb,
XKB_STATE_MODS_LATCHED);
locked_mods = xkb_state_serialize_mods (seat_impl->xkb,
XKB_STATE_MODS_LOCKED);
xkb_state_unref (seat_impl->xkb);
}
seat_impl->xkb = xkb_state_new (xkb_keymap);
xkb_state_update_mask (seat_impl->xkb,
@@ -2932,6 +2936,7 @@ meta_seat_impl_set_keyboard_map (MetaSeatImpl *seat_impl,
MetaKeymapNative *keymap;
g_return_if_fail (META_IS_SEAT_IMPL (seat_impl));
g_return_if_fail (xkb_keymap != NULL);
keymap = seat_impl->keymap;
meta_keymap_native_set_keyboard_map (keymap, xkb_keymap);
@@ -2939,22 +2944,6 @@ meta_seat_impl_set_keyboard_map (MetaSeatImpl *seat_impl,
meta_seat_impl_update_xkb_state (seat_impl);
}
/**
* meta_seat_impl_get_keyboard_map: (skip)
* @seat: the #ClutterSeat created by the evdev backend
*
* Retrieves the #xkb_keymap in use by the evdev backend.
*
* Return value: the #xkb_keymap.
*/
struct xkb_keymap *
meta_seat_impl_get_keyboard_map (MetaSeatImpl *seat_impl)
{
g_return_val_if_fail (META_IS_SEAT_IMPL (seat_impl), NULL);
return xkb_state_get_keymap (seat_impl->xkb);
}
/**
* meta_seat_impl_set_keyboard_layout_index: (skip)
* @seat: the #ClutterSeat created by the evdev backend
@@ -2989,15 +2978,6 @@ meta_seat_impl_set_keyboard_layout_index (MetaSeatImpl *seat_impl,
g_rw_lock_writer_unlock (&seat_impl->state_lock);
}
/**
* meta_seat_impl_get_keyboard_layout_index: (skip)
*/
xkb_layout_index_t
meta_seat_impl_get_keyboard_layout_index (MetaSeatImpl *seat_impl)
{
return seat_impl->layout_idx;
}
/**
* meta_seat_impl_set_keyboard_numlock: (skip)
* @seat: the #ClutterSeat created by the evdev backend