From eb828a5d7627d9d4d702ff86fd7a8fa127a3962d Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 6 Mar 2023 20:49:19 -0800 Subject: [PATCH] x11/surface: Get current drag surface size with compute-size signal Query and update size of drag surfaces, similarly to how it's done for the Wayland backend in the previous commit. --- gdk/x11/gdksurface-x11.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 9ae867eb6f..d5623ffbb2 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -345,6 +345,32 @@ compute_toplevel_size (GdkSurface *surface, return FALSE; } +static gboolean +compute_drag_surface_size (GdkSurface *surface, + int *width, + int *height) +{ + GdkX11Surface *impl = GDK_X11_SURFACE (surface); + int new_width = 0, new_height = 0; + + gdk_drag_surface_notify_compute_size (GDK_DRAG_SURFACE (surface), &new_width, &new_height); + + if ((impl->last_computed_width != new_width || + impl->last_computed_height != new_height) && + (impl->next_layout.configured_width != new_width || + impl->next_layout.configured_height != new_height)) + { + *width = new_width; + *height = new_height; + impl->last_computed_width = new_width; + impl->last_computed_height = new_height; + + return TRUE; + } + + return FALSE; +} + static gboolean compute_size_idle (gpointer user_data) { @@ -394,6 +420,24 @@ gdk_x11_surface_compute_size (GdkSurface *surface) impl->surface_scale); } + impl->next_layout.surface_geometry_dirty = FALSE; + impl->next_layout.configure_pending = FALSE; + } + else if (GDK_IS_DRAG_SURFACE (surface)) + { + int width, height; + + if (compute_drag_surface_size (surface, &width, &height)) + gdk_x11_surface_toplevel_resize (surface, width, height); + + if (surface->resize_count == 0) + { + gdk_x11_surface_update_size (impl, + impl->next_layout.configured_width, + impl->next_layout.configured_height, + impl->surface_scale); + } + impl->next_layout.surface_geometry_dirty = FALSE; impl->next_layout.configure_pending = FALSE; }