[maemo-commits] [maemo-commits] r14814 - in projects/haf/trunk/hildon-desktop: . libhildonwm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Nov 22 14:31:40 EET 2007
Author: jobi
Date: 2007-11-22 14:31:37 +0200 (Thu, 22 Nov 2007)
New Revision: 14814

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c
Log:

2007-11-22  Johan Bilien  <johan.bilien at nokia.com>

	* libhildonwm/hd-keys.c: check if a fn + keycode gives keysym,
	but also if keycode only does not give keysym.
	Fixes: NB#74429



Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-11-22 09:20:46 UTC (rev 14813)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-11-22 12:31:37 UTC (rev 14814)
@@ -1,7 +1,13 @@
 2007-11-22  Johan Bilien  <johan.bilien at nokia.com>
 
+	* libhildonwm/hd-keys.c: check if a fn + keycode gives keysym,
+	but also if keycode only does not give keysym.
+	Fixes: NB#74429
+
+2007-11-22  Johan Bilien  <johan.bilien at nokia.com>
+
 	* libhildondesktop/hildon-home-titlebar.c: use button1 in
-	gtk_menu_popup.
+	gtk_menu_popup. Fixes: NB#76713
 
 2007-11-21  Johan Bilien  <johan.bilien at nokia.com>
 

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c	2007-11-22 09:20:46 UTC (rev 14813)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c	2007-11-22 12:31:37 UTC (rev 14814)
@@ -564,41 +564,72 @@
 }
 
 /* Check whether Fn is required on the built-in keyboard to obtain
- * this keysym with this keycode */
+ * this keysym with this keycode. We need to check that Fn + keycode
+ * gives keysym, but also that keycode alone does not give keysym. Also
+ * we need to perform the same check with Shift */
 static gboolean
 hd_key_shortcut_needs_fn (GdkKeymapKey *key, gint keysym)
 {
-  gint level;
+  gint level, group;
   guint keyval;
   GdkModifierType consumed_modifiers;
+  gboolean with_fn = FALSE, without_fn = FALSE;
+  gboolean with_shift_fn = FALSE, without_shift_fn = FALSE;
 
   if (gdk_keymap_translate_keyboard_state (NULL,
                                            key->keycode,
                                            GDK_MOD5_MASK,
                                            key->group,
                                            &keyval,
-                                           NULL,
+                                           &group,
                                            &level,
                                            &consumed_modifiers))
   {
-    if ((level == key->level) && (keyval == keysym))
-      return TRUE;
+    if ((level == key->level) && (keyval == keysym) && (group == key->group))
+      with_fn = TRUE;
   }
 
   if (gdk_keymap_translate_keyboard_state (NULL,
                                            key->keycode,
-                                           GDK_SHIFT_MASK | GDK_MOD5_MASK,
+                                           0,
                                            key->group,
                                            &keyval,
-                                           NULL,
+                                           &group,
                                            &level,
                                            &consumed_modifiers))
   {
-    if ((level == key->level) && (keyval == keysym))
-      return TRUE;
+    if ((level == key->level) && (keyval == keysym) && (group == key->group))
+      without_fn = TRUE;
   }
 
-  return FALSE;
+  if (gdk_keymap_translate_keyboard_state (NULL,
+                                           key->keycode,
+                                           GDK_MOD5_MASK | GDK_SHIFT_MASK,
+                                           key->group,
+                                           &keyval,
+                                           &group,
+                                           &level,
+                                           &consumed_modifiers))
+  {
+    if ((level == key->level) && (keyval == keysym) && (group == key->group))
+      with_shift_fn = TRUE;
+  }
+
+  if (gdk_keymap_translate_keyboard_state (NULL,
+                                           key->keycode,
+                                           GDK_SHIFT_MASK,
+                                           key->group,
+                                           &keyval,
+                                           &group,
+                                           &level,
+                                           &consumed_modifiers))
+  {
+    if ((level == key->level) && (keyval == keysym) && (group == key->group))
+      without_shift_fn = TRUE;
+  }
+
+  return (with_fn && !without_fn) || (with_shift_fn && !without_shift_fn);
+
 }
 
 static gboolean
@@ -626,11 +657,22 @@
         continue;
       }
 
+      /* ignore shortcuts from a group different than the default one,
+       * as AFAIK there is no way to translate the group information
+       * into a keycode + modifier required by XGrabKey */
+      if (shortcut->keycodes[i_keycode].group != 0)
+      {
+        ignored_mask ++;
+        continue;
+      }
+
       mask = shortcut->mod_mask | ignored_mask;
 
-      needs_fn = hd_key_shortcut_needs_fn (&shortcut->keycodes[i_keycode],
-                                           shortcut->keysym);
 
+      needs_fn = (shortcut->keycodes[i_keycode].level != 0 &&
+                  hd_key_shortcut_needs_fn (&shortcut->keycodes[i_keycode],
+                                            shortcut->keysym));
+
       if (needs_fn)
         mask |= Mod5Mask;
 


More information about the maemo-commits mailing list