[gtk/matthiasc/for-master: 16/18] surface: Be smarter about autohide




commit dcfb6e5ef5577ee6a1bca56e356a91c88d9e8f9c
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Nov 3 15:28:40 2020 -0500

    surface: Be smarter about autohide
    
    When we close grabbing popups due to an outside
    click, check at each level if the click is still
    outside. This makes closing the nested popover
    menu in the popover on page 3 of widget-factory
    work as expected, when you click the menubutton
    again.

 gdk/gdksurface.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 00990ea40e..6d8e92aec3 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2657,18 +2657,6 @@ gdk_synthesize_surface_state (GdkSurface       *surface,
   gdk_surface_set_state (surface, (surface->state | set_flags) & ~unset_flags);
 }
 
-static void
-hide_popup_chain (GdkSurface *surface)
-{
-  GdkSurface *parent;
-
-  gdk_surface_hide (surface);
-
-  parent = surface->parent;
-  if (parent->autohide)
-    hide_popup_chain (parent);
-}
-
 static gboolean
 check_autohide (GdkEvent *event)
 {
@@ -2695,13 +2683,23 @@ check_autohide (GdkEvent *event)
       device = gdk_event_get_device (event);
       if (gdk_device_grab_info (display, device, &grab_surface, NULL))
         {
-          GdkSurface *event_surface = gdk_event_get_surface (event);
+          GdkSurface *event_surface;
+
+          event_surface = gdk_event_get_surface (event);
 
           if (grab_surface != event_surface &&
               grab_surface != event_surface->parent &&
               grab_surface->autohide)
             {
-              hide_popup_chain (grab_surface);
+              GdkSurface *surface = grab_surface;
+
+              do
+                {
+                  gdk_surface_hide (surface);
+                  surface = surface->parent;
+                }
+              while (surface->autohide && surface != event_surface);
+
               return TRUE;
             }
         }


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