gdk/wayland: Avoid relayout with the same properties

When a popup is already showing, and gdk_surface_present_popup() is
called, if the layout didn't change, we're not really interested in
relayouting.

In the future, we'll be able to get notified if position of the popup
would change by some environmental changes, but until then, just don't
support it.
This commit is contained in:
Jonas Ådahl 2020-02-21 21:30:42 +01:00
parent 1d6100e7b0
commit 2f13ac2e4d
3 changed files with 34 additions and 0 deletions

View File

@ -129,6 +129,31 @@ gdk_popup_layout_copy (GdkPopupLayout *layout)
return new_layout;
}
/**
* gdk_popup_layout_equal:
* @layout: a #GdkPopupLayout
* @other: another #GdkPopupLayout
*
* Check whether @layout and @other has identical layout properties.
*
* Returns: %TRUE if @layout and @other have identical layout properties,
* otherwise %FALSE.
*/
gboolean
gdk_popup_layout_equal (GdkPopupLayout *layout,
GdkPopupLayout *other)
{
g_return_val_if_fail (layout, FALSE);
g_return_val_if_fail (other, FALSE);
return (gdk_rectangle_equal (&layout->anchor_rect, &other->anchor_rect) &&
layout->rect_anchor == other->rect_anchor &&
layout->surface_anchor == other->surface_anchor &&
layout->anchor_hints == other->anchor_hints &&
layout->dx == other->dx &&
layout->dy == other->dy);
}
/**
* gdk_popup_layout_set_anchor_rect:
* @layout: a #GdkPopupLayout

View File

@ -93,6 +93,10 @@ void gdk_popup_layout_unref (GdkPopupLayout
GDK_AVAILABLE_IN_ALL
GdkPopupLayout * gdk_popup_layout_copy (GdkPopupLayout *layout);
GDK_AVAILABLE_IN_ALL
gboolean gdk_popup_layout_equal (GdkPopupLayout *layout,
GdkPopupLayout *other);
GDK_AVAILABLE_IN_ALL
void gdk_popup_layout_set_anchor_rect (GdkPopupLayout *layout,
const GdkRectangle *anchor_rect);

View File

@ -2819,6 +2819,11 @@ gdk_wayland_surface_present_popup (GdkSurface *surface,
}
else
{
if (impl->popup.unconstrained_width == width &&
impl->popup.unconstrained_height == height &&
gdk_popup_layout_equal (impl->popup.layout, layout))
return TRUE;
reposition_popup (surface, width, height, layout);
}