source: proiecte/PPPP/gdm/debian/patches/01_default_keyboard_layout_hal.patch @ 134

Last change on this file since 134 was 134, checked in by (none), 14 years ago

gdm sources with the modifications for webcam

File size: 3.9 KB
  • configure.ac

    #
    # Description: Get default keyboard layout from hal
    # Ubuntu: https://bugs.launchpad.net/bugs/395103
    # Fedora: http://cvs.fedoraproject.org/viewvc//devel/gdm/gdm-system-keyboard.patch?view=markup
    #
    diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/configure.ac gdm-2.28.0.new/configure.ac
    old new  
    7070        dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
    7171        gobject-2.0 >= $GLIB_REQUIRED_VERSION
    7272        gio-2.0 >= $GLIB_REQUIRED_VERSION
     73        hal
    7374)
    7475AC_SUBST(DAEMON_CFLAGS)
    7576AC_SUBST(DAEMON_LIBS)
  • daemon/gdm-session-direct.c

    diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/daemon/gdm-session-direct.c gdm-2.28.0.new/daemon/gdm-session-direct.c
    old new  
    4545#include <dbus/dbus-glib.h>
    4646#include <dbus/dbus-glib-lowlevel.h>
    4747
     48#include <libhal.h>
     49
    4850#include "gdm-session-direct.h"
    4951#include "gdm-session.h"
    5052#include "gdm-session-private.h"
     
    598600    return setlocale (LC_MESSAGES, NULL);
    599601}
    600602
     603static char *
     604get_system_default_layout (GdmSessionDirect *session)
     605{
     606    DBusConnection *connection;
     607    LibHalContext *ctx;
     608    char **devices;
     609    int n_devices;
     610    char *layout;
     611    char *variant;
     612    char *result;
     613
     614    result = NULL;
     615
     616    connection = dbus_g_connection_get_connection (session->priv->connection);
     617    ctx = libhal_ctx_new ();
     618    libhal_ctx_set_dbus_connection (ctx, connection);
     619
     620    if (!libhal_ctx_init (ctx, NULL)) {
     621        goto out;
     622    }
     623
     624    devices = libhal_find_device_by_capability (ctx,
     625                                                "input.keyboard",
     626                                                &n_devices,
     627                                                NULL);
     628    if (n_devices > 0) {
     629        layout = libhal_device_get_property_string (ctx,
     630                                                    devices[0],
     631                                                    "input.x11_options.XkbLayout",
     632                                                    NULL);
     633        if (!layout) {
     634            layout = libhal_device_get_property_string (ctx,
     635                                                        devices[0],
     636                                                        "input.xkb.layout",
     637                                                        NULL);
     638        }
     639        if (!layout)
     640            goto out;
     641
     642        variant = libhal_device_get_property_string (ctx,
     643                                                    devices[0],
     644                                                    "input.x11_options.XkbVariant",
     645                                                    NULL);
     646        if (!variant) {
     647            variant = libhal_device_get_property_string (ctx,
     648                                                        devices[0],
     649                                                        "input.xkb.variant",
     650                                                        NULL);
     651        }
     652
     653        if (variant) {
     654            result = g_strdup_printf("%s\t%s", layout, variant);
     655            libhal_free_string (variant);
     656        } else {
     657            result = g_strdup (layout);
     658        }
     659        libhal_free_string (layout);
     660    }
     661
     662    libhal_free_string_array (devices);
     663
     664    libhal_ctx_shutdown (ctx, NULL);
     665    libhal_ctx_free (ctx);
     666
     667out:
     668    if (!result) {
     669        result = g_strdup ("us");
     670    }
     671
     672    g_debug ("GdmSessionDirect: System default keyboard layout: '%s'", result);
     673    return result;
     674}
     675
    601676static const char *
    602677get_default_layout_name (GdmSessionDirect *session)
    603678{
    604     if (session->priv->saved_layout != NULL) {
    605                 return session->priv->saved_layout;
     679    if (!session->priv->saved_layout) {
     680        session->priv->saved_layout = get_system_default_layout (session);
    606681    }
    607682
    608     return "us";
     683    return session->priv->saved_layout;
    609684}
    610685
    611686static char *
Note: See TracBrowser for help on using the repository browser.