[gtk] main: Fix crossing event generation for parented roots



commit f47c376fb145bf4f7094260d918427f54c170284
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 19 19:12:55 2019 -0400

    main: Fix crossing event generation for parented roots
    
    We were walking the parent chain here, which now
    always needs to consider whether it should stop
    at roots. Like this one should.
    
    The symptom was that a label with a popup attached to
    it would end up with an unintentional focus ring that
    would not go away.

 gtk/gtkmain.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index b435c489a3..250a2063c7 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1418,6 +1418,7 @@ synth_crossing (GtkWidget       *widget,
 
   if (gdk_event_get_event_type (source) == GDK_FOCUS_CHANGE)
     {
+g_print ("focus %s: %s\n", enter ? "in" : "out", G_OBJECT_TYPE_NAME (widget));
       event = gdk_event_new (GDK_FOCUS_CHANGE);
       event->focus_change.in = enter;
       event->focus_change.mode = crossing_mode;
@@ -1521,7 +1522,7 @@ gtk_synthesize_crossing_events (GtkRoot         *toplevel,
           if (widget != ancestor || widget == old_target)
             synth_crossing (widget, GTK_WIDGET (toplevel), FALSE,
                             old_target, new_target, event, notify_type, mode);
-          if (widget == ancestor)
+          if (widget == ancestor || widget == GTK_WIDGET (toplevel))
             break;
           widget = gtk_widget_get_parent (widget);
         }
@@ -1536,7 +1537,7 @@ gtk_synthesize_crossing_events (GtkRoot         *toplevel,
       while (widget)
         {
           widgets = g_slist_prepend (widgets, widget);
-          if (widget == ancestor)
+          if (widget == ancestor || widget == GTK_WIDGET (toplevel))
             break;
           widget = gtk_widget_get_parent (widget);
         }


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