From 16da71f1ce26d291cc56b7d4a79b18ac037a6162 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 15 Jun 2021 16:01:09 +0800 Subject: [PATCH 1/2] gdksurface-win32.c: Fix formatting for popup functions --- gdk/win32/gdksurface-win32.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 03250491d4..ae58743ea7 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -4655,9 +4655,9 @@ gdk_win32_popup_init (GdkWin32Popup *popup) static void gdk_win32_popup_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { GdkSurface *surface = GDK_SURFACE (object); @@ -4679,9 +4679,9 @@ gdk_win32_popup_get_property (GObject *object, static void gdk_win32_popup_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { GdkSurface *surface = GDK_SURFACE (object); @@ -4716,9 +4716,9 @@ gdk_win32_popup_class_init (GdkWin32PopupClass *class) static gboolean gdk_win32_popup_present (GdkPopup *popup, - int width, - int height, - GdkPopupLayout *layout) + int width, + int height, + GdkPopupLayout *layout) { return gdk_win32_surface_present_popup (GDK_SURFACE (popup), width, height, layout); } From 90bd5a04fd518a6783815194bac7157cbe4d5810 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 16 Jun 2021 12:24:47 +0800 Subject: [PATCH 2/2] gdksurface-win32.c: Fix up popup placement If we are undergoing a surface move, just apply the next_layout anyways, even if we are not moving a toplevel surface. Update the way how we obtain the x and y coordinates of a surface, if it is a toplevel, apply the x and y coordinates from the results from we obtained the underlying Win32 HWND, as we did before. But if it is a popup, use gdk_win32_surface_get_geometry() to obtain the correct x and y coordinates to place our popup surface. Also correct how we compute the shadow dimensions, and the final popup rectangle as we attempt to layout the popup surface, since GDK-Win32 keeps track of the shadow dimensions in system (unscaled) units, not GDK units. Fixes issue #3793. --- gdk/win32/gdksurface-win32.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index ae58743ea7..4c8eae9ef9 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -1227,6 +1227,7 @@ gdk_win32_surface_layout_popup (GdkSurface *surface, &shadow_right, &shadow_top, &shadow_bottom); + gdk_win32_surface_set_shadow_width (surface, shadow_left, shadow_right, @@ -1236,10 +1237,10 @@ gdk_win32_surface_layout_popup (GdkSurface *surface, gdk_surface_layout_popup_helper (surface, width, height, - impl->shadow.left, - impl->shadow.right, - impl->shadow.top, - impl->shadow.bottom, + shadow_left, + shadow_right, + shadow_top, + shadow_bottom, monitor, &bounds, layout, @@ -1259,9 +1260,7 @@ gdk_win32_surface_layout_popup (GdkSurface *surface, final_rect.height); } else - { - gdk_win32_surface_move (surface, x, y); - } + gdk_win32_surface_move (surface, x, y); } static void @@ -4415,9 +4414,9 @@ gdk_win32_surface_set_shadow_width (GdkSurface *window, if (impl->zero_shadow) return; - impl->shadow.left = left; + impl->shadow.left = left * impl->surface_scale;; impl->shadow.right = right * impl->surface_scale; - impl->shadow.top = top; + impl->shadow.top = top * impl->surface_scale;; impl->shadow.bottom = bottom * impl->surface_scale; impl->shadow_x = left + right; impl->shadow_y = top + bottom; @@ -4553,7 +4552,7 @@ _gdk_win32_surface_request_layout (GdkSurface *surface) int scale = impl->surface_scale; RECT rect; - if (GDK_IS_TOPLEVEL (surface) && impl->drag_move_resize_context.native_move_resize_pending) + if (impl->drag_move_resize_context.native_move_resize_pending) { surface->width = impl->next_layout.configured_width; surface->height = impl->next_layout.configured_height; @@ -4564,8 +4563,18 @@ _gdk_win32_surface_request_layout (GdkSurface *surface) impl->next_layout.configured_width = (rect.right - rect.left + scale - 1) / scale; impl->next_layout.configured_height = (rect.bottom - rect.top + scale - 1) / scale; - surface->x = rect.left / scale; - surface->y = rect.top / scale; + + if (GDK_IS_TOPLEVEL (surface)) + { + surface->x = rect.left / scale; + surface->y = rect.top / scale; + } + else if (GDK_IS_POPUP (surface)) + { + gdk_win32_surface_get_geometry (surface, + &surface->x, &surface->y, + NULL, NULL); + } } }