wayland/dragsurface: Get current size with compute-size signal
authorIvan Molodetskikh <yalterz@gmail.com>
Sun, 5 Mar 2023 18:18:56 +0000 (10:18 -0800)
committerIvan Molodetskikh <yalterz@gmail.com>
Wed, 15 Mar 2023 02:41:44 +0000 (19:41 -0700)
GdkDragSurface-backed widgets are not parented to an existing widget,
unlike popovers, and like toplevels. This means that there's nobody to
actively call gdk_drag_surface_present() to update the size, and
GdkDragSurface should do it on its own, just like GdkToplevel.

This commit implements this for the Wayland backend.

gdk/wayland/gdkdragsurface-wayland.c

index fb42488970cbe4fb7c45578566d79a2e78bc7371..22220a49e48f9a73c20f1bb4446852ba2eec7fd2 100644 (file)
@@ -33,6 +33,7 @@
 #include "gdksurfaceprivate.h"
 #include "gdktoplevelprivate.h"
 #include "gdkdevice-wayland-private.h"
+#include "gdkdragsurfacesizeprivate.h"
 
 #include <wayland/xdg-shell-unstable-v6-client-protocol.h>
 #include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
@@ -78,6 +79,17 @@ gdk_wayland_drag_surface_compute_size (GdkSurface *surface)
 
   if (impl->next_layout.surface_geometry_dirty)
     {
+      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);
+
+      impl->next_layout.configured_width = size.width;
+      impl->next_layout.configured_height = size.height;
+
       gdk_wayland_surface_update_size (surface,
                                        impl->next_layout.configured_width,
                                        impl->next_layout.configured_height,