From 3e2714508f3a4b3fbf3995ce58c28a656103ae36 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 9 Jun 2010 18:55:48 +0200 Subject: [PATCH] app: add log output of key event handling in GimpWindow using the "key-events" debug key. --- app/gimp-log.c | 3 ++- app/gimp-log.h | 4 +++- app/widgets/gimpwindow.c | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/gimp-log.c b/app/gimp-log.c index dabc71a63d..96b5c696fa 100644 --- a/app/gimp-log.c +++ b/app/gimp-log.c @@ -49,8 +49,9 @@ gimp_log_init (void) { "scale", GIMP_LOG_SCALE }, { "wm", GIMP_LOG_WM }, { "floating-selection", GIMP_LOG_FLOATING_SELECTION }, + { "shm", GIMP_LOG_SHM }, { "text-editing", GIMP_LOG_TEXT_EDITING }, - { "shm", GIMP_LOG_SHM } + { "key-events", GIMP_LOG_KEY_EVENTS } }; /* g_parse_debug_string() has special treatment of the string 'help', diff --git a/app/gimp-log.h b/app/gimp-log.h index 6a3aacd48a..8113e32e35 100644 --- a/app/gimp-log.h +++ b/app/gimp-log.h @@ -34,7 +34,8 @@ typedef enum GIMP_LOG_WM = 1 << 10, GIMP_LOG_FLOATING_SELECTION = 1 << 11, GIMP_LOG_SHM = 1 << 12, - GIMP_LOG_TEXT_EDITING = 1 << 13 + GIMP_LOG_TEXT_EDITING = 1 << 13, + GIMP_LOG_KEY_EVENTS = 1 << 14 } GimpLogFlags; @@ -89,6 +90,7 @@ void gimp_logv (const gchar *function, #define FLOATING_SELECTION GIMP_LOG_FLOATING_SELECTION #define SHM GIMP_LOG_SHM #define TEXT_EDITING GIMP_LOG_TEXT_EDITING +#define KEY_EVENTS GIMP_LOG_KEY_EVENTS #if 0 /* last resort */ # define GIMP_LOG /* nothing => no varargs, no log */ diff --git a/app/widgets/gimpwindow.c b/app/widgets/gimpwindow.c index 1b1465087f..7ec90b6956 100644 --- a/app/widgets/gimpwindow.c +++ b/app/widgets/gimpwindow.c @@ -28,6 +28,8 @@ #include "gimpwindow.h" +#include "gimp-log.h" + static gboolean gimp_window_key_press_event (GtkWidget *widget, GdkEventKey *kevent); @@ -65,19 +67,43 @@ gimp_window_key_press_event (GtkWidget *widget, if (GTK_IS_EDITABLE (focus) || GTK_IS_TEXT_VIEW (focus) || GIMP_IS_CANVAS (focus)) - handled = gtk_window_propagate_key_event (window, event); + { + handled = gtk_window_propagate_key_event (window, event); + + if (handled) + GIMP_LOG (KEY_EVENTS, + "handled by gtk_window_propagate_key_event(text_widget)"); + } /* invoke control/alt accelerators */ if (! handled && event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) - handled = gtk_window_activate_key (window, event); + { + handled = gtk_window_activate_key (window, event); + + if (handled) + GIMP_LOG (KEY_EVENTS, + "handled by gtk_window_activate_key(modified)"); + } /* invoke focus widget handlers */ if (! handled) - handled = gtk_window_propagate_key_event (window, event); + { + handled = gtk_window_propagate_key_event (window, event); + + if (handled) + GIMP_LOG (KEY_EVENTS, + "handled by gtk_window_propagate_key_event(other_widget)"); + } /* invoke non-(control/alt) accelerators */ if (! handled && ! (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) - handled = gtk_window_activate_key (window, event); + { + handled = gtk_window_activate_key (window, event); + + if (handled) + GIMP_LOG (KEY_EVENTS, + "handled by gtk_window_activate_key(unmodified)"); + } /* chain up, bypassing gtk_window_key_press(), to invoke binding set */ if (! handled) @@ -87,6 +113,10 @@ gimp_window_key_press_event (GtkWidget *widget, widget_class = g_type_class_peek_static (g_type_parent (GTK_TYPE_WINDOW)); handled = widget_class->key_press_event (widget, event); + + if (handled) + GIMP_LOG (KEY_EVENTS, + "handled by widget_class->key_press_event()"); } return handled;