[gtk: 2/3] gdk/wayland: Avoid relayout with the same properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 2/3] gdk/wayland: Avoid relayout with the same properties
- Date: Sat, 22 Feb 2020 00:28:56 +0000 (UTC)
commit 2f13ac2e4ddf7f34f9f84eba2c32bf36478b8944
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Feb 21 21:30:42 2020 +0100
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.
gdk/gdkpopuplayout.c | 25 +++++++++++++++++++++++++
gdk/gdkpopuplayout.h | 4 ++++
gdk/wayland/gdksurface-wayland.c | 5 +++++
3 files changed, 34 insertions(+)
---
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]