summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-03-05 10:14:56 -0800
committerIvan Molodetskikh <yalterz@gmail.com>2023-03-06 21:04:46 -0800
commit9dcc24e7bfd35f855e7c2d69e2b2617c3e01cb41 (patch)
treeef77c7c694e10b93162f61b4a0a43d09bb5a9a94
parenteaf79cb1f0f61850f1581a3240bb00f04bf8a0ab (diff)
downloadgtk+-9dcc24e7bfd35f855e7c2d69e2b2617c3e01cb41.tar.gz
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.
-rw-r--r--gdk/gdkdragsurface.c27
-rw-r--r--gdk/gdkdragsurfaceprivate.h4
2 files changed, 31 insertions, 0 deletions
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__ */