[gtk+] Fix set_focus_child handling during focus changes
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Fix set_focus_child handling during focus changes
- Date: Tue, 13 Dec 2011 23:27:45 +0000 (UTC)
commit 10b5ec20f2d42949bbec2f3519dbf5dca380fe49
Author: Alexander Larsson <alexl redhat com>
Date: Wed Dec 14 00:23:57 2011 +0100
Fix set_focus_child handling during focus changes
In many cases we used to set focus_child to NULL all the way up
to the top and then to the right value, even if there was
a common ancestor, meaning these see a temporary NULL value for
focus_child. Only when the new focus widgets direct parent was
in the previous ancestor list did we stop early.
This fixes that by always stopping propagation when reaching
the common ancestor.
gtk/gtkwidget.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8d772df..6b96be4 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6468,10 +6468,15 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
if (widget)
{
- while (widget->priv->parent && widget->priv->parent != focus_widget->priv->parent)
+ GtkWidget *common_ancestor = gtk_widget_common_ancestor (widget, focus_widget);
+
+ if (widget != common_ancestor)
{
- widget = widget->priv->parent;
- gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
+ while (widget->priv->parent && widget->priv->parent != common_ancestor)
+ {
+ widget = widget->priv->parent;
+ gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]