forked from AuroraMiddleware/gtk
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 91d6893f02
)
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1884
This commit is contained in:
parent
da90d37b42
commit
ffaf56d1c6
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user