[Xfce4-commits] <libxfce4ui:master> Fix keyboard shortcuts with Shift modifier (bug #8744).

Jérôme Guelfucci noreply at xfce.org
Sun Dec 30 15:42:04 CET 2012


Updating branch refs/heads/master
         to 0da716be5ecc87bcc74c5ea40b14b8f93c0d7d73 (commit)
       from 3bb8c7d4de8132741da54a26c98459167c51fd87 (commit)

commit 0da716be5ecc87bcc74c5ea40b14b8f93c0d7d73
Author: Harald Judt <h.judt at gmx.at>
Date:   Tue Dec 18 09:00:44 2012 +0100

    Fix keyboard shortcuts with Shift modifier (bug #8744).

 libxfce4kbd-private/xfce-shortcut-dialog.c   |    8 ++++++++
 libxfce4kbd-private/xfce-shortcuts-grabber.c |   12 +++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/libxfce4kbd-private/xfce-shortcut-dialog.c b/libxfce4kbd-private/xfce-shortcut-dialog.c
index 0519982..2ee1931 100644
--- a/libxfce4kbd-private/xfce-shortcut-dialog.c
+++ b/libxfce4kbd-private/xfce-shortcut-dialog.c
@@ -371,6 +371,14 @@ xfce_shortcut_dialog_key_pressed (XfceShortcutDialog *dialog,
                                        &keyval, NULL, NULL, &consumed);
 
   /* Get the modifiers */
+
+  /* If Shift was used when translating the keyboard state, we remove it
+   * from the consumed bit because gtk_accelerator_{name,parse} fail to
+   * handle this correctly. This allows us to have shortcuts with Shift
+   * as a modifier key (see bug #8744). */
+  if ((modifiers & GDK_SHIFT_MASK) && (consumed & GDK_SHIFT_MASK))
+    consumed &= ~GDK_SHIFT_MASK;
+
   modifiers &= ~consumed;
   modifiers &= mod_mask;
 
diff --git a/libxfce4kbd-private/xfce-shortcuts-grabber.c b/libxfce4kbd-private/xfce-shortcuts-grabber.c
index b8d2898..dd13f7e 100644
--- a/libxfce4kbd-private/xfce-shortcuts-grabber.c
+++ b/libxfce4kbd-private/xfce-shortcuts-grabber.c
@@ -313,7 +313,7 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber,
     TRACE ("Ungrabbing %s", shortcut_name);
 
   TRACE ("Keyval: %d", key->keyval);
-  TRACE ("Modifiers: 0x%x", key->modifiers);
+  TRACE ("Modifiers: 0x%x", modifiers);
 
   g_free (shortcut_name);
 
@@ -498,6 +498,15 @@ xfce_shortcuts_grabber_event_filter (GdkXEvent            *gdk_xevent,
                                        XkbGroupForCoreState (xevent->xkey.state),
                                        &keyval, NULL, NULL, &consumed);
 
+  /* Get the modifiers */
+
+  /* If Shift was used when translating the keyboard state, we remove it
+   * from the consumed bit because gtk_accelerator_{name,parse} fail to
+   * handle this correctly. This allows us to have shortcuts with Shift
+   * as a modifier key (see bug #8744). */
+  if ((modifiers & GDK_SHIFT_MASK) && (consumed & GDK_SHIFT_MASK))
+    consumed &= ~GDK_SHIFT_MASK;
+
   modifiers &= ~consumed;
   modifiers &= mod_mask;
 
@@ -506,6 +515,7 @@ xfce_shortcuts_grabber_event_filter (GdkXEvent            *gdk_xevent,
   context.consumed = consumed;
 
   raw_shortcut_name = gtk_accelerator_name (keyval, modifiers);
+  gtk_accelerator_parse (raw_shortcut_name, &context.keyval, &context.modifiers);
   TRACE ("Looking for %s", raw_shortcut_name);
   g_free (raw_shortcut_name);
 


More information about the Xfce4-commits mailing list