[Xfce4-commits] <libxfce4ui:jeromeg/keyboard-shortcuts> Fix keyboard shortcuts with Shift modifier (bug #8744).
Jérôme Guelfucci
noreply at xfce.org
Fri Dec 28 15:54:08 CET 2012
Updating branch refs/heads/jeromeg/keyboard-shortcuts
to 9dfbc906f89601f145557fe6846e9ad44a8e9e22 (commit)
from e56596a37ffdb4fe8fda4491466e6f826270accc (commit)
commit 9dfbc906f89601f145557fe6846e9ad44a8e9e22
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