gdm/gdm-system-keyboard.patch

121 lines
4.5 KiB
Diff
Raw Normal View History

diff -up gdm-2.25.2/configure.ac.system-keyboard gdm-2.25.2/configure.ac
2009-02-25 03:56:44 +00:00
--- gdm-2.25.2/configure.ac.system-keyboard 2009-02-24 22:51:00.058815966 -0500
+++ gdm-2.25.2/configure.ac 2009-02-24 22:51:00.154816109 -0500
@@ -69,6 +69,7 @@ AC_SUBST(COMMON_LIBS)
PKG_CHECK_MODULES(DAEMON,
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
gobject-2.0 >= $GLIB_REQUIRED_VERSION
+ hal
)
AC_SUBST(DAEMON_CFLAGS)
AC_SUBST(DAEMON_LIBS)
diff -up gdm-2.25.2/daemon/gdm-session-direct.c.system-keyboard gdm-2.25.2/daemon/gdm-session-direct.c
--- gdm-2.25.2/daemon/gdm-session-direct.c.system-keyboard 2008-08-26 15:04:00.000000000 -0400
2009-02-25 03:56:44 +00:00
+++ gdm-2.25.2/daemon/gdm-session-direct.c 2009-02-24 22:55:02.656566009 -0500
@@ -45,6 +45,8 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#include <libhal.h>
+
#include "gdm-session-direct.h"
#include "gdm-session.h"
#include "gdm-session-private.h"
2009-02-25 03:56:44 +00:00
@@ -595,14 +597,66 @@ get_default_language_name (GdmSessionDir
2008-10-20 16:16:24 +00:00
return setlocale (LC_MESSAGES, NULL);
}
+static char *
+get_system_default_layout (GdmSessionDirect *session)
2008-10-20 16:16:24 +00:00
+{
+ DBusConnection *connection;
+ LibHalContext *ctx;
+ char **devices;
+ int n_devices;
+ char *layout;
2008-10-20 16:16:24 +00:00
+ char *result;
+
+ result = NULL;
+
+ connection = dbus_g_connection_get_connection (session->priv->connection);
+ ctx = libhal_ctx_new ();
+ libhal_ctx_set_dbus_connection (ctx, connection);
+
+ if (!libhal_ctx_init (ctx, NULL)) {
+ goto out;
2008-10-20 16:16:24 +00:00
+ }
+
+ devices = libhal_find_device_by_capability (ctx,
+ "input.keyboard",
+ &n_devices,
+ NULL);
+ if (n_devices > 0) {
+ layout = libhal_device_get_property_string (ctx,
+ devices[0],
2009-02-25 03:56:44 +00:00
+ "input.x11_options.XkbLayout",
+ NULL);
2009-02-25 03:56:44 +00:00
+ if (!layout) {
+ layout = libhal_device_get_property_string (ctx,
+ devices[0],
+ "input.xkb.layout",
+ NULL);
+ }
+ result = g_strdup (layout);
+ libhal_free_string (layout);
+ }
+
+ libhal_free_string_array (devices);
+
+ libhal_ctx_shutdown (ctx, NULL);
+ libhal_ctx_free (ctx);
+
+out:
2008-10-20 16:16:24 +00:00
+ if (!result) {
+ result = g_strdup ("us");
+ }
+
+ return result;
+}
+
static const char *
get_default_layout_name (GdmSessionDirect *session)
{
- if (session->priv->saved_layout != NULL) {
- return session->priv->saved_layout;
+ if (!session->priv->saved_layout) {
+ session->priv->saved_layout = get_system_default_layout (session);
2008-10-20 16:16:24 +00:00
}
- return "us";
+ return session->priv->saved_layout;
}
static char *
2009-02-25 03:56:44 +00:00
@@ -1971,9 +2025,10 @@ setup_session_environment (GdmSessionDir
2008-10-20 16:16:24 +00:00
"GDM_LANG",
get_language_name (session));
- gdm_session_direct_set_environment_variable (session,
- "GDM_KEYBOARD_LAYOUT",
- get_layout_name (session));
+ if (g_strcmp0 (get_layout_name (session), get_system_default_layout (session)) != 0)
2008-10-20 16:16:24 +00:00
+ gdm_session_direct_set_environment_variable (session,
+ "GDM_KEYBOARD_LAYOUT",
+ get_layout_name (session));
gdm_session_direct_set_environment_variable (session,
"DISPLAY",
diff -up gdm-2.25.2/daemon/gdm-session-settings.c.system-keyboard gdm-2.25.2/daemon/gdm-session-settings.c
--- gdm-2.25.2/daemon/gdm-session-settings.c.system-keyboard 2008-08-26 15:04:00.000000000 -0400
2009-02-25 03:56:44 +00:00
+++ gdm-2.25.2/daemon/gdm-session-settings.c 2009-02-24 22:51:00.158815919 -0500
@@ -149,8 +149,7 @@ gdm_session_settings_set_layout_name (Gd
2008-10-20 16:16:24 +00:00
{
g_return_if_fail (GDM_IS_SESSION_SETTINGS (settings));
- if (settings->priv->layout_name == NULL ||
- strcmp (settings->priv->layout_name, layout_name) != 0) {
+ if (g_strcmp0 (settings->priv->layout_name, layout_name) != 0) {
settings->priv->layout_name = g_strdup (layout_name);
g_object_notify (G_OBJECT (settings), "layout-name");
}