summaryrefslogtreecommitdiff
path: root/gtk/gtkeventcontrollerkey.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-05-13 17:01:51 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-05-13 17:01:51 +0000
commit91d6893f02ef42d1650585b4e04223f53477e0cb (patch)
treef5ed67b30e462373a0f8a06288daa6638dd84e55 /gtk/gtkeventcontrollerkey.c
parent1318d3748afba9ef8c476f05cca0516f885faeb7 (diff)
downloadgtk+-91d6893f02ef42d1650585b4e04223f53477e0cb.tar.gz
key controller: Don't eat modifier events
The key controller was consuming key events for modifier keys, for no entirely convincing reason, which leads to problems when somebody actually listens for those, such as the simple input method does for C-S-u processing. Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1884
Diffstat (limited to 'gtk/gtkeventcontrollerkey.c')
-rw-r--r--gtk/gtkeventcontrollerkey.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/gtk/gtkeventcontrollerkey.c b/gtk/gtkeventcontrollerkey.c
index 6ca7020ef7..0ffb4f3eba 100644
--- a/gtk/gtkeventcontrollerkey.c
+++ b/gtk/gtkeventcontrollerkey.c
@@ -46,6 +46,8 @@ struct _GtkEventControllerKey
GtkIMContext *im_context;
GHashTable *pressed_keys;
+ GdkModifierType state;
+
const GdkEvent *current_event;
guint is_focus : 1;
@@ -141,10 +143,10 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
{
GtkEventControllerKey *key = GTK_EVENT_CONTROLLER_KEY (controller);
GdkEventType event_type = gdk_event_get_event_type (event);
- gboolean handled, is_modifier;
GdkModifierType state;
guint16 keycode;
guint keyval;
+ gboolean handled = FALSE;
if (event_type == GDK_FOCUS_CHANGE)
{
@@ -180,24 +182,15 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
return TRUE;
}
- if (!gdk_event_get_state (event, &state) ||
- !gdk_event_get_key_is_modifier (event, &is_modifier))
- return FALSE;
-
key->current_event = event;
- if (is_modifier)
+ gdk_event_get_state (event, &state);
+ if (key->state != state)
{
- if (event_type == GDK_KEY_PRESS)
- g_signal_emit (controller, signals[MODIFIERS], 0, state, &handled);
- else
- handled = TRUE;
+ gboolean unused;
- if (handled == TRUE)
- {
- key->current_event = NULL;
- return TRUE;
- }
+ key->state = state;
+ g_signal_emit (controller, signals[MODIFIERS], 0, state, &unused);
}
gdk_event_get_keycode (event, &keycode);