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

@ -187,12 +187,12 @@ meta_backend_native_post_init (MetaBackend *backend)
MetaSeatNative *seat =
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
backend_native->input_settings = meta_seat_impl_get_input_settings (seat->impl);
g_signal_connect_object (backend_native->input_settings, "kbd-a11y-changed",
G_CALLBACK (kbd_a11y_changed_cb), backend, 0);
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
if (meta_settings_is_experimental_feature_enabled (settings,
META_EXPERIMENTAL_FEATURE_RT_SCHEDULER))
{
@ -286,35 +286,13 @@ meta_backend_native_set_keymap (MetaBackend *backend,
const char *options)
{
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
struct xkb_rule_names names;
struct xkb_keymap *keymap;
struct xkb_context *context;
ClutterSeat *seat;
names.rules = DEFAULT_XKB_RULES_FILE;
names.model = DEFAULT_XKB_MODEL;
names.layout = layouts;
names.variant = variants;
names.options = options;
context = meta_create_xkb_context ();
keymap = xkb_keymap_new_from_names (context, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);
xkb_context_unref (context);
if (keymap == NULL)
{
g_warning ("Unable to load configured keymap: rules=%s, model=%s, layout=%s, variant=%s, options=%s",
DEFAULT_XKB_RULES_FILE, DEFAULT_XKB_MODEL, layouts,
variants, options);
return;
}
seat = clutter_backend_get_default_seat (clutter_backend);
meta_seat_native_set_keyboard_map (META_SEAT_NATIVE (seat), keymap);
meta_seat_native_set_keyboard_map (META_SEAT_NATIVE (seat),
layouts, variants, options);
meta_backend_notify_keymap_changed (backend);
xkb_keymap_unref (keymap);
}
static struct xkb_keymap *