Partial workaround for the Gtk bug with Shift key: make Shift-Fn key combinations work as global shortcuts
This commit is contained in:
parent
becca57e95
commit
1e1d2cc809
@ -411,6 +411,62 @@ _moo_get_accel_label (const char *accel)
|
||||
return g_strdup ("");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
need_workaround_for_671562 (guint keyval)
|
||||
{
|
||||
switch (keyval)
|
||||
{
|
||||
case GDK_KEY_F1:
|
||||
case GDK_KEY_F2:
|
||||
case GDK_KEY_F3:
|
||||
case GDK_KEY_F4:
|
||||
case GDK_KEY_F5:
|
||||
case GDK_KEY_F6:
|
||||
case GDK_KEY_F7:
|
||||
case GDK_KEY_F8:
|
||||
case GDK_KEY_F9:
|
||||
case GDK_KEY_F10:
|
||||
case GDK_KEY_F11:
|
||||
case GDK_KEY_F12:
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Wrapper for gdk_keymap_translate_keyboard_state with a workaround
|
||||
for https://bugzilla.gnome.org/show_bug.cgi?id=671562 */
|
||||
gboolean
|
||||
moo_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
guint hardware_keycode,
|
||||
GdkModifierType state,
|
||||
gint group,
|
||||
guint *keyval_p,
|
||||
gint *effective_group,
|
||||
gint *level,
|
||||
GdkModifierType *consumed_modifiers_p)
|
||||
{
|
||||
guint keyval = 0;
|
||||
GdkModifierType consumed_modifiers = 0;
|
||||
gboolean retval =
|
||||
gdk_keymap_translate_keyboard_state (keymap, hardware_keycode, state, group,
|
||||
&keyval, effective_group, level,
|
||||
&consumed_modifiers);
|
||||
|
||||
/* Check whether Shift mask needs to be added back */
|
||||
if ((state & GDK_SHIFT_MASK) && (consumed_modifiers & GDK_SHIFT_MASK) &&
|
||||
need_workaround_for_671562 (keyval))
|
||||
{
|
||||
consumed_modifiers &= ~GDK_SHIFT_MASK;
|
||||
}
|
||||
|
||||
if (keyval_p)
|
||||
*keyval_p = keyval;
|
||||
if (consumed_modifiers_p)
|
||||
*consumed_modifiers_p = consumed_modifiers;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
moo_accel_translate_event (GtkWidget *widget,
|
||||
@ -433,7 +489,7 @@ moo_accel_translate_event (GtkWidget *widget,
|
||||
else
|
||||
keymap = gdk_keymap_get_default ();
|
||||
|
||||
gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
|
||||
moo_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
|
||||
(GdkModifierType) event->state, event->group,
|
||||
keyval, NULL, NULL, &consumed);
|
||||
if (mods)
|
||||
|
@ -48,6 +48,15 @@ gboolean moo_accel_check_event (GtkWidget *widget,
|
||||
guint keyval,
|
||||
GdkModifierType mods);
|
||||
|
||||
gboolean moo_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
guint hardware_keycode,
|
||||
GdkModifierType state,
|
||||
gint group,
|
||||
guint *keyval,
|
||||
gint *effective_group,
|
||||
gint *level,
|
||||
GdkModifierType *consumed_modifiers);
|
||||
|
||||
|
||||
#define MOO_ACCEL_MODS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK | GDK_META_MASK)
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "mooutils/moodialogs.h"
|
||||
#include "mooutils/mooi18n.h"
|
||||
#include "mooutils/mooaccelbutton-gxml.h"
|
||||
#include "mooutils/mooaccel.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
@ -277,7 +278,7 @@ key_event (GtkWidget *widget,
|
||||
int mods;
|
||||
|
||||
keymap = gdk_keymap_get_for_display (gtk_widget_get_display (widget));
|
||||
gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
|
||||
moo_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
|
||||
(GdkModifierType) event->state, event->group,
|
||||
NULL, NULL, NULL, &consumed_modifiers);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user