[mutter] backend-x11: Re-upload keymap when new keyboard devices are added
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] backend-x11: Re-upload keymap when new keyboard devices are added
- Date: Fri, 3 Oct 2014 17:02:25 +0000 (UTC)
commit 478b75e8039aa144d358389100201e0a6f14d118
Author: Rui Matos <tiagomatos gmail com>
Date: Thu Oct 2 19:07:21 2014 +0200
backend-x11: Re-upload keymap when new keyboard devices are added
The X server applies a default keymap to hotplugged keyboard
devices. To enforce our current settings we must re-upload the keymap
when a new keyboard shows up.
Note that setting the VCK keymap causes the server to propagate it
to all slave keyboard devices.
https://bugzilla.gnome.org/show_bug.cgi?id=737673
src/backends/x11/meta-backend-x11.c | 55 +++++++++++++++++++++++++++++-----
1 files changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 98afbbe..fa99e0d 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -65,9 +65,14 @@ struct _MetaBackendX11Private
uint8_t xkb_error_base;
struct xkb_keymap *keymap;
+ gchar *keymap_layouts;
+ gchar *keymap_variants;
+ gchar *keymap_options;
};
typedef struct _MetaBackendX11Private MetaBackendX11Private;
+static void apply_keymap (MetaBackendX11 *x11);
+
G_DEFINE_TYPE_WITH_PRIVATE (MetaBackendX11, meta_backend_x11, META_TYPE_BACKEND);
static void
@@ -327,6 +332,17 @@ take_touch_grab (MetaBackend *backend)
}
static void
+on_device_added (ClutterDeviceManager *device_manager,
+ ClutterInputDevice *device,
+ gpointer user_data)
+{
+ MetaBackendX11 *x11 = META_BACKEND_X11 (user_data);
+
+ if (clutter_input_device_get_device_type (device) == CLUTTER_KEYBOARD_DEVICE)
+ apply_keymap (x11);
+}
+
+static void
meta_backend_x11_post_init (MetaBackend *backend)
{
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
@@ -376,6 +392,9 @@ meta_backend_x11_post_init (MetaBackend *backend)
meta_fatal ("X server doesn't have the XKB extension, version %d.%d or newer\n",
XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION);
+ g_signal_connect_object (clutter_device_manager_get_default (), "device-added",
+ G_CALLBACK (on_device_added), backend, 0);
+
META_BACKEND_CLASS (meta_backend_x11_parent_class)->post_init (backend);
}
@@ -560,21 +579,22 @@ upload_xkb_description (Display *xdisplay,
}
static void
-meta_backend_x11_set_keymap (MetaBackend *backend,
- const char *layouts,
- const char *variants,
- const char *options)
+apply_keymap (MetaBackendX11 *x11)
{
- MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
XkbRF_RulesRec *xkb_rules;
XkbRF_VarDefsRec xkb_var_defs = { 0 };
gchar *rules_file_path;
+ if (!priv->keymap_layouts ||
+ !priv->keymap_variants ||
+ !priv->keymap_options)
+ return;
+
get_xkbrf_var_defs (priv->xdisplay,
- layouts,
- variants,
- options,
+ priv->keymap_layouts,
+ priv->keymap_variants,
+ priv->keymap_options,
&rules_file_path,
&xkb_var_defs);
@@ -598,6 +618,25 @@ meta_backend_x11_set_keymap (MetaBackend *backend,
g_free (rules_file_path);
}
+static void
+meta_backend_x11_set_keymap (MetaBackend *backend,
+ const char *layouts,
+ const char *variants,
+ const char *options)
+{
+ MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
+ MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
+
+ g_free (priv->keymap_layouts);
+ priv->keymap_layouts = g_strdup (layouts);
+ g_free (priv->keymap_variants);
+ priv->keymap_variants = g_strdup (variants);
+ g_free (priv->keymap_options);
+ priv->keymap_options = g_strdup (options);
+
+ apply_keymap (x11);
+}
+
static struct xkb_keymap *
meta_backend_x11_get_keymap (MetaBackend *backend)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]