forked from AuroraMiddleware/gtk
dnd: Add gdk_drop_finish()
and move the vfunc into GdkDrop.
This commit is contained in:
parent
5b0a6a52c1
commit
316bd6a333
@ -118,16 +118,6 @@ gdk_broadway_drag_context_drag_abort (GdkDragContext *context,
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
/* Destination side */
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_broadway_surface_register_dnd (GdkSurface *surface)
|
||||
{
|
||||
@ -148,5 +138,4 @@ gdk_broadway_drag_context_class_init (GdkBroadwayDragContextClass *klass)
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -589,7 +589,10 @@ gdk_drag_finish (GdkDragContext *context,
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
|
||||
GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_finish (context, success, time_);
|
||||
if (success)
|
||||
gdk_drop_finish (GDK_DROP (context), gdk_drag_context_get_selected_action (context));
|
||||
else
|
||||
gdk_drop_finish (GDK_DROP (context), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -39,9 +39,6 @@ struct _GdkDragContextClass {
|
||||
guint32 time_);
|
||||
void (*drag_drop) (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
void (*drop_finish) (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time_);
|
||||
GdkSurface* (*get_drag_surface) (GdkDragContext *context);
|
||||
void (*set_hotspot) (GdkDragContext *context,
|
||||
gint hot_x,
|
||||
|
@ -377,6 +377,27 @@ gdk_drop_status (GdkDrop *self,
|
||||
GDK_DROP_GET_CLASS (self)->status (self, actions);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drop_finish:
|
||||
* @self: a #GdkDrop
|
||||
* @action: the action performed by the destination or 0 if the drop
|
||||
* failed
|
||||
*
|
||||
* Ends the drag operation after a drop.
|
||||
*
|
||||
* The @action must be a single action selected from the actions
|
||||
* available via gdk_drop_get_actions().
|
||||
**/
|
||||
void
|
||||
gdk_drop_finish (GdkDrop *self,
|
||||
GdkDragAction action)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DROP (self));
|
||||
g_return_if_fail (gdk_drag_action_is_unique (action));
|
||||
|
||||
GDK_DROP_GET_CLASS (self)->finish (self, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drop_read_async:
|
||||
* @self: a #GdkDrop
|
||||
|
@ -51,6 +51,9 @@ GdkDragAction gdk_drop_get_actions (GdkDrop
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_status (GdkDrop *self,
|
||||
GdkDragAction actions);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_finish (GdkDrop *self,
|
||||
GdkDragAction action);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_read_async (GdkDrop *self,
|
||||
|
@ -40,7 +40,10 @@ struct _GdkDropClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* status) (GdkDrop *self,
|
||||
GdkDragAction actions);
|
||||
void (* finish) (GdkDrop *self,
|
||||
GdkDragAction action);
|
||||
|
||||
void (* read_async) (GdkDrop *self,
|
||||
GdkContentFormats *formats,
|
||||
int io_priority,
|
||||
|
@ -70,14 +70,6 @@ gdk_quartz_drag_context_drag_abort (GdkDragContext *context,
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_quartz_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_quartz_surface_register_dnd (GdkSurface *window)
|
||||
{
|
||||
@ -111,5 +103,4 @@ gdk_quartz_drag_context_class_init (GdkQuartzDragContextClass *klass)
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -225,18 +225,16 @@ gdk_wayland_drag_context_status (GdkDrop *drop,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time)
|
||||
gdk_wayland_drag_context_finish (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (context);
|
||||
GdkDisplay *display = gdk_device_get_display (gdk_drag_context_get_device (context));
|
||||
GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (drop);
|
||||
GdkDisplay *display = gdk_drop_get_display (drop);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
if (success && wayland_context->selected_action &&
|
||||
wayland_context->selected_action != GDK_ACTION_ASK)
|
||||
if (action)
|
||||
{
|
||||
gdk_wayland_drag_context_commit_status (context);
|
||||
gdk_wayland_drag_context_commit_status (GDK_DRAG_CONTEXT (drop));
|
||||
|
||||
if (display_wayland->data_device_manager_version >=
|
||||
WL_DATA_OFFER_FINISH_SINCE_VERSION)
|
||||
@ -403,13 +401,12 @@ gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
|
||||
object_class->finalize = gdk_wayland_drag_context_finalize;
|
||||
|
||||
drop_class->status = gdk_wayland_drag_context_status;
|
||||
drop_class->finish = gdk_wayland_drag_context_finish;
|
||||
drop_class->read_async = gdk_wayland_drag_context_read_async;
|
||||
drop_class->read_finish = gdk_wayland_drag_context_read_finish;
|
||||
|
||||
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;
|
||||
context_class->drop_finish = gdk_wayland_drag_context_drop_finish;
|
||||
context_class->get_drag_surface = gdk_wayland_drag_context_get_drag_surface;
|
||||
context_class->set_hotspot = gdk_wayland_drag_context_set_hotspot;
|
||||
context_class->drop_done = gdk_wayland_drag_context_drop_done;
|
||||
|
@ -895,10 +895,10 @@ _gdk_display_put_event (GdkDisplay *display,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_drop_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time)
|
||||
gdk_win32_drop_context_finish (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (drop);
|
||||
GdkDragContext *src_context;
|
||||
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
|
||||
|
||||
@ -906,6 +906,9 @@ gdk_win32_drop_context_drop_finish (GdkDragContext *context,
|
||||
|
||||
GDK_NOTE (DND, g_print ("gdk_drag_finish\n"));
|
||||
|
||||
if (context->action != action)
|
||||
gdk_win32_drop_context_status (context, action);
|
||||
|
||||
if (!use_ole2_dnd)
|
||||
{
|
||||
src_context = _gdk_win32_drag_context_find (context->source_surface,
|
||||
@ -921,9 +924,9 @@ gdk_win32_drop_context_drop_finish (GdkDragContext *context,
|
||||
}
|
||||
else
|
||||
{
|
||||
_gdk_win32_drag_do_leave (context, time);
|
||||
_gdk_win32_drag_do_leave (context, GDK_CURRENT_TIME);
|
||||
|
||||
if (success)
|
||||
if (action)
|
||||
clipdrop->dnd_target_state = GDK_WIN32_DND_DROPPED;
|
||||
else
|
||||
clipdrop->dnd_target_state = GDK_WIN32_DND_FAILED;
|
||||
@ -1205,10 +1208,9 @@ gdk_win32_drop_context_class_init (GdkWin32DropContextClass *klass)
|
||||
object_class->finalize = gdk_win32_drop_context_finalize;
|
||||
|
||||
drop_class->status = gdk_win32_drop_context_status;
|
||||
drop_class->finish = gdk_win32_drop_context_finish;
|
||||
drop_class->read_async = gdk_win32_drop_context_read_async;
|
||||
drop_class->read_finish = gdk_win32_drop_context_read_finish;
|
||||
|
||||
context_class->drop_finish = gdk_win32_drop_context_drop_finish;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -239,9 +239,8 @@ static void gdk_x11_drag_context_drag_abort (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
static void gdk_x11_drag_context_drag_drop (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
static void gdk_x11_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time_);
|
||||
static void gdk_x11_drag_context_finish (GdkDrop *drop,
|
||||
GdkDragAction action);
|
||||
static GdkSurface * gdk_x11_drag_context_get_drag_surface (GdkDragContext *context);
|
||||
static void gdk_x11_drag_context_set_hotspot (GdkDragContext *context,
|
||||
gint hot_x,
|
||||
@ -394,12 +393,12 @@ gdk_x11_drag_context_class_init (GdkX11DragContextClass *klass)
|
||||
object_class->finalize = gdk_x11_drag_context_finalize;
|
||||
|
||||
drop_class->status = gdk_x11_drag_context_status;
|
||||
drop_class->finish = gdk_x11_drag_context_finish;
|
||||
drop_class->read_async = gdk_x11_drag_context_read_async;
|
||||
drop_class->read_finish = gdk_x11_drag_context_read_finish;
|
||||
|
||||
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;
|
||||
context_class->get_drag_surface = gdk_x11_drag_context_get_drag_surface;
|
||||
context_class->set_hotspot = gdk_x11_drag_context_set_hotspot;
|
||||
context_class->drop_done = gdk_x11_drag_context_drop_done;
|
||||
@ -2443,23 +2442,23 @@ gdk_x11_drag_context_status (GdkDrop *drop,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
guint32 time)
|
||||
gdk_x11_drag_context_finish (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
{
|
||||
if (GDK_X11_DRAG_CONTEXT (context)->protocol == GDK_DRAG_PROTO_XDND)
|
||||
if (GDK_X11_DRAG_CONTEXT (drop)->protocol == GDK_DRAG_PROTO_XDND)
|
||||
{
|
||||
GdkDisplay *display = gdk_drag_context_get_display (context);
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (drop);
|
||||
GdkDisplay *display = gdk_drop_get_display (drop);
|
||||
XEvent xev;
|
||||
|
||||
if (success && gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE)
|
||||
if (action == GDK_ACTION_MOVE)
|
||||
{
|
||||
XConvertSelection (GDK_DISPLAY_XDISPLAY (display),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "XdndSelection"),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "DELETE"),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "GDK_SELECTION"),
|
||||
GDK_SURFACE_XID (context->source_surface),
|
||||
time);
|
||||
GDK_X11_DRAG_CONTEXT (drop)->timestamp);
|
||||
/* XXX: Do we need to wait for a reply here before sending the next message? */
|
||||
}
|
||||
|
||||
@ -2469,11 +2468,10 @@ gdk_x11_drag_context_drop_finish (GdkDragContext *context,
|
||||
xev.xclient.window = GDK_SURFACE_XID (context->source_surface);
|
||||
|
||||
xev.xclient.data.l[0] = GDK_SURFACE_XID (context->dest_surface);
|
||||
if (success)
|
||||
if (action != 0)
|
||||
{
|
||||
xev.xclient.data.l[1] = 1;
|
||||
xev.xclient.data.l[2] = xdnd_action_to_atom (display,
|
||||
context->action);
|
||||
xev.xclient.data.l[2] = xdnd_action_to_atom (display, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user