mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
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:
parent
45434d501c
commit
c3dde05d33
@ -37,6 +37,22 @@
|
||||
|
||||
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,
|
||||
GdkDragSurfaceSize *size)
|
||||
{
|
||||
g_signal_emit (surface, signals[COMPUTE_SIZE], 0, size);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_drag_surface_default_present (GdkDragSurface *drag_surface,
|
||||
int width,
|
||||
@ -49,6 +65,35 @@ static void
|
||||
gdk_drag_surface_default_init (GdkDragSurfaceInterface *iface)
|
||||
{
|
||||
iface->present = gdk_drag_surface_default_present;
|
||||
|
||||
/**
|
||||
* GdkDragSurface::compute-size:
|
||||
* @surface: a `GdkDragSurface`
|
||||
* @size: (type Gdk.DragSurfaceSize) (out caller-allocates): a
|
||||
* `GdkDragSurfaceSize`
|
||||
*
|
||||
* Emitted when the size for the surface needs to be computed, when it is
|
||||
* present.
|
||||
*
|
||||
* It will normally be emitted during the native surface layout cycle when the
|
||||
* surface size needs to be recomputed.
|
||||
*
|
||||
* It is the responsibility of the drag surface user to handle this signal and
|
||||
* compute the desired size of the surface, storing the computed size in the
|
||||
* [struct@Gdk.DragSurfaceSize] object. Failing to do so will result in an
|
||||
* arbitrary size being used as a result.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
signals[COMPUTE_SIZE] =
|
||||
g_signal_new (I_("compute-size"),
|
||||
GDK_TYPE_DRAG_SURFACE,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
GDK_TYPE_DRAG_SURFACE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define __GDK_DRAG_SURFACE_PRIVATE_H__
|
||||
|
||||
#include "gdkdragsurface.h"
|
||||
#include "gdkdragsurfacesize.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -15,6 +16,9 @@ struct _GdkDragSurfaceInterface
|
||||
int height);
|
||||
};
|
||||
|
||||
void gdk_drag_surface_notify_compute_size (GdkDragSurface *surface,
|
||||
GdkDragSurfaceSize *size);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DRAG_SURFACE_PRIVATE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user