From: Ivan Molodetskikh Date: Tue, 7 Mar 2023 04:49:19 +0000 (-0800) Subject: x11/surface: Get current drag surface size with compute-size signal X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~549^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=11d9bbfd6e924963f8890e6b14bc948e09947591;p=gtk4.git 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. --- diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 044a1185fa..8f56fe5e74 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -40,6 +40,7 @@ #include "gdkglcontext-x11.h" #include "gdkprivate-x11.h" #include "gdktextureprivate.h" +#include "gdkdragsurfacesizeprivate.h" #include "gdkseatprivate.h" #include "gdkprivate.h" @@ -345,6 +346,36 @@ 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); + GdkDragSurfaceSize size; + + gdk_drag_surface_size_init (&size); + size.width = impl->next_layout.configured_width; + size.height = impl->next_layout.configured_height; + + gdk_drag_surface_notify_compute_size (GDK_DRAG_SURFACE (surface), &size); + + if ((impl->last_computed_width != size.width || + impl->last_computed_height != size.height) && + (impl->next_layout.configured_width != size.width || + impl->next_layout.configured_height != size.height)) + { + *width = size.width; + *height = size.height; + impl->last_computed_width = size.width; + impl->last_computed_height = size.height; + + return TRUE; + } + + return FALSE; +} + static gboolean compute_size_idle (gpointer user_data) { @@ -394,6 +425,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; }