]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwidget.c
Fixed focus handling on embedded windows.
[~andy/gtk] / gtk / gtkwidget.c
index 20a268b8f9ed517d095ebb01a6c5b5dec5f592d9..4ee58865acef0e9c9397cda606d87b1e0322c50a 100644 (file)
@@ -3714,17 +3714,9 @@ gtk_widget_unparent (GtkWidget *widget)
   g_object_freeze_notify (G_OBJECT (widget));
   nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
 
-  /* Need to unset the parent window early, this can result in 
-   * an additional "hierarchy-changed" propagation if we are removing
-   * a parented GtkWindow from the hierarchy.
-   */
-  gtk_widget_set_parent_window (widget, NULL);
-
   toplevel = gtk_widget_get_toplevel (widget);
   if (gtk_widget_is_toplevel (toplevel))
     _gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
-  else
-    toplevel = NULL;
 
   if (gtk_container_get_focus_child (GTK_CONTAINER (priv->parent)) == widget)
     gtk_container_set_focus_child (GTK_CONTAINER (priv->parent), NULL);
@@ -3755,6 +3747,12 @@ gtk_widget_unparent (GtkWidget *widget)
        gtk_widget_unrealize (widget);
     }
 
+  /* Need to unset the parent window early, this can result in 
+   * an additional "hierarchy-changed" propagation if we are removing
+   * a parented GtkWindow from the hierarchy.
+   */
+  gtk_widget_set_parent_window (widget, NULL);
+
   /* Removing a widget from a container restores the child visible
    * flag to the default state, so it doesn't affect the child
    * in the next parent.
@@ -3777,7 +3775,7 @@ gtk_widget_unparent (GtkWidget *widget)
     }
 
   g_signal_emit (widget, widget_signals[PARENT_SET], 0, old_parent);
-  if (toplevel)
+  if (toplevel && gtk_widget_is_toplevel (toplevel))
     {
       _gtk_widget_propagate_hierarchy_changed (widget, toplevel);
       g_object_unref (toplevel);