Author: jannis
Date: 2008-08-31 13:38:18 +0000 (Sun, 31 Aug 2008)
New Revision: 27628

Modified:
   xfce4-settings/trunk/ChangeLog
   xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c
Log:
        * dialogs/keyboard-settings/shortcut-dialog.c: Ignore
          GDK_SUPER_MASK, GDK_HYPER_MASK and GDK_META_MASK when parsing
          key release events. xfce4-settings-helper handles X events
          instead of Gdk events and unlike Gdk X doesn't know which
          of the Super, Meta and Hyper keys are mapped to Mod2-Mod5.
          Having <Super>, <Meta>, <Hyper> or even <Super>Super_L in the
          accelerator name will cause the saved shortcut names to be
          different than the ones generated by parsing X key events.
          This should fix bug #4304 although I suppose it would be
          nicer to determine which keys are mapped to Mod2-Mod5 when
          parsing X key events from the semantic point of view.


Modified: xfce4-settings/trunk/ChangeLog
===================================================================
--- xfce4-settings/trunk/ChangeLog      2008-08-31 07:41:38 UTC (rev 27627)
+++ xfce4-settings/trunk/ChangeLog      2008-08-31 13:38:18 UTC (rev 27628)
@@ -1,3 +1,17 @@
+2008-08-31     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * dialogs/keyboard-settings/shortcut-dialog.c: Ignore
+         GDK_SUPER_MASK, GDK_HYPER_MASK and GDK_META_MASK when parsing
+         key release events. xfce4-settings-helper handles X events
+         instead of Gdk events and unlike Gdk X doesn't know which 
+         of the Super, Meta and Hyper keys are mapped to Mod2-Mod5. 
+         Having <Super>, <Meta>, <Hyper> or even <Super>Super_L in the
+         accelerator name will cause the saved shortcut names to be
+         different than the ones generated by parsing X key events.
+         This should fix bug #4304 although I suppose it would be 
+         nicer to determine which keys are mapped to Mod2-Mod5 when
+         parsing X key events from the semantic point of view.
+
 2008-08-30     Jannis Pohlmann <[EMAIL PROTECTED]>
 
        * dialogs/keyboard-settings/main.c: Don't call gtk_widget_hide()

Modified: xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c
===================================================================
--- xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c    
2008-08-31 07:41:38 UTC (rev 27627)
+++ xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c    
2008-08-31 13:38:18 UTC (rev 27628)
@@ -32,6 +32,15 @@
 
 
 
+/* Modifiers to be ignored (0x2000 is an Xkb modifier) */
+#define IGNORED_MODIFIERS (0x2000 | GDK_LOCK_MASK | GDK_HYPER_MASK | 
GDK_SUPER_MASK | GDK_META_MASK)
+
+/* Modifiers to be used */
+#define USED_MODIFIERS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | 
GDK_MOD2_MASK | \
+                        GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK)
+
+
+
 static void     shortcut_dialog_class_init       (ShortcutDialogClass *klass);
 static void     shortcut_dialog_init             (ShortcutDialog      *dialog);
 static void     shortcut_dialog_dispose          (GObject             *object);
@@ -302,9 +311,13 @@
   gboolean event_handled = FALSE;
   gboolean shortcut_accepted = FALSE;
   gchar   *shortcut;
+  gint     modifiers;
 
+  /* Strip ignored modifiers from the event mask */
+  modifiers = event->state & ~IGNORED_MODIFIERS & GDK_MODIFIER_MASK;
+
   /* Get GTK+ accelerator string */
-  shortcut = gtk_accelerator_name (event->keyval, event->state);
+  shortcut = gtk_accelerator_name (event->keyval, modifiers);
 
   /* Let 'validate-shortcut' listeners decide whether this shortcut is ok or 
not */
   g_signal_emit_by_name (dialog, "validate-shortcut", shortcut, 
&shortcut_accepted);

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to