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.
This commit is contained in:
Ivan Molodetskikh 2023-03-05 10:14:56 -08:00
parent eaf79cb1f0
commit 9dcc24e7bf
2 changed files with 31 additions and 0 deletions

View File

@ -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);
}
/**

View File

@ -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__ */