From 53cbbc00df3884bc3ca87e2818a08ba3ba2fabac Mon Sep 17 00:00:00 2001
From: Keng-Yu Lin <kengyu@ubuntu.com>
Date: Tue, 22 May 2012 15:11:26 +0800
Subject: [PATCH] common: mask out virtual modifiers in key grabbing code

gdk_keymap_map_virtual_modifiers converts all the virtual
modifiers in the state mask (Super, Hyper, Meta, etc) of a
key event to the real modifiers they're mapped to. This
call is needed, because XGrabKey and friends only work
with real modifiers (Mod1, Mod2, ...).

Unforunately, gdk_keymap_map_virtual_modifiers doesn't mask
out the virtual modifers, it merely adds in the associated
real ones.

This commit does the masking immediately following the call,
so that virtual modifier don't ultimately get passed to X
when setting up the key grabs.

https://bugzilla.gnome.org/show_bug.cgi?id=676300
---
 plugins/common/gsd-keygrab.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/plugins/common/gsd-keygrab.c b/plugins/common/gsd-keygrab.c
index f8432cd..bb85b87 100644
--- a/plugins/common/gsd-keygrab.c
+++ b/plugins/common/gsd-keygrab.c
@@ -153,6 +153,7 @@ grab_key_unsafe (Key                 *key,
         /* XGrabKey requires real modifiers, not virtual ones */
         modifiers = key->state;
         gdk_keymap_map_virtual_modifiers (gdk_keymap_get_default (), &modifiers);
+        modifiers &= ~(GDK_META_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK);
 
         /* If key doesn't have a usable modifier, we don't want
          * to grab it, since the user might lose a useful key.
@@ -324,6 +325,7 @@ match_xi2_key (Key *key, XIDeviceEvent *event)
 		 * the XEvent will be using the real modifier, so translate those */
 		mask = key->state;
 		gdk_keymap_map_virtual_modifiers (gdk_keymap_get_default (), &mask);
+                mask &= ~(GDK_META_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK);
 
 		gdk_keyval_convert_case (keyval, &lower, &upper);
 
-- 
1.7.9.5

