From 5f78b818ac2dfe11f97b14e3c4c9408a6815c2e9 Mon Sep 17 00:00:00 2001 From: liyuan Date: Mon, 25 Feb 2008 02:49:56 +0000 Subject: [PATCH] 2008-02-25 Li Yuan * registryd/deviceeventcontroller.c: (global_filter_fn), (dec_lock_modifiers), (dec_unlock_modifiers), (impl_generate_keyboard_event): patch from Franz.Netykafka@runbox.no. Bug #508147. Lock/Unlock modifier keys when xkb extension is missing. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@985 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 12 ++++++++++-- registryd/deviceeventcontroller.c | 41 +++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2058eb1..55c44f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,15 @@ +2008-02-25 Li Yuan + + * registryd/deviceeventcontroller.c: (global_filter_fn), + (dec_lock_modifiers), (dec_unlock_modifiers), + (impl_generate_keyboard_event): patch from Franz.Netykafka@runbox.no. + Bug #508147. Lock/Unlock modifier keys when xkb extension is + missing. + 2008-02-22 Scott Haeger - * libspi/collection.c: - Fixed bug #517761, Collection match rules not working for attributes. + * libspi/collection.c: + Fixed bug #517761, Collection match rules not working for attributes. 2008-02-19 Li Yuan diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index e9ee33a..b80184a 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -82,6 +82,7 @@ static unsigned int key_modifier_mask = static unsigned int _numlock_physical_mask = Mod2Mask; /* a guess, will be reset */ static GQuark spi_dec_private_quark = 0; +static XModifierKeymap* xmkeymap = NULL; static int (*x_default_error_handler) (Display *display, XErrorEvent *error_event); @@ -1119,6 +1120,9 @@ global_filter_fn (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) priv = (DEControllerPrivateData *) g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark); + if (xevent->type == MappingNotify) + xmkeymap = NULL; + if (xevent->type == KeyPress || xevent->type == KeyRelease) { if (controller->xevie_display == NULL) @@ -2130,15 +2134,37 @@ dec_get_modifier_state (SpiDEController *controller) static gboolean dec_lock_modifiers (SpiDEController *controller, unsigned modifiers) { - return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, - modifiers, modifiers); + DEControllerPrivateData *priv = (DEControllerPrivateData *) + g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark); + + if (priv->have_xkb) { + return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, + modifiers, modifiers); + } else { + int mod_index; + for (mod_index=0;mod_index<8;mod_index++) + if (modifiers & (1<modifiermap[mod_index]); + return TRUE; + } } static gboolean dec_unlock_modifiers (SpiDEController *controller, unsigned modifiers) { - return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, - modifiers, 0); + DEControllerPrivateData *priv = (DEControllerPrivateData *) + g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark); + + if (priv->have_xkb) { + return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, + modifiers, 0); + } else { + int mod_index; + for (mod_index=0;mod_index<8;mod_index++) + if (modifiers & (1<modifiermap[mod_index]); + return TRUE; + } } static KeySym @@ -2268,6 +2294,13 @@ impl_generate_keyboard_event (PortableServer_Servant servant, gdk_error_trap_push (); + DEControllerPrivateData *priv = (DEControllerPrivateData *) + g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark); + + if (!priv->have_xkb && xmkeymap==NULL) { + xmkeymap = XGetModifierMapping(spi_get_display ()); + } + switch (synth_type) { case Accessibility_KEY_PRESS: -- 2.7.4