[gdm] daemon: set initial keyboard layout before starting server
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] daemon: set initial keyboard layout before starting server
- Date: Sat, 17 Sep 2011 18:56:00 +0000 (UTC)
commit 7c210e29cc4fd2f2a63900d825e451f63a0d9d0d
Author: Ray Strode <rstrode redhat com>
Date: Sat Sep 17 14:49:21 2011 -0400
daemon: set initial keyboard layout before starting server
If we don't do this magic incantation then the keyboard
layout selector won't work until the user hits some key on their
keyboard.
Since we have to do this incantation anyway, this commit also gives
preferential treatment to the "us" keyboard layout. This makes sense
to do because most usernames and passwords are ascii.
daemon/Makefile.am | 3 ++
daemon/gdm-simple-slave.c | 3 ++
daemon/gdm-slave.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
daemon/gdm-slave.h | 1 +
4 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 98b95ce..65e82b8 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -185,6 +185,7 @@ gdm_factory_slave_SOURCES = \
gdm_factory_slave_LDFLAGS = \
$(PAM_LIBS) \
+ $(LIBXKLAVIER_LIBS) \
$(NULL)
gdm_factory_slave_LDADD = \
@@ -216,6 +217,7 @@ gdm_product_slave_SOURCES = \
gdm_product_slave_LDFLAGS = \
$(PAM_LIBS) \
+ $(LIBXKLAVIER_LIBS) \
$(NULL)
gdm_product_slave_LDADD = \
@@ -257,6 +259,7 @@ gdm_xdmcp_chooser_slave_LDADD = \
$(XLIB_LIBS) \
$(DAEMON_LIBS) \
$(EXTRA_DAEMON_LIBS) \
+ $(LIBXKLAVIER_LIBS) \
$(top_builddir)/common/libgdmcommon.la \
$(NULL)
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index ab69194..38e7a84 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -1208,6 +1208,9 @@ setup_server (GdmSimpleSlave *slave)
/* Set the busy cursor */
gdm_slave_set_busy_cursor (GDM_SLAVE (slave));
+
+ /* Set the initial keyboard layout to something reasonable */
+ gdm_slave_set_initial_keyboard_layout (GDM_SLAVE (slave));
}
static void
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index e7553ad..787ef89 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -47,6 +47,10 @@
#include <X11/extensions/Xrandr.h>
#include <X11/Xatom.h>
+#ifdef HAVE_LIBXKLAVIER
+#include <libxklavier/xklavier.h>
+#endif
+
#include "gdm-common.h"
#include "gdm-xerrors.h"
@@ -355,6 +359,51 @@ gdm_slave_run_script (GdmSlave *slave,
return ret;
}
+void
+gdm_slave_set_initial_keyboard_layout (GdmSlave *slave)
+{
+#ifdef HAVE_LIBXKLAVIER
+ XklEngine *engine;
+ XklConfigRec *config;
+
+ engine = xkl_engine_get_instance (slave->priv->server_display);
+ config = xkl_config_rec_new ();
+
+ if (xkl_config_rec_get_from_server (config, engine)) {
+ int i;
+
+ for (i = 1; config->layouts[i] != NULL; i++) {
+ /* put us at the front of the list, since usernames and
+ * passwords are usually ascii
+ */
+ if (strcmp (config->layouts[i], "us") == 0) {
+ char *temp_layout;
+ char *temp_variant = NULL;
+ char *temp_options = NULL;
+
+ temp_layout = config->layouts[0];
+ config->layouts[0] = config->layouts[i];
+ config->layouts[i] = temp_layout;
+
+ if (config->variants != NULL) {
+ temp_variant = config->variants[0];
+ config->variants[0] = config->variants[i];
+ config->variants[i] = temp_variant;
+ }
+
+ if (config->options != NULL) {
+ temp_options = config->options[0];
+ config->options[0] = config->options[i];
+ config->options[i] = temp_options;
+ }
+ break;
+ }
+ }
+ xkl_config_rec_activate (config, engine);
+ }
+#endif
+}
+
static void
determine_initial_cursor_position (GdmSlave *slave,
int *x,
diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h
index eda2e19..7af20ed 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -74,6 +74,7 @@ gboolean gdm_slave_switch_to_user_session (GdmSlave *slave,
gboolean gdm_slave_connect_to_x11_display (GdmSlave *slave);
+void gdm_slave_set_initial_keyboard_layout (GdmSlave *slave);
void gdm_slave_set_initial_cursor_position (GdmSlave *slave);
void gdm_slave_set_busy_cursor (GdmSlave *slave);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]