[gnome-settings-daemon/shell-keygrab: 2/5] keygrab: Adjust match_key() to match the Shell's DBus API
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/shell-keygrab: 2/5] keygrab: Adjust match_key() to match the Shell's DBus API
- Date: Wed, 5 Dec 2012 08:43:21 +0000 (UTC)
commit dd196a71791d760f60f16d3d1c397c562555c1bb
Author: Florian MÃllner <fmuellner gnome org>
Date: Thu Nov 15 17:17:44 2012 +0100
keygrab: Adjust match_key() to match the Shell's DBus API
plugins/common/gsd-keygrab.c | 45 +++++++++--------------------------------
plugins/common/gsd-keygrab.h | 3 +-
2 files changed, 12 insertions(+), 36 deletions(-)
---
diff --git a/plugins/common/gsd-keygrab.c b/plugins/common/gsd-keygrab.c
index d2f2575..6ab3afa 100644
--- a/plugins/common/gsd-keygrab.c
+++ b/plugins/common/gsd-keygrab.c
@@ -366,50 +366,25 @@ match_xi2_key (Key *key, XIDeviceEvent *event)
}
gboolean
-match_key (Key *key, XEvent *event)
+match_key (Key *key, guint keysym, guint modifiers)
{
- guint keyval;
- GdkModifierType consumed;
- gint group;
+ guint lower, upper;
+ guint mask;
if (key == NULL)
return FALSE;
setup_modifiers ();
- if (have_xkb (event->xkey.display))
- group = XkbGroupForCoreState (event->xkey.state);
- else
- group = (event->xkey.state & GDK_KEY_Mode_switch) ? 1 : 0;
+ /* The Key structure contains virtual modifiers, whereas
+ * the XEvent will be using the real modifier, so translate those */
+ mask = modifiers;
+ gdk_keymap_map_virtual_modifiers (gdk_keymap_get_default (), &mask);
- /* Check if we find a keysym that matches our current state */
- if (gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (), event->xkey.keycode,
- event->xkey.state, group,
- &keyval, NULL, NULL, &consumed)) {
- guint lower, upper;
- guint mask;
+ gdk_keyval_convert_case (keysym, &lower, &upper);
- /* The Key structure contains virtual modifiers, whereas
- * the XEvent will be using the real modifier, so translate those */
- mask = key->state;
- gdk_keymap_map_virtual_modifiers (gdk_keymap_get_default (), &mask);
-
- gdk_keyval_convert_case (keyval, &lower, &upper);
-
- /* If we are checking against the lower version of the
- * keysym, we might need the Shift state for matching,
- * so remove it from the consumed modifiers */
- if (lower == key->keysym)
- consumed &= ~GDK_SHIFT_MASK;
-
- return ((lower == key->keysym || upper == key->keysym)
- && (event->xkey.state & ~consumed & gsd_used_mods) == mask);
- }
-
- /* The key we passed doesn't have a keysym, so try with just the keycode */
- return (key != NULL
- && key->state == (event->xkey.state & gsd_used_mods)
- && key_uses_keycode (key, event->xkey.keycode));
+ return ((lower == key->keysym || upper == key->keysym)
+ && (modifiers & gsd_used_mods) == mask);
}
Key *
diff --git a/plugins/common/gsd-keygrab.h b/plugins/common/gsd-keygrab.h
index ee542ea..4c6d560 100644
--- a/plugins/common/gsd-keygrab.h
+++ b/plugins/common/gsd-keygrab.h
@@ -48,7 +48,8 @@ void ungrab_key_unsafe (Key *key,
gboolean match_xi2_key (Key *key,
XIDeviceEvent *event);
gboolean match_key (Key *key,
- XEvent *event);
+ guint keysym,
+ guint modifiers);
gboolean key_uses_keycode (const Key *key,
guint keycode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]