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