mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
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
This commit is contained in:
parent
e16b75a0b7
commit
ef2e04a613
@ -28,6 +28,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "clutter/clutter.h"
|
#include "clutter/clutter.h"
|
||||||
|
#include "meta/meta-backend.h"
|
||||||
#include "meta/meta-background-actor.h"
|
#include "meta/meta-background-actor.h"
|
||||||
#include "meta/meta-background-group.h"
|
#include "meta/meta-background-group.h"
|
||||||
#include "meta/meta-monitor-manager.h"
|
#include "meta/meta-monitor-manager.h"
|
||||||
@ -369,6 +370,67 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
|
|||||||
g_rand_free (rand);
|
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
|
static void
|
||||||
start (MetaPlugin *plugin)
|
start (MetaPlugin *plugin)
|
||||||
{
|
{
|
||||||
@ -385,6 +447,9 @@ start (MetaPlugin *plugin)
|
|||||||
|
|
||||||
on_monitors_changed (monitor_manager, plugin);
|
on_monitors_changed (monitor_manager, plugin);
|
||||||
|
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
init_keymap (self);
|
||||||
|
|
||||||
clutter_actor_show (meta_get_stage_for_display (display));
|
clutter_actor_show (meta_get_stage_for_display (display));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user