[gtk: 2/4] surface: Hide chained autohiding popups together



commit 0a79eb02acc1041704b26a0b1483cb8e4574c22b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sat Apr 18 22:33:52 2020 +0200

    surface: Hide chained autohiding popups together
    
    When we autohide a popup surface with a grab, hide all other auto hiding
    popups up the popup chain. The end result is that when you click outside
    a menu with submenus open, the whole menu chain is dismissed.

 gdk/gdksurface.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 9f26ff828d..6c8195523b 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2783,6 +2783,18 @@ 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)
 {
@@ -2812,7 +2824,7 @@ check_autohide (GdkEvent *event)
           if (grab_surface != gdk_event_get_surface (event) &&
               grab_surface->autohide)
             {
-              gdk_surface_hide (grab_surface);
+              hide_popup_chain (grab_surface);
               return TRUE;
             }
         }


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