[gtk/wip/carlosg/key-controller-fixes: 1/3] key controller: Don't eat modifier events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/key-controller-fixes: 1/3] key controller: Don't eat modifier events
- Date: Mon, 21 Oct 2019 21:45:32 +0000 (UTC)
commit ffaf56d1c65947bfe1d4e801bea88ce906d611bd
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 13 17:01:51 2019 +0000
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.
(cherry-picked from 91d6893f02ef42d1650585b4e04223f53477e0cb)
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1884
gtk/gtkeventcontrollerkey.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkeventcontrollerkey.c b/gtk/gtkeventcontrollerkey.c
index a6e949cc8e..d32ac28aa8 100644
--- a/gtk/gtkeventcontrollerkey.c
+++ b/gtk/gtkeventcontrollerkey.c
@@ -47,6 +47,8 @@ struct _GtkEventControllerKey
GtkIMContext *im_context;
GHashTable *pressed_keys;
+ GdkModifierType state;
+
const GdkEvent *current_event;
};
@@ -87,10 +89,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;
GdkModifierType state;
guint16 keycode;
guint keyval;
+ gboolean handled = FALSE;
if (event_type == GDK_FOCUS_CHANGE)
{
@@ -112,23 +114,15 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
return TRUE;
}
- if (!gdk_event_get_state (event, &state) || !event->key.is_modifier)
- return FALSE;
-
key->current_event = event;
- if (event->key.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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]