ports/131533: x11/gdm: gdm-2.24.1_6: wrong keyboard layout selected by default

Andreas Wetzel mickey242 at gmx.net
Thu Apr 16 21:00:09 UTC 2009


The following reply was made to PR ports/131533; it has been noted by GNATS.

From: Andreas Wetzel <mickey242 at gmx.net>
To: bug-followup at FreeBSD.org, mickey242 at gmx.net
Cc:  
Subject: Re: ports/131533: x11/gdm: gdm-2.24.1_6: wrong keyboard layout selected
 by default
Date: Thu, 16 Apr 2009 22:30:40 +0200

 This is a multi-part message in MIME format.
 --------------020709070508000500070809
 Content-Type: text/plain; charset=ISO-8859-15; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Same behaviour with most recent gnome-2.26.0_1
 
 I have found a patch that reads the keyboard layout from HAL on the gnome 
 distributor mailing list. It originally comes from the fedora people.
 
 I supplemented the patch, so that it also reads the keyboard variant from HAL.
 Find the patch attached.
 
 
 --------------020709070508000500070809
 Content-Type: text/plain;
  name="patch-gdm-hal-kbdlayout"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="patch-gdm-hal-kbdlayout"
 
 --- configure.ac.orig	2009-03-13 05:00:28.000000000 +0100
 +++ configure.ac	2009-04-16 20:50:28.000000000 +0200
 @@ -69,6 +69,7 @@
  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)
 --- daemon/gdm-session-direct.c.orig	2009-02-20 03:45:13.000000000 +0100
 +++ daemon/gdm-session-direct.c	2009-04-16 21:56:08.000000000 +0200
 @@ -45,6 +45,8 @@
  #include <dbus/dbus-glib.h>
  #include <dbus/dbus-glib-lowlevel.h>
  
 +#include <hal/libhal.h>
 +
  #include "gdm-session-direct.h"
  #include "gdm-session.h"
  #include "gdm-session-private.h"
 @@ -595,14 +597,78 @@
      return setlocale (LC_MESSAGES, NULL);
  }
  
 +static char *
 +get_system_default_layout(GdmSessionDirect *session)
 +{
 +	DBusConnection *connection;
 +	LibHalContext *ctx;
 +	char **devices;
 +	int n_devices;
 +	char *layout;
 +	char *variant;
 +	char *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;
 +
 +	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],
 +			"input.x11_options.XkbLayout", NULL);
 +
 +		if(!layout)
 +		{
 +			layout = libhal_device_get_property_string(ctx,
 +				devices[0], "input.xkb.layout", NULL);
 +		}
 +
 +		variant = libhal_device_get_property_string(ctx, devices[0],
 +			"input.x11_options.XkbVariant", NULL);
 +
 +		if(!variant)
 +		{
 +			variant = libhal_device_get_property_string(ctx,
 +				devices[0], "input.xkb.variant", NULL);
 +		}
 +
 +		if(layout && variant)
 +			result = g_strdup_printf("%s\t%s", layout, variant);
 +		else if(layout)
 +			result = g_strdup(layout);
 +
 +		if(layout)
 +			libhal_free_string (layout);
 +	
 +		if(variant)
 +			libhal_free_string (variant);
 +	}
 +
 +	libhal_free_string_array (devices);
 +
 +	libhal_ctx_shutdown (ctx, NULL);
 +	libhal_ctx_free (ctx);
 +
 +out:
 +	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);
  
 -    return "us";
 +	return session->priv->saved_layout;
  }
  
  static char *
 @@ -1971,9 +2037,10 @@
                                                       "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)
 +        	gdm_session_direct_set_environment_variable (session,
 +                                                     	     "GDM_KEYBOARD_LAYOUT",
 +                                                             get_layout_name (session));
  
          gdm_session_direct_set_environment_variable (session,
                                                       "DISPLAY",
 --- daemon/gdm-session-settings.c.orig	2009-02-20 03:45:13.000000000 +0100
 +++ daemon/gdm-session-settings.c	2009-04-16 20:50:29.000000000 +0200
 @@ -149,8 +149,7 @@
  {
          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");
          }
 
 --------------020709070508000500070809--


More information about the freebsd-gnome mailing list