[gtk/wip/carlosg/grabbing-popovers] gtkpopover: Set GTK grab on autohide popovers



commit b20f21df24e7df63d43a0c7c8d70a3ad032c37fd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Apr 20 19:48:10 2020 +0200

    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

 gtk/gtkpopover.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index ad0ec0f862..a2a6adf654 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]