[gtk/popup-shadow-width: 84/84] popuplayout: Add shadow width
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/popup-shadow-width: 84/84] popuplayout: Add shadow width
- Date: Tue, 19 Jan 2021 19:30:48 +0000 (UTC)
commit e024a14643bd8af6cdc445f87cc941d7461ad756
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 12 08:19:47 2021 -0500
popuplayout: Add shadow width
Add shadow width to the GdkPopupLayout struct. This
information is needed by the compositor to make correct
positioning decisions about popups.
gdk/gdkpopuplayout.c | 70 +++++++++++++++++++++++++++++++++++++++-
gdk/gdkpopuplayout.h | 14 ++++++++
gdk/wayland/gdksurface-wayland.c | 30 ++++++++++++-----
3 files changed, 105 insertions(+), 9 deletions(-)
---
diff --git a/gdk/gdkpopuplayout.c b/gdk/gdkpopuplayout.c
index 7192ef259d..686a2cbafe 100644
--- a/gdk/gdkpopuplayout.c
+++ b/gdk/gdkpopuplayout.c
@@ -74,6 +74,10 @@ struct _GdkPopupLayout
GdkAnchorHints anchor_hints;
int dx;
int dy;
+ int shadow_left;
+ int shadow_right;
+ int shadow_top;
+ int shadow_bottom;
};
G_DEFINE_BOXED_TYPE (GdkPopupLayout, gdk_popup_layout,
@@ -165,6 +169,10 @@ gdk_popup_layout_copy (GdkPopupLayout *layout)
new_layout->anchor_hints = layout->anchor_hints;
new_layout->dx = layout->dx;
new_layout->dy = layout->dy;
+ new_layout->shadow_left = layout->shadow_left;
+ new_layout->shadow_right = layout->shadow_right;
+ new_layout->shadow_top = layout->shadow_top;
+ new_layout->shadow_bottom = layout->shadow_bottom;
return new_layout;
}
@@ -191,7 +199,11 @@ gdk_popup_layout_equal (GdkPopupLayout *layout,
layout->surface_anchor == other->surface_anchor &&
layout->anchor_hints == other->anchor_hints &&
layout->dx == other->dx &&
- layout->dy == other->dy);
+ layout->dy == other->dy &&
+ layout->shadow_left == other->shadow_left &&
+ layout->shadow_right == other->shadow_right &&
+ layout->shadow_top == other->shadow_top &&
+ layout->shadow_bottom == other->shadow_bottom);
}
/**
@@ -346,3 +358,59 @@ gdk_popup_layout_get_offset (GdkPopupLayout *layout,
if (dy)
*dy = layout->dy;
}
+
+/**
+ * gdk_popup_layout_set_shadow_width:
+ * @layout: a #GdkPopupLayout
+ * @left: width of the left part of the shadow
+ * @right: width of the right part of the shadow
+ * @top: height of the top part of the shadow
+ * @bottom: height of the bottom part of the shadow
+ *
+ * The shadow width corresponds to the part of the computed surface size
+ * that would consist of the shadow margin surrounding the window, would
+ * there be any.
+ *
+ * Since: 4.2
+ */
+void
+gdk_popup_layout_set_shadow_width (GdkPopupLayout *layout,
+ int left,
+ int right,
+ int top,
+ int bottom)
+{
+ layout->shadow_left = left;
+ layout->shadow_right = right;
+ layout->shadow_top = top;
+ layout->shadow_bottom = bottom;
+}
+
+/**
+ * gdk_popup_layout_get_shadow_width:
+ * @layout: a #GdkPopupLayout
+ * @left: (out): return location for the left shadow width
+ * @right: (out): return location for the right shadow width
+ * @top: (out): return location for the top shadow width
+ * @bottom: (out): return location for the bottom shadow width
+ *
+ * Obtains the shadow widths of this layout.
+ *
+ * Since: 4.2
+ */
+void
+gdk_popup_layout_get_shadow_width (GdkPopupLayout *layout,
+ int *left,
+ int *right,
+ int *top,
+ int *bottom)
+{
+ if (left)
+ *left = layout->shadow_left;
+ if (right)
+ *right = layout->shadow_right;
+ if (top)
+ *top = layout->shadow_top;
+ if (bottom)
+ *bottom = layout->shadow_bottom;
+}
diff --git a/gdk/gdkpopuplayout.h b/gdk/gdkpopuplayout.h
index f55c748895..254704ead5 100644
--- a/gdk/gdkpopuplayout.h
+++ b/gdk/gdkpopuplayout.h
@@ -137,6 +137,20 @@ void gdk_popup_layout_get_offset (GdkPopupLayout
int *dx,
int *dy);
+GDK_AVAILABLE_IN_4_2
+void gdk_popup_layout_set_shadow_width (GdkPopupLayout *layout,
+ int left,
+ int right,
+ int top,
+ int bottom);
+GDK_AVAILABLE_IN_4_2
+void gdk_popup_layout_get_shadow_width (GdkPopupLayout *layout,
+ int *left,
+ int *right,
+ int *top,
+ int *bottom);
+
+
G_END_DECLS
#endif /* __GDK_POPUP_LAYOUT_H__ */
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index c114c04f29..828eff9da3 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -2271,12 +2271,17 @@ calculate_popup_rect (GdkSurface *surface,
int width, height;
GdkRectangle anchor_rect;
int dx, dy;
+ int shadow_left, shadow_right, shadow_top, shadow_bottom;
int x = 0, y = 0;
- width = (impl->popup.unconstrained_width -
- (impl->shadow_left + impl->shadow_right));
- height = (impl->popup.unconstrained_height -
- (impl->shadow_top + impl->shadow_bottom));
+ gdk_popup_layout_get_shadow_width (layout,
+ shadow_left,
+ shadow_right,
+ shadow_top,
+ shadow_bottom);
+
+ width = (impl->popup.unconstrained_width - (shadow_left + shadow_right));
+ height = (impl->popup.unconstrained_height - (shadow_top + shadow_bottom));
anchor_rect = *gdk_popup_layout_get_anchor_rect (layout);
gdk_popup_layout_get_offset (layout, &dx, &dy);
@@ -2475,12 +2480,21 @@ create_dynamic_positioner (GdkSurface *surface,
GdkGravity rect_anchor;
GdkGravity surface_anchor;
GdkAnchorHints anchor_hints;
+ int shadow_left;
+ int shadow_right;
+ int shadow_top;
+ int shadow_bottom;
+ gdk_popup_layout_get_shadow_width (layout,
+ shadow_left,
+ shadow_right,
+ shadow_top,
+ shadow_bottom);
geometry = (GdkRectangle) {
- .x = impl->shadow_left,
- .y = impl->shadow_top,
- .width = width - (impl->shadow_left + impl->shadow_right),
- .height = height - (impl->shadow_top + impl->shadow_bottom),
+ .x = shadow_left,
+ .y = shadow_top,
+ .width = width - (shadow_left + shadow_right),
+ .height = height - (shadow_top + shadow_bottom),
};
anchor_rect = gdk_popup_layout_get_anchor_rect (layout);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]