Merge branch 'wip/fix-multi-popup-hide' into 'master'

Fix autohiding popup chain

See merge request GNOME/gtk!1717
This commit is contained in:
Matthias Clasen 2020-04-18 22:33:52 +00:00
commit 853de6c511
3 changed files with 31 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -2334,7 +2334,7 @@ can_map_grabbing_popup (GdkSurface *surface,
return top_most_popup == parent;
}
static void
static gboolean
gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
GdkSurface *parent,
GdkWaylandSeat *grab_input_seat,
@ -2348,27 +2348,27 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
gpointer positioner;
if (!impl->display_server.wl_surface)
return;
return FALSE;
if (!is_realized_shell_surface (parent))
return;
return FALSE;
if (is_realized_toplevel (surface))
{
g_warning ("Can't map popup, already mapped as toplevel");
return;
return FALSE;
}
if (is_realized_popup (surface))
{
g_warning ("Can't map popup, already mapped");
return;
return FALSE;
}
if (grab_input_seat &&
!can_map_grabbing_popup (surface, parent))
{
g_warning ("Tried to map a grabbing popup with a non-top most parent");
return;
return FALSE;
}
gdk_surface_freeze_updates (surface);
@ -2453,6 +2453,8 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
display->current_grabbing_popups =
g_list_prepend (display->current_grabbing_popups, surface);
}
return TRUE;
}
static GdkWaylandSeat *
@ -2827,11 +2829,13 @@ gdk_wayland_surface_map_popup (GdkSurface *surface,
grab_input_seat = find_grab_input_seat (surface, parent);
else
grab_input_seat = NULL;
gdk_wayland_surface_create_xdg_popup (surface,
parent,
grab_input_seat,
width, height,
layout);
if (!gdk_wayland_surface_create_xdg_popup (surface,
parent,
grab_input_seat,
width, height,
layout))
return;
impl->popup.layout = gdk_popup_layout_copy (layout);
impl->popup.unconstrained_width = width;

View File

@ -550,9 +550,9 @@ present_popup (GtkPopover *popover)
layout = create_popup_layout (popover);
gtk_widget_get_preferred_size (GTK_WIDGET (popover), NULL, &req);
if (gdk_popup_present (GDK_POPUP (priv->surface),
MAX (req.width, 1),
MAX (req.height, 1),
layout))
MAX (req.width, 1),
MAX (req.height, 1),
layout))
update_popover_layout (popover, layout);
}