diff --git a/gdk/gdkpopuplayout.c b/gdk/gdkpopuplayout.c index 4509944c55..f612efb727 100644 --- a/gdk/gdkpopuplayout.c +++ b/gdk/gdkpopuplayout.c @@ -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 diff --git a/gdk/gdkpopuplayout.h b/gdk/gdkpopuplayout.h index 9a07c0aeea..7427cdb426 100644 --- a/gdk/gdkpopuplayout.h +++ b/gdk/gdkpopuplayout.h @@ -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); diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 52b85f4233..2174bdf72a 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -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); }