gtkpopover: Set GTK grab on autohide popovers

These popovers handle clicks outside the widget, and expect input
to be routed through it when it is shown. This pretty much matches
the characteristics of GTK grabs, and setting one up will ensure
the cancellation of event controllers that were active at the time
of showing the popover.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2446
This commit is contained in:
Carlos Garnacho 2020-04-20 19:48:10 +02:00
parent 2869f80bc0
commit b20f21df24

View File

@ -920,12 +920,20 @@ gtk_popover_show (GtkWidget *widget)
{
if (!gtk_widget_get_focus_child (widget))
gtk_widget_child_focus (widget, GTK_DIR_TAB_FORWARD);
gtk_grab_add (widget);
}
}
static void
gtk_popover_hide (GtkWidget *widget)
{
GtkPopover *popover = GTK_POPOVER (widget);
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
if (priv->autohide)
gtk_grab_remove (widget);
gtk_popover_set_mnemonics_visible (GTK_POPOVER (widget), FALSE);
_gtk_widget_set_visible_flag (widget, FALSE);
gtk_widget_unmap (widget);