forked from AuroraMiddleware/gtk
Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups See merge request GNOME/gtk!243
This commit is contained in:
commit
89f25d1484
@ -104,13 +104,6 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
|
||||
return new_context;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_drag_drop (GdkDrag *context,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_broadway_surface_register_dnd (GdkSurface *surface)
|
||||
{
|
||||
@ -128,6 +121,4 @@ gdk_broadway_drag_class_init (GdkBroadwayDragClass *klass)
|
||||
GdkDragClass *context_class = GDK_DRAG_CLASS (klass);
|
||||
|
||||
object_class->finalize = gdk_broadway_drag_finalize;
|
||||
|
||||
context_class->drag_drop = gdk_broadway_drag_drag_drop;
|
||||
}
|
||||
|
149
gdk/gdkdrag.c
149
gdk/gdkdrag.c
@ -55,6 +55,7 @@ enum {
|
||||
PROP_FORMATS,
|
||||
PROP_SELECTED_ACTION,
|
||||
PROP_ACTIONS,
|
||||
PROP_SURFACE,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
@ -65,11 +66,27 @@ enum {
|
||||
N_SIGNALS
|
||||
};
|
||||
|
||||
typedef struct _GdkDragPrivate GdkDragPrivate;
|
||||
|
||||
struct _GdkDragPrivate {
|
||||
GdkSurface *surface;
|
||||
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
GdkContentFormats *formats;
|
||||
GdkContentProvider *content;
|
||||
|
||||
GdkDragAction actions;
|
||||
GdkDragAction selected_action;
|
||||
|
||||
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
|
||||
static guint signals[N_SIGNALS] = { 0 };
|
||||
static GList *drags = NULL;
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
|
||||
|
||||
/**
|
||||
* SECTION:dnd
|
||||
@ -108,9 +125,11 @@ G_DEFINE_ABSTRACT_TYPE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
|
||||
GdkDisplay *
|
||||
gdk_drag_get_display (GdkDrag *drag)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
|
||||
|
||||
return drag->display;
|
||||
return priv->display;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,9 +143,11 @@ gdk_drag_get_display (GdkDrag *drag)
|
||||
GdkContentFormats *
|
||||
gdk_drag_get_formats (GdkDrag *drag)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
|
||||
|
||||
return drag->formats;
|
||||
return priv->formats;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,9 +161,11 @@ gdk_drag_get_formats (GdkDrag *drag)
|
||||
GdkDragAction
|
||||
gdk_drag_get_actions (GdkDrag *drag)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
|
||||
|
||||
return drag->actions;
|
||||
return priv->actions;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,9 +179,11 @@ gdk_drag_get_actions (GdkDrag *drag)
|
||||
GdkDragAction
|
||||
gdk_drag_get_selected_action (GdkDrag *drag)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), 0);
|
||||
|
||||
return drag->selected_action;
|
||||
return priv->selected_action;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,9 +197,11 @@ gdk_drag_get_selected_action (GdkDrag *drag)
|
||||
GdkDevice *
|
||||
gdk_drag_get_device (GdkDrag *drag)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DRAG (drag), NULL);
|
||||
|
||||
return drag->device;
|
||||
return priv->device;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -190,38 +217,39 @@ gdk_drag_set_property (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDrag *drag = GDK_DRAG (gobject);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTENT:
|
||||
drag->content = g_value_dup_object (value);
|
||||
if (drag->content)
|
||||
priv->content = g_value_dup_object (value);
|
||||
if (priv->content)
|
||||
{
|
||||
g_assert (drag->formats == NULL);
|
||||
drag->formats = gdk_content_provider_ref_formats (drag->content);
|
||||
g_assert (priv->formats == NULL);
|
||||
priv->formats = gdk_content_provider_ref_formats (priv->content);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEVICE:
|
||||
drag->device = g_value_dup_object (value);
|
||||
g_assert (drag->device != NULL);
|
||||
drag->display = gdk_device_get_display (drag->device);
|
||||
priv->device = g_value_dup_object (value);
|
||||
g_assert (priv->device != NULL);
|
||||
priv->display = gdk_device_get_display (priv->device);
|
||||
break;
|
||||
|
||||
case PROP_FORMATS:
|
||||
if (drag->formats)
|
||||
if (priv->formats)
|
||||
{
|
||||
GdkContentFormats *override = g_value_dup_boxed (value);
|
||||
if (override)
|
||||
{
|
||||
gdk_content_formats_unref (drag->formats);
|
||||
drag->formats = override;
|
||||
gdk_content_formats_unref (priv->formats);
|
||||
priv->formats = override;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
drag->formats = g_value_dup_boxed (value);
|
||||
g_assert (drag->formats != NULL);
|
||||
priv->formats = g_value_dup_boxed (value);
|
||||
g_assert (priv->formats != NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -239,6 +267,11 @@ gdk_drag_set_property (GObject *gobject,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SURFACE:
|
||||
priv->surface = g_value_dup_object (value);
|
||||
g_assert (priv->surface != NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@ -252,31 +285,36 @@ gdk_drag_get_property (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDrag *drag = GDK_DRAG (gobject);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTENT:
|
||||
g_value_set_object (value, drag->content);
|
||||
g_value_set_object (value, priv->content);
|
||||
break;
|
||||
|
||||
case PROP_DEVICE:
|
||||
g_value_set_object (value, drag->device);
|
||||
g_value_set_object (value, priv->device);
|
||||
break;
|
||||
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_object (value, drag->display);
|
||||
g_value_set_object (value, priv->display);
|
||||
break;
|
||||
|
||||
case PROP_FORMATS:
|
||||
g_value_set_boxed (value, drag->formats);
|
||||
g_value_set_boxed (value, priv->formats);
|
||||
break;
|
||||
|
||||
case PROP_SELECTED_ACTION:
|
||||
g_value_set_flags (value, drag->selected_action);
|
||||
g_value_set_flags (value, priv->selected_action);
|
||||
break;
|
||||
|
||||
case PROP_ACTIONS:
|
||||
g_value_set_flags (value, drag->actions);
|
||||
g_value_set_flags (value, priv->actions);
|
||||
break;
|
||||
|
||||
case PROP_SURFACE:
|
||||
g_value_set_object (value, priv->surface);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -289,14 +327,14 @@ static void
|
||||
gdk_drag_finalize (GObject *object)
|
||||
{
|
||||
GdkDrag *drag = GDK_DRAG (object);
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
drags = g_list_remove (drags, drag);
|
||||
|
||||
g_clear_object (&drag->content);
|
||||
g_clear_pointer (&drag->formats, gdk_content_formats_unref);
|
||||
g_clear_object (&priv->content);
|
||||
g_clear_pointer (&priv->formats, gdk_content_formats_unref);
|
||||
|
||||
if (drag->source_surface)
|
||||
g_object_unref (drag->source_surface);
|
||||
g_clear_object (&priv->surface);
|
||||
|
||||
G_OBJECT_CLASS (gdk_drag_parent_class)->finalize (object);
|
||||
}
|
||||
@ -388,6 +426,17 @@ gdk_drag_class_init (GdkDragClass *klass)
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
properties[PROP_SURFACE] =
|
||||
g_param_spec_object ("surface",
|
||||
"Surface",
|
||||
"The surface where the drag originates",
|
||||
GDK_TYPE_SURFACE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GdkDrag::cancel:
|
||||
* @drag: The object on which the signal is emitted
|
||||
@ -439,24 +488,6 @@ gdk_drag_class_init (GdkDragClass *klass)
|
||||
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
||||
}
|
||||
|
||||
/*
|
||||
* gdk_drag_drop:
|
||||
* @drag: a #GdkDrag
|
||||
* @time_: the timestamp for this operation
|
||||
*
|
||||
* Drops on the current destination.
|
||||
*
|
||||
* This function is called by the drag source.
|
||||
*/
|
||||
void
|
||||
gdk_drag_drop (GdkDrag *drag,
|
||||
guint32 time_)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
|
||||
GDK_DRAG_GET_CLASS (drag)->drag_drop (drag, time_);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_write_done (GObject *content,
|
||||
GAsyncResult *result,
|
||||
@ -496,12 +527,13 @@ gdk_drag_write_async (GdkDrag *drag,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
GdkContentFormats *formats, *mime_formats;
|
||||
GTask *task;
|
||||
GType gtype;
|
||||
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
g_return_if_fail (drag->content);
|
||||
g_return_if_fail (priv->content);
|
||||
g_return_if_fail (mime_type != NULL);
|
||||
g_return_if_fail (mime_type == g_intern_string (mime_type));
|
||||
g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
|
||||
@ -512,10 +544,10 @@ gdk_drag_write_async (GdkDrag *drag,
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_drag_write_async);
|
||||
|
||||
formats = gdk_content_provider_ref_formats (drag->content);
|
||||
formats = gdk_content_provider_ref_formats (priv->content);
|
||||
if (gdk_content_formats_contain_mime_type (formats, mime_type))
|
||||
{
|
||||
gdk_content_provider_write_mime_type_async (drag->content,
|
||||
gdk_content_provider_write_mime_type_async (priv->content,
|
||||
mime_type,
|
||||
stream,
|
||||
io_priority,
|
||||
@ -537,7 +569,7 @@ gdk_drag_write_async (GdkDrag *drag,
|
||||
g_assert (gtype != G_TYPE_INVALID);
|
||||
|
||||
g_value_init (&value, gtype);
|
||||
if (gdk_content_provider_get_value (drag->content, &value, &error))
|
||||
if (gdk_content_provider_get_value (priv->content, &value, &error))
|
||||
{
|
||||
gdk_content_serialize_async (stream,
|
||||
mime_type,
|
||||
@ -580,10 +612,12 @@ void
|
||||
gdk_drag_set_actions (GdkDrag *drag,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
if (drag->actions == actions)
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
if (priv->actions == actions)
|
||||
return;
|
||||
|
||||
drag->actions = actions;
|
||||
priv->actions = actions;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (drag), properties[PROP_ACTIONS]);
|
||||
}
|
||||
@ -592,12 +626,13 @@ void
|
||||
gdk_drag_set_selected_action (GdkDrag *drag,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
GdkCursor *cursor;
|
||||
|
||||
if (drag->selected_action == action)
|
||||
if (priv->selected_action == action)
|
||||
return;
|
||||
|
||||
drag->selected_action = action;
|
||||
priv->selected_action = action;
|
||||
|
||||
cursor = gdk_drag_get_cursor (drag, action);
|
||||
gdk_drag_set_cursor (drag, cursor);
|
||||
@ -670,12 +705,14 @@ void
|
||||
gdk_drag_drop_done (GdkDrag *drag,
|
||||
gboolean success)
|
||||
{
|
||||
GdkDragPrivate *priv = gdk_drag_get_instance_private (drag);
|
||||
|
||||
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||
|
||||
if (drag->drop_done)
|
||||
if (priv->drop_done)
|
||||
return;
|
||||
|
||||
drag->drop_done = TRUE;
|
||||
priv->drop_done = TRUE;
|
||||
|
||||
if (GDK_DRAG_GET_CLASS (drag)->drop_done)
|
||||
GDK_DRAG_GET_CLASS (drag)->drop_done (drag, success);
|
||||
|
@ -33,8 +33,6 @@ typedef struct _GdkDragClass GdkDragClass;
|
||||
struct _GdkDragClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*drag_drop) (GdkDrag *drag,
|
||||
guint32 time_);
|
||||
GdkSurface* (*get_drag_surface) (GdkDrag *drag);
|
||||
void (*set_hotspot) (GdkDrag *drag,
|
||||
gint hot_x,
|
||||
@ -56,20 +54,6 @@ struct _GdkDragClass {
|
||||
|
||||
struct _GdkDrag {
|
||||
GObject parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
GdkSurface *source_surface;
|
||||
GdkSurface *drag_surface;
|
||||
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
GdkContentFormats *formats;
|
||||
GdkContentProvider *content;
|
||||
|
||||
GdkDragAction actions;
|
||||
GdkDragAction selected_action;
|
||||
|
||||
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
|
||||
};
|
||||
|
||||
void gdk_drag_set_cursor (GdkDrag *drag,
|
||||
@ -85,9 +69,6 @@ gboolean gdk_drag_handle_source_event (GdkEvent *event);
|
||||
GdkCursor * gdk_drag_get_cursor (GdkDrag *drag,
|
||||
GdkDragAction action);
|
||||
|
||||
void gdk_drag_drop (GdkDrag *drag,
|
||||
guint32 time_);
|
||||
|
||||
void gdk_drag_write_async (GdkDrag *drag,
|
||||
const char *mime_type,
|
||||
GOutputStream *stream,
|
||||
|
130
gdk/gdkdrop.c
130
gdk/gdkdrop.c
@ -34,6 +34,16 @@
|
||||
#include "gdkpipeiostreamprivate.h"
|
||||
#include "gdksurface.h"
|
||||
|
||||
typedef struct _GdkDropPrivate GdkDropPrivate;
|
||||
|
||||
struct _GdkDropPrivate {
|
||||
GdkDevice *device;
|
||||
GdkDrag *drag;
|
||||
GdkContentFormats *formats;
|
||||
GdkSurface *surface;
|
||||
GdkDragAction actions;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ACTIONS,
|
||||
@ -47,7 +57,7 @@ enum {
|
||||
|
||||
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GdkDrop, gdk_drop, G_TYPE_OBJECT)
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrop, gdk_drop, G_TYPE_OBJECT)
|
||||
|
||||
/**
|
||||
* GdkDrop:
|
||||
@ -84,15 +94,17 @@ gdk_drop_read_local_async (GdkDrop *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkContentFormats *content_formats;
|
||||
const char *mime_type;
|
||||
GTask *task;
|
||||
GdkContentProvider *content;
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_priority (task, io_priority);
|
||||
g_task_set_source_tag (task, gdk_drop_read_local_async);
|
||||
|
||||
if (self->drag == NULL)
|
||||
if (priv->drag == NULL)
|
||||
{
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Drag'n'drop from other applications is not supported."));
|
||||
@ -100,7 +112,9 @@ gdk_drop_read_local_async (GdkDrop *self,
|
||||
return;
|
||||
}
|
||||
|
||||
content_formats = gdk_content_provider_ref_formats (self->drag->content);
|
||||
g_object_get (priv->drag, "content", &content, NULL);
|
||||
content_formats = gdk_content_provider_ref_formats (content);
|
||||
g_object_unref (content);
|
||||
content_formats = gdk_content_formats_union_serialize_mime_types (content_formats);
|
||||
mime_type = gdk_content_formats_match_mime_type (content_formats, formats);
|
||||
|
||||
@ -111,7 +125,7 @@ gdk_drop_read_local_async (GdkDrop *self,
|
||||
|
||||
stream = gdk_pipe_io_stream_new ();
|
||||
output_stream = g_io_stream_get_output_stream (stream);
|
||||
gdk_drag_write_async (self->drag,
|
||||
gdk_drag_write_async (priv->drag,
|
||||
mime_type,
|
||||
output_stream,
|
||||
io_priority,
|
||||
@ -155,6 +169,7 @@ gdk_drop_set_property (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDrop *self = GDK_DROP (gobject);
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -163,26 +178,26 @@ gdk_drop_set_property (GObject *gobject,
|
||||
break;
|
||||
|
||||
case PROP_DEVICE:
|
||||
self->device = g_value_dup_object (value);
|
||||
g_assert (self->device != NULL);
|
||||
if (self->surface)
|
||||
g_assert (gdk_surface_get_display (self->surface) == gdk_device_get_display (self->device));
|
||||
priv->device = g_value_dup_object (value);
|
||||
g_assert (priv->device != NULL);
|
||||
if (priv->surface)
|
||||
g_assert (gdk_surface_get_display (priv->surface) == gdk_device_get_display (priv->device));
|
||||
break;
|
||||
|
||||
case PROP_DRAG:
|
||||
self->drag = g_value_dup_object (value);
|
||||
priv->drag = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_FORMATS:
|
||||
self->formats = g_value_dup_boxed (value);
|
||||
g_assert (self->formats != NULL);
|
||||
priv->formats = g_value_dup_boxed (value);
|
||||
g_assert (priv->formats != NULL);
|
||||
break;
|
||||
|
||||
case PROP_SURFACE:
|
||||
self->surface = g_value_dup_object (value);
|
||||
g_assert (self->surface != NULL);
|
||||
if (self->device)
|
||||
g_assert (gdk_surface_get_display (self->surface) == gdk_device_get_display (self->device));
|
||||
priv->surface = g_value_dup_object (value);
|
||||
g_assert (priv->surface != NULL);
|
||||
if (priv->device)
|
||||
g_assert (gdk_surface_get_display (priv->surface) == gdk_device_get_display (priv->device));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -198,31 +213,32 @@ gdk_drop_get_property (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkDrop *self = GDK_DROP (gobject);
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACTIONS:
|
||||
g_value_set_flags (value, self->actions);
|
||||
g_value_set_flags (value, priv->actions);
|
||||
break;
|
||||
|
||||
case PROP_DEVICE:
|
||||
g_value_set_object (value, self->device);
|
||||
g_value_set_object (value, priv->device);
|
||||
break;
|
||||
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_object (value, gdk_device_get_display (self->device));
|
||||
g_value_set_object (value, gdk_device_get_display (priv->device));
|
||||
break;
|
||||
|
||||
case PROP_DRAG:
|
||||
g_value_set_object (value, self->drag);
|
||||
g_value_set_object (value, priv->drag);
|
||||
break;
|
||||
|
||||
case PROP_FORMATS:
|
||||
g_value_set_boxed (value, self->formats);
|
||||
g_value_set_boxed (value, priv->formats);
|
||||
break;
|
||||
|
||||
case PROP_SURFACE:
|
||||
g_value_set_object (value, self->surface);
|
||||
g_value_set_object (value, priv->surface);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -235,9 +251,10 @@ static void
|
||||
gdk_drop_finalize (GObject *object)
|
||||
{
|
||||
GdkDrop *self = GDK_DROP (object);
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_clear_object (&self->device);
|
||||
g_clear_object (&self->drag);
|
||||
g_clear_object (&priv->device);
|
||||
g_clear_object (&priv->drag);
|
||||
|
||||
G_OBJECT_CLASS (gdk_drop_parent_class)->finalize (object);
|
||||
}
|
||||
@ -362,9 +379,11 @@ gdk_drop_init (GdkDrop *self)
|
||||
GdkDisplay *
|
||||
gdk_drop_get_display (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DROP (self), NULL);
|
||||
|
||||
return gdk_device_get_display (self->device);
|
||||
return gdk_device_get_display (priv->device);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -378,9 +397,11 @@ gdk_drop_get_display (GdkDrop *self)
|
||||
GdkDevice *
|
||||
gdk_drop_get_device (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DROP (self), NULL);
|
||||
|
||||
return self->device;
|
||||
return priv->device;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,9 +416,11 @@ gdk_drop_get_device (GdkDrop *self)
|
||||
GdkContentFormats *
|
||||
gdk_drop_get_formats (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DROP (self), NULL);
|
||||
|
||||
return self->formats;
|
||||
return priv->formats;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -411,9 +434,11 @@ gdk_drop_get_formats (GdkDrop *self)
|
||||
GdkSurface *
|
||||
gdk_drop_get_surface (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DROP (self), NULL);
|
||||
|
||||
return self->surface;
|
||||
return priv->surface;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,22 +460,26 @@ gdk_drop_get_surface (GdkDrop *self)
|
||||
GdkDragAction
|
||||
gdk_drop_get_actions (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DROP (self), 0);
|
||||
|
||||
return self->actions;
|
||||
return priv->actions;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_drop_set_actions (GdkDrop *self,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GDK_IS_DROP (self));
|
||||
g_return_if_fail ((actions & GDK_ACTION_ASK) == 0);
|
||||
|
||||
if (self->actions == actions)
|
||||
if (priv->actions == actions)
|
||||
return;
|
||||
|
||||
self->actions = actions;
|
||||
priv->actions = actions;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIONS]);
|
||||
}
|
||||
@ -469,9 +498,11 @@ gdk_drop_set_actions (GdkDrop *self,
|
||||
GdkDrag *
|
||||
gdk_drop_get_drag (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DROP (self), 0);
|
||||
|
||||
return self->drag;
|
||||
return priv->drag;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -529,7 +560,9 @@ gdk_drop_read_internal (GdkDrop *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (self->drag)
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
if (priv->drag)
|
||||
{
|
||||
gdk_drop_read_local_async (self,
|
||||
formats,
|
||||
@ -678,6 +711,7 @@ gdk_drop_read_value_internal (GdkDrop *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkContentFormatsBuilder *builder;
|
||||
GdkContentFormats *formats;
|
||||
GValue *value;
|
||||
@ -690,11 +724,19 @@ gdk_drop_read_value_internal (GdkDrop *self,
|
||||
g_value_init (value, type);
|
||||
g_task_set_task_data (task, value, free_value);
|
||||
|
||||
if (self->drag)
|
||||
if (priv->drag)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GdkContentProvider *content;
|
||||
gboolean res;
|
||||
|
||||
if (gdk_content_provider_get_value (self->drag->content, value, &error))
|
||||
g_object_get (priv->drag, "content", &content, NULL);
|
||||
|
||||
res = gdk_content_provider_get_value (content, value, &error);
|
||||
|
||||
g_object_unref (content);
|
||||
|
||||
if (res)
|
||||
{
|
||||
g_task_return_pointer (task, value, NULL);
|
||||
g_object_unref (task);
|
||||
@ -875,13 +917,14 @@ gdk_drop_emit_enter_event (GdkDrop *self,
|
||||
gboolean dont_queue,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_DRAG_ENTER);
|
||||
event->any.surface = g_object_ref (self->surface);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
gdk_event_set_device (event, self->device);
|
||||
gdk_event_set_device (event, priv->device);
|
||||
|
||||
gdk_drop_do_emit_event (event, dont_queue);
|
||||
}
|
||||
@ -893,15 +936,16 @@ gdk_drop_emit_motion_event (GdkDrop *self,
|
||||
double y_root,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_DRAG_MOTION);
|
||||
event->any.surface = g_object_ref (self->surface);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
event->dnd.x_root = x_root;
|
||||
event->dnd.y_root = y_root;
|
||||
gdk_event_set_device (event, self->device);
|
||||
gdk_event_set_device (event, priv->device);
|
||||
|
||||
gdk_drop_do_emit_event (event, dont_queue);
|
||||
}
|
||||
@ -911,13 +955,14 @@ gdk_drop_emit_leave_event (GdkDrop *self,
|
||||
gboolean dont_queue,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_DRAG_LEAVE);
|
||||
event->any.surface = g_object_ref (self->surface);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
gdk_event_set_device (event, self->device);
|
||||
gdk_event_set_device (event, priv->device);
|
||||
|
||||
gdk_drop_do_emit_event (event, dont_queue);
|
||||
}
|
||||
@ -929,15 +974,16 @@ gdk_drop_emit_drop_event (GdkDrop *self,
|
||||
double y_root,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_DROP_START);
|
||||
event->any.surface = g_object_ref (self->surface);
|
||||
event->any.surface = g_object_ref (priv->surface);
|
||||
event->dnd.drop = g_object_ref (self);
|
||||
event->dnd.time = time;
|
||||
event->dnd.x_root = x_root;
|
||||
event->dnd.y_root = y_root;
|
||||
gdk_event_set_device (event, self->device);
|
||||
gdk_event_set_device (event, priv->device);
|
||||
|
||||
gdk_drop_do_emit_event (event, dont_queue);
|
||||
}
|
||||
|
@ -34,12 +34,6 @@ typedef struct _GdkDropClass GdkDropClass;
|
||||
|
||||
struct _GdkDrop {
|
||||
GObject parent_instance;
|
||||
|
||||
GdkDevice *device;
|
||||
GdkDrag *drag;
|
||||
GdkContentFormats *formats;
|
||||
GdkSurface *surface;
|
||||
GdkDragAction actions;
|
||||
};
|
||||
|
||||
struct _GdkDropClass {
|
||||
|
@ -104,12 +104,6 @@ gdk_to_wl_actions (GdkDragAction action)
|
||||
return dnd_actions;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_drag_drop (GdkDrag *drag,
|
||||
guint32 time)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_init (GdkWaylandDrag *drag_wayland)
|
||||
{
|
||||
@ -196,7 +190,6 @@ gdk_wayland_drag_class_init (GdkWaylandDragClass *klass)
|
||||
|
||||
object_class->finalize = gdk_wayland_drag_finalize;
|
||||
|
||||
drag_class->drag_drop = gdk_wayland_drag_drag_drop;
|
||||
drag_class->get_drag_surface = gdk_wayland_drag_get_drag_surface;
|
||||
drag_class->set_hotspot = gdk_wayland_drag_set_hotspot;
|
||||
drag_class->drop_done = gdk_wayland_drag_drop_done;
|
||||
@ -362,7 +355,7 @@ gdk_wayland_drag_create_data_source (GdkDrag *drag)
|
||||
}
|
||||
|
||||
GdkDrag *
|
||||
_gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
_gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
@ -379,11 +372,13 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
seat = gdk_device_get_seat (device);
|
||||
|
||||
drag_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG,
|
||||
"surface", surface,
|
||||
"device", device,
|
||||
"content", content,
|
||||
"actions", actions,
|
||||
NULL);
|
||||
|
||||
drag = GDK_DRAG (drag_wayland);
|
||||
drag->source_surface = g_object_ref (surface);
|
||||
|
||||
drag_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
|
||||
drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface);
|
||||
@ -412,14 +407,3 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
||||
|
||||
return drag;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_drag_set_source_surface (GdkDrag *drag,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
if (drag->source_surface)
|
||||
g_object_unref (drag->source_surface);
|
||||
|
||||
drag->source_surface = surface ? g_object_ref (surface) : NULL;
|
||||
}
|
||||
|
||||
|
@ -115,9 +115,6 @@ void gdk_wayland_drop_set_source_actions (GdkDrop
|
||||
void gdk_wayland_drop_set_action (GdkDrop *drop,
|
||||
uint32_t action);
|
||||
|
||||
void _gdk_wayland_drag_set_source_surface (GdkDrag *drag,
|
||||
GdkSurface *surface);
|
||||
|
||||
void _gdk_wayland_display_create_surface_impl (GdkDisplay *display,
|
||||
GdkSurface *surface,
|
||||
GdkSurface *real_parent,
|
||||
|
@ -785,6 +785,7 @@ gdk_win32_drag_finalize (GObject *object)
|
||||
|
||||
static GdkDrag *
|
||||
gdk_drag_new (GdkDisplay *display,
|
||||
GdkSurface *surface,
|
||||
GdkContentProvider *content,
|
||||
GdkDragAction actions,
|
||||
GdkDevice *device,
|
||||
@ -797,6 +798,8 @@ gdk_drag_new (GdkDisplay *display,
|
||||
drag_win32 = g_object_new (GDK_TYPE_WIN32_DRAG,
|
||||
"device", device,
|
||||
"content", content,
|
||||
"surface", surface,
|
||||
"actions", actions,
|
||||
NULL);
|
||||
|
||||
drag = GDK_DRAG (drag_win32);
|
||||
@ -806,7 +809,6 @@ gdk_drag_new (GdkDisplay *display,
|
||||
else
|
||||
drag_win32->scale = _gdk_win32_display_get_monitor_scale_factor (win32_display, NULL, NULL, NULL);
|
||||
|
||||
gdk_drag_set_actions (drag, actions);
|
||||
drag_win32->protocol = protocol;
|
||||
|
||||
return drag;
|
||||
@ -1590,19 +1592,24 @@ source_context_new (GdkDrag *drag,
|
||||
{
|
||||
GdkWin32Drag *drag_win32;
|
||||
source_drag_context *result;
|
||||
GdkSurface *surface;
|
||||
|
||||
drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
g_object_get (drag, "surface", &surface, NULL);
|
||||
|
||||
result = g_new0 (source_drag_context, 1);
|
||||
result->drag = g_object_ref (drag);
|
||||
result->ids.lpVtbl = &ids_vtbl;
|
||||
result->idsn.lpVtbl = &idsn_vtbl;
|
||||
result->ref_count = 1;
|
||||
result->source_window_handle = GDK_SURFACE_HWND (drag->source_surface);
|
||||
result->source_window_handle = GDK_SURFACE_HWND (surface);
|
||||
result->scale = drag_win32->scale;
|
||||
result->util_data.state = GDK_WIN32_DND_PENDING; /* Implicit */
|
||||
result->dest_window_handle = INVALID_HANDLE_VALUE;
|
||||
|
||||
g_object_unref (surface);
|
||||
|
||||
GDK_NOTE (DND, g_print ("source_context_new: %p (drag %p)\n", result, result->drag));
|
||||
|
||||
return result;
|
||||
@ -1715,14 +1722,13 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
|
||||
g_return_val_if_fail (surface != NULL, NULL);
|
||||
|
||||
drag = gdk_drag_new (gdk_surface_get_display (surface),
|
||||
surface,
|
||||
content,
|
||||
actions,
|
||||
device,
|
||||
use_ole2_dnd ? GDK_DRAG_PROTO_OLE2 : GDK_DRAG_PROTO_LOCAL);
|
||||
drag_win32 = GDK_WIN32_DRAG (drag);
|
||||
|
||||
g_set_object (&drag->source_surface, surface);
|
||||
|
||||
GDK_NOTE (DND, g_print ("_gdk_win32_surface_drag_begin\n"));
|
||||
|
||||
gdk_device_get_position (device, &x_root, &y_root);
|
||||
@ -2287,7 +2293,8 @@ gdk_win32_drag_drop_performed (GdkDrag *drag,
|
||||
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop_performed: 0x%p %u\n",
|
||||
drag,
|
||||
time_));
|
||||
gdk_drag_drop (drag, time_);
|
||||
|
||||
gdk_win32_drag_drop (drag, time_);
|
||||
gdk_drag_set_cursor (drag, NULL);
|
||||
drag_context_ungrab (drag);
|
||||
}
|
||||
@ -2564,8 +2571,6 @@ gdk_win32_drag_class_init (GdkWin32DragClass *klass)
|
||||
|
||||
object_class->finalize = gdk_win32_drag_finalize;
|
||||
|
||||
drag_class->drag_drop = gdk_win32_drag_drop;
|
||||
|
||||
drag_class->get_drag_surface = gdk_win32_drag_get_drag_surface;
|
||||
drag_class->set_hotspot = gdk_win32_drag_set_hotspot;
|
||||
drag_class->drop_done = gdk_win32_drag_drop_done;
|
||||
|
@ -196,7 +196,7 @@ static gboolean gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
GdkDragAction suggested_action,
|
||||
GdkDragAction possible_actions,
|
||||
guint32 time);
|
||||
static void gdk_x11_drag_drag_drop (GdkDrag *drag,
|
||||
static void gdk_x11_drag_drop (GdkDrag *drag,
|
||||
guint32 time_);
|
||||
static GdkSurface * gdk_x11_drag_get_drag_surface (GdkDrag *drag);
|
||||
static void gdk_x11_drag_set_hotspot (GdkDrag *drag,
|
||||
@ -219,7 +219,6 @@ gdk_x11_drag_class_init (GdkX11DragClass *klass)
|
||||
|
||||
object_class->finalize = gdk_x11_drag_finalize;
|
||||
|
||||
drag_class->drag_drop = gdk_x11_drag_drag_drop;
|
||||
drag_class->get_drag_surface = gdk_x11_drag_get_drag_surface;
|
||||
drag_class->set_hotspot = gdk_x11_drag_set_hotspot;
|
||||
drag_class->drop_done = gdk_x11_drag_drop_done;
|
||||
@ -241,7 +240,7 @@ gdk_x11_drag_finalize (GObject *object)
|
||||
|
||||
drags = g_list_remove (drags, drag);
|
||||
|
||||
drag_surface = drag->drag_surface;
|
||||
drag_surface = x11_drag->drag_surface;
|
||||
ipc_surface = x11_drag->ipc_surface;
|
||||
|
||||
G_OBJECT_CLASS (gdk_x11_drag_parent_class)->finalize (object);
|
||||
@ -263,6 +262,8 @@ gdk_x11_drag_find (GdkDisplay *display,
|
||||
GdkDrag *drag;
|
||||
GdkX11Drag *drag_x11;
|
||||
Window drag_dest_xid;
|
||||
GdkSurface *surface;
|
||||
Window surface_xid;
|
||||
|
||||
for (tmp_list = drags; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
@ -272,14 +273,17 @@ gdk_x11_drag_find (GdkDisplay *display,
|
||||
if (gdk_drag_get_display (drag) != display)
|
||||
continue;
|
||||
|
||||
g_object_get (drag, "surface", &surface, NULL);
|
||||
surface_xid = surface ? GDK_SURFACE_XID (surface) : None;
|
||||
g_object_unref (surface);
|
||||
|
||||
drag_dest_xid = drag_x11->proxy_xid
|
||||
? (drag_x11->drop_xid
|
||||
? drag_x11->drop_xid
|
||||
: drag_x11->proxy_xid)
|
||||
: None;
|
||||
|
||||
if (((source_xid == None) || (drag->source_surface &&
|
||||
(GDK_SURFACE_XID (drag->source_surface) == source_xid))) &&
|
||||
if (((source_xid == None) || (surface && (surface_xid == source_xid))) &&
|
||||
((dest_xid == None) || (drag_dest_xid == dest_xid)))
|
||||
return drag;
|
||||
}
|
||||
@ -1600,8 +1604,8 @@ gdk_x11_drag_drag_motion (GdkDrag *drag,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_drag_drag_drop (GdkDrag *drag,
|
||||
guint32 time)
|
||||
gdk_x11_drag_drop (GdkDrag *drag,
|
||||
guint32 time)
|
||||
{
|
||||
GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag);
|
||||
|
||||
@ -2074,13 +2078,18 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
|
||||
GdkDisplay *display;
|
||||
int x_root, y_root;
|
||||
Atom xselection;
|
||||
GdkSurface *ipc_surface;
|
||||
|
||||
display = gdk_surface_get_display (surface);
|
||||
|
||||
ipc_surface = gdk_surface_new_popup (display, &(GdkRectangle) { -99, -99, 1, 1 });
|
||||
|
||||
drag = (GdkDrag *) g_object_new (GDK_TYPE_X11_DRAG,
|
||||
"device", device,
|
||||
"content", content,
|
||||
NULL);
|
||||
"surface", ipc_surface,
|
||||
"device", device,
|
||||
"content", content,
|
||||
"actions", actions,
|
||||
NULL);
|
||||
x11_drag = GDK_X11_DRAG (drag);
|
||||
|
||||
g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_drag_xevent), drag);
|
||||
@ -2098,14 +2107,11 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
|
||||
|
||||
x11_drag->protocol = GDK_DRAG_PROTO_XDND;
|
||||
x11_drag->actions = actions;
|
||||
x11_drag->ipc_surface = gdk_surface_new_popup (display, &(GdkRectangle) { -99, -99, 1, 1 });
|
||||
x11_drag->ipc_surface = ipc_surface;
|
||||
if (gdk_surface_get_group (surface))
|
||||
gdk_surface_set_group (x11_drag->ipc_surface, surface);
|
||||
gdk_surface_show (x11_drag->ipc_surface);
|
||||
|
||||
drag->source_surface = x11_drag->ipc_surface;
|
||||
g_object_ref (drag->source_surface);
|
||||
|
||||
x11_drag->drag_surface = create_drag_surface (display);
|
||||
|
||||
if (!drag_grab (drag))
|
||||
@ -2165,7 +2171,7 @@ static void
|
||||
gdk_x11_drag_drop_performed (GdkDrag *drag,
|
||||
guint32 time_)
|
||||
{
|
||||
gdk_drag_drop (drag, time_);
|
||||
gdk_x11_drag_drop (drag, time_);
|
||||
drag_ungrab (drag);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ gdk_x11_sources = files([
|
||||
'gdkdevicemanager-x11.c',
|
||||
'gdkdevicemanager-xi2.c',
|
||||
'gdkdisplay-x11.c',
|
||||
'gdkdnd-x11.c',
|
||||
'gdkdrag-x11.c',
|
||||
'gdkdrop-x11.c',
|
||||
'gdkeventsource.c',
|
||||
'gdkeventtranslator.c',
|
||||
|
Loading…
Reference in New Issue
Block a user