Keyboard application shortcut fixes

Warren Block wblock at wonkity.com
Sat Jun 9 15:11:23 UTC 2012


https://bugzilla.xfce.org/show_bug.cgi?id=8744 has a couple of patches 
to allow certain modifiers like shift to work again in the 
Settings/Keyboard/Application Shortcuts dialog.  These should be 
considered experimental, but are working here.

These two patches go in x11/libxfce4menu/files.  The diff paths have 
been changed from the originals so they would apply in the port.
-------------- next part --------------
commit 7324dea66d754ff863fea3362c90acc9689670c6
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri May 4 22:15:16 2012 +0200

    Enable <Shift> as modifier key in shortcut dialog.
    
    This restores the functionality of <Shift> as a modifier key.
    Using <Shift_L> and <Shift_R> as a single key is still possible.
    
    It seems gtk_accelerator_name is not designed to distinguish between
    upper-/lowercase, so we just store the <Shift> key in the accelerator
    name. This might not be the recommended way to store accelerators
    as specified by the GTK docs, but at least it fixes the regression
    and seems to not cause any troubles.

diff --git a/libxfce4kbd-private/xfce-shortcut-dialog.c b/libxfce4kbd-private/xfce-shortcut-dialog.c
index 5f1b058..b1ce159 100644
--- libxfce4kbd-private/xfce-shortcut-dialog.c
+++ libxfce4kbd-private/xfce-shortcut-dialog.c
@@ -327,6 +327,8 @@ xfce_shortcut_dialog_key_pressed (XfceShortcutDialog *dialog,
                                        &keyval, NULL, NULL, &consumed);
 
   /* Get the modifiers */
+  if ((modifiers & GDK_SHIFT_MASK) && (consumed & GDK_SHIFT_MASK))
+    consumed &= ~GDK_SHIFT_MASK;
   modifiers &= ~consumed;
   modifiers &= mod_mask;
 
-------------- next part --------------
commit fe4aff6a20024d9480199e19c13614dd118be725
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri May 4 22:24:12 2012 +0200

    Enable <Shift> as modifier key in shortcuts grabber.
    
    This restores the functionality of <Shift> as a modifier key.
    Using <Shift_L> and <Shift_R> as a single key is still possible.
    
    It seems gtk_accelerator_name is not designed to distinguish between
    upper-/lowercase, so we just store the <Shift> key in the accelerator
    name. This might not be the recommended way to store accelerators
    as specified by the GTK docs, but at least it fixes the regression
    and seems to not cause any troubles.
    
    Additionally, we need to gtk_accelerator_parse the value returned by
    gtk_accelerator_name, because the key values of both functions are
    not consistent.

diff --git a/libxfce4kbd-private/xfce-shortcuts-grabber.c b/libxfce4kbd-private/xfce-shortcuts-grabber.c
index 9faec07..01b85c3 100644
--- libxfce4kbd-private/xfce-shortcuts-grabber.c
+++ libxfce4kbd-private/xfce-shortcuts-grabber.c
@@ -512,8 +512,10 @@ xfce_shortcuts_grabber_event_filter (GdkXEvent            *gdk_xevent,
                                        &keyval, NULL, NULL, &consumed);
 
   /* Get the modifiers */
-  modifiers &= ~consumed;
+  if ((modifiers & GDK_SHIFT_MASK) && (consumed & GDK_SHIFT_MASK))
+    consumed &= ~GDK_SHIFT_MASK;
   gdk_keymap_add_virtual_modifiers (keymap, &modifiers);
+  modifiers &= ~consumed;
   modifiers &= mod_mask;
 
   context.keyval = keyval;
@@ -521,6 +523,7 @@ xfce_shortcuts_grabber_event_filter (GdkXEvent            *gdk_xevent,
 
   raw_shortcut_name = gtk_accelerator_name (keyval, modifiers);
   TRACE ("Looking for %s", raw_shortcut_name);
+  gtk_accelerator_parse (raw_shortcut_name, &context.keyval, &context.modifiers);
   g_free (raw_shortcut_name);
 
   g_hash_table_foreach (grabber->priv->keys, (GHFunc) find_event_key, &context);


More information about the freebsd-xfce mailing list