summaryrefslogtreecommitdiff
path: root/gtk/gtkeventcontrollerkey.c
diff options
context:
space:
mode:
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);