From 75f96b83de6ab547220b1ce2cbaf03087f365412 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 3 Nov 2020 15:26:47 -0500 Subject: [PATCH 1/4] surface: Be more lenient for autohide When an event happens on a non-grabbing popup that hangs off a grabbing popup, don't trigger the autohide. This makes touch text handles work inside the popover on page 3 of widget-factory. --- gdk/gdksurface.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index f28c6ac4d1..00990ea40e 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -2695,7 +2695,10 @@ check_autohide (GdkEvent *event) device = gdk_event_get_device (event); if (gdk_device_grab_info (display, device, &grab_surface, NULL)) { - if (grab_surface != gdk_event_get_surface (event) && + GdkSurface *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); From dcfb6e5ef5577ee6a1bca56e356a91c88d9e8f9c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 3 Nov 2020 15:28:40 -0500 Subject: [PATCH 2/4] 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; } } From d2cc9365fc0bc712c983f521812197ffc59ebc96 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 3 Nov 2020 15:47:03 -0500 Subject: [PATCH 3/4] Cosmetics Extraneous pair of parens snuck in with 2120e9df88. --- gdk/gdksurface.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 6d8e92aec3..e7689830fd 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -1491,9 +1491,7 @@ gdk_surface_freeze_updates (GdkSurface *surface) surface->update_freeze_count++; if (surface->update_freeze_count == 1) - { _gdk_frame_clock_uninhibit_freeze (surface->frame_clock); - } } /* From 8ae415acffa25e400b453094cdd358fffe63ada2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 4 Nov 2020 14:56:52 -0500 Subject: [PATCH 4/4] popovermenu: Fail gracefully if no model If we don't have a model yet, return FALSE from gtk_popover_menu_add_custom(). --- gtk/gtkmenusectionbox.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c index 9f988d98f5..332252bb51 100644 --- a/gtk/gtkmenusectionbox.c +++ b/gtk/gtkmenusectionbox.c @@ -696,6 +696,8 @@ gtk_menu_section_box_add_custom (GtkPopoverMenu *popover, stack = gtk_popover_get_child (GTK_POPOVER (popover)); box = GTK_MENU_SECTION_BOX (gtk_stack_get_child_by_name (GTK_STACK (stack), "main")); + if (box == NULL) + return FALSE; slot = (GtkWidget *)g_hash_table_lookup (box->custom_slots, id);