popover: Track toplevel's focus widget when visible

If the toplevel focus widget is forced out of the popover (eg. through
gtk_widget_grab_focus() anywhere else), then dismiss the popover.
This commit is contained in:
Carlos Garnacho 2014-03-06 16:58:06 +01:00
parent dcba77fcc4
commit 43e8852829

View File

@ -301,6 +301,19 @@ window_focus_out (GtkWidget *widget,
return FALSE;
}
static void
window_set_focus (GtkWindow *window,
GtkWidget *widget,
GtkPopover *popover)
{
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
if (priv->modal &&
gtk_widget_is_drawable (GTK_WIDGET (popover)) &&
(!widget || !gtk_widget_is_ancestor (widget, GTK_WIDGET (popover))))
gtk_widget_hide (GTK_WIDGET (popover));
}
static void
gtk_popover_apply_modality (GtkPopover *popover,
gboolean modal)
@ -322,6 +335,8 @@ gtk_popover_apply_modality (GtkPopover *popover,
G_CALLBACK (window_focus_in), popover);
g_signal_connect (priv->window, "focus-out-event",
G_CALLBACK (window_focus_out), popover);
g_signal_connect (priv->window, "set-focus",
G_CALLBACK (window_set_focus), popover);
}
else
{