From a26865e741f9dadd5b2251c53a7d986fef1ebf72 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 26 Jun 2020 14:05:57 -0400 Subject: [PATCH] widget: Add a debug message for consumed key events Run the application with GTK_DEBUG=keybindings to get some hints where key events get lost. --- gtk/gtkwidget.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 897ce13965..9b936ef6f2 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4371,6 +4371,22 @@ gtk_widget_run_controllers (GtkWidget *widget, is_gesture = GTK_IS_GESTURE (controller); this_handled = gtk_event_controller_handle_event (controller, event, target, x, y); +#ifdef G_ENABLE_DEBUG + if (GTK_DEBUG_CHECK (KEYBINDINGS)) + { + GdkEventType type = gdk_event_get_event_type (event); + if (this_handled && + (type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE)) + { + g_message ("key %s (keyval %d) handled at widget %s by controller %s\n", + type == GDK_KEY_PRESS ? "press" : "release", + gdk_key_event_get_keyval (event), + G_OBJECT_TYPE_NAME (widget), + gtk_event_controller_get_name (controller)); + } + } +#endif + handled |= this_handled; /* Non-gesture controllers are basically unique entities not meant