[gtk+/wip/baedert/children: 38/44] widget: Fix grab_focus for child widgets



commit 2a20f604acd9f31fd2fc65633838ee21240ce63f
Author: Timm Bäder <mail baedert org>
Date:   Thu Nov 24 17:14:14 2016 +0100

    widget: Fix grab_focus for child widgets

 gtk/gtkwidget.c |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d63c7dd..b55d150 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -7229,19 +7229,17 @@ gtk_widget_grab_focus (GtkWidget *widget)
 }
 
 static void
-reset_focus_recurse (GtkWidget *widget,
-                    gpointer   data)
+reset_focus_recurse (GtkWidget *widget)
 {
-  if (GTK_IS_CONTAINER (widget))
-    {
-      GtkContainer *container;
+  GtkWidget *child;
 
-      container = GTK_CONTAINER (widget);
-      gtk_container_set_focus_child (container, NULL);
+  gtk_widget_set_focus_child (widget, NULL);
 
-      gtk_container_foreach (container,
-                            reset_focus_recurse,
-                            NULL);
+  for (child = gtk_widget_get_first_child (widget);
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child))
+    {
+      reset_focus_recurse (child);
     }
 }
 
@@ -7283,7 +7281,7 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
                  while (widget->priv->parent)
                    {
                      widget = widget->priv->parent;
-                     gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
+                      gtk_widget_set_focus_child (widget, NULL);
                      if (widget == common_ancestor)
                        break;
                    }
@@ -7292,13 +7290,16 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
        }
       else if (toplevel != focus_widget)
        {
+          GtkWidget *child;
          /* gtk_widget_grab_focus() operates on a tree without window...
           * actually, this is very questionable behavior.
           */
-
-         gtk_container_foreach (GTK_CONTAINER (toplevel),
-                                reset_focus_recurse,
-                                NULL);
+          for (child = gtk_widget_get_first_child (toplevel);
+               child != NULL;
+               child = gtk_widget_get_next_sibling (child))
+            {
+              reset_focus_recurse (child);
+            }
        }
 
       /* now propagate the new focus up the widget tree and finally
@@ -7307,7 +7308,7 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
       widget = focus_widget;
       while (widget->priv->parent)
        {
-         gtk_container_set_focus_child (GTK_CONTAINER (widget->priv->parent), widget);
+          gtk_widget_set_focus_child (widget->priv->parent, widget);
          widget = widget->priv->parent;
        }
       if (GTK_IS_WINDOW (widget))


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