2008-07-01 22:57:50 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
2002-10-07 22:43:26 +00:00
|
|
|
* Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2002-10-07 22:43:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
|
2010-12-11 05:14:53 +00:00
|
|
|
#include "gdkdndprivate.h"
|
2010-10-15 02:05:51 +00:00
|
|
|
#include "gdkdisplay.h"
|
|
|
|
#include "gdkwindow.h"
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
#include "gdkintl.h"
|
|
|
|
#include "gdkenumtypes.h"
|
2016-01-13 19:51:19 +00:00
|
|
|
#include "gdkcursor.h"
|
2017-08-05 13:34:39 +00:00
|
|
|
#include "gdkeventsprivate.h"
|
2016-01-13 19:51:19 +00:00
|
|
|
|
|
|
|
static struct {
|
|
|
|
GdkDragAction action;
|
|
|
|
const gchar *name;
|
|
|
|
GdkCursor *cursor;
|
|
|
|
} drag_cursors[] = {
|
|
|
|
{ GDK_ACTION_DEFAULT, NULL, NULL },
|
|
|
|
{ GDK_ACTION_ASK, "dnd-ask", NULL },
|
|
|
|
{ GDK_ACTION_COPY, "dnd-copy", NULL },
|
|
|
|
{ GDK_ACTION_MOVE, "dnd-move", NULL },
|
|
|
|
{ GDK_ACTION_LINK, "dnd-link", NULL },
|
|
|
|
{ 0, "dnd-none", NULL },
|
|
|
|
};
|
2010-07-09 00:34:45 +00:00
|
|
|
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
enum {
|
|
|
|
CANCEL,
|
|
|
|
DROP_PERFORMED,
|
|
|
|
DND_FINISHED,
|
|
|
|
ACTION_CHANGED,
|
|
|
|
N_SIGNALS
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[N_SIGNALS] = { 0 };
|
|
|
|
static GList *contexts = NULL;
|
2002-10-07 22:43:26 +00:00
|
|
|
|
2010-06-08 19:21:18 +00:00
|
|
|
/**
|
|
|
|
* SECTION:dnd
|
|
|
|
* @title: Drag And Drop
|
|
|
|
* @short_description: Functions for controlling drag and drop handling
|
|
|
|
*
|
|
|
|
* These functions provide a low level interface for drag and drop.
|
|
|
|
* The X backend of GDK supports both the Xdnd and Motif drag and drop
|
|
|
|
* protocols transparently, the Win32 backend supports the WM_DROPFILES
|
|
|
|
* protocol.
|
|
|
|
*
|
|
|
|
* GTK+ provides a higher level abstraction based on top of these functions,
|
|
|
|
* and so they are not normally needed in GTK+ applications.
|
2014-02-07 02:07:03 +00:00
|
|
|
* See the [Drag and Drop][gtk3-Drag-and-Drop] section of
|
2010-06-08 19:21:18 +00:00
|
|
|
* the GTK+ documentation for more information.
|
|
|
|
*/
|
|
|
|
|
2010-05-25 15:54:16 +00:00
|
|
|
/**
|
|
|
|
* gdk_drag_context_list_targets:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Retrieves the list of targets of the context.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer none) (element-type GdkAtom): a #GList of targets
|
2010-05-25 15:54:16 +00:00
|
|
|
*
|
|
|
|
* Since: 2.22
|
|
|
|
**/
|
|
|
|
GList *
|
|
|
|
gdk_drag_context_list_targets (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
return context->targets;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_get_actions:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Determines the bitmask of actions proposed by the source if
|
2014-05-17 03:12:51 +00:00
|
|
|
* gdk_drag_context_get_suggested_action() returns %GDK_ACTION_ASK.
|
2010-05-25 15:54:16 +00:00
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: the #GdkDragAction flags
|
2010-05-25 15:54:16 +00:00
|
|
|
*
|
|
|
|
* Since: 2.22
|
|
|
|
**/
|
|
|
|
GdkDragAction
|
|
|
|
gdk_drag_context_get_actions (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_ACTION_DEFAULT);
|
|
|
|
|
|
|
|
return context->actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_get_suggested_action:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Determines the suggested drag action of the context.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: a #GdkDragAction value
|
2010-05-25 15:54:16 +00:00
|
|
|
*
|
|
|
|
* Since: 2.22
|
|
|
|
**/
|
|
|
|
GdkDragAction
|
|
|
|
gdk_drag_context_get_suggested_action (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
|
|
|
|
|
|
|
|
return context->suggested_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-06-10 11:15:12 +00:00
|
|
|
* gdk_drag_context_get_selected_action:
|
2010-05-25 15:54:16 +00:00
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Determines the action chosen by the drag destination.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: a #GdkDragAction value
|
2010-05-25 15:54:16 +00:00
|
|
|
*
|
|
|
|
* Since: 2.22
|
|
|
|
**/
|
|
|
|
GdkDragAction
|
2010-06-02 18:42:11 +00:00
|
|
|
gdk_drag_context_get_selected_action (GdkDragContext *context)
|
2010-05-25 15:54:16 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
|
|
|
|
|
|
|
|
return context->action;
|
|
|
|
}
|
|
|
|
|
2010-06-10 13:52:45 +00:00
|
|
|
/**
|
|
|
|
* gdk_drag_context_get_source_window:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Returns the #GdkWindow where the DND operation started.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer none): a #GdkWindow
|
2010-06-10 13:52:45 +00:00
|
|
|
*
|
|
|
|
* Since: 2.22
|
|
|
|
**/
|
|
|
|
GdkWindow *
|
|
|
|
gdk_drag_context_get_source_window (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
return context->source_window;
|
|
|
|
}
|
2010-12-10 05:58:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_get_dest_window:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
2016-10-03 19:26:20 +00:00
|
|
|
* Returns the destination window for the DND operation.
|
2010-12-10 05:58:33 +00:00
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: (transfer none): a #GdkWindow
|
2010-12-10 05:58:33 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GdkWindow *
|
|
|
|
gdk_drag_context_get_dest_window (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
return context->dest_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_get_protocol:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Returns the drag protocol thats used by this context.
|
|
|
|
*
|
|
|
|
* Returns: the drag protocol
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
GdkDragProtocol
|
|
|
|
gdk_drag_context_get_protocol (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_DRAG_PROTO_NONE);
|
|
|
|
|
|
|
|
return context->protocol;
|
|
|
|
}
|
|
|
|
|
2010-12-10 06:27:10 +00:00
|
|
|
/**
|
|
|
|
* gdk_drag_context_set_device:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @device: a #GdkDevice
|
|
|
|
*
|
|
|
|
* Associates a #GdkDevice to @context, so all Drag and Drop events
|
|
|
|
* for @context are emitted as if they came from this device.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drag_context_set_device (GdkDragContext *context,
|
|
|
|
GdkDevice *device)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
|
|
|
|
|
|
|
if (context->device)
|
|
|
|
g_object_unref (context->device);
|
|
|
|
|
|
|
|
context->device = device;
|
|
|
|
|
|
|
|
if (context->device)
|
|
|
|
g_object_ref (context->device);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_get_device:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Returns the #GdkDevice associated to the drag context.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The #GdkDevice associated to @context.
|
|
|
|
**/
|
|
|
|
GdkDevice *
|
|
|
|
gdk_drag_context_get_device (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
return context->device;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_drag_context_init (GdkDragContext *context)
|
|
|
|
{
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
contexts = g_list_prepend (contexts, context);
|
2010-12-10 06:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_drag_context_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
|
|
|
|
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
contexts = g_list_remove (contexts, context);
|
2010-12-10 06:27:10 +00:00
|
|
|
g_list_free (context->targets);
|
|
|
|
|
|
|
|
if (context->source_window)
|
|
|
|
g_object_unref (context->source_window);
|
|
|
|
|
|
|
|
if (context->dest_window)
|
|
|
|
g_object_unref (context->dest_window);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_drag_context_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_drag_context_class_init (GdkDragContextClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gdk_drag_context_finalize;
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GdkDragContext::cancel:
|
2016-01-24 09:48:48 +00:00
|
|
|
* @context: The object on which the signal is emitted
|
2016-04-26 07:50:17 +00:00
|
|
|
* @reason: The reason the context was cancelled
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
*
|
|
|
|
* The drag and drop operation was cancelled.
|
|
|
|
*
|
|
|
|
* This signal will only be emitted if the #GdkDragContext manages
|
|
|
|
* the drag and drop operation. See gdk_drag_context_manage_dnd()
|
|
|
|
* for more information.
|
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
*/
|
|
|
|
signals[CANCEL] =
|
2016-01-26 17:42:04 +00:00
|
|
|
g_signal_new ("cancel",
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
2016-02-15 16:05:50 +00:00
|
|
|
G_SIGNAL_RUN_LAST,
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
G_STRUCT_OFFSET (GdkDragContextClass, cancel),
|
|
|
|
NULL, NULL,
|
2016-02-15 16:02:14 +00:00
|
|
|
g_cclosure_marshal_VOID__ENUM,
|
|
|
|
G_TYPE_NONE, 1, GDK_TYPE_DRAG_CANCEL_REASON);
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GdkDragContext::drop-performed:
|
2016-01-24 09:48:48 +00:00
|
|
|
* @context: The object on which the signal is emitted
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
* @time: the time at which the drop happened.
|
|
|
|
*
|
|
|
|
* The drag and drop operation was performed on an accepting client.
|
|
|
|
*
|
|
|
|
* This signal will only be emitted if the #GdkDragContext manages
|
|
|
|
* the drag and drop operation. See gdk_drag_context_manage_dnd()
|
|
|
|
* for more information.
|
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
*/
|
|
|
|
signals[DROP_PERFORMED] =
|
2016-01-26 17:42:04 +00:00
|
|
|
g_signal_new ("drop-performed",
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GdkDragContextClass, drop_performed),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__INT,
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_INT);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GdkDragContext::dnd-finished:
|
2016-01-24 09:48:48 +00:00
|
|
|
* @context: The object on which the signal is emitted
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
*
|
|
|
|
* The drag and drop operation was finished, the drag destination
|
|
|
|
* finished reading all data. The drag source can now free all
|
|
|
|
* miscellaneous data.
|
|
|
|
*
|
|
|
|
* This signal will only be emitted if the #GdkDragContext manages
|
|
|
|
* the drag and drop operation. See gdk_drag_context_manage_dnd()
|
|
|
|
* for more information.
|
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
*/
|
|
|
|
signals[DND_FINISHED] =
|
2016-01-26 17:42:04 +00:00
|
|
|
g_signal_new ("dnd-finished",
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GdkDragContextClass, dnd_finished),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GdkDragContext::action-changed:
|
2016-01-24 09:48:48 +00:00
|
|
|
* @context: The object on which the signal is emitted
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
* @action: The action currently chosen
|
|
|
|
*
|
|
|
|
* A new action is being chosen for the drag and drop operation.
|
|
|
|
*
|
|
|
|
* This signal will only be emitted if the #GdkDragContext manages
|
|
|
|
* the drag and drop operation. See gdk_drag_context_manage_dnd()
|
|
|
|
* for more information.
|
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
*/
|
|
|
|
signals[ACTION_CHANGED] =
|
2016-01-26 17:42:04 +00:00
|
|
|
g_signal_new ("action-changed",
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GdkDragContextClass, action_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__FLAGS,
|
|
|
|
G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
|
2010-12-10 06:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-31 14:16:18 +00:00
|
|
|
* gdk_drag_find_window:
|
2010-12-10 06:27:10 +00:00
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @drag_window: a window which may be at the pointer position, but
|
|
|
|
* should be ignored, since it is put up by the drag source as an icon
|
|
|
|
* @x_root: the x position of the pointer in root coordinates
|
|
|
|
* @y_root: the y position of the pointer in root coordinates
|
|
|
|
* @dest_window: (out): location to store the destination window in
|
|
|
|
* @protocol: (out): location to store the DND protocol in
|
|
|
|
*
|
|
|
|
* Finds the destination window and DND protocol to use at the
|
|
|
|
* given pointer position.
|
|
|
|
*
|
|
|
|
* This function is called by the drag source to obtain the
|
|
|
|
* @dest_window and @protocol parameters for gdk_drag_motion().
|
|
|
|
*
|
|
|
|
* Since: 2.2
|
|
|
|
*/
|
|
|
|
void
|
2017-10-31 14:16:18 +00:00
|
|
|
gdk_drag_find_window (GdkDragContext *context,
|
|
|
|
GdkWindow *drag_window,
|
|
|
|
gint x_root,
|
|
|
|
gint y_root,
|
|
|
|
GdkWindow **dest_window,
|
|
|
|
GdkDragProtocol *protocol)
|
2010-12-10 06:27:10 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
|
|
|
*dest_window = GDK_DRAG_CONTEXT_GET_CLASS (context)
|
2017-10-31 14:16:18 +00:00
|
|
|
->find_window (context, drag_window, x_root, y_root, protocol);
|
2010-12-10 06:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_status:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @action: the selected action which will be taken when a drop happens,
|
|
|
|
* or 0 to indicate that a drop will not be accepted
|
|
|
|
* @time_: the timestamp for this operation
|
|
|
|
*
|
|
|
|
* Selects one of the actions offered by the drag source.
|
|
|
|
*
|
|
|
|
* This function is called by the drag destination in response to
|
|
|
|
* gdk_drag_motion() called by the drag source.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drag_status (GdkDragContext *context,
|
|
|
|
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_drag_motion:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @dest_window: the new destination window, obtained by
|
|
|
|
* gdk_drag_find_window()
|
|
|
|
* @protocol: the DND protocol in use, obtained by gdk_drag_find_window()
|
|
|
|
* @x_root: the x position of the pointer in root coordinates
|
|
|
|
* @y_root: the y position of the pointer in root coordinates
|
|
|
|
* @suggested_action: the suggested action
|
|
|
|
* @possible_actions: the possible actions
|
|
|
|
* @time_: the timestamp for this operation
|
|
|
|
*
|
|
|
|
* Updates the drag context when the pointer moves or the
|
|
|
|
* set of actions changes.
|
|
|
|
*
|
|
|
|
* This function is called by the drag source.
|
2013-09-17 05:13:03 +00:00
|
|
|
*
|
2016-01-18 21:22:24 +00:00
|
|
|
* This function does not need to be called in managed drag and drop
|
|
|
|
* operations. See gdk_drag_context_manage_dnd() for more information.
|
|
|
|
*
|
2013-09-17 05:13:03 +00:00
|
|
|
* Returns:
|
2010-12-10 06:27:10 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gdk_drag_motion (GdkDragContext *context,
|
|
|
|
GdkWindow *dest_window,
|
|
|
|
GdkDragProtocol protocol,
|
|
|
|
gint x_root,
|
|
|
|
gint y_root,
|
|
|
|
GdkDragAction suggested_action,
|
|
|
|
GdkDragAction possible_actions,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
|
|
|
|
|
|
|
|
return GDK_DRAG_CONTEXT_GET_CLASS (context)
|
|
|
|
->drag_motion (context,
|
|
|
|
dest_window,
|
|
|
|
protocol,
|
|
|
|
x_root,
|
|
|
|
y_root,
|
|
|
|
suggested_action,
|
|
|
|
possible_actions,
|
|
|
|
time_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_abort:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @time_: the timestamp for this operation
|
|
|
|
*
|
|
|
|
* Aborts a drag without dropping.
|
|
|
|
*
|
|
|
|
* This function is called by the drag source.
|
2016-01-18 21:22:24 +00:00
|
|
|
*
|
|
|
|
* This function does not need to be called in managed drag and drop
|
|
|
|
* operations. See gdk_drag_context_manage_dnd() for more information.
|
2010-12-10 06:27:10 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drag_abort (GdkDragContext *context,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
|
|
|
GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_abort (context, time_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_drop:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @time_: the timestamp for this operation
|
|
|
|
*
|
|
|
|
* Drops on the current destination.
|
|
|
|
*
|
|
|
|
* This function is called by the drag source.
|
2016-01-18 21:22:24 +00:00
|
|
|
*
|
|
|
|
* This function does not need to be called in managed drag and drop
|
|
|
|
* operations. See gdk_drag_context_manage_dnd() for more information.
|
2010-12-10 06:27:10 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drag_drop (GdkDragContext *context,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
|
|
|
GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_drop (context, time_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drop_reply:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @accepted: %TRUE if the drop is accepted
|
|
|
|
* @time_: the timestamp for this operation
|
|
|
|
*
|
|
|
|
* Accepts or rejects a drop.
|
|
|
|
*
|
|
|
|
* This function is called by the drag destination in response
|
|
|
|
* to a drop initiated by the drag source.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drop_reply (GdkDragContext *context,
|
|
|
|
gboolean accepted,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
|
|
|
GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_reply (context, accepted, time_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drop_finish:
|
2014-01-20 22:40:01 +00:00
|
|
|
* @context: a #GdkDragContext
|
2010-12-10 06:27:10 +00:00
|
|
|
* @success: %TRUE if the data was successfully received
|
|
|
|
* @time_: the timestamp for this operation
|
|
|
|
*
|
|
|
|
* Ends the drag operation after a drop.
|
|
|
|
*
|
|
|
|
* This function is called by the drag destination.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drop_finish (GdkDragContext *context,
|
|
|
|
gboolean success,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
|
|
|
GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_finish (context, success, time_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_drop_succeeded:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Returns whether the dropped data has been successfully
|
|
|
|
* transferred. This function is intended to be used while
|
|
|
|
* handling a %GDK_DROP_FINISHED event, its return value is
|
|
|
|
* meaningless at other times.
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: %TRUE if the drop was successful.
|
2010-12-10 06:27:10 +00:00
|
|
|
*
|
|
|
|
* Since: 2.6
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gdk_drag_drop_succeeded (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
|
|
|
|
|
|
|
|
return GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_status (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_get_selection:
|
|
|
|
* @context: a #GdkDragContext.
|
|
|
|
*
|
|
|
|
* Returns the selection atom for the current source window.
|
|
|
|
*
|
2017-11-15 17:13:31 +00:00
|
|
|
* Returns: (transfer none): the selection atom, or %NULL
|
2010-12-10 06:27:10 +00:00
|
|
|
*/
|
|
|
|
GdkAtom
|
|
|
|
gdk_drag_get_selection (GdkDragContext *context)
|
|
|
|
{
|
2017-11-15 17:13:31 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
2010-12-10 06:27:10 +00:00
|
|
|
|
|
|
|
return GDK_DRAG_CONTEXT_GET_CLASS (context)->get_selection (context);
|
|
|
|
}
|
2015-12-02 04:33:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_get_drag_window:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
*
|
|
|
|
* Returns the window on which the drag icon should be rendered
|
|
|
|
* during the drag operation. Note that the window may not be
|
|
|
|
* available until the drag operation has begun. GDK will move
|
|
|
|
* the window in accordance with the ongoing drag operation.
|
|
|
|
* The window is owned by @context and will be destroyed when
|
|
|
|
* the drag operation is over.
|
|
|
|
*
|
2016-09-22 11:56:47 +00:00
|
|
|
* Returns: (nullable) (transfer none): the drag window, or %NULL
|
2015-12-02 04:33:53 +00:00
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
*/
|
|
|
|
GdkWindow *
|
|
|
|
gdk_drag_context_get_drag_window (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_window)
|
|
|
|
return GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_window (context);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-12-08 02:52:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_set_hotspot:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @hot_x: x coordinate of the drag window hotspot
|
|
|
|
* @hot_y: y coordinate of the drag window hotspot
|
|
|
|
*
|
|
|
|
* Sets the position of the drag window that will be kept
|
|
|
|
* under the cursor hotspot. Initially, the hotspot is at the
|
|
|
|
* top left corner of the drag window.
|
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drag_context_set_hotspot (GdkDragContext *context,
|
|
|
|
gint hot_x,
|
|
|
|
gint hot_y)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
|
|
|
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot)
|
|
|
|
GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot (context, hot_x, hot_y);
|
|
|
|
}
|
2015-12-07 20:07:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_drop_done:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @success: whether the drag was ultimatively successful
|
|
|
|
*
|
|
|
|
* Inform GDK if the drop ended successfully. Passing %FALSE
|
|
|
|
* for @success may trigger a drag cancellation animation.
|
|
|
|
*
|
|
|
|
* This function is called by the drag source, and should
|
|
|
|
* be the last call before dropping the reference to the
|
|
|
|
* @context.
|
|
|
|
*
|
2016-02-15 17:56:42 +00:00
|
|
|
* The #GdkDragContext will only take the first gdk_drag_drop_done()
|
|
|
|
* call as effective, if this function is called multiple times,
|
|
|
|
* all subsequent calls will be ignored.
|
|
|
|
*
|
2015-12-07 20:07:13 +00:00
|
|
|
* Since: 3.20
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gdk_drag_drop_done (GdkDragContext *context,
|
|
|
|
gboolean success)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
2016-02-15 17:56:42 +00:00
|
|
|
if (context->drop_done)
|
|
|
|
return;
|
|
|
|
|
|
|
|
context->drop_done = TRUE;
|
|
|
|
|
2015-12-07 20:07:13 +00:00
|
|
|
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done)
|
|
|
|
GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done (context, success);
|
|
|
|
}
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_drag_context_manage_dnd:
|
|
|
|
* @context: a #GdkDragContext
|
|
|
|
* @ipc_window: Window to use for IPC messaging/events
|
|
|
|
* @actions: the actions supported by the drag source
|
|
|
|
*
|
|
|
|
* Requests the drag and drop operation to be managed by @context.
|
|
|
|
* When a drag and drop operation becomes managed, the #GdkDragContext
|
|
|
|
* will internally handle all input and source-side #GdkEventDND events
|
|
|
|
* as required by the windowing system.
|
|
|
|
*
|
|
|
|
* Once the drag and drop operation is managed, the drag context will
|
|
|
|
* emit the following signals:
|
|
|
|
* - The #GdkDragContext::action-changed signal whenever the final action
|
|
|
|
* to be performed by the drag and drop operation changes.
|
|
|
|
* - The #GdkDragContext::drop-performed signal after the user performs
|
|
|
|
* the drag and drop gesture (typically by releasing the mouse button).
|
|
|
|
* - The #GdkDragContext::dnd-finished signal after the drag and drop
|
|
|
|
* operation concludes (after all #GdkSelection transfers happen).
|
|
|
|
* - The #GdkDragContext::cancel signal if the drag and drop operation is
|
|
|
|
* finished but doesn't happen over an accepting destination, or is
|
|
|
|
* cancelled through other means.
|
|
|
|
*
|
|
|
|
* Returns: #TRUE if the drag and drop operation is managed.
|
2016-03-21 02:45:06 +00:00
|
|
|
*
|
|
|
|
* Since: 3.20
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gdk_drag_context_manage_dnd (GdkDragContext *context,
|
|
|
|
GdkWindow *ipc_window,
|
|
|
|
GdkDragAction actions)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
|
|
|
|
g_return_val_if_fail (GDK_IS_WINDOW (ipc_window), FALSE);
|
|
|
|
|
|
|
|
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->manage_dnd)
|
2016-03-21 02:45:06 +00:00
|
|
|
return GDK_DRAG_CONTEXT_GET_CLASS (context)->manage_dnd (context, ipc_window, actions);
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_drag_context_set_cursor (GdkDragContext *context,
|
|
|
|
GdkCursor *cursor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
|
|
|
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor)
|
|
|
|
GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor (context, cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-15 16:02:14 +00:00
|
|
|
gdk_drag_context_cancel (GdkDragContext *context,
|
|
|
|
GdkDragCancelReason reason)
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
|
2016-02-15 16:02:14 +00:00
|
|
|
g_signal_emit (context, signals[CANCEL], 0, reason);
|
gdk: Allow internal management of source-side DnD
We've traditionally left GTK+ to handle the input side of things,
letting GDK only manage the windowing-specific messaging. This
way of splitting responsibilities is not compatible however with
some backends, we must fold then input management at the DnD stage
into GDK (and backends) domain.
The gdk_drag_context_manage_dnd() call is meant to be the entry
point for this mode of operation, if the drag and drop operation
becomes managed, the caller (i.e. gtkdnd.c) doesn't need to perform
grabs, nor manage input events itself.
As a consequence of this, different aspects now belong to the
backend GdkDragContext implementation:
- Because the caller doesn't see keyboard events anymore,
keyboard navigation must be managed in GDK, so is the decision
of the current action based on modifiers/button pressed.
- Because the caller won't see input events in general, the lifetime
of the drag and drop operation is now communicated through the
::drop-performed, ::dnd-finished and ::cancel events
- Because the caller doesn't participate anymore on the action
being chosen, the pointer cursor must be set by the backend.
The caller is rather notified of the final action through the
::action signal.
The caller is still responsible of dealing with the corresponding
GdkSelection, ensuring its ownership and communicating the supported
mimetypes.
2016-01-08 20:03:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
gdk_drag_context_list (void)
|
|
|
|
{
|
|
|
|
return contexts;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gdk_drag_context_handle_source_event (GdkEvent *event)
|
|
|
|
{
|
|
|
|
GdkDragContext *context;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = contexts; l; l = l->next)
|
|
|
|
{
|
|
|
|
context = l->data;
|
|
|
|
|
|
|
|
if (!context->is_source)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event (context, event))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2016-01-13 19:51:19 +00:00
|
|
|
|
|
|
|
GdkCursor *
|
2016-04-26 07:31:33 +00:00
|
|
|
gdk_drag_get_cursor (GdkDragContext *context,
|
|
|
|
GdkDragAction action)
|
2016-01-13 19:51:19 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < G_N_ELEMENTS (drag_cursors) - 1; i++)
|
|
|
|
if (drag_cursors[i].action == action)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (drag_cursors[i].cursor == NULL)
|
2017-11-03 22:19:22 +00:00
|
|
|
drag_cursors[i].cursor = gdk_cursor_new_from_name (drag_cursors[i].name, NULL);
|
|
|
|
|
2016-01-13 19:51:19 +00:00
|
|
|
return drag_cursors[i].cursor;
|
|
|
|
}
|
2016-03-09 16:00:31 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_drag_context_commit_drag_status (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
GdkDragContextClass *context_class;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
|
|
|
g_return_if_fail (!context->is_source);
|
|
|
|
|
|
|
|
context_class = GDK_DRAG_CONTEXT_GET_CLASS (context);
|
|
|
|
|
|
|
|
if (context_class->commit_drag_status)
|
|
|
|
context_class->commit_drag_status (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gdk_drag_context_handle_dest_event (GdkEvent *event)
|
|
|
|
{
|
|
|
|
GdkDragContext *context = NULL;
|
|
|
|
GList *l;
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
switch ((guint) event->type)
|
2016-03-09 16:00:31 +00:00
|
|
|
{
|
|
|
|
case GDK_DRAG_MOTION:
|
|
|
|
case GDK_DROP_START:
|
|
|
|
context = event->dnd.context;
|
|
|
|
break;
|
|
|
|
case GDK_SELECTION_NOTIFY:
|
|
|
|
for (l = contexts; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkDragContext *c = l->data;
|
|
|
|
|
|
|
|
if (!c->is_source &&
|
|
|
|
event->selection.selection == gdk_drag_get_selection (c))
|
|
|
|
{
|
|
|
|
context = c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gdk_drag_context_commit_drag_status (context);
|
|
|
|
return TRUE;;
|
|
|
|
}
|