From 9dcc24e7bfd35f855e7c2d69e2b2617c3e01cb41 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 5 Mar 2023 10:14:56 -0800 Subject: dragsurface: Add compute-size signal Similarly to GdkToplevel, GdkDragSurface's compute-size should be called by backends to query the current surface size, and should be connected to by widget implementations (like GtkDragIcon) to report the current size. 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. --- gdk/gdkdragsurface.c | 27 +++++++++++++++++++++++++++ gdk/gdkdragsurfaceprivate.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/gdk/gdkdragsurface.c b/gdk/gdkdragsurface.c index 97c3e7dd36..2a29dedef3 100644 --- a/gdk/gdkdragsurface.c +++ b/gdk/gdkdragsurface.c @@ -37,6 +37,23 @@ G_DEFINE_INTERFACE (GdkDragSurface, gdk_drag_surface, GDK_TYPE_SURFACE) +enum +{ + COMPUTE_SIZE, + + N_SIGNALS +}; + +static guint signals[N_SIGNALS] = { 0 }; + +void +gdk_drag_surface_notify_compute_size (GdkDragSurface *surface, + int *width, + int *height) +{ + g_signal_emit (surface, signals[COMPUTE_SIZE], 0, width, height); +} + static gboolean gdk_drag_surface_default_present (GdkDragSurface *drag_surface, int width, @@ -49,6 +66,16 @@ static void gdk_drag_surface_default_init (GdkDragSurfaceInterface *iface) { iface->present = gdk_drag_surface_default_present; + + signals[COMPUTE_SIZE] = + g_signal_new (I_("compute-size"), + GDK_TYPE_DRAG_SURFACE, + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + NULL, + G_TYPE_NONE, 2, + G_TYPE_POINTER, G_TYPE_POINTER); } /** diff --git a/gdk/gdkdragsurfaceprivate.h b/gdk/gdkdragsurfaceprivate.h index e32cfd780c..ae4730afe9 100644 --- a/gdk/gdkdragsurfaceprivate.h +++ b/gdk/gdkdragsurfaceprivate.h @@ -15,6 +15,10 @@ struct _GdkDragSurfaceInterface int height); }; +void gdk_drag_surface_notify_compute_size (GdkDragSurface *surface, + int *width, + int *height); + G_END_DECLS #endif /* __GDK_DRAG_SURFACE_PRIVATE_H__ */ -- cgit v1.2.1