It's now gdk_drop_status().
Also clarify the intended semantics.
/* Destination side */
-static void
-gdk_broadway_drag_context_drag_status (GdkDragContext *context,
- GdkDragAction action,
- guint32 time)
-{
- g_return_if_fail (context != NULL);
-}
-
static void
gdk_broadway_drag_context_drop_finish (GdkDragContext *context,
gboolean success,
object_class->finalize = gdk_broadway_drag_context_finalize;
- context_class->drag_status = gdk_broadway_drag_context_drag_status;
context_class->drag_abort = gdk_broadway_drag_context_drag_abort;
context_class->drag_drop = gdk_broadway_drag_context_drag_drop;
context_class->drop_finish = gdk_broadway_drag_context_drop_finish;
GdkDragAction action,
guint32 time_)
{
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
-
- GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_status (context, action, time_);
+ gdk_drop_status (GDK_DROP (context), action);
}
/*
struct _GdkDragContextClass {
GdkDropClass parent_class;
- void (*drag_status) (GdkDragContext *context,
- GdkDragAction action,
- guint32 time_);
void (*drag_abort) (GdkDragContext *context,
guint32 time_);
void (*drag_drop) (GdkDragContext *context,
* should not be accessed directly.
*/
+static void
+gdk_drop_default_status (GdkDrop *self,
+ GdkDragAction actions)
+{
+}
+
static void
gdk_drop_read_local_async (GdkDrop *self,
GdkContentFormats *formats,
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ klass->status = gdk_drop_default_status;
+
object_class->get_property = gdk_drop_get_property;
object_class->set_property = gdk_drop_set_property;
object_class->finalize = gdk_drop_finalize;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIONS]);
}
+/**
+ * gdk_drop_status:
+ * @self: a #GdkDrop
+ * @actions: Supported actions of the destination, or 0 to indicate
+ * that a drop will not be accepted
+ *
+ * Selects all actions that are potentially supported by the destination.
+ *
+ * When calling this function, do not restrict the passed in actions to
+ * the ones provided by gdk_drop_get_actions(). Those actions may
+ * change in the future, even depending on the actions you provide here.
+ *
+ * This function should be called by drag destinations in response to
+ * %GDK_DRAG_ENTER or %GDK_DRAG_MOTION events. If the destination does
+ * not yet know the exact actions it supports, it should set any possible
+ * actions first and then later call this function again.
+ */
+void
+gdk_drop_status (GdkDrop *self,
+ GdkDragAction actions)
+{
+ g_return_if_fail (GDK_IS_DROP (self));
+
+ GDK_DROP_GET_CLASS (self)->status (self, actions);
+}
+
/**
* gdk_drop_read_async:
* @self: a #GdkDrop
GDK_AVAILABLE_IN_ALL
GdkDragAction gdk_drop_get_actions (GdkDrop *self);
+GDK_AVAILABLE_IN_ALL
+void gdk_drop_status (GdkDrop *self,
+ GdkDragAction actions);
+
GDK_AVAILABLE_IN_ALL
void gdk_drop_read_async (GdkDrop *self,
const char **mime_types,
struct _GdkDropClass {
GObjectClass parent_class;
+ void (* status) (GdkDrop *self,
+ GdkDragAction action);
void (* read_async) (GdkDrop *self,
GdkContentFormats *formats,
int io_priority,
/* FIXME: Implement */
}
-static void
-gdk_quartz_drag_context_drag_status (GdkDragContext *context,
- GdkDragAction action,
- guint32 time)
-{
- context->action = action;
-}
-
static void
gdk_quartz_drag_context_drop_finish (GdkDragContext *context,
gboolean success,
object_class->finalize = gdk_quartz_drag_context_finalize;
- context_class->drag_status = gdk_quartz_drag_context_drag_status;
context_class->drag_abort = gdk_quartz_drag_context_drag_abort;
context_class->drag_drop = gdk_quartz_drag_context_drag_drop;
context_class->drop_finish = gdk_quartz_drag_context_drop_finish;
}
static void
-gdk_wayland_drag_context_drag_status (GdkDragContext *context,
- GdkDragAction action,
- guint32 time_)
+gdk_wayland_drag_context_status (GdkDrop *drop,
+ GdkDragAction action)
{
GdkWaylandDragContext *wayland_context;
- wayland_context = GDK_WAYLAND_DRAG_CONTEXT (context);
+ wayland_context = GDK_WAYLAND_DRAG_CONTEXT (drop);
wayland_context->selected_action = action;
}
object_class->finalize = gdk_wayland_drag_context_finalize;
+ drop_class->status = gdk_wayland_drag_context_status;
drop_class->read_async = gdk_wayland_drag_context_read_async;
drop_class->read_finish = gdk_wayland_drag_context_read_finish;
- context_class->drag_status = gdk_wayland_drag_context_drag_status;
context_class->drag_abort = gdk_wayland_drag_context_drag_abort;
context_class->drag_drop = gdk_wayland_drag_context_drag_drop;
context_class->drop_finish = gdk_wayland_drag_context_drop_finish;
/* Destination side */
static void
-gdk_win32_drop_context_drag_status (GdkDragContext *context,
- GdkDragAction action,
- guint32 time)
+gdk_win32_drop_context_status (GdkDrop *drop,
+ GdkDragAction action)
{
+ GdkDragContext *context = GDK_DRAG_CONTEXT (drop);
GdkDragContext *src_context;
g_return_if_fail (context != NULL);
object_class->finalize = gdk_win32_drop_context_finalize;
+ drop_class->status = gdk_win32_drop_context_status;
drop_class->read_async = gdk_win32_drop_context_read_async;
drop_class->read_finish = gdk_win32_drop_context_read_finish;
- context_class->drag_status = gdk_win32_drop_context_drag_status;
context_class->drop_finish = gdk_win32_drop_context_drop_finish;
}
GdkDragAction suggested_action,
GdkDragAction possible_actions,
guint32 time);
-static void gdk_x11_drag_context_drag_status (GdkDragContext *context,
- GdkDragAction action,
- guint32 time_);
+static void gdk_x11_drag_context_status (GdkDrop *drop,
+ GdkDragAction actions);
static void gdk_x11_drag_context_drag_abort (GdkDragContext *context,
guint32 time_);
static void gdk_x11_drag_context_drag_drop (GdkDragContext *context,
object_class->finalize = gdk_x11_drag_context_finalize;
+ drop_class->status = gdk_x11_drag_context_status;
drop_class->read_async = gdk_x11_drag_context_read_async;
drop_class->read_finish = gdk_x11_drag_context_read_finish;
- context_class->drag_status = gdk_x11_drag_context_drag_status;
context_class->drag_abort = gdk_x11_drag_context_drag_abort;
context_class->drag_drop = gdk_x11_drag_context_drag_drop;
context_class->drop_finish = gdk_x11_drag_context_drop_finish;
/* Destination side */
static void
-gdk_x11_drag_context_drag_status (GdkDragContext *context,
- GdkDragAction action,
- guint32 time_)
+gdk_x11_drag_context_status (GdkDrop *drop,
+ GdkDragAction actions)
{
+ GdkDragContext *context = GDK_DRAG_CONTEXT (drop);
GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
XEvent xev;
GdkDisplay *display;
display = gdk_drag_context_get_display (context);
- context->action = action;
+ context->action = actions;
if (context_x11->protocol == GDK_DRAG_PROTO_XDND)
{
+ GdkDragAction possible_actions = actions & gdk_drop_get_actions (drop);
+
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
xev.xclient.format = 32;
xev.xclient.window = GDK_SURFACE_XID (context->source_surface);
xev.xclient.data.l[0] = GDK_SURFACE_XID (context->dest_surface);
- xev.xclient.data.l[1] = (action != 0) ? (2 | 1) : 0;
+ xev.xclient.data.l[1] = (possible_actions != 0) ? (2 | 1) : 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
- xev.xclient.data.l[4] = xdnd_action_to_atom (display, action);
+ xev.xclient.data.l[4] = xdnd_action_to_atom (display, possible_actions);
if (!xdnd_send_xevent (context_x11, context->source_surface, FALSE, &xev))
{
GDK_DISPLAY_NOTE (display, DND,