Commit 72ea348a authored by Phillip Wood's avatar Phillip Wood Committed by Matthias Clasen

Fix hiding popover when focus moves outside

Commit a01fe140 changed the behaviour of popovers when the focus leaves
them to stop child popovers being hidden when the focus leaves their
parent. However they are now a bit too reluctant to hide - if the
focus passes to an unrelated popover the first popover is not
hidden. Also if the focus passes to another widget that does not
perform a gtk grab then the popover isn't hidden until the user
presses a non-movement key or clicks outside the popover.

The solution is to go back to checking if the focused widget is a
descendant of the popover, but to include popovers and their related
widgets in the ancestry chain.

https://bugzilla.gnome.org/show_bug.cgi?id=765595
parent 0943c9f6
......@@ -439,17 +439,23 @@ window_set_focus (GtkWindow *window,
{
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
if (priv->modal && widget &&
gtk_widget_is_drawable (GTK_WIDGET (popover)) &&
!gtk_widget_is_ancestor (widget, GTK_WIDGET (popover)))
{
GtkWidget *grab_widget;
if (!priv->modal || !widget || !gtk_widget_is_drawable (GTK_WIDGET (popover)))
return;
grab_widget = gtk_grab_get_current ();
widget = gtk_widget_get_ancestor (widget, GTK_TYPE_POPOVER);
while (widget != NULL)
{
if (widget == GTK_WIDGET (popover))
return;
if (!grab_widget || !GTK_IS_POPOVER (grab_widget))
gtk_widget_hide (GTK_WIDGET (popover));
widget = gtk_popover_get_relative_to (GTK_POPOVER (widget));
if (widget == NULL)
break;
widget = gtk_widget_get_ancestor (widget, GTK_TYPE_POPOVER);
}
popover_unset_prev_focus (popover);
gtk_widget_hide (GTK_WIDGET (popover));
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment