[mutter] plugins/default: Get default keymap from localed
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] plugins/default: Get default keymap from localed
- Date: Tue, 10 Sep 2019 21:00:40 +0000 (UTC)
commit ef2e04a613f6af5e16ec9e8aa8197d95638a4178
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Sep 9 19:13:59 2019 +0200
plugins/default: Get default keymap from localed
When starting standalone mutter and running using the native backend, we
always fall back on using the us pc105 keyboard layout. This can be very
frustrating if one is used to using some other keyboard layout, such as
dvorak, causing keyboard fumbling everytime when doing something with
standalone mutter.
Avoid this involuntary fumbling by having the default plugin query
localed what layout the user has actually configured the machine to
operate using. It doesn't add any keymap selection user interface, so
it'll always use the first one it encounters.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/787
src/compositor/plugins/default.c | 65 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
---
diff --git a/src/compositor/plugins/default.c b/src/compositor/plugins/default.c
index 33c00989e..089c6299d 100644
--- a/src/compositor/plugins/default.c
+++ b/src/compositor/plugins/default.c
@@ -28,6 +28,7 @@
#include <string.h>
#include "clutter/clutter.h"
+#include "meta/meta-backend.h"
#include "meta/meta-background-actor.h"
#include "meta/meta-background-group.h"
#include "meta/meta-monitor-manager.h"
@@ -369,6 +370,67 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
g_rand_free (rand);
}
+static void
+init_keymap (MetaDefaultPlugin *self)
+{
+ g_autoptr (GError) error = NULL;
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) result = NULL;
+ g_autoptr (GVariant) props = NULL;
+ g_autofree char *x11_layout = NULL;
+ g_autofree char *x11_options = NULL;
+ g_autofree char *x11_variant = NULL;
+
+ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.locale1",
+ "/org/freedesktop/locale1",
+ "org.freedesktop.DBus.Properties",
+ NULL,
+ &error);
+ if (!proxy)
+ {
+ g_message ("Failed to acquire org.freedesktop.locale1 proxy: %s, "
+ "probably running in CI",
+ error->message);
+ return;
+ }
+
+ result = g_dbus_proxy_call_sync (proxy,
+ "GetAll",
+ g_variant_new ("(s)",
+ "org.freedesktop.locale1"),
+ G_DBUS_CALL_FLAGS_NONE,
+ 100,
+ NULL,
+ &error);
+ if (!result)
+ {
+ g_warning ("Failed to retrieve locale properties: %s", error->message);
+ return;
+ }
+
+ props = g_variant_get_child_value (result, 0);
+ if (!props)
+ {
+ g_warning ("No locale properties found");
+ return;
+ }
+
+ if (!g_variant_lookup (props, "X11Layout", "s", &x11_layout))
+ x11_layout = g_strdup ("us");
+
+ if (!g_variant_lookup (props, "X11Options", "s", &x11_options))
+ x11_options = g_strdup ("");
+
+ if (!g_variant_lookup (props, "X11Variant", "s", &x11_variant))
+ x11_variant = g_strdup ("");
+
+ meta_backend_set_keymap (meta_get_backend (),
+ x11_layout, x11_variant, x11_options);
+}
+
static void
start (MetaPlugin *plugin)
{
@@ -385,6 +447,9 @@ start (MetaPlugin *plugin)
on_monitors_changed (monitor_manager, plugin);
+ if (meta_is_wayland_compositor ())
+ init_keymap (self);
+
clutter_actor_show (meta_get_stage_for_display (display));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]