[maemo-commits] [maemo-commits] r8304 - in projects/haf/trunk/maemo-af-desktop: . hildon-navigator

From: www-data at stage.maemo.org www-data at stage.maemo.org
Date: Fri Nov 24 11:05:27 EET 2006
Author: jobi
Date: 2006-11-24 11:05:25 +0200 (Fri, 24 Nov 2006)
New Revision: 8304

Modified:
   projects/haf/trunk/maemo-af-desktop/ChangeLog
   projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.c
   projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.h
Log:

2006-11-24  Johan Bilien <johan.bilien at nokia.com>

	* hildon-navigator/hn-keys.[ch]: Replaced XKeysymToKeycode with
	gdk_keymap_get_entries_for_keyval, to get all the possible
	keycodes. Fixes: NB#43855, Fixes: NB#38950



Modified: projects/haf/trunk/maemo-af-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/maemo-af-desktop/ChangeLog	2006-11-24 08:54:16 UTC (rev 8303)
+++ projects/haf/trunk/maemo-af-desktop/ChangeLog	2006-11-24 09:05:25 UTC (rev 8304)
@@ -1,5 +1,11 @@
 2006-11-24  Johan Bilien <johan.bilien at nokia.com>
 
+	* hildon-navigator/hn-keys.[ch]: Replaced XKeysymToKeycode with
+	gdk_keymap_get_entries_for_keyval, to get all the possible
+	keycodes. Fixes: NB#43855, Fixes: NB#38950
+
+2006-11-24  Johan Bilien <johan.bilien at nokia.com>
+
 	* hildon-navigator/hn-app-button.[ch]: Cache the button emblems
 	as class variable. Fixes: NB#42971
 

Modified: projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.c
===================================================================
--- projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.c	2006-11-24 08:54:16 UTC (rev 8303)
+++ projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.c	2006-11-24 09:05:25 UTC (rev 8304)
@@ -436,7 +436,10 @@
     = HNKeysActionConfLookup[conf_index].action_func_data;
   shortcut->mod_mask = mask;
   shortcut->keysym   = ks;
-  shortcut->keycode  = XKeysymToKeycode(GDK_DISPLAY(), ks);
+  gdk_keymap_get_entries_for_keyval (NULL /* default keymap */,
+                                     ks,
+                                     &shortcut->keycodes,
+                                     &shortcut->n_keycodes);
   shortcut->index    = index;
 
   HN_DBG("'%s' to new shortcut with ks:%li, mask:%i",
@@ -445,71 +448,86 @@
   return shortcut;
 }
 
+static void
+hn_keys_shortcut_free (HNKeyShortcut *shortcut)
+{
+  g_free (shortcut->keycodes);
+  g_free (shortcut);
+}
 
+
 static gboolean
 hn_key_shortcut_grab (HNKeysConfig  *keys, 
 		      HNKeyShortcut *shortcut,
 		      gboolean       ungrab)
 {
   int ignored_mask = 0;
+  gint i_keycode;
 
+  if (!shortcut->keycodes)
+    return FALSE;
+
   /* Needed to grab all ignored combo's too if num of scroll lock are on */
-  while (ignored_mask < (int) keys->lock_mask)
-    {                                       
-      if (ignored_mask & ~(keys->lock_mask))
-	{
-	  ++ignored_mask;
-	  continue;
-	}
+  for (i_keycode = 0; i_keycode < shortcut->n_keycodes; i_keycode++)
+    {
+      while (ignored_mask < (int) keys->lock_mask)
+        {                                       
+          if (ignored_mask & ~(keys->lock_mask))
+            {
+              ++ignored_mask;
+              continue;
+            }
 
-      if (ungrab)
-	{
-	  XUngrabKey(GDK_DISPLAY(),
-		     shortcut->keycode, 
-		     shortcut->mod_mask | ignored_mask,
-		     GDK_ROOT_WINDOW());
-	} 
-      else 
-	{
-	  int result; 
+          if (ungrab)
+            {
+              XUngrabKey(GDK_DISPLAY(),
+                         shortcut->keycodes[i_keycode].keycode, 
+                         shortcut->mod_mask | ignored_mask,
+                         GDK_ROOT_WINDOW());
+            } 
+          else 
+            {
+              int result; 
 
-	  gdk_error_trap_push();	  
-	  
-	  XGrabKey (GDK_DISPLAY(), 
-                    shortcut->keycode, 
-		    shortcut->mod_mask | ignored_mask,
-		    GDK_ROOT_WINDOW(), 
-		    False, 
-		    GrabModeAsync, 
-		    GrabModeAsync);
-	  
-	  XSync(GDK_DISPLAY(), False);
-	  result = gdk_error_trap_pop();
+              gdk_error_trap_push();	  
 
-	  if (result)
-	    {
-	      /* FIXME: Log below somewhere */
-	      if (result == BadAccess)
-		{
-		  fprintf(stderr, 
-			  "Some other program is already using the key %s "
-			  "with modifiers %x as a binding\n",  
-			  (XKeysymToString (shortcut->keysym)) ? 
-			    XKeysymToString (shortcut->keysym) : "unknown", 
-			    shortcut->mod_mask | ignored_mask );
-		}
-	      else
-		{
-		  fprintf(stderr, 
-			  "Unable to grab the key %s with modifiers %x"
-			  "as a binding\n",  
-			  (XKeysymToString (shortcut->keysym)) ? 
-			    XKeysymToString (shortcut->keysym) : "unknown", 
-			    shortcut->mod_mask | ignored_mask );
-		}
-	    }
-	}
-      ++ignored_mask;
+              XGrabKey (GDK_DISPLAY(), 
+                        shortcut->keycodes[i_keycode].keycode, 
+                        shortcut->mod_mask | ignored_mask,
+                        GDK_ROOT_WINDOW(), 
+                        False, 
+                        GrabModeAsync, 
+                        GrabModeAsync);
+
+              XSync(GDK_DISPLAY(), False);
+              result = gdk_error_trap_pop();
+
+              if (result)
+                {
+                  /* FIXME: Log below somewhere */
+                  if (result == BadAccess)
+                    {
+                      fprintf(stderr, 
+                              "Some other program is already using the key %s "
+                              "with modifiers %x as a binding\n",  
+                              (XKeysymToString (shortcut->keysym)) ? 
+                              XKeysymToString (shortcut->keysym) : "unknown", 
+                              shortcut->mod_mask | ignored_mask );
+                    }
+                  else
+                    {
+                      fprintf(stderr, 
+                              "Unable to grab the key %s with modifiers %x"
+                              "as a binding\n",  
+                              (XKeysymToString (shortcut->keysym)) ? 
+                              XKeysymToString (shortcut->keysym) : "unknown", 
+                              shortcut->mod_mask | ignored_mask );
+                    }
+                }
+            }
+          ++ignored_mask;
+        }
+      ignored_mask = 0;
     }
   
   return TRUE;
@@ -593,7 +611,7 @@
 	      HN_DBG("removing exisiting action %i", sc->action);
 	      hn_key_shortcut_grab (keys, sc, TRUE); 
 	      keys->shortcuts = g_slist_remove (keys->shortcuts, item->data);
-	      g_free (sc);
+	      hn_keys_shortcut_free (sc);
 	      break;
 	    }
 	  item = g_slist_next(item);
@@ -660,7 +678,7 @@
       gpointer data = shortcut->data;
       hn_key_shortcut_grab (keys, shortcut->data, TRUE);
       shortcut = g_slist_remove (shortcut, shortcut->data);
-      g_free (data);
+      hn_keys_shortcut_free (data);
     }
 
   keys->shortcuts = NULL;

Modified: projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.h
===================================================================
--- projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.h	2006-11-24 08:54:16 UTC (rev 8303)
+++ projects/haf/trunk/maemo-af-desktop/hildon-navigator/hn-keys.h	2006-11-24 09:05:25 UTC (rev 8304)
@@ -62,7 +62,8 @@
 {
   HNKeyAction       action;
   KeySym            keysym;
-  KeyCode           keycode;
+  GdkKeymapKey     *keycodes;
+  gint              n_keycodes;
   gint              mod_mask;
   gint              index;
   HNKeysActionFunc  action_func;


More information about the maemo-commits mailing list