mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
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:
parent
dcba77fcc4
commit
43e8852829
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user