[gtk/popup-shadow-width: 1/8] wayland: Set shadow width on popup surfaces




commit aec738745a014925899611e333a35aac796ab895
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 13 20:48:15 2021 -0500

    wayland: Set shadow width on popup surfaces
    
    Take the shadow width from the popup layout into account.

 gdk/wayland/gdksurface-wayland.c | 54 +++++++++++++++++++++++++++++-----------
 1 file changed, 40 insertions(+), 14 deletions(-)
---
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index d31e4ae6ee..2f95339fb0 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -630,12 +630,19 @@ static void
 configure_popup_geometry (GdkSurface *surface)
 {
   GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+  int x, y;
+  int width, height;
+
+  x = impl->next_layout.popup.x - impl->shadow_left;
+  y = impl->next_layout.popup.y - impl->shadow_top;
+  width =
+    impl->next_layout.configured_width +
+    (impl->shadow_left + impl->shadow_right);
+  height =
+    impl->next_layout.configured_height +
+    (impl->shadow_top + impl->shadow_bottom);
 
-  gdk_wayland_surface_move_resize (surface,
-                                   impl->next_layout.popup.x,
-                                   impl->next_layout.popup.y,
-                                   impl->next_layout.configured_width,
-                                   impl->next_layout.configured_height);
+  gdk_wayland_surface_move_resize (surface, x, y, width, height);
 }
 
 static void
@@ -2289,12 +2296,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);
@@ -2478,7 +2490,6 @@ create_dynamic_positioner (GdkSurface     *surface,
                            GdkPopupLayout *layout,
                            gboolean        ack_parent_configure)
 {
-  GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
   GdkSurface *parent = surface->parent;
   GdkWaylandSurface *parent_impl = GDK_WAYLAND_SURFACE (parent);
   GdkWaylandDisplay *display =
@@ -2493,12 +2504,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);
@@ -2724,6 +2744,12 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface     *surface,
       g_assert_not_reached ();
     }
 
+  gdk_popup_layout_get_shadow_width (layout,
+                                     &impl->shadow_left,
+                                     &impl->shadow_right,
+                                     &impl->shadow_top,
+                                     &impl->shadow_bottom);
+
   if (grab_input_seat)
     {
       struct wl_seat *seat;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]