[gtk/shortcuts-rebased-again: 164/171] window: Actually listen for focus change



commit da36d0502f57e8d1340d78f7f7b4cd1d08c9b4a1
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jun 24 02:57:33 2019 +0000

    window: Actually listen for focus change
    
    Same as the previous commit: We need a bubble
    phase key controller to receive focus change
    events.

 gtk/gtkwindow.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 56ded34521..3011d61135 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1872,15 +1872,20 @@ gtk_window_init (GtkWindow *window)
 
   controller = gtk_event_controller_key_new ();
   gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+  gtk_event_controller_set_name (controller, "window mnemonics");
+  g_signal_connect_swapped (controller, "key-pressed",
+                            G_CALLBACK (gtk_window_key_pressed), window);
+  g_signal_connect_swapped (controller, "key-released",
+                            G_CALLBACK (gtk_window_key_released), window);
+  gtk_widget_add_controller (widget, controller);
+
+  controller = gtk_event_controller_key_new ();
+  gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE);
   gtk_event_controller_set_name (controller, "window focus");
   g_signal_connect_swapped (controller, "focus-in",
                             G_CALLBACK (gtk_window_focus_in), window);
   g_signal_connect_swapped (controller, "focus-out",
                             G_CALLBACK (gtk_window_focus_out), window);
-  g_signal_connect_swapped (controller, "key-pressed",
-                            G_CALLBACK (gtk_window_key_pressed), window);
-  g_signal_connect_swapped (controller, "key-released",
-                            G_CALLBACK (gtk_window_key_released), window);
   gtk_widget_add_controller (widget, controller);
 
   controller = gtk_shortcut_controller_new ();
@@ -6072,7 +6077,6 @@ gtk_window_set_focus (GtkWindow *window,
 
   g_return_if_fail (GTK_IS_WINDOW (window));
 
-g_print ("window set focus: %s\n", focus ? gtk_widget_get_name (focus):"");
   if (focus && !gtk_widget_is_sensitive (focus))
     return;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]