[gtk+] Fixed focus handling on embedded windows.



commit aa787c9dd17c9dbee97c76209e62284cd836fdea
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Fri Dec 24 13:25:02 2010 +0900

    Fixed focus handling on embedded windows.
    
    Now GtkWindow chains up in focus vfuncs when non-toplevel, this
    fixes focus in testtoplevelembed.

 gtk/gtkwidget.c |    4 +---
 gtk/gtkwindow.c |    9 +++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 0a5e5b8..4ee5886 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3717,8 +3717,6 @@ gtk_widget_unparent (GtkWidget *widget)
   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);
@@ -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);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 60693ff..963e221 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5996,6 +5996,9 @@ gtk_window_focus (GtkWidget        *widget,
   GtkWidget *old_focus_child;
   GtkWidget *parent;
 
+  if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+    return GTK_WIDGET_CLASS (gtk_window_parent_class)->focus (widget, direction);
+
   container = GTK_CONTAINER (widget);
   window = GTK_WINDOW (widget);
   priv = window->priv;
@@ -6049,6 +6052,12 @@ static void
 gtk_window_move_focus (GtkWidget       *widget,
                        GtkDirectionType dir)
 {
+  if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+    {
+      GTK_WIDGET_CLASS (gtk_window_parent_class)->move_focus (widget, dir);
+      return;
+    }
+
   gtk_widget_child_focus (widget, dir);
 
   if (! gtk_container_get_focus_child (GTK_CONTAINER (widget)))



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