walters / rpms / gdm

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