widget: Fix set_focus_child handling during focus changes

10b5ec20 made sure not to set focus_child to NULL all the way up to the
top, but only up to the common ancestor. However, it would never set it
on the common ancestor itself, which would therefore remain with a
focus_child set when it shouldn't.

A manifestation of the bug: focus column headers of a treeview, press Tab.
Now pressing Shift+Tab will go to another widget and not the column
headers, and Tab will (appear to) do nothing, all because the treeview
still has a focus_child set to column headers after a grab_focus().

Signed-off-by: Olivier Brunel <jjk@jjacky.com>

https://bugzilla.gnome.org/show_bug.cgi?id=723402
This commit is contained in:
Olivier Brunel 2014-01-28 20:33:09 +01:00 committed by Matthias Clasen
parent 5e80ec87f3
commit a8d72a9c1e

View File

@ -7533,10 +7533,12 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
if (widget != common_ancestor) if (widget != common_ancestor)
{ {
while (widget->priv->parent && widget->priv->parent != common_ancestor) while (widget->priv->parent)
{ {
widget = widget->priv->parent; widget = widget->priv->parent;
gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL); gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
if (widget == common_ancestor)
break;
} }
} }
} }