diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-06-29 13:34:14 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-07-02 14:59:26 +0200 |
commit | 7733f646d6985f2d90e43507b8063719e44288ba (patch) | |
tree | 88f3797341f89f429779920e724798bb17a6e564 | |
parent | 88b4076fe5146c84e5a9fb590371c50917be604e (diff) | |
download | gtk+-7733f646d6985f2d90e43507b8063719e44288ba.tar.gz |
gdk: Rename GdkDragContext to GdkDrag
This is to go along with the newly introduced GdkDrop.
This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.
47 files changed, 1191 insertions, 1205 deletions
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c index bdea28dbb3..658c716c4d 100644 --- a/demos/gtk-demo/clipboard.c +++ b/demos/gtk-demo/clipboard.c @@ -120,7 +120,7 @@ get_image_paintable (GtkImage *image) static void drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GdkPaintable *paintable; @@ -128,14 +128,14 @@ drag_begin (GtkWidget *widget, paintable = get_image_paintable (GTK_IMAGE (widget)); if (paintable) { - gtk_drag_set_icon_paintable (context, paintable, -2, -2); + gtk_drag_set_icon_paintable (drag, paintable, -2, -2); g_object_unref (paintable); } } void drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, guint info, gpointer data) diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c index 409695d03b..094ecf0468 100644 --- a/demos/icon-browser/iconbrowserwin.c +++ b/demos/icon-browser/iconbrowserwin.c @@ -376,7 +376,7 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w static void get_image_data (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection, guint target_info, gpointer data) @@ -398,7 +398,7 @@ get_image_data (GtkWidget *widget, static void get_scalable_image_data (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection, guint target_info, gpointer data) diff --git a/gdk/broadway/gdkdnd-broadway.c b/gdk/broadway/gdkdnd-broadway.c index fecf3b9c04..5e0830c15e 100644 --- a/gdk/broadway/gdkdnd-broadway.c +++ b/gdk/broadway/gdkdnd-broadway.c @@ -34,56 +34,56 @@ #include <string.h> -#define GDK_TYPE_BROADWAY_DRAG_CONTEXT (gdk_broadway_drag_context_get_type ()) -#define GDK_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContext)) -#define GDK_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass)) -#define GDK_IS_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT)) -#define GDK_IS_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT)) -#define GDK_BROADWAY_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass)) +#define GDK_TYPE_BROADWAY_DRAG (gdk_broadway_drag_get_type ()) +#define GDK_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDrag)) +#define GDK_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass)) +#define GDK_IS_BROADWAY_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG)) +#define GDK_IS_BROADWAY_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG)) +#define GDK_BROADWAY_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG, GdkBroadwayDragClass)) #ifdef GDK_COMPILATION -typedef struct _GdkBroadwayDragContext GdkBroadwayDragContext; +typedef struct _GdkBroadwayDrag GdkBroadwayDrag; #else -typedef GdkDragContext GdkBroadwayDragContext; +typedef GdkDrag GdkBroadwayDrag; #endif -typedef struct _GdkBroadwayDragContextClass GdkBroadwayDragContextClass; +typedef struct _GdkBroadwayDragClass GdkBroadwayDragClass; -GType gdk_broadway_drag_context_get_type (void); +GType gdk_broadway_drag_get_type (void); -struct _GdkBroadwayDragContext { - GdkDragContext context; +struct _GdkBroadwayDrag { + GdkDrag context; }; -struct _GdkBroadwayDragContextClass +struct _GdkBroadwayDragClass { - GdkDragContextClass parent_class; + GdkDragClass parent_class; }; -static void gdk_broadway_drag_context_finalize (GObject *object); +static void gdk_broadway_drag_finalize (GObject *object); static GList *contexts; -G_DEFINE_TYPE (GdkBroadwayDragContext, gdk_broadway_drag_context, GDK_TYPE_DRAG_CONTEXT) +G_DEFINE_TYPE (GdkBroadwayDrag, gdk_broadway_drag, GDK_TYPE_DRAG) static void -gdk_broadway_drag_context_init (GdkBroadwayDragContext *dragcontext) +gdk_broadway_drag_init (GdkBroadwayDrag *dragcontext) { contexts = g_list_prepend (contexts, dragcontext); } static void -gdk_broadway_drag_context_finalize (GObject *object) +gdk_broadway_drag_finalize (GObject *object) { - GdkDragContext *context = GDK_DRAG_CONTEXT (object); + GdkDrag *context = GDK_DRAG (object); contexts = g_list_remove (contexts, context); - G_OBJECT_CLASS (gdk_broadway_drag_context_parent_class)->finalize (object); + G_OBJECT_CLASS (gdk_broadway_drag_parent_class)->finalize (object); } /* Drag Contexts */ -GdkDragContext * +GdkDrag * _gdk_broadway_surface_drag_begin (GdkSurface *surface, GdkDevice *device, GdkContentProvider *content, @@ -91,12 +91,12 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface, gint dx, gint dy) { - GdkDragContext *new_context; + GdkDrag *new_context; g_return_val_if_fail (surface != NULL, NULL); g_return_val_if_fail (GDK_SURFACE_IS_BROADWAY (surface), NULL); - new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT, + new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG, "device", device, "content", content, NULL); @@ -105,14 +105,14 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface, } static void -gdk_broadway_drag_context_drag_drop (GdkDragContext *context, +gdk_broadway_drag_drag_drop (GdkDrag *context, guint32 time) { g_return_if_fail (context != NULL); } static void -gdk_broadway_drag_context_drag_abort (GdkDragContext *context, +gdk_broadway_drag_drag_abort (GdkDrag *context, guint32 time) { g_return_if_fail (context != NULL); @@ -129,13 +129,13 @@ _gdk_broadway_display_init_dnd (GdkDisplay *display) } static void -gdk_broadway_drag_context_class_init (GdkBroadwayDragContextClass *klass) +gdk_broadway_drag_class_init (GdkBroadwayDragClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass); + GdkDragClass *context_class = GDK_DRAG_CLASS (klass); - object_class->finalize = gdk_broadway_drag_context_finalize; + object_class->finalize = gdk_broadway_drag_finalize; - context_class->drag_abort = gdk_broadway_drag_context_drag_abort; - context_class->drag_drop = gdk_broadway_drag_context_drag_drop; + context_class->drag_abort = gdk_broadway_drag_drag_abort; + context_class->drag_drop = gdk_broadway_drag_drag_drop; } diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h index 737bb9ed8c..11a48a0291 100644 --- a/gdk/broadway/gdkprivate-broadway.h +++ b/gdk/broadway/gdkprivate-broadway.h @@ -46,7 +46,7 @@ void gdk_broadway_surface_set_nodes (GdkSurface *surface, GPtrArray *node_textures); void _gdk_broadway_surface_register_dnd (GdkSurface *surface); -GdkDragContext * _gdk_broadway_surface_drag_begin (GdkSurface *surface, +GdkDrag * _gdk_broadway_surface_drag_begin (GdkSurface *surface, GdkDevice *device, GdkContentProvider *content, GdkDragAction actions, diff --git a/gdk/gdk-autocleanup.h b/gdk/gdk-autocleanup.h index 7d2cc3f733..6ec5aa9ba2 100644 --- a/gdk/gdk-autocleanup.h +++ b/gdk/gdk-autocleanup.h @@ -27,7 +27,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkCursor, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDevice, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplay, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDisplayManager, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDragContext, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrag, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrawContext, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkFrameClock, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkGLContext, g_object_unref) diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index bf42a561f5..8cdd208285 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -35,9 +35,9 @@ #include "gdkenumtypes.h" #include "gdkeventsprivate.h" -typedef struct _GdkDragContextPrivate GdkDragContextPrivate; +typedef struct _GdkDragPrivate GdkDragPrivate; -struct _GdkDragContextPrivate +struct _GdkDragPrivate { GdkDisplay *display; GdkDevice *device; @@ -77,9 +77,9 @@ enum { static GParamSpec *properties[N_PROPERTIES] = { NULL, }; static guint signals[N_SIGNALS] = { 0 }; -static GList *contexts = NULL; +static GList *drags = NULL; -G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT) /** * SECTION:dnd @@ -98,142 +98,142 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OB */ /** - * GdkDragContext: + * GdkDrag: * - * The GdkDragContext struct contains only private fields and + * The GdkDrag struct contains only private fields and * should not be accessed directly. */ /** - * gdk_drag_context_get_display: - * @context: a #GdkDragContext + * gdk_drag_get_display: + * @drag: a #GdkDrag * - * Gets the #GdkDisplay that the drag context was created for. + * Gets the #GdkDisplay that the drag object was created for. * * Returns: (transfer none): a #GdkDisplay **/ GdkDisplay * -gdk_drag_context_get_display (GdkDragContext *context) +gdk_drag_get_display (GdkDrag *drag) { - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); + g_return_val_if_fail (GDK_IS_DRAG (drag), NULL); return priv->display; } /** - * gdk_drag_context_get_formats: - * @context: a #GdkDragContext + * gdk_drag_get_formats: + * @drag: a #GdkDrag * - * Retrieves the formats supported by this context. + * Retrieves the formats supported by this GdkDrag object. * * Returns: (transfer none): a #GdkContentFormats **/ GdkContentFormats * -gdk_drag_context_get_formats (GdkDragContext *context) +gdk_drag_get_formats (GdkDrag *drag) { - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); + g_return_val_if_fail (GDK_IS_DRAG (drag), NULL); return priv->formats; } /** - * gdk_drag_context_get_actions: - * @context: a #GdkDragContext + * gdk_drag_get_actions: + * @drag: a #GdkDrag * * Determines the bitmask of actions proposed by the source if - * gdk_drag_context_get_suggested_action() returns %GDK_ACTION_ASK. + * gdk_drag_get_suggested_action() returns %GDK_ACTION_ASK. * * Returns: the #GdkDragAction flags **/ GdkDragAction -gdk_drag_context_get_actions (GdkDragContext *context) +gdk_drag_get_actions (GdkDrag *drag) { - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0); + g_return_val_if_fail (GDK_IS_DRAG (drag), 0); return priv->actions; } /** - * gdk_drag_context_get_suggested_action: - * @context: a #GdkDragContext + * gdk_drag_get_suggested_action: + * @drag: a #GdkDrag * - * Determines the suggested drag action of the context. + * Determines the suggested drag action of the GdkDrag object. * * Returns: a #GdkDragAction value **/ GdkDragAction -gdk_drag_context_get_suggested_action (GdkDragContext *context) +gdk_drag_get_suggested_action (GdkDrag *drag) { - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0); + g_return_val_if_fail (GDK_IS_DRAG (drag), 0); return priv->suggested_action; } /** - * gdk_drag_context_get_selected_action: - * @context: a #GdkDragContext + * gdk_drag_get_selected_action: + * @drag: a #GdkDrag * * Determines the action chosen by the drag destination. * * Returns: a #GdkDragAction value **/ GdkDragAction -gdk_drag_context_get_selected_action (GdkDragContext *context) +gdk_drag_get_selected_action (GdkDrag *drag) { - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0); + g_return_val_if_fail (GDK_IS_DRAG (drag), 0); - return context->action; + return drag->action; } /** - * gdk_drag_context_get_device: - * @context: a #GdkDragContext + * gdk_drag_get_device: + * @drag: a #GdkDrag * - * Returns the #GdkDevice associated to the drag context. + * Returns the #GdkDevice associated to the GdkDrag object. * - * Returns: (transfer none): The #GdkDevice associated to @context. + * Returns: (transfer none): The #GdkDevice associated to @drag. **/ GdkDevice * -gdk_drag_context_get_device (GdkDragContext *context) +gdk_drag_get_device (GdkDrag *drag) { - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); + g_return_val_if_fail (GDK_IS_DRAG (drag), NULL); return priv->device; } static void -gdk_drag_context_init (GdkDragContext *context) +gdk_drag_init (GdkDrag *drag) { - contexts = g_list_prepend (contexts, context); + drags = g_list_prepend (drags, drag); } static void -gdk_drag_context_set_property (GObject *gobject, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +gdk_drag_set_property (GObject *gobject, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - GdkDragContext *context = GDK_DRAG_CONTEXT (gobject); - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDrag *drag = GDK_DRAG (gobject); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); switch (prop_id) { case PROP_CONTENT: - context->content = g_value_dup_object (value); - if (context->content) + drag->content = g_value_dup_object (value); + if (drag->content) { g_assert (priv->formats == NULL); - priv->formats = gdk_content_provider_ref_formats (context->content); + priv->formats = gdk_content_provider_ref_formats (drag->content); } break; @@ -267,18 +267,18 @@ gdk_drag_context_set_property (GObject *gobject, } static void -gdk_drag_context_get_property (GObject *gobject, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gdk_drag_get_property (GObject *gobject, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - GdkDragContext *context = GDK_DRAG_CONTEXT (gobject); - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDrag *drag = GDK_DRAG (gobject); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); switch (prop_id) { case PROP_CONTENT: - g_value_set_object (value, context->content); + g_value_set_object (value, drag->content); break; case PROP_DEVICE: @@ -300,36 +300,35 @@ gdk_drag_context_get_property (GObject *gobject, } static void -gdk_drag_context_finalize (GObject *object) +gdk_drag_finalize (GObject *object) { - GdkDragContext *context = GDK_DRAG_CONTEXT (object); - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDrag *drag = GDK_DRAG (object); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); - contexts = g_list_remove (contexts, context); + drags = g_list_remove (drags, drag); - g_clear_object (&context->content); + g_clear_object (&drag->content); g_clear_pointer (&priv->formats, gdk_content_formats_unref); - if (context->source_surface) - g_object_unref (context->source_surface); + if (drag->source_surface) + g_object_unref (drag->source_surface); - G_OBJECT_CLASS (gdk_drag_context_parent_class)->finalize (object); + G_OBJECT_CLASS (gdk_drag_parent_class)->finalize (object); } static void -gdk_drag_context_class_init (GdkDragContextClass *klass) +gdk_drag_class_init (GdkDragClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->get_property = gdk_drag_context_get_property; - object_class->set_property = gdk_drag_context_set_property; - object_class->finalize = gdk_drag_context_finalize; + object_class->get_property = gdk_drag_get_property; + object_class->set_property = gdk_drag_set_property; + object_class->finalize = gdk_drag_finalize; /** - * GdkDragContext:content: + * GdkDrag:content: * - * The #GdkContentProvider or %NULL if the context is not a source-side - * context. + * The #GdkContentProvider. */ properties[PROP_CONTENT] = g_param_spec_object ("content", @@ -342,7 +341,7 @@ gdk_drag_context_class_init (GdkDragContextClass *klass) G_PARAM_EXPLICIT_NOTIFY); /** - * GdkDragContext:device: + * GdkDrag:device: * * The #GdkDevice that is performing the drag. */ @@ -357,9 +356,9 @@ gdk_drag_context_class_init (GdkDragContextClass *klass) G_PARAM_EXPLICIT_NOTIFY); /** - * GdkDragContext:display: + * GdkDrag:display: * - * The #GdkDisplay that the drag context belongs to. + * The #GdkDisplay that the drag belongs to. */ properties[PROP_DISPLAY] = g_param_spec_object ("display", @@ -371,9 +370,9 @@ gdk_drag_context_class_init (GdkDragContextClass *klass) G_PARAM_EXPLICIT_NOTIFY); /** - * GdkDragContext:formats: + * GdkDrag:formats: * - * The possible formats that the context can provide its data in. + * The possible formats that the drag can provide its data in. */ properties[PROP_FORMATS] = g_param_spec_boxed ("formats", @@ -386,65 +385,65 @@ gdk_drag_context_class_init (GdkDragContextClass *klass) G_PARAM_EXPLICIT_NOTIFY); /** - * GdkDragContext::cancel: - * @context: The object on which the signal is emitted - * @reason: The reason the context was cancelled + * GdkDrag::cancel: + * @drag: The object on which the signal is emitted + * @reason: The reason the drag was cancelled * - * The drag and drop operation was cancelled. + * The drag operation was cancelled. */ signals[CANCEL] = g_signal_new (g_intern_static_string ("cancel"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkDragContextClass, cancel), + G_STRUCT_OFFSET (GdkDragClass, cancel), NULL, NULL, g_cclosure_marshal_VOID__ENUM, G_TYPE_NONE, 1, GDK_TYPE_DRAG_CANCEL_REASON); /** - * GdkDragContext::drop-performed: - * @context: The object on which the signal is emitted + * GdkDrag::drop-performed: + * @drag: The object on which the signal is emitted * - * The drag and drop operation was performed on an accepting client. + * The drag operation was performed on an accepting client. */ signals[DROP_PERFORMED] = g_signal_new (g_intern_static_string ("drop-performed"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkDragContextClass, drop_performed), + G_STRUCT_OFFSET (GdkDragClass, drop_performed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); /** - * GdkDragContext::dnd-finished: - * @context: The object on which the signal is emitted + * GdkDrag::dnd-finished: + * @drag: The object on which the signal is emitted * - * The drag and drop operation was finished, the drag destination - * finished reading all data. The drag source can now free all - * miscellaneous data. + * The drag operation was finished, the destination + * finished reading all data. The drag object can now + * free all miscellaneous data. */ signals[DND_FINISHED] = g_signal_new (g_intern_static_string ("dnd-finished"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkDragContextClass, dnd_finished), + G_STRUCT_OFFSET (GdkDragClass, dnd_finished), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); /** - * GdkDragContext::action-changed: - * @context: The object on which the signal is emitted + * GdkDrag::action-changed: + * @drag: The object on which the signal is emitted * @action: The action currently chosen * - * A new action is being chosen for the drag and drop operation. + * A new action is being chosen for the drag operation. */ signals[ACTION_CHANGED] = g_signal_new (g_intern_static_string ("action-changed"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdkDragContextClass, action_changed), + G_STRUCT_OFFSET (GdkDragClass, action_changed), NULL, NULL, g_cclosure_marshal_VOID__FLAGS, G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION); @@ -454,7 +453,7 @@ gdk_drag_context_class_init (GdkDragContextClass *klass) /* * gdk_drag_abort: - * @context: a #GdkDragContext + * @drag: a #GdkDrag * @time_: the timestamp for this operation * * Aborts a drag without dropping. @@ -462,17 +461,17 @@ gdk_drag_context_class_init (GdkDragContextClass *klass) * This function is called by the drag source. */ void -gdk_drag_abort (GdkDragContext *context, - guint32 time_) +gdk_drag_abort (GdkDrag *drag, + guint32 time_) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_abort (context, time_); + GDK_DRAG_GET_CLASS (drag)->drag_abort (drag, time_); } /* * gdk_drag_drop: - * @context: a #GdkDragContext + * @drag: a #GdkDrag * @time_: the timestamp for this operation * * Drops on the current destination. @@ -480,18 +479,18 @@ gdk_drag_abort (GdkDragContext *context, * This function is called by the drag source. */ void -gdk_drag_drop (GdkDragContext *context, - guint32 time_) +gdk_drag_drop (GdkDrag *drag, + guint32 time_) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_drop (context, time_); + GDK_DRAG_GET_CLASS (drag)->drag_drop (drag, time_); } static void -gdk_drag_context_write_done (GObject *content, - GAsyncResult *result, - gpointer task) +gdk_drag_write_done (GObject *content, + GAsyncResult *result, + gpointer task) { GError *error = NULL; @@ -504,9 +503,9 @@ gdk_drag_context_write_done (GObject *content, } static void -gdk_drag_context_write_serialize_done (GObject *content, - GAsyncResult *result, - gpointer task) +gdk_drag_write_serialize_done (GObject *content, + GAsyncResult *result, + gpointer task) { GError *error = NULL; @@ -519,39 +518,39 @@ gdk_drag_context_write_serialize_done (GObject *content, } void -gdk_drag_context_write_async (GdkDragContext *context, - const char *mime_type, - GOutputStream *stream, - int io_priority, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +gdk_drag_write_async (GdkDrag *drag, + const char *mime_type, + GOutputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { GdkContentFormats *formats, *mime_formats; GTask *task; GType gtype; - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (context->content); + g_return_if_fail (GDK_IS_DRAG (drag)); + g_return_if_fail (drag->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)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (callback != NULL); - task = g_task_new (context, cancellable, callback, user_data); + task = g_task_new (drag, cancellable, callback, user_data); g_task_set_priority (task, io_priority); - g_task_set_source_tag (task, gdk_drag_context_write_async); + g_task_set_source_tag (task, gdk_drag_write_async); - formats = gdk_content_provider_ref_formats (context->content); + formats = gdk_content_provider_ref_formats (drag->content); if (gdk_content_formats_contain_mime_type (formats, mime_type)) { - gdk_content_provider_write_mime_type_async (context->content, + gdk_content_provider_write_mime_type_async (drag->content, mime_type, stream, io_priority, cancellable, - gdk_drag_context_write_done, + gdk_drag_write_done, task); gdk_content_formats_unref (formats); return; @@ -568,14 +567,14 @@ gdk_drag_context_write_async (GdkDragContext *context, g_assert (gtype != G_TYPE_INVALID); g_value_init (&value, gtype); - if (gdk_content_provider_get_value (context->content, &value, &error)) + if (gdk_content_provider_get_value (drag->content, &value, &error)) { gdk_content_serialize_async (stream, mime_type, &value, io_priority, cancellable, - gdk_drag_context_write_serialize_done, + gdk_drag_write_serialize_done, g_object_ref (task)); } else @@ -597,54 +596,54 @@ gdk_drag_context_write_async (GdkDragContext *context, } gboolean -gdk_drag_context_write_finish (GdkDragContext *context, - GAsyncResult *result, - GError **error) +gdk_drag_write_finish (GdkDrag *drag, + GAsyncResult *result, + GError **error) { - g_return_val_if_fail (g_task_is_valid (result, context), FALSE); - g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_context_write_async, FALSE); + g_return_val_if_fail (g_task_is_valid (result, drag), FALSE); + g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_drag_write_async, FALSE); return g_task_propagate_boolean (G_TASK (result), error); } void -gdk_drag_context_set_actions (GdkDragContext *context, - GdkDragAction actions, - GdkDragAction suggested_action) +gdk_drag_set_actions (GdkDrag *drag, + GdkDragAction actions, + GdkDragAction suggested_action) { - GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + GdkDragPrivate *priv = gdk_drag_get_instance_private (drag); priv->actions = actions; priv->suggested_action = suggested_action; } /** - * gdk_drag_context_get_drag_surface: - * @context: a #GdkDragContext + * gdk_drag_get_drag_surface: + * @drag: a #GdkDrag * * Returns the surface on which the drag icon should be rendered * during the drag operation. Note that the surface may not be * available until the drag operation has begun. GDK will move * the surface in accordance with the ongoing drag operation. - * The surface is owned by @context and will be destroyed when + * The surface is owned by @drag and will be destroyed when * the drag operation is over. * * Returns: (nullable) (transfer none): the drag surface, or %NULL */ GdkSurface * -gdk_drag_context_get_drag_surface (GdkDragContext *context) +gdk_drag_get_drag_surface (GdkDrag *drag) { - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); + g_return_val_if_fail (GDK_IS_DRAG (drag), NULL); - if (GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_surface) - return GDK_DRAG_CONTEXT_GET_CLASS (context)->get_drag_surface (context); + if (GDK_DRAG_GET_CLASS (drag)->get_drag_surface) + return GDK_DRAG_GET_CLASS (drag)->get_drag_surface (drag); return NULL; } /** - * gdk_drag_context_set_hotspot: - * @context: a #GdkDragContext + * gdk_drag_set_hotspot: + * @drag: a #GdkDrag * @hot_x: x coordinate of the drag surface hotspot * @hot_y: y coordinate of the drag surface hotspot * @@ -653,19 +652,19 @@ gdk_drag_context_get_drag_surface (GdkDragContext *context) * top left corner of the drag surface. */ void -gdk_drag_context_set_hotspot (GdkDragContext *context, - gint hot_x, - gint hot_y) +gdk_drag_set_hotspot (GdkDrag *drag, + gint hot_x, + gint hot_y) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot) - GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot (context, hot_x, hot_y); + if (GDK_DRAG_GET_CLASS (drag)->set_hotspot) + GDK_DRAG_GET_CLASS (drag)->set_hotspot (drag, hot_x, hot_y); } /** * gdk_drag_drop_done: - * @context: a #GdkDragContext + * @drag: a #GdkDrag * @success: whether the drag was ultimatively successful * * Inform GDK if the drop ended successfully. Passing %FALSE @@ -673,60 +672,60 @@ gdk_drag_context_set_hotspot (GdkDragContext *context, * * This function is called by the drag source, and should * be the last call before dropping the reference to the - * @context. + * @drag. * - * The #GdkDragContext will only take the first gdk_drag_drop_done() + * The #GdkDrag 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. */ void -gdk_drag_drop_done (GdkDragContext *context, - gboolean success) +gdk_drag_drop_done (GdkDrag *drag, + gboolean success) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - if (context->drop_done) + if (drag->drop_done) return; - context->drop_done = TRUE; + drag->drop_done = TRUE; - if (GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done) - GDK_DRAG_CONTEXT_GET_CLASS (context)->drop_done (context, success); + if (GDK_DRAG_GET_CLASS (drag)->drop_done) + GDK_DRAG_GET_CLASS (drag)->drop_done (drag, success); } void -gdk_drag_context_set_cursor (GdkDragContext *context, - GdkCursor *cursor) +gdk_drag_set_cursor (GdkDrag *drag, + GdkCursor *cursor) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor) - GDK_DRAG_CONTEXT_GET_CLASS (context)->set_cursor (context, cursor); + if (GDK_DRAG_GET_CLASS (drag)->set_cursor) + GDK_DRAG_GET_CLASS (drag)->set_cursor (drag, cursor); } void -gdk_drag_context_cancel (GdkDragContext *context, - GdkDragCancelReason reason) +gdk_drag_cancel (GdkDrag *drag, + GdkDragCancelReason reason) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - g_signal_emit (context, signals[CANCEL], 0, reason); + g_signal_emit (drag, signals[CANCEL], 0, reason); } gboolean -gdk_drag_context_handle_source_event (GdkEvent *event) +gdk_drag_handle_source_event (GdkEvent *event) { - GdkDragContext *context; + GdkDrag *drag; GList *l; - for (l = contexts; l; l = l->next) + for (l = drags; l; l = l->next) { - context = l->data; + drag = l->data; - if (!GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event) + if (!GDK_DRAG_GET_CLASS (drag)->handle_event) continue; - if (GDK_DRAG_CONTEXT_GET_CLASS (context)->handle_event (context, event)) + if (GDK_DRAG_GET_CLASS (drag)->handle_event (drag, event)) return TRUE; } @@ -734,8 +733,8 @@ gdk_drag_context_handle_source_event (GdkEvent *event) } GdkCursor * -gdk_drag_get_cursor (GdkDragContext *context, - GdkDragAction action) +gdk_drag_get_cursor (GdkDrag *drag, + GdkDragAction action) { gint i; diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h index 30e391b1ac..dd24c72fb1 100644 --- a/gdk/gdkdnd.h +++ b/gdk/gdkdnd.h @@ -35,9 +35,9 @@ G_BEGIN_DECLS -#define GDK_TYPE_DRAG_CONTEXT (gdk_drag_context_get_type ()) -#define GDK_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG_CONTEXT, GdkDragContext)) -#define GDK_IS_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG_CONTEXT)) +#define GDK_TYPE_DRAG (gdk_drag_get_type ()) +#define GDK_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAG, GdkDrag)) +#define GDK_IS_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAG)) /** * GdkDragCancelReason: @@ -45,7 +45,7 @@ G_BEGIN_DECLS * @GDK_DRAG_CANCEL_USER_CANCELLED: Drag cancelled by the user * @GDK_DRAG_CANCEL_ERROR: Unspecified error. * - * Used in #GdkDragContext to the reason of a cancelled DND operation. + * Used in #GdkDrag to the reason of a cancelled DND operation. */ typedef enum { GDK_DRAG_CANCEL_NO_TARGET, @@ -54,46 +54,44 @@ typedef enum { } GdkDragCancelReason; GDK_AVAILABLE_IN_ALL -GType gdk_drag_context_get_type (void) G_GNUC_CONST; +GType gdk_drag_get_type (void) G_GNUC_CONST; GDK_AVAILABLE_IN_ALL -GdkDisplay * gdk_drag_context_get_display (GdkDragContext *context); +GdkDisplay * gdk_drag_get_display (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -GdkDevice * gdk_drag_context_get_device (GdkDragContext *context); +GdkDevice * gdk_drag_get_device (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -GdkContentFormats *gdk_drag_context_get_formats (GdkDragContext *context); +GdkContentFormats *gdk_drag_get_formats (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -GdkDragAction gdk_drag_context_get_actions (GdkDragContext *context); +GdkDragAction gdk_drag_get_actions (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -GdkDragAction gdk_drag_context_get_suggested_action (GdkDragContext *context); +GdkDragAction gdk_drag_get_suggested_action (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -GdkDragAction gdk_drag_context_get_selected_action (GdkDragContext *context); +GdkDragAction gdk_drag_get_selected_action (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -gboolean gdk_drag_action_is_unique (GdkDragAction action); - -/* Source side */ +gboolean gdk_drag_action_is_unique (GdkDragAction action); GDK_AVAILABLE_IN_ALL -GdkDragContext * gdk_drag_begin (GdkSurface *surface, - GdkDevice *device, - GdkContentProvider *content, - GdkDragAction actions, - gint dx, - gint dy); +GdkDrag * gdk_drag_begin (GdkSurface *surface, + GdkDevice *device, + GdkContentProvider *content, + GdkDragAction actions, + gint dx, + gint dy); GDK_AVAILABLE_IN_ALL -void gdk_drag_drop_done (GdkDragContext *context, - gboolean success); +void gdk_drag_drop_done (GdkDrag *drag, + gboolean success); GDK_AVAILABLE_IN_ALL -GdkSurface *gdk_drag_context_get_drag_surface (GdkDragContext *context); +GdkSurface *gdk_drag_get_drag_surface (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -void gdk_drag_context_set_hotspot (GdkDragContext *context, - gint hot_x, - gint hot_y); +void gdk_drag_set_hotspot (GdkDrag *drag, + gint hot_x, + gint hot_y); G_END_DECLS diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h index 0e586ca979..b3f75ea069 100644 --- a/gdk/gdkdndprivate.h +++ b/gdk/gdkdndprivate.h @@ -23,42 +23,42 @@ G_BEGIN_DECLS -#define GDK_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG_CONTEXT, GdkDragContextClass)) -#define GDK_IS_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG_CONTEXT)) -#define GDK_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG_CONTEXT, GdkDragContextClass)) +#define GDK_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAG, GdkDragClass)) +#define GDK_IS_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAG)) +#define GDK_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAG, GdkDragClass)) -typedef struct _GdkDragContextClass GdkDragContextClass; +typedef struct _GdkDragClass GdkDragClass; -struct _GdkDragContextClass { +struct _GdkDragClass { GObjectClass parent_class; - void (*drag_abort) (GdkDragContext *context, + void (*drag_abort) (GdkDrag *drag, guint32 time_); - void (*drag_drop) (GdkDragContext *context, + void (*drag_drop) (GdkDrag *drag, guint32 time_); - GdkSurface* (*get_drag_surface) (GdkDragContext *context); - void (*set_hotspot) (GdkDragContext *context, + GdkSurface* (*get_drag_surface) (GdkDrag *drag); + void (*set_hotspot) (GdkDrag *drag, gint hot_x, gint hot_y); - void (*drop_done) (GdkDragContext *context, + void (*drop_done) (GdkDrag *drag, gboolean success); - void (*set_cursor) (GdkDragContext *context, + void (*set_cursor) (GdkDrag *drag, GdkCursor *cursor); - void (*cancel) (GdkDragContext *context, + void (*cancel) (GdkDrag *drag, GdkDragCancelReason reason); - void (*drop_performed) (GdkDragContext *context, + void (*drop_performed) (GdkDrag *drag, guint32 time); - void (*dnd_finished) (GdkDragContext *context); + void (*dnd_finished) (GdkDrag *drag); - gboolean (*handle_event) (GdkDragContext *context, + gboolean (*handle_event) (GdkDrag *drag, const GdkEvent *event); - void (*action_changed) (GdkDragContext *context, + void (*action_changed) (GdkDrag *drag, GdkDragAction action); }; -struct _GdkDragContext { +struct _GdkDrag { GObject parent_instance; /*< private >*/ @@ -71,33 +71,33 @@ struct _GdkDragContext { guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */ }; -void gdk_drag_context_set_cursor (GdkDragContext *context, - GdkCursor *cursor); -void gdk_drag_context_set_actions (GdkDragContext *context, - GdkDragAction actions, - GdkDragAction suggested_action); - -void gdk_drag_context_cancel (GdkDragContext *context, - GdkDragCancelReason reason); -gboolean gdk_drag_context_handle_source_event (GdkEvent *event); -GdkCursor * gdk_drag_get_cursor (GdkDragContext *context, - GdkDragAction action); - -void gdk_drag_abort (GdkDragContext *context, - guint32 time_); -void gdk_drag_drop (GdkDragContext *context, - guint32 time_); - -void gdk_drag_context_write_async (GdkDragContext *context, - const char *mime_type, - GOutputStream *stream, - int io_priority, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean gdk_drag_context_write_finish (GdkDragContext *context, - GAsyncResult *result, - GError **error); +void gdk_drag_set_cursor (GdkDrag *drag, + GdkCursor *cursor); +void gdk_drag_set_actions (GdkDrag *drag, + GdkDragAction actions, + GdkDragAction suggested_action); + +void gdk_drag_cancel (GdkDrag *drag, + GdkDragCancelReason reason); +gboolean gdk_drag_handle_source_event (GdkEvent *event); +GdkCursor * gdk_drag_get_cursor (GdkDrag *drag, + GdkDragAction action); + +void gdk_drag_abort (GdkDrag *drag, + guint32 time_); +void gdk_drag_drop (GdkDrag *drag, + guint32 time_); + +void gdk_drag_write_async (GdkDrag *drag, + const char *mime_type, + GOutputStream *stream, + int io_priority, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean gdk_drag_write_finish (GdkDrag *drag, + GAsyncResult *result, + GError **error); G_END_DECLS diff --git a/gdk/gdkdrop.c b/gdk/gdkdrop.c index bdcc3866d0..03bc1e2485 100644 --- a/gdk/gdkdrop.c +++ b/gdk/gdkdrop.c @@ -38,7 +38,7 @@ typedef struct _GdkDropPrivate GdkDropPrivate; struct _GdkDropPrivate { GdkDevice *device; - GdkDragContext *drag; + GdkDrag *drag; GdkContentFormats *formats; GdkSurface *surface; GdkDragAction actions; @@ -78,7 +78,7 @@ gdk_drop_read_local_write_done (GObject *drag, gpointer stream) { /* we don't care about the error, we just want to clean up */ - gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (drag), result, NULL); + gdk_drag_write_finish (GDK_DRAG (drag), result, NULL); /* XXX: Do we need to close_async() here? */ g_output_stream_close (stream, NULL, NULL); @@ -122,7 +122,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_context_write_async (priv->drag, + gdk_drag_write_async (priv->drag, mime_type, output_stream, io_priority, @@ -321,7 +321,7 @@ gdk_drop_class_init (GdkDropClass *klass) g_param_spec_object ("drag", "Drag", "The drag that initiated this drop", - GDK_TYPE_DRAG_CONTEXT, + GDK_TYPE_DRAG, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | @@ -492,7 +492,7 @@ gdk_drop_set_actions (GdkDrop *self, * * Returns: (transfer none) (nullable): the corresponding #GdkDrag **/ -GdkDragContext * +GdkDrag * gdk_drop_get_drag (GdkDrop *self) { GdkDropPrivate *priv = gdk_drop_get_instance_private (self); diff --git a/gdk/gdkdrop.h b/gdk/gdkdrop.h index 43daf94b1d..b91b562367 100644 --- a/gdk/gdkdrop.h +++ b/gdk/gdkdrop.h @@ -50,7 +50,7 @@ GdkContentFormats * gdk_drop_get_formats (GdkDrop GDK_AVAILABLE_IN_ALL GdkDragAction gdk_drop_get_actions (GdkDrop *self); GDK_AVAILABLE_IN_ALL -GdkDragContext * gdk_drop_get_drag (GdkDrop *self); +GdkDrag * gdk_drop_get_drag (GdkDrop *self); GDK_AVAILABLE_IN_ALL void gdk_drop_status (GdkDrop *self, diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 178bbd3b85..7d810d9fda 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -165,7 +165,7 @@ gdk_event_class_init (GdkEventClass *klass) void _gdk_event_emit (GdkEvent *event) { - if (gdk_drag_context_handle_source_event (event)) + if (gdk_drag_handle_source_event (event)) return; if (_gdk_event_func) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index c9a27018b5..7348ce1fe8 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -5140,10 +5140,10 @@ gdk_surface_register_dnd (GdkSurface *surface) * * This function is called by the drag source. * - * Returns: (transfer full) (nullable): a newly created #GdkDragContext or + * Returns: (transfer full) (nullable): a newly created #GdkDrag or * %NULL on error. */ -GdkDragContext * +GdkDrag * gdk_drag_begin (GdkSurface *surface, GdkDevice *device, GdkContentProvider *content, diff --git a/gdk/gdksurfaceimpl.h b/gdk/gdksurfaceimpl.h index dfd9716617..03342e477f 100644 --- a/gdk/gdksurfaceimpl.h +++ b/gdk/gdksurfaceimpl.h @@ -193,7 +193,7 @@ struct _GdkSurfaceImplClass gdouble opacity); void (* destroy_notify) (GdkSurface *surface); void (* register_dnd) (GdkSurface *surface); - GdkDragContext * (*drag_begin) (GdkSurface *surface, + GdkDrag * (*drag_begin) (GdkSurface *surface, GdkDevice *device, GdkContentProvider*content, GdkDragAction actions, diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h index b967ad7259..16a64df3fc 100644 --- a/gdk/gdktypes.h +++ b/gdk/gdktypes.h @@ -123,7 +123,7 @@ typedef struct _GdkContentProvider GdkContentProvider; typedef struct _GdkCursor GdkCursor; typedef struct _GdkTexture GdkTexture; typedef struct _GdkDevice GdkDevice; -typedef struct _GdkDragContext GdkDragContext; +typedef struct _GdkDrag GdkDrag; typedef struct _GdkDrop GdkDrop; typedef struct _GdkClipboard GdkClipboard; @@ -571,7 +571,7 @@ typedef enum * useful if source and destination agree on what it means. * @GDK_ACTION_ASK: Ask the user what to do with the data. * - * Used in #GdkDragContext to indicate what the destination + * Used in #GdkDrag to indicate what the destination * should do with the dropped data. */ typedef enum diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 9c9b79b563..7c8202e9d7 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -247,7 +247,7 @@ struct _GdkWaylandSeat GdkClipboard *clipboard; GdkClipboard *primary_clipboard; struct wl_data_device *data_device; - GdkDragContext *drag; + GdkDrag *drag; GdkDrop *drop; /* Source/dest for non-local dnd */ @@ -5133,12 +5133,12 @@ gdk_wayland_seat_set_global_cursor (GdkSeat *seat, } void -gdk_wayland_seat_set_drag (GdkSeat *seat, - GdkDragContext *context) +gdk_wayland_seat_set_drag (GdkSeat *seat, + GdkDrag *drag) { GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat); - g_set_object (&wayland_seat->drag, context); + g_set_object (&wayland_seat->drag, drag); } struct wl_data_device * diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index 36c0c9b138..5b9792028b 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -34,19 +34,19 @@ #include <gio/gunixoutputstream.h> #include <string.h> -#define GDK_TYPE_WAYLAND_DRAG_CONTEXT (gdk_wayland_drag_context_get_type ()) -#define GDK_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContext)) -#define GDK_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass)) -#define GDK_IS_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT)) -#define GDK_IS_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT)) -#define GDK_WAYLAND_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass)) +#define GDK_TYPE_WAYLAND_DRAG (gdk_wayland_drag_get_type ()) +#define GDK_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDrag)) +#define GDK_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass)) +#define GDK_IS_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG)) +#define GDK_IS_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG)) +#define GDK_WAYLAND_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass)) -typedef struct _GdkWaylandDragContext GdkWaylandDragContext; -typedef struct _GdkWaylandDragContextClass GdkWaylandDragContextClass; +typedef struct _GdkWaylandDrag GdkWaylandDrag; +typedef struct _GdkWaylandDragClass GdkWaylandDragClass; -struct _GdkWaylandDragContext +struct _GdkWaylandDrag { - GdkDragContext context; + GdkDrag drag; GdkSurface *dnd_surface; struct wl_surface *dnd_wl_surface; struct wl_data_source *data_source; @@ -57,34 +57,34 @@ struct _GdkWaylandDragContext gint hot_y; }; -struct _GdkWaylandDragContextClass +struct _GdkWaylandDragClass { - GdkDragContextClass parent_class; + GdkDragClass parent_class; }; -static GList *contexts; +static GList *drags; -GType gdk_wayland_drag_context_get_type (void); +GType gdk_wayland_drag_get_type (void); -G_DEFINE_TYPE (GdkWaylandDragContext, gdk_wayland_drag_context, GDK_TYPE_DRAG_CONTEXT) +G_DEFINE_TYPE (GdkWaylandDrag, gdk_wayland_drag, GDK_TYPE_DRAG) static void -gdk_wayland_drag_context_finalize (GObject *object) +gdk_wayland_drag_finalize (GObject *object) { - GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (object); - GdkDragContext *context = GDK_DRAG_CONTEXT (object); + GdkWaylandDrag *wayland_drag = GDK_WAYLAND_DRAG (object); + GdkDrag *drag = GDK_DRAG (object); GdkSurface *dnd_surface; - contexts = g_list_remove (contexts, context); + drags = g_list_remove (drags, drag); - gdk_drag_context_set_cursor (context, NULL); + gdk_drag_set_cursor (drag, NULL); - g_clear_pointer (&wayland_context->data_source, (GDestroyNotify) wl_data_source_destroy); - g_clear_pointer (&wayland_context->offer, (GDestroyNotify) wl_data_offer_destroy); + g_clear_pointer (&wayland_drag->data_source, (GDestroyNotify) wl_data_source_destroy); + g_clear_pointer (&wayland_drag->offer, (GDestroyNotify) wl_data_offer_destroy); - dnd_surface = wayland_context->dnd_surface; + dnd_surface = wayland_drag->dnd_surface; - G_OBJECT_CLASS (gdk_wayland_drag_context_parent_class)->finalize (object); + G_OBJECT_CLASS (gdk_wayland_drag_parent_class)->finalize (object); if (dnd_surface) gdk_surface_destroy (dnd_surface); @@ -106,121 +106,121 @@ gdk_to_wl_actions (GdkDragAction action) } static void -gdk_wayland_drag_context_drag_abort (GdkDragContext *context, - guint32 time) +gdk_wayland_drag_drag_abort (GdkDrag *drag, + guint32 time) { } static void -gdk_wayland_drag_context_drag_drop (GdkDragContext *context, - guint32 time) +gdk_wayland_drag_drag_drop (GdkDrag *drag, + guint32 time) { } static void -gdk_wayland_drag_context_init (GdkWaylandDragContext *context_wayland) +gdk_wayland_drag_init (GdkWaylandDrag *drag_wayland) { - GdkDragContext *context; + GdkDrag *drag; - context = GDK_DRAG_CONTEXT (context_wayland); - contexts = g_list_prepend (contexts, context); + drag = GDK_DRAG (drag_wayland); + drags = g_list_prepend (drags, drag); - context->action = GDK_ACTION_COPY; + drag->action = GDK_ACTION_COPY; } static GdkSurface * -gdk_wayland_drag_context_get_drag_surface (GdkDragContext *context) +gdk_wayland_drag_get_drag_surface (GdkDrag *drag) { - return GDK_WAYLAND_DRAG_CONTEXT (context)->dnd_surface; + return GDK_WAYLAND_DRAG (drag)->dnd_surface; } static void -gdk_wayland_drag_context_set_hotspot (GdkDragContext *context, - gint hot_x, - gint hot_y) +gdk_wayland_drag_set_hotspot (GdkDrag *drag, + gint hot_x, + gint hot_y) { - GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context); - gint prev_hot_x = context_wayland->hot_x; - gint prev_hot_y = context_wayland->hot_y; + GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag); + gint prev_hot_x = drag_wayland->hot_x; + gint prev_hot_y = drag_wayland->hot_y; const GdkRectangle damage_rect = { .width = 1, .height = 1 }; - context_wayland->hot_x = hot_x; - context_wayland->hot_y = hot_y; + drag_wayland->hot_x = hot_x; + drag_wayland->hot_y = hot_y; if (prev_hot_x == hot_x && prev_hot_y == hot_y) return; - _gdk_wayland_surface_offset_next_wl_buffer (context_wayland->dnd_surface, + _gdk_wayland_surface_offset_next_wl_buffer (drag_wayland->dnd_surface, -hot_x, -hot_y); - gdk_surface_invalidate_rect (context_wayland->dnd_surface, &damage_rect); + gdk_surface_invalidate_rect (drag_wayland->dnd_surface, &damage_rect); } static void -gdk_wayland_drag_context_set_cursor (GdkDragContext *context, - GdkCursor *cursor) +gdk_wayland_drag_set_cursor (GdkDrag *drag, + GdkCursor *cursor) { - GdkDevice *device = gdk_drag_context_get_device (context); + GdkDevice *device = gdk_drag_get_device (drag); gdk_wayland_seat_set_global_cursor (gdk_device_get_seat (device), cursor); } static void -gdk_wayland_drag_context_action_changed (GdkDragContext *context, - GdkDragAction action) +gdk_wayland_drag_action_changed (GdkDrag *drag, + GdkDragAction action) { GdkCursor *cursor; - cursor = gdk_drag_get_cursor (context, action); - gdk_drag_context_set_cursor (context, cursor); + cursor = gdk_drag_get_cursor (drag, action); + gdk_drag_set_cursor (drag, cursor); } static void -gdk_wayland_drag_context_drop_performed (GdkDragContext *context, - guint32 time_) +gdk_wayland_drag_drop_performed (GdkDrag *drag, + guint32 time_) { - gdk_drag_context_set_cursor (context, NULL); + gdk_drag_set_cursor (drag, NULL); } static void -gdk_wayland_drag_context_cancel (GdkDragContext *context, - GdkDragCancelReason reason) +gdk_wayland_drag_cancel (GdkDrag *drag, + GdkDragCancelReason reason) { - gdk_drag_context_set_cursor (context, NULL); + gdk_drag_set_cursor (drag, NULL); } static void -gdk_wayland_drag_context_drop_done (GdkDragContext *context, - gboolean success) +gdk_wayland_drag_drop_done (GdkDrag *drag, + gboolean success) { - GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context); - GdkDevice *device = gdk_drag_context_get_device (context); + GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag); + GdkDevice *device = gdk_drag_get_device (drag); - gdk_wayland_seat_set_drag (gdk_device_get_seat (device), context); + gdk_wayland_seat_set_drag (gdk_device_get_seat (device), drag); if (success) { - if (context_wayland->dnd_surface) - gdk_surface_hide (context_wayland->dnd_surface); + if (drag_wayland->dnd_surface) + gdk_surface_hide (drag_wayland->dnd_surface); } } static void -gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass) +gdk_wayland_drag_class_init (GdkWaylandDragClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass); - - object_class->finalize = gdk_wayland_drag_context_finalize; - - context_class->drag_abort = gdk_wayland_drag_context_drag_abort; - context_class->drag_drop = gdk_wayland_drag_context_drag_drop; - context_class->get_drag_surface = gdk_wayland_drag_context_get_drag_surface; - context_class->set_hotspot = gdk_wayland_drag_context_set_hotspot; - context_class->drop_done = gdk_wayland_drag_context_drop_done; - context_class->set_cursor = gdk_wayland_drag_context_set_cursor; - context_class->action_changed = gdk_wayland_drag_context_action_changed; - context_class->drop_performed = gdk_wayland_drag_context_drop_performed; - context_class->cancel = gdk_wayland_drag_context_cancel; + GdkDragClass *drag_class = GDK_DRAG_CLASS (klass); + + object_class->finalize = gdk_wayland_drag_finalize; + + drag_class->drag_abort = gdk_wayland_drag_drag_abort; + 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; + drag_class->set_cursor = gdk_wayland_drag_set_cursor; + drag_class->action_changed = gdk_wayland_drag_action_changed; + drag_class->drop_performed = gdk_wayland_drag_drop_performed; + drag_class->cancel = gdk_wayland_drag_cancel; } void @@ -266,15 +266,15 @@ data_source_target (void *data, } static void -gdk_wayland_drag_context_write_done (GObject *context, - GAsyncResult *result, - gpointer user_data) +gdk_wayland_drag_write_done (GObject *drag, + GAsyncResult *result, + gpointer user_data) { GError *error = NULL; - if (!gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (context), result, &error)) + if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error)) { - GDK_DISPLAY_NOTE (gdk_drag_context_get_display (GDK_DRAG_CONTEXT (context)), DND, g_message ("%p: failed to write stream: %s", context, error->message)); + GDK_DISPLAY_NOTE (gdk_drag_get_display (GDK_DRAG (drag)), DND, g_message ("%p: failed to write stream: %s", drag, error->message)); g_error_free (error); } } @@ -285,23 +285,23 @@ data_source_send (void *data, const char *mime_type, int32_t fd) { - GdkDragContext *context = data; + GdkDrag *drag = data; GOutputStream *stream; - GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), DND, g_message ("%p: data source send request for %s on fd %d\n", + GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), DND, g_message ("%p: data source send request for %s on fd %d\n", source, mime_type, fd)); //mime_type = gdk_intern_mime_type (mime_type); mime_type = g_intern_string (mime_type); stream = g_unix_output_stream_new (fd, TRUE); - gdk_drag_context_write_async (context, - mime_type, - stream, - G_PRIORITY_DEFAULT, - NULL, - gdk_wayland_drag_context_write_done, - context); + gdk_drag_write_async (drag, + mime_type, + stream, + G_PRIORITY_DEFAULT, + NULL, + gdk_wayland_drag_write_done, + drag); g_object_unref (stream); } @@ -309,30 +309,30 @@ static void data_source_cancelled (void *data, struct wl_data_source *source) { - GdkDragContext *context = data; + GdkDrag *drag = data; - GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), EVENTS, + GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS, g_message ("data source cancelled, source = %p", source)); - gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR); + gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR); } static void data_source_dnd_drop_performed (void *data, struct wl_data_source *source) { - GdkDragContext *context = data; + GdkDrag *drag = data; - g_signal_emit_by_name (context, "drop-performed"); + g_signal_emit_by_name (drag, "drop-performed"); } static void data_source_dnd_finished (void *data, struct wl_data_source *source) { - GdkDragContext *context = data; + GdkDrag *drag = data; - g_signal_emit_by_name (context, "dnd-finished"); + g_signal_emit_by_name (drag, "dnd-finished"); } static void @@ -340,14 +340,14 @@ data_source_action (void *data, struct wl_data_source *source, uint32_t action) { - GdkDragContext *context = data; + GdkDrag *drag = data; - GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), EVENTS, + GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS, g_message ("data source action, source = %p action=%x", source, action)); - context->action = _wl_to_gdk_actions (action); - g_signal_emit_by_name (context, "action-changed", context->action); + drag->action = _wl_to_gdk_actions (action); + g_signal_emit_by_name (drag, "action-changed", drag->action); } static const struct wl_data_source_listener data_source_listener = { @@ -360,27 +360,27 @@ static const struct wl_data_source_listener data_source_listener = { }; static void -gdk_wayland_drag_context_create_data_source (GdkDragContext *context) +gdk_wayland_drag_create_data_source (GdkDrag *drag) { - GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context); - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag); + GdkDisplay *display = gdk_drag_get_display (drag); GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); const char *const *mimetypes; gsize i, n_mimetypes; - context_wayland->data_source = wl_data_device_manager_create_data_source (display_wayland->data_device_manager); - wl_data_source_add_listener (context_wayland->data_source, + drag_wayland->data_source = wl_data_device_manager_create_data_source (display_wayland->data_device_manager); + wl_data_source_add_listener (drag_wayland->data_source, &data_source_listener, - context); + drag); - mimetypes = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (context), &n_mimetypes); + mimetypes = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_mimetypes); for (i = 0; i < n_mimetypes; i++) { - wl_data_source_offer (context_wayland->data_source, mimetypes[i]); + wl_data_source_offer (drag_wayland->data_source, mimetypes[i]); } } -GdkDragContext * +GdkDrag * _gdk_wayland_surface_drag_begin (GdkSurface *surface, GdkDevice *device, GdkContentProvider *content, @@ -388,53 +388,53 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface, gint dx, gint dy) { - GdkWaylandDragContext *context_wayland; - GdkDragContext *context; + GdkWaylandDrag *drag_wayland; + GdkDrag *drag; GdkSeat *seat; GdkWaylandDisplay *display_wayland; display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device)); seat = gdk_device_get_seat (device); - context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, - "device", device, - "content", content, - NULL); - context = GDK_DRAG_CONTEXT (context_wayland); - context->source_surface = g_object_ref (surface); + drag_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG, + "device", device, + "content", content, + NULL); + drag = GDK_DRAG (drag_wayland); + drag->source_surface = g_object_ref (surface); - context_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface)); - context_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (context_wayland->dnd_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); - gdk_wayland_drag_context_create_data_source (context); + gdk_wayland_drag_create_data_source (drag); if (display_wayland->data_device_manager_version >= WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION) { - wl_data_source_set_actions (context_wayland->data_source, + wl_data_source_set_actions (drag_wayland->data_source, gdk_to_wl_actions (actions)); } - gdk_wayland_seat_set_drag (seat, context); + gdk_wayland_seat_set_drag (seat, drag); wl_data_device_start_drag (gdk_wayland_device_get_data_device (device), - context_wayland->data_source, + drag_wayland->data_source, gdk_wayland_surface_get_wl_surface (surface), - context_wayland->dnd_wl_surface, + drag_wayland->dnd_wl_surface, _gdk_wayland_display_get_serial (display_wayland)); gdk_seat_ungrab (seat); - return context; + return drag; } void -_gdk_wayland_drag_context_set_source_surface (GdkDragContext *context, - GdkSurface *surface) +_gdk_wayland_drag_set_source_surface (GdkDrag *drag, + GdkSurface *surface) { - if (context->source_surface) - g_object_unref (context->source_surface); + if (drag->source_surface) + g_object_unref (drag->source_surface); - context->source_surface = surface ? g_object_ref (surface) : NULL; + drag->source_surface = surface ? g_object_ref (surface) : NULL; } diff --git a/gdk/wayland/gdkdrop-wayland.c b/gdk/wayland/gdkdrop-wayland.c index d290c6229b..1c21dafdfa 100644 --- a/gdk/wayland/gdkdrop-wayland.c +++ b/gdk/wayland/gdkdrop-wayland.c @@ -261,7 +261,7 @@ gdk_wayland_drop_init (GdkWaylandDrop *drop) GdkDrop * gdk_wayland_drop_new (GdkDevice *device, - GdkDragContext *drag, + GdkDrag *drag, GdkContentFormats *formats, GdkSurface *surface, struct wl_data_offer *offer, diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index e4984cc5d4..68bd84b4a5 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -95,7 +95,7 @@ void gdk_wayland_surface_attach_image (GdkSurface const cairo_region_t *damage); void _gdk_wayland_surface_register_dnd (GdkSurface *surface); -GdkDragContext *_gdk_wayland_surface_drag_begin (GdkSurface *surface, +GdkDrag *_gdk_wayland_surface_drag_begin (GdkSurface *surface, GdkDevice *device, GdkContentProvider *content, GdkDragAction actions, @@ -105,7 +105,7 @@ void _gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface, int x, int y); GdkDrop * gdk_wayland_drop_new (GdkDevice *device, - GdkDragContext *drag, + GdkDrag *drag, GdkContentFormats *formats, GdkSurface *surface, struct wl_data_offer *offer, @@ -115,13 +115,13 @@ void gdk_wayland_drop_set_source_actions (GdkDrop void gdk_wayland_drop_set_action (GdkDrop *drop, uint32_t action); -void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context, - GdkSurface *surface); +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, - GdkSurfaceAttr *attributes); +void _gdk_wayland_display_create_surface_impl (GdkDisplay *display, + GdkSurface *surface, + GdkSurface *real_parent, + GdkSurfaceAttr *attributes); gint _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display, GdkAtom encoding, @@ -147,7 +147,7 @@ struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_devic void gdk_wayland_device_set_selection (GdkDevice *gdk_device, struct wl_data_source *source); -GdkDragContext * gdk_wayland_device_get_drop_context (GdkDevice *gdk_device); +GdkDrag* gdk_wayland_device_get_drop_context (GdkDevice *gdk_device); void gdk_wayland_device_unset_touch_grab (GdkDevice *device, GdkEventSequence *sequence); @@ -193,7 +193,7 @@ struct gtk_surface1 * gdk_wayland_surface_get_gtk_surface (GdkSurface *surface); void gdk_wayland_seat_set_global_cursor (GdkSeat *seat, GdkCursor *cursor); void gdk_wayland_seat_set_drag (GdkSeat *seat, - GdkDragContext *drag); + GdkDrag *drag); struct wl_output *gdk_wayland_surface_get_wl_output (GdkSurface *surface); diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index 04b6178948..8377636a4e 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -65,7 +65,7 @@ typedef enum { * @GDK_DRAG_PROTO_ROOTWIN: An extension to the Xdnd protocol for * unclaimed root window drops. * - * Used in #GdkDragContext to indicate the protocol according to + * Used in #GdkDrag to indicate the protocol according to * which DND is done. */ typedef enum @@ -93,9 +93,9 @@ struct _GdkSurfaceCache { }; -struct _GdkX11DragContext +struct _GdkX11Drag { - GdkDragContext context; + GdkDrag drag; GdkDragProtocol protocol; @@ -129,9 +129,9 @@ struct _GdkX11DragContext guint drop_failed : 1; /* Whether the drop was unsuccessful */ }; -struct _GdkX11DragContextClass +struct _GdkX11DragClass { - GdkDragContextClass parent_class; + GdkDragClass parent_class; }; typedef struct { @@ -168,89 +168,89 @@ static GrabKey grab_keys[] = { static GdkSurfaceCache *gdk_surface_cache_ref (GdkSurfaceCache *cache); static void gdk_surface_cache_unref (GdkSurfaceCache *cache); -gboolean gdk_x11_drag_context_handle_event (GdkDragContext *context, - const GdkEvent *event); -void gdk_x11_drag_context_action_changed (GdkDragContext *context, - GdkDragAction action); +gboolean gdk_x11_drag_handle_event (GdkDrag *drag, + const GdkEvent *event); +void gdk_x11_drag_action_changed (GdkDrag *drag, + GdkDragAction action); -static GList *contexts; +static GList *drags; static GSList *window_caches; -G_DEFINE_TYPE (GdkX11DragContext, gdk_x11_drag_context, GDK_TYPE_DRAG_CONTEXT) +G_DEFINE_TYPE (GdkX11Drag, gdk_x11_drag, GDK_TYPE_DRAG) static void -gdk_x11_drag_context_init (GdkX11DragContext *context) -{ - contexts = g_list_prepend (contexts, context); -} - -static void gdk_x11_drag_context_finalize (GObject *object); -static Window gdk_x11_drag_context_find_surface (GdkDragContext *context, - GdkSurface *drag_surface, - gint x_root, - gint y_root, - GdkDragProtocol *protocol); -static gboolean gdk_x11_drag_context_drag_motion (GdkDragContext *context, - Window proxy_xid, - GdkDragProtocol protocol, - gint x_root, - gint y_root, - GdkDragAction suggested_action, - GdkDragAction possible_actions, - guint32 time); -static void gdk_x11_drag_context_drag_abort (GdkDragContext *context, - guint32 time_); -static void gdk_x11_drag_context_drag_drop (GdkDragContext *context, - guint32 time_); -static GdkSurface * gdk_x11_drag_context_get_drag_surface (GdkDragContext *context); -static void gdk_x11_drag_context_set_hotspot (GdkDragContext *context, - gint hot_x, - gint hot_y); -static void gdk_x11_drag_context_drop_done (GdkDragContext *context, - gboolean success); -static void gdk_x11_drag_context_set_cursor (GdkDragContext *context, - GdkCursor *cursor); -static void gdk_x11_drag_context_cancel (GdkDragContext *context, - GdkDragCancelReason reason); -static void gdk_x11_drag_context_drop_performed (GdkDragContext *context, - guint32 time); +gdk_x11_drag_init (GdkX11Drag *drag) +{ + drags = g_list_prepend (drags, drag); +} + +static void gdk_x11_drag_finalize (GObject *object); +static Window gdk_x11_drag_find_surface (GdkDrag *drag, + GdkSurface *drag_surface, + gint x_root, + gint y_root, + GdkDragProtocol *protocol); +static gboolean gdk_x11_drag_drag_motion (GdkDrag *drag, + Window proxy_xid, + GdkDragProtocol protocol, + gint x_root, + gint y_root, + GdkDragAction suggested_action, + GdkDragAction possible_actions, + guint32 time); +static void gdk_x11_drag_drag_abort (GdkDrag *drag, + guint32 time_); +static void gdk_x11_drag_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, + gint hot_x, + gint hot_y); +static void gdk_x11_drag_drop_done (GdkDrag *drag, + gboolean success); +static void gdk_x11_drag_set_cursor (GdkDrag *drag, + GdkCursor *cursor); +static void gdk_x11_drag_cancel (GdkDrag *drag, + GdkDragCancelReason reason); +static void gdk_x11_drag_drop_performed (GdkDrag *drag, + guint32 time); static void -gdk_x11_drag_context_class_init (GdkX11DragContextClass *klass) +gdk_x11_drag_class_init (GdkX11DragClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass); + GdkDragClass *drag_class = GDK_DRAG_CLASS (klass); - object_class->finalize = gdk_x11_drag_context_finalize; + object_class->finalize = gdk_x11_drag_finalize; - context_class->drag_abort = gdk_x11_drag_context_drag_abort; - context_class->drag_drop = gdk_x11_drag_context_drag_drop; - context_class->get_drag_surface = gdk_x11_drag_context_get_drag_surface; - context_class->set_hotspot = gdk_x11_drag_context_set_hotspot; - context_class->drop_done = gdk_x11_drag_context_drop_done; - context_class->set_cursor = gdk_x11_drag_context_set_cursor; - context_class->cancel = gdk_x11_drag_context_cancel; - context_class->drop_performed = gdk_x11_drag_context_drop_performed; - context_class->handle_event = gdk_x11_drag_context_handle_event; - context_class->action_changed = gdk_x11_drag_context_action_changed; + drag_class->drag_abort = gdk_x11_drag_drag_abort; + 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; + drag_class->set_cursor = gdk_x11_drag_set_cursor; + drag_class->cancel = gdk_x11_drag_cancel; + drag_class->drop_performed = gdk_x11_drag_drop_performed; + drag_class->handle_event = gdk_x11_drag_handle_event; + drag_class->action_changed = gdk_x11_drag_action_changed; } static void -gdk_x11_drag_context_finalize (GObject *object) +gdk_x11_drag_finalize (GObject *object) { - GdkDragContext *context = GDK_DRAG_CONTEXT (object); - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (object); + GdkDrag *drag = GDK_DRAG (object); + GdkX11Drag *x11_drag = GDK_X11_DRAG (object); GdkSurface *drag_surface, *ipc_surface; - if (x11_context->cache) - gdk_surface_cache_unref (x11_context->cache); + if (x11_drag->cache) + gdk_surface_cache_unref (x11_drag->cache); - contexts = g_list_remove (contexts, context); + drags = g_list_remove (drags, drag); - drag_surface = context->drag_surface; - ipc_surface = x11_context->ipc_surface; + drag_surface = drag->drag_surface; + ipc_surface = x11_drag->ipc_surface; - G_OBJECT_CLASS (gdk_x11_drag_context_parent_class)->finalize (object); + G_OBJECT_CLASS (gdk_x11_drag_parent_class)->finalize (object); if (drag_surface) gdk_surface_destroy (drag_surface); @@ -260,49 +260,49 @@ gdk_x11_drag_context_finalize (GObject *object) /* Drag Contexts */ -GdkDragContext * -gdk_x11_drag_context_find (GdkDisplay *display, - Window source_xid, - Window dest_xid) +GdkDrag * +gdk_x11_drag_find (GdkDisplay *display, + Window source_xid, + Window dest_xid) { GList *tmp_list; - GdkDragContext *context; - GdkX11DragContext *context_x11; - Window context_dest_xid; + GdkDrag *drag; + GdkX11Drag *drag_x11; + Window drag_dest_xid; - for (tmp_list = contexts; tmp_list; tmp_list = tmp_list->next) + for (tmp_list = drags; tmp_list; tmp_list = tmp_list->next) { - context = (GdkDragContext *)tmp_list->data; - context_x11 = (GdkX11DragContext *)context; + drag = (GdkDrag *)tmp_list->data; + drag_x11 = (GdkX11Drag *)drag; - if (gdk_drag_context_get_display (context) != display) + if (gdk_drag_get_display (drag) != display) continue; - context_dest_xid = context_x11->proxy_xid - ? (context_x11->drop_xid - ? context_x11->drop_xid - : context_x11->proxy_xid) + drag_dest_xid = drag_x11->proxy_xid + ? (drag_x11->drop_xid + ? drag_x11->drop_xid + : drag_x11->proxy_xid) : None; - if (((source_xid == None) || (context->source_surface && - (GDK_SURFACE_XID (context->source_surface) == source_xid))) && - ((dest_xid == None) || (context_dest_xid == dest_xid))) - return context; + if (((source_xid == None) || (drag->source_surface && + (GDK_SURFACE_XID (drag->source_surface) == source_xid))) && + ((dest_xid == None) || (drag_dest_xid == dest_xid))) + return drag; } return NULL; } static void -precache_target_list (GdkDragContext *context) +precache_target_list (GdkDrag *drag) { - GdkContentFormats *formats = gdk_drag_context_get_formats (context); + GdkContentFormats *formats = gdk_drag_get_formats (drag); const char * const *atoms; gsize n_atoms; atoms = gdk_content_formats_get_mime_types (formats, &n_atoms); - _gdk_x11_precache_atoms (gdk_drag_context_get_display (context), + _gdk_x11_precache_atoms (gdk_drag_get_display (drag), (const gchar **) atoms, n_atoms); } @@ -328,13 +328,13 @@ free_cache_child (GdkCacheChild *child, static void gdk_surface_cache_add (GdkSurfaceCache *cache, - guint32 xid, - gint x, - gint y, - gint width, - gint height, - gboolean mapped) -{ + guint32 xid, + gint x, + gint y, + gint width, + gint height, + gboolean mapped) +{ GdkCacheChild *child = g_new (GdkCacheChild, 1); child->xid = xid; @@ -354,8 +354,8 @@ gdk_surface_cache_add (GdkSurfaceCache *cache, GdkFilterReturn gdk_surface_cache_shape_filter (const XEvent *xevent, - GdkEvent *event, - gpointer data) + GdkEvent *event, + gpointer data) { GdkSurfaceCache *cache = data; @@ -388,8 +388,8 @@ gdk_surface_cache_shape_filter (const XEvent *xevent, GdkFilterReturn gdk_surface_cache_filter (const XEvent *xevent, - GdkEvent *event, - gpointer data) + GdkEvent *event, + gpointer data) { GdkSurfaceCache *cache = data; @@ -855,25 +855,25 @@ xdnd_action_to_atom (GdkDisplay *display, /* Source side */ void -gdk_x11_drag_context_handle_status (GdkDisplay *display, - const XEvent *xevent) +gdk_x11_drag_handle_status (GdkDisplay *display, + const XEvent *xevent) { guint32 dest_surface = xevent->xclient.data.l[0]; guint32 flags = xevent->xclient.data.l[1]; Atom action = xevent->xclient.data.l[4]; - GdkDragContext *context; + GdkDrag *drag; - context = gdk_x11_drag_context_find (display, xevent->xclient.window, dest_surface); + drag = gdk_x11_drag_find (display, xevent->xclient.window, dest_surface); GDK_DISPLAY_NOTE (display, DND, g_message ("XdndStatus: dest_surface: %#x action: %ld", dest_surface, action)); - if (context) + if (drag) { - GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context); - if (context_x11->drag_status == GDK_DRAG_STATUS_MOTION_WAIT) - context_x11->drag_status = GDK_DRAG_STATUS_DRAG; + GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag); + if (drag_x11->drag_status == GDK_DRAG_STATUS_MOTION_WAIT) + drag_x11->drag_status = GDK_DRAG_STATUS_DRAG; if (!(action != 0) != !(flags & 1)) { @@ -882,80 +882,80 @@ gdk_x11_drag_context_handle_status (GdkDisplay *display, action = 0; } - context->action = xdnd_action_from_atom (display, action); + drag->action = xdnd_action_from_atom (display, action); - if (context->action != context_x11->current_action) + if (drag->action != drag_x11->current_action) { - context_x11->current_action = context->action; - g_signal_emit_by_name (context, "action-changed", context->action); + drag_x11->current_action = drag->action; + g_signal_emit_by_name (drag, "action-changed", drag->action); } } } void -gdk_x11_drag_context_handle_finished (GdkDisplay *display, - const XEvent *xevent) +gdk_x11_drag_handle_finished (GdkDisplay *display, + const XEvent *xevent) { guint32 dest_surface = xevent->xclient.data.l[0]; - GdkDragContext *context; - GdkX11DragContext *context_x11; + GdkDrag *drag; + GdkX11Drag *drag_x11; - context = gdk_x11_drag_context_find (display, xevent->xclient.window, dest_surface); + drag = gdk_x11_drag_find (display, xevent->xclient.window, dest_surface); GDK_DISPLAY_NOTE (display, DND, g_message ("XdndFinished: dest_surface: %#x", dest_surface)); - if (context) + if (drag) { - g_object_ref (context); + g_object_ref (drag); - context_x11 = GDK_X11_DRAG_CONTEXT (context); - if (context_x11->version == 5) - context_x11->drop_failed = xevent->xclient.data.l[1] == 0; + drag_x11 = GDK_X11_DRAG (drag); + if (drag_x11->version == 5) + drag_x11->drop_failed = xevent->xclient.data.l[1] == 0; - g_signal_emit_by_name (context, "dnd-finished"); - gdk_drag_drop_done (context, !context_x11->drop_failed); + g_signal_emit_by_name (drag, "dnd-finished"); + gdk_drag_drop_done (drag, !drag_x11->drop_failed); - g_object_unref (context); + g_object_unref (drag); } } static void -xdnd_set_targets (GdkX11DragContext *context_x11) +xdnd_set_targets (GdkX11Drag *drag_x11) { - GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11); + GdkDrag *drag = GDK_DRAG (drag_x11); Atom *atomlist; const char * const *atoms; gsize i, n_atoms; - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDisplay *display = gdk_drag_get_display (drag); - atoms = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (context), &n_atoms); + atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms); atomlist = g_new (Atom, n_atoms); for (i = 0; i < n_atoms; i++) atomlist[i] = gdk_x11_get_xatom_by_name_for_display (display, atoms[i]); XChangeProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_SURFACE_XID (context_x11->ipc_surface), + GDK_SURFACE_XID (drag_x11->ipc_surface), gdk_x11_get_xatom_by_name_for_display (display, "XdndTypeList"), XA_ATOM, 32, PropModeReplace, (guchar *)atomlist, n_atoms); g_free (atomlist); - context_x11->xdnd_targets_set = 1; + drag_x11->xdnd_targets_set = 1; } static void -xdnd_set_actions (GdkX11DragContext *context_x11) +xdnd_set_actions (GdkX11Drag *drag_x11) { - GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11); + GdkDrag *drag = GDK_DRAG (drag_x11); Atom *atomlist; gint i; gint n_atoms; guint actions; - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDisplay *display = gdk_drag_get_display (drag); - actions = gdk_drag_context_get_actions (context); + actions = gdk_drag_get_actions (drag); n_atoms = 0; for (i = 0; i < xdnd_n_actions; i++) { @@ -968,7 +968,7 @@ xdnd_set_actions (GdkX11DragContext *context_x11) atomlist = g_new (Atom, n_atoms); - actions = gdk_drag_context_get_actions (context); + actions = gdk_drag_get_actions (drag); n_atoms = 0; for (i = 0; i < xdnd_n_actions; i++) { @@ -981,14 +981,14 @@ xdnd_set_actions (GdkX11DragContext *context_x11) } XChangeProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_SURFACE_XID (context_x11->ipc_surface), + GDK_SURFACE_XID (drag_x11->ipc_surface), gdk_x11_get_xatom_by_name_for_display (display, "XdndActionList"), XA_ATOM, 32, PropModeReplace, (guchar *)atomlist, n_atoms); g_free (atomlist); - context_x11->xdnd_actions = gdk_drag_context_get_actions (context); + drag_x11->xdnd_actions = gdk_drag_get_actions (drag); } static void @@ -996,10 +996,10 @@ send_client_message_async_cb (Window window, gboolean success, gpointer data) { - GdkX11DragContext *context_x11 = data; - GdkDragContext *context = data; + GdkX11Drag *drag_x11 = data; + GdkDrag *drag = data; - GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), DND, + GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), DND, g_message ("Got async callback for #%lx, success = %d", window, success)); @@ -1007,69 +1007,69 @@ send_client_message_async_cb (Window window, * so we don't end up blocking for a timeout */ if (!success && - window == context_x11->proxy_xid) + window == drag_x11->proxy_xid) { - context_x11->proxy_xid = None; - context->action = 0; - if (context->action != context_x11->current_action) + drag_x11->proxy_xid = None; + drag->action = 0; + if (drag->action != drag_x11->current_action) { - context_x11->current_action = 0; - g_signal_emit_by_name (context, "action-changed", 0); + drag_x11->current_action = 0; + g_signal_emit_by_name (drag, "action-changed", 0); } - context_x11->drag_status = GDK_DRAG_STATUS_DRAG; + drag_x11->drag_status = GDK_DRAG_STATUS_DRAG; } - g_object_unref (context); + g_object_unref (drag); } static void -send_client_message_async (GdkDragContext *context, +send_client_message_async (GdkDrag *drag, Window window, glong event_mask, XClientMessageEvent *event_send) { - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDisplay *display = gdk_drag_get_display (drag); - g_object_ref (context); + g_object_ref (drag); _gdk_x11_send_client_message_async (display, window, FALSE, event_mask, event_send, - send_client_message_async_cb, context); + send_client_message_async_cb, drag); } static void -xdnd_send_xevent (GdkX11DragContext *context_x11, +xdnd_send_xevent (GdkX11Drag *drag_x11, XEvent *event_send) { - GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11); - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDrag *drag = GDK_DRAG (drag_x11); + GdkDisplay *display = gdk_drag_get_display (drag); GdkSurface *surface; glong event_mask; g_assert (event_send->xany.type == ClientMessage); /* We short-circuit messages to ourselves */ - surface = gdk_x11_surface_lookup_for_display (display, context_x11->proxy_xid); + surface = gdk_x11_surface_lookup_for_display (display, drag_x11->proxy_xid); if (surface) { if (gdk_x11_drop_filter (surface, event_send)) return; } - if (_gdk_x11_display_is_root_window (display, context_x11->proxy_xid)) + if (_gdk_x11_display_is_root_window (display, drag_x11->proxy_xid)) event_mask = ButtonPressMask; else event_mask = 0; - send_client_message_async (context, context_x11->proxy_xid, event_mask, + send_client_message_async (drag, drag_x11->proxy_xid, event_mask, &event_send->xclient); } static void -xdnd_send_enter (GdkX11DragContext *context_x11) +xdnd_send_enter (GdkX11Drag *drag_x11) { - GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11); - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDrag *drag = GDK_DRAG (drag_x11); + GdkDisplay *display = gdk_drag_get_display (drag); const char * const *atoms; gsize i, n_atoms; XEvent xev; @@ -1077,24 +1077,24 @@ xdnd_send_enter (GdkX11DragContext *context_x11) xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndEnter"); xev.xclient.format = 32; - xev.xclient.window = context_x11->drop_xid - ? context_x11->drop_xid - : context_x11->proxy_xid; - xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface); - xev.xclient.data.l[1] = (context_x11->version << 24); /* version */ + xev.xclient.window = drag_x11->drop_xid + ? drag_x11->drop_xid + : drag_x11->proxy_xid; + xev.xclient.data.l[0] = GDK_SURFACE_XID (drag_x11->ipc_surface); + xev.xclient.data.l[1] = (drag_x11->version << 24); /* version */ xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; xev.xclient.data.l[4] = 0; GDK_DISPLAY_NOTE (display, DND, g_message ("Sending enter source window %#lx XDND protocol version %d\n", - GDK_SURFACE_XID (context_x11->ipc_surface), context_x11->version)); - atoms = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (context), &n_atoms); + GDK_SURFACE_XID (drag_x11->ipc_surface), drag_x11->version)); + atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms); if (n_atoms > 3) { - if (!context_x11->xdnd_targets_set) - xdnd_set_targets (context_x11); + if (!drag_x11->xdnd_targets_set) + xdnd_set_targets (drag_x11); xev.xclient.data.l[1] |= 1; } else @@ -1105,79 +1105,79 @@ xdnd_send_enter (GdkX11DragContext *context_x11) } } - xdnd_send_xevent (context_x11, &xev); + xdnd_send_xevent (drag_x11, &xev); } static void -xdnd_send_leave (GdkX11DragContext *context_x11) +xdnd_send_leave (GdkX11Drag *drag_x11) { - GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11); - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDrag *drag = GDK_DRAG (drag_x11); + GdkDisplay *display = gdk_drag_get_display (drag); XEvent xev; xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndLeave"); xev.xclient.format = 32; - xev.xclient.window = context_x11->drop_xid - ? context_x11->drop_xid - : context_x11->proxy_xid; - xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface); + xev.xclient.window = drag_x11->drop_xid + ? drag_x11->drop_xid + : drag_x11->proxy_xid; + xev.xclient.data.l[0] = GDK_SURFACE_XID (drag_x11->ipc_surface); xev.xclient.data.l[1] = 0; xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 0; xev.xclient.data.l[4] = 0; - xdnd_send_xevent (context_x11, &xev); + xdnd_send_xevent (drag_x11, &xev); } static void -xdnd_send_drop (GdkX11DragContext *context_x11, +xdnd_send_drop (GdkX11Drag *drag_x11, guint32 time) { - GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11); - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDrag *drag = GDK_DRAG (drag_x11); + GdkDisplay *display = gdk_drag_get_display (drag); XEvent xev; xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndDrop"); xev.xclient.format = 32; - xev.xclient.window = context_x11->drop_xid - ? context_x11->drop_xid - : context_x11->proxy_xid; - xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface); + xev.xclient.window = drag_x11->drop_xid + ? drag_x11->drop_xid + : drag_x11->proxy_xid; + xev.xclient.data.l[0] = GDK_SURFACE_XID (drag_x11->ipc_surface); xev.xclient.data.l[1] = 0; xev.xclient.data.l[2] = time; xev.xclient.data.l[3] = 0; xev.xclient.data.l[4] = 0; - xdnd_send_xevent (context_x11, &xev); + xdnd_send_xevent (drag_x11, &xev); } static void -xdnd_send_motion (GdkX11DragContext *context_x11, +xdnd_send_motion (GdkX11Drag *drag_x11, gint x_root, gint y_root, GdkDragAction action, guint32 time) { - GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11); - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDrag *drag = GDK_DRAG (drag_x11); + GdkDisplay *display = gdk_drag_get_display (drag); XEvent xev; xev.xclient.type = ClientMessage; xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndPosition"); xev.xclient.format = 32; - xev.xclient.window = context_x11->drop_xid - ? context_x11->drop_xid - : context_x11->proxy_xid; - xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface); + xev.xclient.window = drag_x11->drop_xid + ? drag_x11->drop_xid + : drag_x11->proxy_xid; + xev.xclient.data.l[0] = GDK_SURFACE_XID (drag_x11->ipc_surface); xev.xclient.data.l[1] = 0; xev.xclient.data.l[2] = (x_root << 16) | y_root; xev.xclient.data.l[3] = time; xev.xclient.data.l[4] = xdnd_action_to_atom (display, action); - xdnd_send_xevent (context_x11, &xev); - context_x11->drag_status = GDK_DRAG_STATUS_MOTION_WAIT; + xdnd_send_xevent (drag_x11, &xev); + drag_x11->drag_status = GDK_DRAG_STATUS_MOTION_WAIT; } static guint32 @@ -1309,15 +1309,15 @@ xdnd_precache_atoms (GdkDisplay *display) /* Source side */ static void -gdk_drag_do_leave (GdkX11DragContext *context_x11, +gdk_drag_do_leave (GdkX11Drag *drag_x11, guint32 time) { - if (context_x11->proxy_xid) + if (drag_x11->proxy_xid) { - switch (context_x11->protocol) + switch (drag_x11->protocol) { case GDK_DRAG_PROTO_XDND: - xdnd_send_leave (context_x11); + xdnd_send_leave (drag_x11); break; case GDK_DRAG_PROTO_ROOTWIN: case GDK_DRAG_PROTO_NONE: @@ -1325,7 +1325,7 @@ gdk_drag_do_leave (GdkX11DragContext *context_x11, break; } - context_x11->proxy_xid = None; + drag_x11->proxy_xid = None; } } @@ -1401,33 +1401,33 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display, } static GdkSurfaceCache * -drag_context_find_window_cache (GdkX11DragContext *context_x11, +drag_find_window_cache (GdkX11Drag *drag_x11, GdkDisplay *display) { - if (!context_x11->cache) - context_x11->cache = gdk_surface_cache_get (display); + if (!drag_x11->cache) + drag_x11->cache = gdk_surface_cache_get (display); - return context_x11->cache; + return drag_x11->cache; } static Window -gdk_x11_drag_context_find_surface (GdkDragContext *context, +gdk_x11_drag_find_surface (GdkDrag *drag, GdkSurface *drag_surface, gint x_root, gint y_root, GdkDragProtocol *protocol) { GdkX11Screen *screen_x11; - GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag); GdkSurfaceCache *window_cache; GdkDisplay *display; Window dest; Window proxy; - display = gdk_drag_context_get_display (context); + display = gdk_drag_get_display (drag); screen_x11 = GDK_X11_SCREEN(GDK_X11_DISPLAY (display)->screen); - window_cache = drag_context_find_window_cache (context_x11, display); + window_cache = drag_find_window_cache (drag_x11, display); dest = get_client_window_at_coords (window_cache, drag_surface && GDK_SURFACE_IS_X11 (drag_surface) ? @@ -1435,9 +1435,9 @@ gdk_x11_drag_context_find_surface (GdkDragContext *context, x_root * screen_x11->surface_scale, y_root * screen_x11->surface_scale); - if (context_x11->dest_xid != dest) + if (drag_x11->dest_xid != dest) { - context_x11->dest_xid = dest; + drag_x11->dest_xid = dest; /* Check if new destination accepts drags, and which protocol */ @@ -1450,32 +1450,32 @@ gdk_x11_drag_context_find_surface (GdkDragContext *context, proxy = _gdk_x11_display_get_drag_protocol (display, dest, protocol, - &context_x11->version); + &drag_x11->version); } else { proxy = dest; - *protocol = context_x11->protocol; + *protocol = drag_x11->protocol; } return proxy; } static void -move_drag_surface (GdkDragContext *context, +move_drag_surface (GdkDrag *drag, guint x_root, guint y_root) { - GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag); - gdk_surface_move (context_x11->drag_surface, - x_root - context_x11->hot_x, - y_root - context_x11->hot_y); - gdk_surface_raise (context_x11->drag_surface); + gdk_surface_move (drag_x11->drag_surface, + x_root - drag_x11->hot_x, + y_root - drag_x11->hot_y); + gdk_surface_raise (drag_x11->drag_surface); } static gboolean -gdk_x11_drag_context_drag_motion (GdkDragContext *context, +gdk_x11_drag_drag_motion (GdkDrag *drag, Window proxy_xid, GdkDragProtocol protocol, gint x_root, @@ -1484,68 +1484,68 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context, GdkDragAction possible_actions, guint32 time) { - GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag); - if (context_x11->drag_surface) - move_drag_surface (context, x_root, y_root); + if (drag_x11->drag_surface) + move_drag_surface (drag, x_root, y_root); - gdk_drag_context_set_actions (context, possible_actions, suggested_action); + gdk_drag_set_actions (drag, possible_actions, suggested_action); - if (protocol == GDK_DRAG_PROTO_XDND && context_x11->version == 0) + if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->version == 0) { /* This ugly hack is necessary since GTK+ doesn't know about * the XDND protocol version, and in particular doesn't know * that gdk_drag_find_window() has the side-effect - * of setting context_x11->version, and therefore sometimes call - * gdk_x11_drag_context_drag_motion() without a prior call to + * of setting drag_x11->version, and therefore sometimes call + * gdk_x11_drag_drag_motion() without a prior call to * gdk_drag_find_window(). This happens, e.g. * when GTK+ is proxying DND events to embedded windows. */ if (proxy_xid) { - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDisplay *display = gdk_drag_get_display (drag); xdnd_check_dest (display, proxy_xid, - &context_x11->version); + &drag_x11->version); } } /* When we have a Xdnd target, make sure our XdndActionList * matches the current actions; */ - if (protocol == GDK_DRAG_PROTO_XDND && context_x11->xdnd_actions != gdk_drag_context_get_actions (context)) + if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->xdnd_actions != gdk_drag_get_actions (drag)) { if (proxy_xid) { - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDisplay *display = gdk_drag_get_display (drag); GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop; if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid) gdk_x11_drop_read_actions (drop); else - xdnd_set_actions (context_x11); + xdnd_set_actions (drag_x11); } } - if (context_x11->proxy_xid != proxy_xid) + if (drag_x11->proxy_xid != proxy_xid) { /* Send a leave to the last destination */ - gdk_drag_do_leave (context_x11, time); - context_x11->drag_status = GDK_DRAG_STATUS_DRAG; + gdk_drag_do_leave (drag_x11, time); + drag_x11->drag_status = GDK_DRAG_STATUS_DRAG; /* Check if new destination accepts drags, and which protocol */ if (proxy_xid) { - context_x11->proxy_xid = proxy_xid; - context_x11->drop_xid = context_x11->dest_xid; - context_x11->protocol = protocol; + drag_x11->proxy_xid = proxy_xid; + drag_x11->drop_xid = drag_x11->dest_xid; + drag_x11->protocol = protocol; switch (protocol) { case GDK_DRAG_PROTO_XDND: - xdnd_send_enter (context_x11); + xdnd_send_enter (drag_x11); break; case GDK_DRAG_PROTO_ROOTWIN: @@ -1556,60 +1556,60 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context, } else { - context_x11->proxy_xid = None; - context_x11->drop_xid = None; - context->action = 0; + drag_x11->proxy_xid = None; + drag_x11->drop_xid = None; + drag->action = 0; } /* Push a status event, to let the client know that * the drag changed */ - if (context->action != context_x11->current_action) + if (drag->action != drag_x11->current_action) { - context_x11->current_action = context->action; - g_signal_emit_by_name (context, "action-changed", context->action); + drag_x11->current_action = drag->action; + g_signal_emit_by_name (drag, "action-changed", drag->action); } } /* Send a drag-motion event */ - context_x11->last_x = x_root; - context_x11->last_y = y_root; + drag_x11->last_x = x_root; + drag_x11->last_y = y_root; - if (context_x11->proxy_xid) + if (drag_x11->proxy_xid) { - GdkDisplay *display = gdk_drag_context_get_display (context); + GdkDisplay *display = gdk_drag_get_display (drag); GdkX11Screen *screen_x11 = GDK_X11_SCREEN(GDK_X11_DISPLAY (display)->screen); - if (context_x11->drag_status == GDK_DRAG_STATUS_DRAG) + if (drag_x11->drag_status == GDK_DRAG_STATUS_DRAG) { - switch (context_x11->protocol) + switch (drag_x11->protocol) { case GDK_DRAG_PROTO_XDND: - xdnd_send_motion (context_x11, x_root * screen_x11->surface_scale, y_root * screen_x11->surface_scale, suggested_action, time); + xdnd_send_motion (drag_x11, x_root * screen_x11->surface_scale, y_root * screen_x11->surface_scale, suggested_action, time); break; case GDK_DRAG_PROTO_ROOTWIN: { - GdkContentFormats *formats = gdk_drag_context_get_formats (context); + GdkContentFormats *formats = gdk_drag_get_formats (drag); /* GTK+ traditionally has used application/x-rootwin-drop, * but the XDND spec specifies x-rootwindow-drop. */ if (gdk_content_formats_contain_mime_type (formats, "application/x-rootwindow-drop") || gdk_content_formats_contain_mime_type (formats, "application/x-rootwin-drop")) - context->action = gdk_drag_context_get_suggested_action (context); + drag->action = gdk_drag_get_suggested_action (drag); else - context->action = 0; + drag->action = 0; - if (context->action != context_x11->current_action) + if (drag->action != drag_x11->current_action) { - context_x11->current_action = context->action; - g_signal_emit_by_name (context, "action-changed", context->action); + drag_x11->current_action = drag->action; + g_signal_emit_by_name (drag, "action-changed", drag->action); } } break; case GDK_DRAG_PROTO_NONE: - g_warning ("Invalid drag protocol %u in gdk_x11_drag_context_drag_motion()", context_x11->protocol); + g_warning ("Invalid drag protocol %u in gdk_x11_drag_drag_motion()", drag_x11->protocol); break; default: break; @@ -1623,24 +1623,24 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context, } static void -gdk_x11_drag_context_drag_abort (GdkDragContext *context, +gdk_x11_drag_drag_abort (GdkDrag *drag, guint32 time) { - gdk_drag_do_leave (GDK_X11_DRAG_CONTEXT (context), time); + gdk_drag_do_leave (GDK_X11_DRAG (drag), time); } static void -gdk_x11_drag_context_drag_drop (GdkDragContext *context, +gdk_x11_drag_drag_drop (GdkDrag *drag, guint32 time) { - GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *drag_x11 = GDK_X11_DRAG (drag); - if (context_x11->proxy_xid) + if (drag_x11->proxy_xid) { - switch (context_x11->protocol) + switch (drag_x11->protocol) { case GDK_DRAG_PROTO_XDND: - xdnd_send_drop (context_x11, time); + xdnd_send_drop (drag_x11, time); break; case GDK_DRAG_PROTO_ROOTWIN: @@ -1650,7 +1650,7 @@ gdk_x11_drag_context_drag_drop (GdkDragContext *context, g_warning ("GDK_DRAG_PROTO_NONE is not valid in gdk_drag_drop()"); break; default: - g_warning ("Drag protocol %u is not valid in gdk_drag_drop()", context_x11->protocol); + g_warning ("Drag protocol %u is not valid in gdk_drag_drop()", drag_x11->protocol); break; } } @@ -1684,68 +1684,68 @@ _gdk_x11_surface_register_dnd (GdkSurface *surface) } static GdkSurface * -gdk_x11_drag_context_get_drag_surface (GdkDragContext *context) +gdk_x11_drag_get_drag_surface (GdkDrag *drag) { - return GDK_X11_DRAG_CONTEXT (context)->drag_surface; + return GDK_X11_DRAG (drag)->drag_surface; } static void -gdk_x11_drag_context_set_hotspot (GdkDragContext *context, +gdk_x11_drag_set_hotspot (GdkDrag *drag, gint hot_x, gint hot_y) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); - x11_context->hot_x = hot_x; - x11_context->hot_y = hot_y; + x11_drag->hot_x = hot_x; + x11_drag->hot_y = hot_y; - if (x11_context->grab_seat) + if (x11_drag->grab_seat) { /* DnD is managed, update current position */ - move_drag_surface (context, x11_context->last_x, x11_context->last_y); + move_drag_surface (drag, x11_drag->last_x, x11_drag->last_y); } } static void -gdk_x11_drag_context_default_output_done (GObject *context, +gdk_x11_drag_default_output_done (GObject *drag, GAsyncResult *result, gpointer user_data) { GError *error = NULL; - if (!gdk_drag_context_write_finish (GDK_DRAG_CONTEXT (context), result, &error)) + if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error)) { - GDK_DISPLAY_NOTE (gdk_drag_context_get_display (GDK_DRAG_CONTEXT (context)), DND, g_printerr ("failed to write stream: %s\n", error->message)); + GDK_DISPLAY_NOTE (gdk_drag_get_display (GDK_DRAG (drag)), DND, g_printerr ("failed to write stream: %s\n", error->message)); g_error_free (error); } } static void -gdk_x11_drag_context_default_output_handler (GOutputStream *stream, +gdk_x11_drag_default_output_handler (GOutputStream *stream, const char *mime_type, gpointer user_data) { - gdk_drag_context_write_async (GDK_DRAG_CONTEXT (user_data), + gdk_drag_write_async (GDK_DRAG (user_data), mime_type, stream, G_PRIORITY_DEFAULT, NULL, - gdk_x11_drag_context_default_output_done, + gdk_x11_drag_default_output_done, NULL); g_object_unref (stream); } static gboolean -gdk_x11_drag_context_xevent (GdkDisplay *display, +gdk_x11_drag_xevent (GdkDisplay *display, const XEvent *xevent, gpointer data) { - GdkDragContext *context = GDK_DRAG_CONTEXT (data); - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkDrag *drag = GDK_DRAG (data); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); Window xwindow; Atom xselection; - xwindow = GDK_SURFACE_XID (x11_context->ipc_surface); + xwindow = GDK_SURFACE_XID (x11_drag->ipc_surface); xselection = gdk_x11_get_xatom_by_name_for_display (display, "XdndSelection"); if (xevent->xany.window != xwindow) @@ -1757,15 +1757,15 @@ gdk_x11_drag_context_xevent (GdkDisplay *display, if (xevent->xselectionclear.selection != xselection) return FALSE; - if (xevent->xselectionclear.time < x11_context->timestamp) + if (xevent->xselectionclear.time < x11_drag->timestamp) { GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("ignoring SelectionClear with too old timestamp (%lu vs %lu)\n", - xevent->xselectionclear.time, x11_context->timestamp)); + xevent->xselectionclear.time, x11_drag->timestamp)); return FALSE; } GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("got SelectionClear, aborting DND\n")); - gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR); + gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR); return TRUE; case SelectionRequest: @@ -1792,23 +1792,23 @@ gdk_x11_drag_context_xevent (GdkDisplay *display, target, property)); gdk_x11_selection_output_streams_create (display, - gdk_drag_context_get_formats (context), + gdk_drag_get_formats (drag), xevent->xselectionrequest.requestor, xevent->xselectionrequest.selection, xevent->xselectionrequest.target, xevent->xselectionrequest.property ? xevent->xselectionrequest.property : xevent->xselectionrequest.target, xevent->xselectionrequest.time, - gdk_x11_drag_context_default_output_handler, - context); + gdk_x11_drag_default_output_handler, + drag); return TRUE; } case ClientMessage: if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus")) - gdk_x11_drag_context_handle_status (display, xevent); + gdk_x11_drag_handle_status (display, xevent); else if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "XdndFinished")) - gdk_x11_drag_context_handle_finished (display, xevent); + gdk_x11_drag_handle_finished (display, xevent); else return FALSE; return TRUE; @@ -1830,7 +1830,7 @@ ease_out_cubic (double t) typedef struct _GdkDragAnim GdkDragAnim; struct _GdkDragAnim { - GdkX11DragContext *context; + GdkX11Drag *drag; GdkFrameClock *frame_clock; gint64 start_time; }; @@ -1838,7 +1838,7 @@ struct _GdkDragAnim { static void gdk_drag_anim_destroy (GdkDragAnim *anim) { - g_object_unref (anim->context); + g_object_unref (anim->drag); g_slice_free (GdkDragAnim, anim); } @@ -1846,7 +1846,7 @@ static gboolean gdk_drag_anim_timeout (gpointer data) { GdkDragAnim *anim = data; - GdkX11DragContext *context = anim->context; + GdkX11Drag *drag = anim->drag; GdkFrameClock *frame_clock = anim->frame_clock; gint64 current_time; double f; @@ -1864,38 +1864,38 @@ gdk_drag_anim_timeout (gpointer data) t = ease_out_cubic (f); - gdk_surface_show (context->drag_surface); - gdk_surface_move (context->drag_surface, - context->last_x + (context->start_x - context->last_x) * t, - context->last_y + (context->start_y - context->last_y) * t); - gdk_surface_set_opacity (context->drag_surface, 1.0 - f); + gdk_surface_show (drag->drag_surface); + gdk_surface_move (drag->drag_surface, + drag->last_x + (drag->start_x - drag->last_x) * t, + drag->last_y + (drag->start_y - drag->last_y) * t); + gdk_surface_set_opacity (drag->drag_surface, 1.0 - f); return G_SOURCE_CONTINUE; } static void -gdk_x11_drag_context_release_selection (GdkDragContext *context) +gdk_x11_drag_release_selection (GdkDrag *drag) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); GdkDisplay *display; Display *xdisplay; Window xwindow; Atom xselection; - display = gdk_drag_context_get_display (context); + display = gdk_drag_get_display (drag); xdisplay = GDK_DISPLAY_XDISPLAY (display); xselection = gdk_x11_get_xatom_by_name_for_display (display, "XdndSelection"); - xwindow = GDK_SURFACE_XID (x11_context->ipc_surface); + xwindow = GDK_SURFACE_XID (x11_drag->ipc_surface); if (XGetSelectionOwner (xdisplay, xselection) == xwindow) XSetSelectionOwner (xdisplay, xselection, None, CurrentTime); } static void -gdk_x11_drag_context_drop_done (GdkDragContext *context, +gdk_x11_drag_drop_done (GdkDrag *drag, gboolean success) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); GdkDragAnim *anim; /* cairo_surface_t *win_surface; @@ -1904,23 +1904,23 @@ gdk_x11_drag_context_drop_done (GdkDragContext *context, */ guint id; - gdk_x11_drag_context_release_selection (context); + gdk_x11_drag_release_selection (drag); - g_signal_handlers_disconnect_by_func (gdk_drag_context_get_display (context), - gdk_x11_drag_context_xevent, - context); + g_signal_handlers_disconnect_by_func (gdk_drag_get_display (drag), + gdk_x11_drag_xevent, + drag); if (success) { - gdk_surface_hide (x11_context->drag_surface); + gdk_surface_hide (x11_drag->drag_surface); return; } /* - win_surface = _gdk_surface_ref_cairo_surface (x11_context->drag_surface); - surface = gdk_surface_create_similar_surface (x11_context->drag_surface, + win_surface = _gdk_surface_ref_cairo_surface (x11_drag->drag_surface); + surface = gdk_surface_create_similar_surface (x11_drag->drag_surface, cairo_surface_get_content (win_surface), - gdk_surface_get_width (x11_context->drag_surface), - gdk_surface_get_height (x11_context->drag_surface)); + gdk_surface_get_width (x11_drag->drag_surface), + gdk_surface_get_height (x11_drag->drag_surface)); cr = cairo_create (surface); cairo_set_source_surface (cr, win_surface, 0, 0); cairo_paint (cr); @@ -1929,15 +1929,15 @@ gdk_x11_drag_context_drop_done (GdkDragContext *context, pattern = cairo_pattern_create_for_surface (surface); - gdk_surface_set_background_pattern (x11_context->drag_surface, pattern); + gdk_surface_set_background_pattern (x11_drag->drag_surface, pattern); cairo_pattern_destroy (pattern); cairo_surface_destroy (surface); */ anim = g_slice_new0 (GdkDragAnim); - anim->context = g_object_ref (x11_context); - anim->frame_clock = gdk_surface_get_frame_clock (x11_context->drag_surface); + anim->drag = g_object_ref (x11_drag); + anim->frame_clock = gdk_surface_get_frame_clock (x11_drag->drag_surface); anim->start_time = gdk_frame_clock_get_frame_time (anim->frame_clock); id = g_timeout_add_full (G_PRIORITY_DEFAULT, 17, @@ -1947,10 +1947,10 @@ gdk_x11_drag_context_drop_done (GdkDragContext *context, } static gboolean -drag_context_grab (GdkDragContext *context) +drag_grab (GdkDrag *drag) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); - GdkDevice *device = gdk_drag_context_get_device (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); + GdkDevice *device = gdk_drag_get_device (drag); GdkSeatCapabilities capabilities; GdkDisplay *display; Window root; @@ -1958,12 +1958,12 @@ drag_context_grab (GdkDragContext *context) gint keycode, i; GdkCursor *cursor; - if (!x11_context->ipc_surface) + if (!x11_drag->ipc_surface) return FALSE; - display = gdk_drag_context_get_display (context); + display = gdk_drag_get_display (drag); root = GDK_DISPLAY_XROOTWIN (display); - seat = gdk_device_get_seat (gdk_drag_context_get_device (context)); + seat = gdk_device_get_seat (gdk_drag_get_device (drag)); #ifdef XINPUT_2 if (GDK_IS_X11_DEVICE_XI2 (device)) @@ -1972,15 +1972,15 @@ drag_context_grab (GdkDragContext *context) #endif capabilities = GDK_SEAT_CAPABILITY_ALL; - cursor = gdk_drag_get_cursor (context, x11_context->current_action); - g_set_object (&x11_context->cursor, cursor); + cursor = gdk_drag_get_cursor (drag, x11_drag->current_action); + g_set_object (&x11_drag->cursor, cursor); - if (gdk_seat_grab (seat, x11_context->ipc_surface, + if (gdk_seat_grab (seat, x11_drag->ipc_surface, capabilities, FALSE, - x11_context->cursor, NULL, NULL, NULL) != GDK_GRAB_SUCCESS) + x11_drag->cursor, NULL, NULL, NULL) != GDK_GRAB_SUCCESS) return FALSE; - g_set_object (&x11_context->grab_seat, seat); + g_set_object (&x11_drag->grab_seat, seat); gdk_x11_display_error_trap_push (display); @@ -2040,23 +2040,23 @@ drag_context_grab (GdkDragContext *context) } static void -drag_context_ungrab (GdkDragContext *context) +drag_ungrab (GdkDrag *drag) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); GdkDisplay *display; GdkDevice *keyboard; Window root; gint keycode, i; - if (!x11_context->grab_seat) + if (!x11_drag->grab_seat) return; - gdk_seat_ungrab (x11_context->grab_seat); + gdk_seat_ungrab (x11_drag->grab_seat); - display = gdk_drag_context_get_display (context); - keyboard = gdk_seat_get_keyboard (x11_context->grab_seat); + display = gdk_drag_get_display (drag); + keyboard = gdk_seat_get_keyboard (x11_drag->grab_seat); root = GDK_DISPLAY_XROOTWIN (display); - g_clear_object (&x11_context->grab_seat); + g_clear_object (&x11_drag->grab_seat); for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i) { @@ -2091,91 +2091,91 @@ drag_context_ungrab (GdkDragContext *context) } } -GdkDragContext * -_gdk_x11_surface_drag_begin (GdkSurface *surface, - GdkDevice *device, - GdkContentProvider *content, - GdkDragAction actions, - gint dx, - gint dy) +GdkDrag * +_gdk_x11_surface_drag_begin (GdkSurface *surface, + GdkDevice *device, + GdkContentProvider *content, + GdkDragAction actions, + gint dx, + gint dy) { - GdkX11DragContext *x11_context; - GdkDragContext *context; + GdkX11Drag *x11_drag; + GdkDrag *drag; GdkDisplay *display; int x_root, y_root; Atom xselection; display = gdk_surface_get_display (surface); - context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, + drag = (GdkDrag *) g_object_new (GDK_TYPE_X11_DRAG, "device", device, "content", content, NULL); - x11_context = GDK_X11_DRAG_CONTEXT (context); + x11_drag = GDK_X11_DRAG (drag); - g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_drag_context_xevent), context); + g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_drag_xevent), drag); - precache_target_list (context); + precache_target_list (drag); gdk_device_get_position (device, &x_root, &y_root); x_root += dx; y_root += dy; - x11_context->start_x = x_root; - x11_context->start_y = y_root; - x11_context->last_x = x_root; - x11_context->last_y = y_root; + x11_drag->start_x = x_root; + x11_drag->start_y = y_root; + x11_drag->last_x = x_root; + x11_drag->last_y = y_root; - x11_context->protocol = GDK_DRAG_PROTO_XDND; - x11_context->actions = actions; - x11_context->ipc_surface = gdk_surface_new_popup (display, &(GdkRectangle) { -99, -99, 1, 1 }); + 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 }); if (gdk_surface_get_group (surface)) - gdk_surface_set_group (x11_context->ipc_surface, surface); - gdk_surface_show (x11_context->ipc_surface); + gdk_surface_set_group (x11_drag->ipc_surface, surface); + gdk_surface_show (x11_drag->ipc_surface); - context->source_surface = x11_context->ipc_surface; - g_object_ref (context->source_surface); + drag->source_surface = x11_drag->ipc_surface; + g_object_ref (drag->source_surface); - x11_context->drag_surface = create_drag_surface (display); + x11_drag->drag_surface = create_drag_surface (display); - if (!drag_context_grab (context)) + if (!drag_grab (drag)) { - g_object_unref (context); + g_object_unref (drag); return NULL; } - move_drag_surface (context, x_root, y_root); + move_drag_surface (drag, x_root, y_root); - x11_context->timestamp = gdk_display_get_last_seen_time (display); + x11_drag->timestamp = gdk_display_get_last_seen_time (display); xselection = gdk_x11_get_xatom_by_name_for_display (display, "XdndSelection"); XSetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), xselection, - GDK_SURFACE_XID (x11_context->ipc_surface), - x11_context->timestamp); - if (XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), xselection) != GDK_SURFACE_XID (x11_context->ipc_surface)) + GDK_SURFACE_XID (x11_drag->ipc_surface), + x11_drag->timestamp); + if (XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), xselection) != GDK_SURFACE_XID (x11_drag->ipc_surface)) { GDK_DISPLAY_NOTE (display, DND, g_printerr ("failed XSetSelectionOwner() on \"XdndSelection\", aborting DND\n")); - g_object_unref (context); + g_object_unref (drag); return NULL; } - return context; + return drag; } static void -gdk_x11_drag_context_set_cursor (GdkDragContext *context, - GdkCursor *cursor) +gdk_x11_drag_set_cursor (GdkDrag *drag, + GdkCursor *cursor) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); - if (!g_set_object (&x11_context->cursor, cursor)) + if (!g_set_object (&x11_drag->cursor, cursor)) return; - if (x11_context->grab_seat) + if (x11_drag->grab_seat) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - gdk_device_grab (gdk_seat_get_pointer (x11_context->grab_seat), - x11_context->ipc_surface, + gdk_device_grab (gdk_seat_get_pointer (x11_drag->grab_seat), + x11_drag->ipc_surface, GDK_OWNERSHIP_APPLICATION, FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, cursor, GDK_CURRENT_TIME); @@ -2184,19 +2184,19 @@ gdk_x11_drag_context_set_cursor (GdkDragContext *context, } static void -gdk_x11_drag_context_cancel (GdkDragContext *context, - GdkDragCancelReason reason) +gdk_x11_drag_cancel (GdkDrag *drag, + GdkDragCancelReason reason) { - drag_context_ungrab (context); - gdk_drag_drop_done (context, FALSE); + drag_ungrab (drag); + gdk_drag_drop_done (drag, FALSE); } static void -gdk_x11_drag_context_drop_performed (GdkDragContext *context, - guint32 time_) +gdk_x11_drag_drop_performed (GdkDrag *drag, + guint32 time_) { - gdk_drag_drop (context, time_); - drag_context_ungrab (context); + gdk_drag_drop (drag, time_); + drag_ungrab (drag); } #define BIG_STEP 20 @@ -2260,30 +2260,30 @@ gdk_drag_get_current_actions (GdkModifierType state, } static void -gdk_drag_update (GdkDragContext *context, +gdk_drag_update (GdkDrag *drag, gdouble x_root, gdouble y_root, GdkModifierType mods, guint32 evtime) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); GdkDragAction action, possible_actions; GdkDragProtocol protocol; Window proxy; - gdk_drag_get_current_actions (mods, GDK_BUTTON_PRIMARY, x11_context->actions, + gdk_drag_get_current_actions (mods, GDK_BUTTON_PRIMARY, x11_drag->actions, &action, &possible_actions); - proxy = gdk_x11_drag_context_find_surface (context, - x11_context->drag_surface, + proxy = gdk_x11_drag_find_surface (drag, + x11_drag->drag_surface, x_root, y_root, &protocol); - gdk_x11_drag_context_drag_motion (context, proxy, protocol, x_root, y_root, + gdk_x11_drag_drag_motion (drag, proxy, protocol, x_root, y_root, action, possible_actions, evtime); } static gboolean -gdk_dnd_handle_motion_event (GdkDragContext *context, +gdk_dnd_handle_motion_event (GdkDrag *drag, const GdkEventMotion *event) { GdkModifierType state; @@ -2291,16 +2291,16 @@ gdk_dnd_handle_motion_event (GdkDragContext *context, if (!gdk_event_get_state ((GdkEvent *) event, &state)) return FALSE; - gdk_drag_update (context, event->x_root, event->y_root, state, + gdk_drag_update (drag, event->x_root, event->y_root, state, gdk_event_get_time ((GdkEvent *) event)); return TRUE; } static gboolean -gdk_dnd_handle_key_event (GdkDragContext *context, +gdk_dnd_handle_key_event (GdkDrag *drag, const GdkEventKey *event) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); GdkModifierType state; GdkDevice *pointer; gint dx, dy; @@ -2314,7 +2314,7 @@ gdk_dnd_handle_key_event (GdkDragContext *context, switch (event->keyval) { case GDK_KEY_Escape: - gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_USER_CANCELLED); + gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED); return TRUE; case GDK_KEY_space: @@ -2322,13 +2322,13 @@ gdk_dnd_handle_key_event (GdkDragContext *context, case GDK_KEY_ISO_Enter: case GDK_KEY_KP_Enter: case GDK_KEY_KP_Space: - if ((gdk_drag_context_get_selected_action (context) != 0) && - (x11_context->proxy_xid != None)) + if ((gdk_drag_get_selected_action (drag) != 0) && + (x11_drag->proxy_xid != None)) { - g_signal_emit_by_name (context, "drop-performed"); + g_signal_emit_by_name (drag, "drop-performed"); } else - gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_NO_TARGET); + gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET); return TRUE; @@ -2365,83 +2365,83 @@ gdk_dnd_handle_key_event (GdkDragContext *context, if (dx != 0 || dy != 0) { - x11_context->last_x += dx; - x11_context->last_y += dy; - gdk_device_warp (pointer, x11_context->last_x, x11_context->last_y); + x11_drag->last_x += dx; + x11_drag->last_y += dy; + gdk_device_warp (pointer, x11_drag->last_x, x11_drag->last_y); } - gdk_drag_update (context, x11_context->last_x, x11_context->last_y, state, + gdk_drag_update (drag, x11_drag->last_x, x11_drag->last_y, state, gdk_event_get_time ((GdkEvent *) event)); return TRUE; } static gboolean -gdk_dnd_handle_grab_broken_event (GdkDragContext *context, +gdk_dnd_handle_grab_broken_event (GdkDrag *drag, const GdkEventGrabBroken *event) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); /* Don't cancel if we break the implicit grab from the initial button_press. * Also, don't cancel if we re-grab on the widget or on our IPC window, for * example, when changing the drag cursor. */ if (event->implicit || - event->grab_surface == x11_context->drag_surface || - event->grab_surface == x11_context->ipc_surface) + event->grab_surface == x11_drag->drag_surface || + event->grab_surface == x11_drag->ipc_surface) return FALSE; if (gdk_event_get_device ((GdkEvent *) event) != - gdk_drag_context_get_device (context)) + gdk_drag_get_device (drag)) return FALSE; - gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR); + gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR); return TRUE; } static gboolean -gdk_dnd_handle_button_event (GdkDragContext *context, +gdk_dnd_handle_button_event (GdkDrag *drag, const GdkEventButton *event) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); #if 0 /* FIXME: Check the button matches */ - if (event->button != x11_context->button) + if (event->button != x11_drag->button) return FALSE; #endif - if ((gdk_drag_context_get_selected_action (context) != 0) && - (x11_context->proxy_xid != None)) + if ((gdk_drag_get_selected_action (drag) != 0) && + (x11_drag->proxy_xid != None)) { - g_signal_emit_by_name (context, "drop-performed"); + g_signal_emit_by_name (drag, "drop-performed"); } else - gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_NO_TARGET); + gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET); return TRUE; } gboolean -gdk_x11_drag_context_handle_event (GdkDragContext *context, - const GdkEvent *event) +gdk_x11_drag_handle_event (GdkDrag *drag, + const GdkEvent *event) { - GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context); + GdkX11Drag *x11_drag = GDK_X11_DRAG (drag); - if (!x11_context->grab_seat) + if (!x11_drag->grab_seat) return FALSE; switch ((guint) event->any.type) { case GDK_MOTION_NOTIFY: - return gdk_dnd_handle_motion_event (context, &event->motion); + return gdk_dnd_handle_motion_event (drag, &event->motion); case GDK_BUTTON_RELEASE: - return gdk_dnd_handle_button_event (context, &event->button); + return gdk_dnd_handle_button_event (drag, &event->button); case GDK_KEY_PRESS: case GDK_KEY_RELEASE: - return gdk_dnd_handle_key_event (context, &event->key); + return gdk_dnd_handle_key_event (drag, &event->key); case GDK_GRAB_BROKEN: - return gdk_dnd_handle_grab_broken_event (context, &event->grab_broken); + return gdk_dnd_handle_grab_broken_event (drag, &event->grab_broken); default: break; } @@ -2450,11 +2450,11 @@ gdk_x11_drag_context_handle_event (GdkDragContext *context, } void -gdk_x11_drag_context_action_changed (GdkDragContext *context, - GdkDragAction action) -{ +gdk_x11_drag_action_changed (GdkDrag *drag, + GdkDragAction action) +{ GdkCursor *cursor; - cursor = gdk_drag_get_cursor (context, action); - gdk_drag_context_set_cursor (context, cursor); + cursor = gdk_drag_get_cursor (drag, action); + gdk_drag_set_cursor (drag, cursor); } diff --git a/gdk/x11/gdkdrop-x11.c b/gdk/x11/gdkdrop-x11.c index add5c98cd4..c07f423fd5 100644 --- a/gdk/x11/gdkdrop-x11.c +++ b/gdk/x11/gdkdrop-x11.c @@ -336,7 +336,7 @@ gdk_x11_drop_read_actions (GdkDrop *drop) { GdkX11Drop *drop_x11 = GDK_X11_DROP (drop); GdkDisplay *display = gdk_drop_get_display (drop); - GdkDragContext *drag; + GdkDrag *drag; GdkDragAction actions = GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK; Atom type; int format; @@ -398,7 +398,7 @@ gdk_x11_drop_read_actions (GdkDrop *drop) } else { - actions = gdk_drag_context_get_actions (drag); + actions = gdk_drag_get_actions (drag); drop_x11->xdnd_have_actions = TRUE; } @@ -468,7 +468,7 @@ xdnd_enter_filter (GdkSurface *surface, GdkX11Display *display_x11; GdkDrop *drop; GdkX11Drop *drop_x11; - GdkDragContext *drag; + GdkDrag *drag; GdkSeat *seat; gint i; Atom type; @@ -548,7 +548,7 @@ xdnd_enter_filter (GdkSurface *surface, print_target_list (content_formats); #endif /* G_ENABLE_DEBUG */ - drag = gdk_x11_drag_context_find (display, source_window, GDK_SURFACE_XID (surface)); + drag = gdk_x11_drag_find (display, source_window, GDK_SURFACE_XID (surface)); drop_x11 = g_object_new (GDK_TYPE_X11_DROP, "device", gdk_seat_get_pointer (seat), @@ -768,7 +768,7 @@ gdk_x11_drop_status (GdkDrop *drop, if (gdk_drop_get_drag (drop)) { - gdk_x11_drag_context_handle_status (display, &xev); + gdk_x11_drag_handle_status (display, &xev); } else { @@ -821,7 +821,7 @@ gdk_x11_drop_finish (GdkDrop *drop, if (gdk_drop_get_drag (drop)) { - gdk_x11_drag_context_handle_status (display, &xev); + gdk_x11_drag_handle_status (display, &xev); } else { @@ -849,7 +849,7 @@ gdk_x11_drop_class_init (GdkX11DropClass *klass) } static void -gdk_x11_drop_init (GdkX11Drop *context) +gdk_x11_drop_init (GdkX11Drop *drag) { } diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 6af2811756..a609c4b93e 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -196,16 +196,16 @@ Atom _gdk_x11_get_xatom_for_display_printf (GdkDisplay *display, const gchar *format, ...) G_GNUC_PRINTF (2, 3); -GdkDragContext *gdk_x11_drag_context_find (GdkDisplay *display, - Window source_xid, - Window dest_xid); -void gdk_x11_drag_context_handle_status (GdkDisplay *display, - const XEvent *xevent); -void gdk_x11_drag_context_handle_finished (GdkDisplay *display, - const XEvent *xevent); -void gdk_x11_drop_read_actions (GdkDrop *drop); -gboolean gdk_x11_drop_filter (GdkSurface *surface, - const XEvent *xevent); +GdkDrag *gdk_x11_drag_find (GdkDisplay *display, + Window source_xid, + Window dest_xid); +void gdk_x11_drag_handle_status (GdkDisplay *display, + const XEvent *xevent); +void gdk_x11_drag_handle_finished (GdkDisplay *display, + const XEvent *xevent); +void gdk_x11_drop_read_actions (GdkDrop *drop); +gboolean gdk_x11_drop_filter (GdkSurface *surface, + const XEvent *xevent); typedef struct _GdkSurfaceCache GdkSurfaceCache; @@ -225,7 +225,7 @@ void _gdk_x11_cursor_display_finalize (GdkDisplay *display); void _gdk_x11_surface_register_dnd (GdkSurface *window); -GdkDragContext * _gdk_x11_surface_drag_begin (GdkSurface *window, +GdkDrag * _gdk_x11_surface_drag_begin (GdkSurface *window, GdkDevice *device, GdkContentProvider *content, GdkDragAction actions, diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h index ff3d5a43a9..a6e6e1c024 100644 --- a/gdk/x11/gdkx-autocleanups.h +++ b/gdk/x11/gdkx-autocleanups.h @@ -27,7 +27,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceManagerCore, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceManagerXI2, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Drag, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref) diff --git a/gdk/x11/gdkx11dnd.h b/gdk/x11/gdkx11dnd.h index a676314219..dfe60500c6 100644 --- a/gdk/x11/gdkx11dnd.h +++ b/gdk/x11/gdkx11dnd.h @@ -26,23 +26,23 @@ G_BEGIN_DECLS -#define GDK_TYPE_X11_DRAG_CONTEXT (gdk_x11_drag_context_get_type ()) -#define GDK_X11_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContext)) -#define GDK_X11_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContextClass)) -#define GDK_IS_X11_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_DRAG_CONTEXT)) -#define GDK_IS_X11_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_DRAG_CONTEXT)) -#define GDK_X11_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_DRAG_CONTEXT, GdkX11DragContextClass)) +#define GDK_TYPE_X11_DRAG (gdk_x11_drag_get_type ()) +#define GDK_X11_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_DRAG, GdkX11Drag)) +#define GDK_X11_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_DRAG, GdkX11DragClass)) +#define GDK_IS_X11_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_DRAG)) +#define GDK_IS_X11_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_DRAG)) +#define GDK_X11_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_DRAG, GdkX11DragClass)) #ifdef GDK_COMPILATION -typedef struct _GdkX11DragContext GdkX11DragContext; +typedef struct _GdkX11Drag GdkX11Drag; #else -typedef GdkDragContext GdkX11DragContext; +typedef GdkDrag GdkX11Drag; #endif -typedef struct _GdkX11DragContextClass GdkX11DragContextClass; +typedef struct _GdkX11DragClass GdkX11DragClass; GDK_AVAILABLE_IN_ALL -GType gdk_x11_drag_context_get_type (void); +GType gdk_x11_drag_get_type (void); G_END_DECLS -#endif /* __GDK_X11_DRAG_CONTEXT_H__ */ +#endif /* __GDK_X11_DRAG_H__ */ diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 1ccbed01c5..9273969028 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -308,7 +308,7 @@ static gboolean gtk_calendar_query_tooltip (GtkWidget *widget, GtkTooltip *tooltip); static void gtk_calendar_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data); static void gtk_calendar_drag_data_received (GtkWidget *widget, GdkDrop *drop, @@ -2660,7 +2660,7 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture, GtkWidget *widget = data; GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; gdouble start_x, start_y; - GdkDragContext *context; + GdkDrag *drag; GdkContentFormats *targets; if (!priv->in_drag) @@ -2675,15 +2675,15 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture, targets = gdk_content_formats_new (NULL, 0); targets = gtk_content_formats_add_text_targets (targets); - context = gtk_drag_begin_with_coordinates (widget, - gtk_gesture_get_device (GTK_GESTURE (gesture)), - targets, GDK_ACTION_COPY, - start_x, start_y); + drag = gtk_drag_begin_with_coordinates (widget, + gtk_gesture_get_device (GTK_GESTURE (gesture)), + targets, GDK_ACTION_COPY, + start_x, start_y); priv->in_drag = 0; gdk_content_formats_unref (targets); - gtk_drag_set_icon_default (context); + gtk_drag_set_icon_default (drag); } static void @@ -2900,7 +2900,7 @@ gtk_calendar_grab_notify (GtkWidget *widget, static void gtk_calendar_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data) { GtkCalendar *calendar = GTK_CALENDAR (widget); diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c index 78eec0e16d..9091b65c65 100644 --- a/gtk/gtkcolorbutton.c +++ b/gtk/gtkcolorbutton.c @@ -110,10 +110,10 @@ static void gtk_color_button_clicked (GtkButton *button, /* source side drag signals */ static void gtk_color_button_drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data); static void gtk_color_button_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, GtkColorButton *button); @@ -312,7 +312,7 @@ gtk_color_button_drag_data_received (GtkWidget *widget, } static void -set_color_icon (GdkDragContext *context, +set_color_icon (GdkDrag *drag, const GdkRGBA *rgba) { GtkSnapshot *snapshot; @@ -324,24 +324,24 @@ set_color_icon (GdkDragContext *context, &GRAPHENE_RECT_INIT(0, 0, 48, 32)); paintable = gtk_snapshot_free_to_paintable (snapshot, NULL); - gtk_drag_set_icon_paintable (context, paintable, 0, 0); + gtk_drag_set_icon_paintable (drag, paintable, 0, 0); g_object_unref (paintable); } static void gtk_color_button_drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GtkColorButton *button = data; GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button); - set_color_icon (context, &priv->rgba); + set_color_icon (drag, &priv->rgba); } static void gtk_color_button_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, GtkColorButton *button) { diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index 5fd2b11e66..abd972461b 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -157,7 +157,7 @@ swatch_snapshot (GtkWidget *widget, static void -drag_set_color_icon (GdkDragContext *context, +drag_set_color_icon (GdkDrag *drag, const GdkRGBA *color) { GtkSnapshot *snapshot; @@ -169,24 +169,24 @@ drag_set_color_icon (GdkDragContext *context, &GRAPHENE_RECT_INIT(0, 0, 48, 32)); paintable = gtk_snapshot_free_to_paintable (snapshot, NULL); - gtk_drag_set_icon_paintable (context, paintable, 4, 4); + gtk_drag_set_icon_paintable (drag, paintable, 4, 4); g_object_unref (paintable); } static void swatch_drag_begin (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget); GdkRGBA color; gtk_color_swatch_get_rgba (swatch, &color); - drag_set_color_icon (context, &color); + drag_set_color_icon (drag, &color); } static void swatch_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data) { GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget); diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 349167f018..f00a213da7 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -67,7 +67,7 @@ struct _GtkDragSourceInfo { GtkWidget *widget; GdkContentFormats *target_list; /* Targets for drag data */ - GdkDragContext *context; /* drag context */ + GdkDrag *drag; /* drag context */ GtkWidget *icon_window; /* Window for drag */ GtkWidget *icon_widget; /* Widget for drag */ @@ -115,9 +115,9 @@ static void gtk_drag_dest_set_widget (GtkDragDestInfo *info, static GtkDragDestInfo * gtk_drag_get_dest_info (GdkDrop *drop, gboolean create); -static GtkDragSourceInfo *gtk_drag_get_source_info (GdkDragContext *context, +static GtkDragSourceInfo *gtk_drag_get_source_info (GdkDrag *drag, gboolean create); -static void gtk_drag_clear_source_info (GdkDragContext *context); +static void gtk_drag_clear_source_info (GdkDrag *drag); static void gtk_drag_drop (GtkDragSourceInfo *info); static void gtk_drag_drop_finished (GtkDragSourceInfo *info, @@ -128,20 +128,20 @@ static void gtk_drag_cancel_internal (GtkDragSourceInfo *info, static void gtk_drag_remove_icon (GtkDragSourceInfo *info); static void gtk_drag_source_info_destroy (GtkDragSourceInfo *info); -static void gtk_drag_context_drop_performed_cb (GdkDragContext *context, - GtkDragSourceInfo *info); -static void gtk_drag_context_cancel_cb (GdkDragContext *context, - GdkDragCancelReason reason, - GtkDragSourceInfo *info); -static void gtk_drag_context_dnd_finished_cb (GdkDragContext *context, - GtkDragSourceInfo *info); +static void gtk_drag_drop_performed_cb (GdkDrag *drag, + GtkDragSourceInfo *info); +static void gtk_drag_cancel_cb (GdkDrag *drag, + GdkDragCancelReason reason, + GtkDragSourceInfo *info); +static void gtk_drag_dnd_finished_cb (GdkDrag *drag, + GtkDragSourceInfo *info); static gboolean gtk_drag_abort_timeout (gpointer data); -static void set_icon_helper (GdkDragContext *context, - GtkImageDefinition*def, - gint hot_x, - gint hot_y); +static void set_icon_helper (GdkDrag *drag, + GtkImageDefinition *def, + gint hot_x, + gint hot_y); /******************** @@ -304,7 +304,7 @@ gtk_drag_get_data (GtkWidget *widget, /** * gtk_drag_get_source_widget: - * @context: a (destination side) drag context + * @drag: a drag context * * Determines the source widget for a drag. * @@ -313,13 +313,13 @@ gtk_drag_get_data (GtkWidget *widget, * Otherwise, %NULL. */ GtkWidget * -gtk_drag_get_source_widget (GdkDragContext *context) +gtk_drag_get_source_widget (GdkDrag *drag) { GtkDragSourceInfo *info; - g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); + g_return_val_if_fail (GDK_IS_DRAG (drag), NULL); - info = gtk_drag_get_source_info (context, FALSE); + info = gtk_drag_get_source_info (drag, FALSE); if (info == NULL) return NULL; @@ -594,28 +594,28 @@ gtk_drag_get_dest_info (GdkDrop *drop, static GQuark dest_info_quark = 0; static GtkDragSourceInfo * -gtk_drag_get_source_info (GdkDragContext *context, - gboolean create) +gtk_drag_get_source_info (GdkDrag *drag, + gboolean create) { GtkDragSourceInfo *info; if (!dest_info_quark) dest_info_quark = g_quark_from_static_string ("gtk-source-info"); - info = g_object_get_qdata (G_OBJECT (context), dest_info_quark); + info = g_object_get_qdata (G_OBJECT (drag), dest_info_quark); if (!info && create) { info = g_new0 (GtkDragSourceInfo, 1); - info->context = context; - g_object_set_qdata (G_OBJECT (context), dest_info_quark, info); + info->drag = drag; + g_object_set_qdata (G_OBJECT (drag), dest_info_quark, info); } return info; } static void -gtk_drag_clear_source_info (GdkDragContext *context) +gtk_drag_clear_source_info (GdkDrag *drag) { - g_object_set_qdata (G_OBJECT (context), dest_info_quark, NULL); + g_object_set_qdata (G_OBJECT (drag), dest_info_quark, NULL); } /* @@ -743,7 +743,7 @@ struct _GtkDragContent GdkContentProvider parent; GtkWidget *widget; - GdkDragContext *context; + GdkDrag *drag; GdkContentFormats *formats; guint32 time; }; @@ -809,7 +809,7 @@ gtk_drag_content_write_mime_type_async (GdkContentProvider *provider, sdata.display = gtk_widget_get_display (content->widget); g_signal_emit_by_name (content->widget, "drag-data-get", - content->context, + content->drag, &sdata); if (sdata.length == -1) @@ -873,7 +873,7 @@ gtk_drag_content_init (GtkDragContent *content) /* Like gtk_drag_begin(), but also takes a GtkImageDefinition * so that we can set the icon from the source site information */ -GdkDragContext * +GdkDrag * gtk_drag_begin_internal (GtkWidget *widget, GdkDevice *device, GtkImageDefinition *icon, @@ -884,7 +884,7 @@ gtk_drag_begin_internal (GtkWidget *widget, { GtkDragSourceInfo *info; GtkWidget *toplevel; - GdkDragContext *context; + GdkDrag *drag; int dx, dy; GtkDragContent *content; @@ -905,17 +905,17 @@ gtk_drag_begin_internal (GtkWidget *widget, content->widget = g_object_ref (widget); content->formats = gdk_content_formats_ref (target_list); - context = gdk_drag_begin (gtk_widget_get_surface (toplevel), device, GDK_CONTENT_PROVIDER (content), actions, dx, dy); - if (context == NULL) + drag = gdk_drag_begin (gtk_widget_get_surface (toplevel), device, GDK_CONTENT_PROVIDER (content), actions, dx, dy); + if (drag == NULL) { g_object_unref (content); return NULL; } - content->context = context; + content->drag = drag; g_object_unref (content); - info = gtk_drag_get_source_info (context, TRUE); + info = gtk_drag_get_source_info (drag, TRUE); g_object_set_data (G_OBJECT (widget), I_("gtk-info"), info); @@ -930,7 +930,7 @@ gtk_drag_begin_internal (GtkWidget *widget, gtk_widget_reset_controllers (widget); - g_signal_emit_by_name (widget, "drag-begin", info->context); + g_signal_emit_by_name (widget, "drag-begin", info->drag); /* Ensure that we have an icon before we start the drag; the * application may have set one in ::drag_begin, or it may @@ -940,24 +940,24 @@ gtk_drag_begin_internal (GtkWidget *widget, { if (icon) { - set_icon_helper (info->context, icon, 0, 0); + set_icon_helper (info->drag, icon, 0, 0); } else { icon = gtk_image_definition_new_icon_name ("text-x-generic"); - set_icon_helper (info->context, icon, 0, 0); + set_icon_helper (info->drag, icon, 0, 0); gtk_image_definition_unref (icon); } } - g_signal_connect (context, "drop-performed", - G_CALLBACK (gtk_drag_context_drop_performed_cb), info); - g_signal_connect (context, "dnd-finished", - G_CALLBACK (gtk_drag_context_dnd_finished_cb), info); - g_signal_connect (context, "cancel", - G_CALLBACK (gtk_drag_context_cancel_cb), info); + g_signal_connect (drag, "drop-performed", + G_CALLBACK (gtk_drag_drop_performed_cb), info); + g_signal_connect (drag, "dnd-finished", + G_CALLBACK (gtk_drag_dnd_finished_cb), info); + g_signal_connect (drag, "cancel", + G_CALLBACK (gtk_drag_cancel_cb), info); - return info->context; + return info->drag; } /** @@ -979,7 +979,7 @@ gtk_drag_begin_internal (GtkWidget *widget, * * Returns: (transfer none): the context for this drag */ -GdkDragContext * +GdkDrag * gtk_drag_begin_with_coordinates (GtkWidget *widget, GdkDevice *device, GdkContentFormats *targets, @@ -1016,7 +1016,7 @@ icon_widget_destroyed (GtkWidget *widget, } static void -gtk_drag_set_icon_widget_internal (GdkDragContext *context, +gtk_drag_set_icon_widget_internal (GdkDrag *drag, GtkWidget *widget, gint hot_x, gint hot_y, @@ -1026,7 +1026,7 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context, g_return_if_fail (!GTK_IS_WINDOW (widget)); - info = gtk_drag_get_source_info (context, FALSE); + info = gtk_drag_get_source_info (drag, FALSE); if (info == NULL) { if (destroy_on_release) @@ -1047,13 +1047,13 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context, g_signal_connect (widget, "destroy", G_CALLBACK (icon_widget_destroyed), info); - gdk_drag_context_set_hotspot (context, hot_x, hot_y); + gdk_drag_set_hotspot (drag, hot_x, hot_y); if (!info->icon_window) { GdkDisplay *display; - display = gdk_drag_context_get_display (context); + display = gdk_drag_get_display (drag); info->icon_window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_type_hint (GTK_WINDOW (info->icon_window), GDK_SURFACE_TYPE_HINT_DND); @@ -1062,7 +1062,7 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context, gtk_style_context_remove_class (gtk_widget_get_style_context (info->icon_window), "background"); gtk_window_set_hardcoded_surface (GTK_WINDOW (info->icon_window), - gdk_drag_context_get_drag_surface (context)); + gdk_drag_get_drag_surface (drag)); gtk_widget_show (info->icon_window); } @@ -1073,8 +1073,7 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context, /** * gtk_drag_set_icon_widget: - * @context: the context for a drag. (This must be called - with a context for the source side of a drag) + * @drag: the context for a drag * @widget: a widget to use as an icon * @hot_x: the X offset within @widget of the hotspot * @hot_y: the Y offset within @widget of the hotspot @@ -1085,19 +1084,19 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context, * signal and destroy it yourself. */ void -gtk_drag_set_icon_widget (GdkDragContext *context, +gtk_drag_set_icon_widget (GdkDrag *drag, GtkWidget *widget, gint hot_x, gint hot_y) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); g_return_if_fail (GTK_IS_WIDGET (widget)); - gtk_drag_set_icon_widget_internal (context, widget, hot_x, hot_y, FALSE); + gtk_drag_set_icon_widget_internal (drag, widget, hot_x, hot_y, FALSE); } static void -set_icon_helper (GdkDragContext *context, +set_icon_helper (GdkDrag *drag, GtkImageDefinition *def, gint hot_x, gint hot_y) @@ -1107,25 +1106,24 @@ set_icon_helper (GdkDragContext *context, widget = gtk_image_new (); gtk_style_context_add_class (gtk_widget_get_style_context (widget), "drag-icon"); gtk_image_set_from_definition (GTK_IMAGE (widget), def); - gtk_drag_set_icon_widget_internal (context, widget, hot_x, hot_y, TRUE); + gtk_drag_set_icon_widget_internal (drag, widget, hot_x, hot_y, TRUE); } void -gtk_drag_set_icon_definition (GdkDragContext *context, +gtk_drag_set_icon_definition (GdkDrag *drag, GtkImageDefinition *def, gint hot_x, gint hot_y) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); g_return_if_fail (def != NULL); - set_icon_helper (context, def, hot_x, hot_y); + set_icon_helper (drag, def, hot_x, hot_y); } /** * gtk_drag_set_icon_paintable: - * @context: the context for a drag (This must be called - * with a context for the source side of a drag) + * @drag: the context for a drag * @paintable: the #GdkPaintable to use as icon * @hot_x: the X offset of the hotspot within the icon * @hot_y: the Y offset of the hotspot within the icon @@ -1139,26 +1137,25 @@ gtk_drag_set_icon_definition (GdkDragContext *context, * mouse cursor. */ void -gtk_drag_set_icon_paintable (GdkDragContext *context, +gtk_drag_set_icon_paintable (GdkDrag *drag, GdkPaintable *paintable, int hot_x, int hot_y) { GtkWidget *widget; - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); g_return_if_fail (GDK_IS_PAINTABLE (paintable)); widget = gtk_picture_new_for_paintable (paintable); gtk_picture_set_can_shrink (GTK_PICTURE (widget), FALSE); - gtk_drag_set_icon_widget_internal (context, widget, hot_x, hot_y, TRUE); + gtk_drag_set_icon_widget_internal (drag, widget, hot_x, hot_y, TRUE); } /** * gtk_drag_set_icon_name: - * @context: the context for a drag (This must be called - * with a context for the source side of a drag) + * @drag: the context for a drag * @icon_name: name of icon to use * @hot_x: the X offset of the hotspot within the icon * @hot_y: the Y offset of the hotspot within the icon @@ -1170,26 +1167,25 @@ gtk_drag_set_icon_paintable (GdkDragContext *context, * @hot_x and @hot_y have to be used with care. */ void -gtk_drag_set_icon_name (GdkDragContext *context, +gtk_drag_set_icon_name (GdkDrag *drag, const gchar *icon_name, gint hot_x, gint hot_y) { GtkImageDefinition *def; - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); g_return_if_fail (icon_name != NULL && icon_name[0] != '\0'); def = gtk_image_definition_new_icon_name (icon_name); - set_icon_helper (context, def, hot_x, hot_y); + set_icon_helper (drag, def, hot_x, hot_y); gtk_image_definition_unref (def); } /** * gtk_drag_set_icon_gicon: - * @context: the context for a drag (This must be called - * with a context for the source side of a drag) + * @drag: the context for a drag * @icon: a #GIcon * @hot_x: the X offset of the hotspot within the icon * @hot_y: the Y offset of the hotspot within the icon @@ -1199,36 +1195,35 @@ gtk_drag_set_icon_name (GdkDragContext *context, * for more details about using icons in drag and drop. */ void -gtk_drag_set_icon_gicon (GdkDragContext *context, +gtk_drag_set_icon_gicon (GdkDrag *drag, GIcon *icon, gint hot_x, gint hot_y) { GtkImageDefinition *def; - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); g_return_if_fail (icon != NULL); def = gtk_image_definition_new_gicon (icon); - set_icon_helper (context, def, hot_x, hot_y); + set_icon_helper (drag, def, hot_x, hot_y); gtk_image_definition_unref (def); } /** * gtk_drag_set_icon_default: - * @context: the context for a drag (This must be called - * with a context for the source side of a drag) + * @drag: the context for a drag * * Sets the icon for a particular drag to the default * icon. */ void -gtk_drag_set_icon_default (GdkDragContext *context) +gtk_drag_set_icon_default (GdkDrag *drag) { - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - gtk_drag_set_icon_name (context, "text-x-generic", -2, -2); + gtk_drag_set_icon_name (drag, "text-x-generic", -2, -2); } /* Clean up from the drag, and display snapback, if necessary. */ @@ -1242,9 +1237,9 @@ gtk_drag_drop_finished (GtkDragSourceInfo *info, if (!success) g_signal_emit_by_name (info->widget, "drag-failed", - info->context, result, &success); + info->drag, result, &success); - gdk_drag_drop_done (info->context, success); + gdk_drag_drop_done (info->drag, success); gtk_drag_source_info_destroy (info); } @@ -1296,17 +1291,11 @@ gtk_drag_source_info_free (GtkDragSourceInfo *info) static void gtk_drag_source_info_destroy (GtkDragSourceInfo *info) { - g_signal_handlers_disconnect_by_func (info->context, - gtk_drag_context_drop_performed_cb, - info); - g_signal_handlers_disconnect_by_func (info->context, - gtk_drag_context_dnd_finished_cb, - info); - g_signal_handlers_disconnect_by_func (info->context, - gtk_drag_context_cancel_cb, - info); - - g_signal_emit_by_name (info->widget, "drag-end", info->context); + g_signal_handlers_disconnect_by_func (info->drag, gtk_drag_drop_performed_cb, info); + g_signal_handlers_disconnect_by_func (info->drag, gtk_drag_dnd_finished_cb, info); + g_signal_handlers_disconnect_by_func (info->drag, gtk_drag_cancel_cb, info); + + g_signal_emit_by_name (info->widget, "drag-end", info->drag); g_object_set_data (G_OBJECT (info->widget), I_("gtk-info"), NULL); @@ -1318,10 +1307,10 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info) g_source_remove (info->drop_timeout); /* keep the icon_window alive until the (possible) drag cancel animation is done */ - g_object_set_data_full (G_OBJECT (info->context), "former-gtk-source-info", info, (GDestroyNotify)gtk_drag_source_info_free); + g_object_set_data_full (G_OBJECT (info->drag), "former-gtk-source-info", info, (GDestroyNotify)gtk_drag_source_info_free); - gtk_drag_clear_source_info (info->context); - g_object_unref (info->context); + gtk_drag_clear_source_info (info->drag); + g_object_unref (info->drag); } /* Called on cancellation of a drag, either by the user @@ -1335,16 +1324,16 @@ gtk_drag_cancel_internal (GtkDragSourceInfo *info, } static void -gtk_drag_context_drop_performed_cb (GdkDragContext *context, - GtkDragSourceInfo *info) +gtk_drag_drop_performed_cb (GdkDrag *drag, + GtkDragSourceInfo *info) { gtk_drag_drop (info); } static void -gtk_drag_context_cancel_cb (GdkDragContext *context, - GdkDragCancelReason reason, - GtkDragSourceInfo *info) +gtk_drag_cancel_cb (GdkDrag *drag, + GdkDragCancelReason reason, + GtkDragSourceInfo *info) { GtkDragResult result; @@ -1365,14 +1354,14 @@ gtk_drag_context_cancel_cb (GdkDragContext *context, } static void -gtk_drag_context_dnd_finished_cb (GdkDragContext *context, - GtkDragSourceInfo *info) +gtk_drag_dnd_finished_cb (GdkDrag *drag, + GtkDragSourceInfo *info) { - if (gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE) + if (gdk_drag_get_selected_action (drag) == GDK_ACTION_MOVE) { g_signal_emit_by_name (info->widget, "drag-data-delete", - context); + drag); } gtk_drag_source_info_destroy (info); @@ -1422,7 +1411,7 @@ gtk_drag_check_threshold (GtkWidget *widget, /** * gtk_drag_cancel: - * @context: a #GdkDragContext, as e.g. returned by gtk_drag_begin_with_coordinates() + * @drag: a drag context, as e.g. returned by gtk_drag_begin_with_coordinates() * * Cancels an ongoing drag operation on the source side. * @@ -1438,13 +1427,13 @@ gtk_drag_check_threshold (GtkWidget *widget, * #GtkWidget::drag-failed is set to @GTK_DRAG_RESULT_ERROR. */ void -gtk_drag_cancel (GdkDragContext *context) +gtk_drag_cancel (GdkDrag *drag) { GtkDragSourceInfo *info; - g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (GDK_IS_DRAG (drag)); - info = gtk_drag_get_source_info (context, FALSE); + info = gtk_drag_get_source_info (drag, FALSE); if (info != NULL) gtk_drag_cancel_internal (info, GTK_DRAG_RESULT_ERROR); } diff --git a/gtk/gtkdnd.h b/gtk/gtkdnd.h index 2626ce02fb..2db8978c24 100644 --- a/gtk/gtkdnd.h +++ b/gtk/gtkdnd.h @@ -45,7 +45,7 @@ void gtk_drag_get_data (GtkWidget *widget, GdkAtom target); GDK_AVAILABLE_IN_ALL -GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context); +GtkWidget *gtk_drag_get_source_widget (GdkDrag *drag); GDK_AVAILABLE_IN_ALL void gtk_drag_highlight (GtkWidget *widget); @@ -55,39 +55,39 @@ void gtk_drag_unhighlight (GtkWidget *widget); /* Source side */ GDK_AVAILABLE_IN_ALL -GdkDragContext *gtk_drag_begin_with_coordinates (GtkWidget *widget, - GdkDevice *device, - GdkContentFormats *targets, - GdkDragAction actions, - gint x, - gint y); +GdkDrag *gtk_drag_begin_with_coordinates (GtkWidget *widget, + GdkDevice *device, + GdkContentFormats *targets, + GdkDragAction actions, + gint x, + gint y); GDK_AVAILABLE_IN_ALL -void gtk_drag_cancel (GdkDragContext *context); +void gtk_drag_cancel (GdkDrag *drag); GDK_AVAILABLE_IN_ALL -void gtk_drag_set_icon_widget (GdkDragContext *context, +void gtk_drag_set_icon_widget (GdkDrag *drag, GtkWidget *widget, gint hot_x, gint hot_y); GDK_AVAILABLE_IN_ALL -void gtk_drag_set_icon_paintable (GdkDragContext *context, +void gtk_drag_set_icon_paintable (GdkDrag *drag, GdkPaintable *paintable, int hot_x, int hot_y); GDK_AVAILABLE_IN_ALL -void gtk_drag_set_icon_name (GdkDragContext *context, +void gtk_drag_set_icon_name (GdkDrag *drag, const gchar *icon_name, gint hot_x, gint hot_y); GDK_AVAILABLE_IN_ALL -void gtk_drag_set_icon_gicon (GdkDragContext *context, +void gtk_drag_set_icon_gicon (GdkDrag *drag, GIcon *icon, gint hot_x, gint hot_y); GDK_AVAILABLE_IN_ALL -void gtk_drag_set_icon_default (GdkDragContext *context); +void gtk_drag_set_icon_default (GdkDrag *drag); GDK_AVAILABLE_IN_ALL gboolean gtk_drag_check_threshold (GtkWidget *widget, diff --git a/gtk/gtkdndprivate.h b/gtk/gtkdndprivate.h index 854316ce5d..45448a17e2 100644 --- a/gtk/gtkdndprivate.h +++ b/gtk/gtkdndprivate.h @@ -40,14 +40,14 @@ struct _GtkDragDestSite G_BEGIN_DECLS -GdkDragContext * gtk_drag_begin_internal (GtkWidget *widget, +GdkDrag * gtk_drag_begin_internal (GtkWidget *widget, GdkDevice *device, GtkImageDefinition *icon, GdkContentFormats *target_list, GdkDragAction actions, int x, int y); -void gtk_drag_set_icon_definition (GdkDragContext *context, +void gtk_drag_set_icon_definition (GdkDrag *drag, GtkImageDefinition *def, gint hot_x, gint hot_y); diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c index d1dccd2100..ce6040ad2b 100644 --- a/gtk/gtkdragdest.c +++ b/gtk/gtkdragdest.c @@ -125,7 +125,7 @@ gtk_drag_dest_set_internal (GtkWidget *widget, * |[<!-- language="C" --> * static void * drag_motion (GtkWidget *widget, - * GdkDragContext *context, + * GdkDrag *drag, * gint x, * gint y, * guint time) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 105bd935ca..8ad735129e 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -445,14 +445,14 @@ static void gtk_entry_drag_data_received (GtkWidget *widget, GdkDrop *drop, GtkSelectionData *selection_data); static void gtk_entry_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data); static void gtk_entry_drag_data_delete (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_entry_drag_begin (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_entry_drag_end (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); /* GtkEditable method implementations @@ -8478,7 +8478,7 @@ gtk_entry_selection_bubble_popup_set (GtkEntry *entry) static void gtk_entry_drag_begin (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); @@ -8493,7 +8493,7 @@ gtk_entry_drag_begin (GtkWidget *widget, { if (icon_info->in_drag) { - gtk_drag_set_icon_definition (context, + gtk_drag_set_icon_definition (drag, gtk_image_get_definition (GTK_IMAGE (icon_info->widget)), -2, -2); return; @@ -8511,7 +8511,7 @@ gtk_entry_drag_begin (GtkWidget *widget, paintable = gtk_text_util_create_drag_icon (widget, text, -1); gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges); - gtk_drag_set_icon_paintable (context, + gtk_drag_set_icon_paintable (drag, paintable, priv->drag_start_x - ranges[0], priv->drag_start_y); @@ -8524,7 +8524,7 @@ gtk_entry_drag_begin (GtkWidget *widget, static void gtk_entry_drag_end (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); @@ -8632,7 +8632,7 @@ gtk_entry_get_action (GtkEntry *entry, GdkDrop *drop) { GtkWidget *widget = GTK_WIDGET (entry); - GdkDragContext *drag = gdk_drop_get_drag (drop); + GdkDrag *drag = gdk_drop_get_drag (drop); GtkWidget *source_widget = gtk_drag_get_source_widget (drag); GdkDragAction actions; @@ -8700,7 +8700,7 @@ gtk_entry_drag_data_received (GtkWidget *widget, static void gtk_entry_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data) { GtkEntry *entry = GTK_ENTRY (widget); @@ -8734,7 +8734,7 @@ gtk_entry_drag_data_get (GtkWidget *widget, static void gtk_entry_drag_data_delete (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 4abc8e529a..680ddb61de 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -277,14 +277,14 @@ static void update_pixbuf_cell (GtkIco /* Source side drag signals */ static void gtk_icon_view_drag_begin (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_icon_view_drag_end (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_icon_view_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data); static void gtk_icon_view_drag_data_delete (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); /* Target side drag signals */ static void gtk_icon_view_drag_leave (GtkWidget *widget, @@ -5702,27 +5702,27 @@ unset_reorderable (GtkIconView *icon_view) } static void -set_source_row (GdkDragContext *context, +set_source_row (GdkDrag *drag, GtkTreeModel *model, GtkTreePath *source_row) { if (source_row) - g_object_set_data_full (G_OBJECT (context), + g_object_set_data_full (G_OBJECT (drag), I_("gtk-icon-view-source-row"), gtk_tree_row_reference_new (model, source_row), (GDestroyNotify) gtk_tree_row_reference_free); else - g_object_set_data_full (G_OBJECT (context), + g_object_set_data_full (G_OBJECT (drag), I_("gtk-icon-view-source-row"), NULL, NULL); } static GtkTreePath* -get_source_row (GdkDragContext *context) +get_source_row (GdkDrag *drag) { GtkTreeRowReference *ref; - ref = g_object_get_data (G_OBJECT (context), "gtk-icon-view-source-row"); + ref = g_object_get_data (G_OBJECT (drag), "gtk-icon-view-source-row"); if (ref) return gtk_tree_row_reference_get_path (ref); @@ -6020,7 +6020,7 @@ gtk_icon_view_maybe_begin_drag (GtkIconView *icon_view, GdkDevice *device) { GtkWidget *widget = GTK_WIDGET (icon_view); - GdkDragContext *context; + GdkDrag *drag; GtkTreePath *path = NULL; GtkTreeModel *model; gboolean retval = FALSE; @@ -6064,14 +6064,14 @@ gtk_icon_view_maybe_begin_drag (GtkIconView *icon_view, retval = TRUE; - context = gtk_drag_begin_with_coordinates (widget, - device, - gtk_drag_source_get_target_list (widget), - icon_view->priv->source_actions, - icon_view->priv->press_start_x, - icon_view->priv->press_start_y); + drag = gtk_drag_begin_with_coordinates (widget, + device, + gtk_drag_source_get_target_list (widget), + icon_view->priv->source_actions, + icon_view->priv->press_start_x, + icon_view->priv->press_start_y); - set_source_row (context, model, path); + set_source_row (drag, model, path); out: if (path) @@ -6083,7 +6083,7 @@ gtk_icon_view_maybe_begin_drag (GtkIconView *icon_view, /* Source side drag signals */ static void gtk_icon_view_drag_begin (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkIconView *icon_view; GtkIconViewItem *item; @@ -6112,21 +6112,21 @@ gtk_icon_view_drag_begin (GtkWidget *widget, icon = gtk_icon_view_create_drag_icon (icon_view, path); gtk_tree_path_free (path); - gtk_drag_set_icon_paintable (context, icon, x, y); + gtk_drag_set_icon_paintable (drag, icon, x, y); g_object_unref (icon); } static void gtk_icon_view_drag_end (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { /* do nothing */ } static void gtk_icon_view_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data) { GtkIconView *icon_view; @@ -6142,7 +6142,7 @@ gtk_icon_view_drag_data_get (GtkWidget *widget, if (!icon_view->priv->source_set) return; - source_row = get_source_row (context); + source_row = get_source_row (drag); if (source_row == NULL) return; @@ -6170,7 +6170,7 @@ gtk_icon_view_drag_data_get (GtkWidget *widget, static void gtk_icon_view_drag_data_delete (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkTreeModel *model; GtkIconView *icon_view; @@ -6185,7 +6185,7 @@ gtk_icon_view_drag_data_delete (GtkWidget *widget, if (!icon_view->priv->source_set) return; - source_row = get_source_row (context); + source_row = get_source_row (drag); if (source_row == NULL) return; @@ -6195,7 +6195,7 @@ gtk_icon_view_drag_data_delete (GtkWidget *widget, gtk_tree_path_free (source_row); - set_source_row (context, NULL, NULL); + set_source_row (drag, NULL, NULL); } /* Target side drag signals */ @@ -6333,7 +6333,7 @@ static GdkDragAction gtk_icon_view_get_action (GtkWidget *treeview, GdkDrop *drop) { - GdkDragContext *drag = gdk_drop_get_drag (drop); + GdkDrag *drag = gdk_drop_get_drag (drop); GtkWidget *source_widget = gtk_drag_get_source_widget (drag); GdkDragAction actions; diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index f007fecf37..86661a8d36 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -476,7 +476,7 @@ static gboolean gtk_label_mnemonic_activate (GtkWidget *widget, static void gtk_label_setup_mnemonic (GtkLabel *label, guint last_key); static void gtk_label_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data); static void gtk_label_buildable_interface_init (GtkBuildableIface *iface); @@ -4576,7 +4576,7 @@ connect_mnemonics_visible_notify (GtkLabel *label) static void drag_begin_cb (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GtkLabel *label = GTK_LABEL (widget); @@ -4612,12 +4612,12 @@ drag_begin_cb (GtkWidget *widget, if (paintable) { - gtk_drag_set_icon_paintable (context, paintable, 0, 0); + gtk_drag_set_icon_paintable (drag, paintable, 0, 0); g_object_unref (paintable); } else { - gtk_drag_set_icon_default (context); + gtk_drag_set_icon_default (drag); } } @@ -5169,7 +5169,7 @@ gtk_label_set_selection_text (GtkLabel *label, static void gtk_label_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data) { gtk_label_set_selection_text (GTK_LABEL (widget), selection_data); diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c index 51d7c58b43..ee5468aa55 100644 --- a/gtk/gtklinkbutton.c +++ b/gtk/gtklinkbutton.c @@ -107,7 +107,7 @@ static void gtk_link_button_set_property (GObject *object, static void gtk_link_button_clicked (GtkButton *button); static gboolean gtk_link_button_popup_menu (GtkWidget *widget); static void gtk_link_button_drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection, gpointer user_data); static gboolean gtk_link_button_query_tooltip_cb (GtkWidget *widget, @@ -433,7 +433,7 @@ gtk_link_button_popup_menu (GtkWidget *widget) static void gtk_link_button_drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection, gpointer user_data) { diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index a51110d9ed..c371de0128 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -383,11 +383,11 @@ static gboolean gtk_notebook_focus (GtkWidget *widget, /*** Drag and drop Methods ***/ static void gtk_notebook_drag_begin (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_notebook_drag_end (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static gboolean gtk_notebook_drag_failed (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkDragResult result); static gboolean gtk_notebook_drag_motion (GtkWidget *widget, GdkDrop *drop, @@ -400,7 +400,7 @@ static gboolean gtk_notebook_drag_drop (GtkWidget *widget, gint x, gint y); static void gtk_notebook_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *data); static void gtk_notebook_drag_data_received (GtkWidget *widget, GdkDrop *drop, @@ -2864,7 +2864,7 @@ update_arrow_nodes (GtkNotebook *notebook) static void gtk_notebook_drag_begin (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebookPrivate *priv = notebook->priv; @@ -2895,14 +2895,14 @@ gtk_notebook_drag_begin (GtkWidget *widget, gtk_style_context_add_class (gtk_widget_get_style_context (priv->dnd_child), "background"); - gtk_drag_set_icon_widget (context, tab_label, -2, -2); - g_object_set_data (G_OBJECT (priv->dnd_child), "drag-context", context); + gtk_drag_set_icon_widget (drag, tab_label, -2, -2); + g_object_set_data (G_OBJECT (priv->dnd_child), "drag-context", drag); g_object_unref (tab_label); } static void gtk_notebook_drag_end (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebookPrivate *priv = notebook->priv; @@ -2914,7 +2914,7 @@ gtk_notebook_drag_end (GtkWidget *widget, GtkNotebook *dest_notebook = NULL; gint x, y; - gdk_device_get_position (gdk_drag_context_get_device (context), &x, &y); + gdk_device_get_position (gdk_drag_get_device (drag), &x, &y); g_signal_emit (notebook, notebook_signals[CREATE_WINDOW], 0, priv->detached_tab->child, x, y, &dest_notebook); @@ -2950,7 +2950,7 @@ gtk_notebook_create_window (GtkNotebook *notebook, static gboolean gtk_notebook_drag_failed (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkDragResult result) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); @@ -2963,7 +2963,7 @@ gtk_notebook_drag_failed (GtkWidget *widget, GtkNotebook *dest_notebook = NULL; gint x, y; - gdk_device_get_position (gdk_drag_context_get_device (context), &x, &y); + gdk_device_get_position (gdk_drag_get_device (drag), &x, &y); g_signal_emit (notebook, notebook_signals[CREATE_WINDOW], 0, priv->detached_tab->child, x, y, &dest_notebook); @@ -3200,7 +3200,7 @@ do_detach_tab (GtkNotebook *from, static void gtk_notebook_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *data) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); @@ -3230,7 +3230,7 @@ gtk_notebook_drag_data_received (GtkWidget *widget, GtkSelectionData *data) { GtkNotebook *notebook; - GdkDragContext *drag; + GdkDrag *drag; GtkWidget *source_widget; GtkWidget **child; @@ -4162,10 +4162,10 @@ gtk_notebook_real_remove (GtkNotebook *notebook, if (priv->operation == DRAG_OPERATION_DETACH && !priv->remove_in_detach) { - GdkDragContext *context; + GdkDrag *drag; - context = (GdkDragContext *)g_object_get_data (G_OBJECT (priv->dnd_child), "drag-context"); - gtk_drag_cancel (context); + drag = (GdkDrag *)g_object_get_data (G_OBJECT (priv->dnd_child), "drag-context"); + gtk_drag_cancel (drag); } } if (priv->switch_tab == list) @@ -7038,7 +7038,7 @@ gtk_notebook_get_tab_detachable (GtkNotebook *notebook, * |[<!-- language="C" --> * static void * on_drag_data_received (GtkWidget *widget, - * GdkDragContext *context, + * GdkDrag *drag, * GtkSelectionData *data, * guint time, * gpointer user_data) @@ -7046,7 +7046,7 @@ gtk_notebook_get_tab_detachable (GtkNotebook *notebook, * GtkWidget *notebook; * GtkWidget **child; * - * notebook = gtk_drag_get_source_widget (context); + * notebook = gtk_drag_get_source_widget (drag); * child = (void*) gtk_selection_data_get_data (data); * * // process_widget (*child); diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index 9a2b5556e6..eeaf6e4326 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -1283,7 +1283,7 @@ find_button_type (GtkPathBar *path_bar, static void button_drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, gpointer data) { diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 95683c6622..5ec8408ee9 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -203,7 +203,7 @@ struct _GtkPlacesSidebarClass { const gchar *primary, const gchar *secondary); GdkDragAction (* drag_action_requested) (GtkPlacesSidebar *sidebar, - GdkDragContext *context, + GdkDrag *drag, GFile *dest_file, GList *source_file_list); GdkDragAction (* drag_action_ask) (GtkPlacesSidebar *sidebar, @@ -1722,7 +1722,7 @@ stop_drop_feedback (GtkPlacesSidebar *sidebar) static void drag_begin_callback (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer user_data) { GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data); @@ -1738,7 +1738,7 @@ drag_begin_callback (GtkWidget *widget, gtk_widget_set_opacity (drag_widget, 0.8); - gtk_drag_set_icon_widget (context, + gtk_drag_set_icon_widget (drag, drag_widget, sidebar->drag_row_x, sidebar->drag_row_y); @@ -1951,7 +1951,7 @@ drop_files_as_bookmarks (GtkPlacesSidebar *sidebar, static void drag_data_get_callback (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *data, gpointer user_data) { @@ -2085,7 +2085,7 @@ out: static void drag_end_callback (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer user_data) { stop_drop_feedback (GTK_PLACES_SIDEBAR (user_data)); diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index d242059ffd..1c6aa8f2db 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -417,14 +417,14 @@ static GtkTextBuffer* gtk_text_view_create_buffer (GtkTextView *text_view); /* Source side drag signals */ static void gtk_text_view_drag_begin (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_text_view_drag_end (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_text_view_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data); static void gtk_text_view_drag_data_delete (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); /* Target side drag signals */ static void gtk_text_view_drag_leave (GtkWidget *widget, @@ -7585,7 +7585,7 @@ gtk_text_view_im_context_filter_keypress (GtkTextView *text_view, static void drag_begin_cb (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GtkTextView *text_view = GTK_TEXT_VIEW (widget); @@ -7601,12 +7601,12 @@ drag_begin_cb (GtkWidget *widget, if (paintable) { - gtk_drag_set_icon_paintable (context, paintable, 0, 0); + gtk_drag_set_icon_paintable (drag, paintable, 0, 0); g_object_unref (paintable); } else { - gtk_drag_set_icon_default (context); + gtk_drag_set_icon_default (drag); } } @@ -7632,14 +7632,14 @@ gtk_text_view_start_selection_dnd (GtkTextView *text_view, static void gtk_text_view_drag_begin (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { /* do nothing */ } static void gtk_text_view_drag_end (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkTextView *text_view; @@ -7649,7 +7649,7 @@ gtk_text_view_drag_end (GtkWidget *widget, static void gtk_text_view_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data) { GtkTextView *text_view = GTK_TEXT_VIEW (widget); @@ -7685,7 +7685,7 @@ gtk_text_view_drag_data_get (GtkWidget *widget, static void gtk_text_view_drag_data_delete (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { gtk_text_buffer_delete_selection (GTK_TEXT_VIEW (widget)->priv->buffer, TRUE, GTK_TEXT_VIEW (widget)->priv->editable); @@ -7861,7 +7861,7 @@ static GdkDragAction gtk_text_view_get_action (GtkWidget *textview, GdkDrop *drop) { - GdkDragContext *drag = gdk_drop_get_drag (drop); + GdkDrag *drag = gdk_drop_get_drag (drop); GtkWidget *source_widget = gtk_drag_get_source_widget (drag); GdkDragAction actions; diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index f77f60d3a8..95a96a111e 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -618,14 +618,14 @@ static void gtk_tree_view_forall (GtkContainer *container, /* Source side drag signals */ static void gtk_tree_view_drag_begin (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_tree_view_drag_end (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); static void gtk_tree_view_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data); static void gtk_tree_view_drag_data_delete (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); /* Target side drag signals */ static void gtk_tree_view_drag_leave (GtkWidget *widget, @@ -6817,21 +6817,21 @@ _gtk_tree_view_column_autosize (GtkTreeView *tree_view, /* Drag-and-drop */ static void -set_source_row (GdkDragContext *context, +set_source_row (GdkDrag *drag, GtkTreeModel *model, GtkTreePath *source_row) { - g_object_set_data_full (G_OBJECT (context), + g_object_set_data_full (G_OBJECT (drag), I_("gtk-tree-view-source-row"), source_row ? gtk_tree_row_reference_new (model, source_row) : NULL, (GDestroyNotify) (source_row ? gtk_tree_row_reference_free : NULL)); } static GtkTreePath* -get_source_row (GdkDragContext *context) +get_source_row (GdkDrag *drag) { GtkTreeRowReference *ref = - g_object_get_data (G_OBJECT (context), "gtk-tree-view-source-row"); + g_object_get_data (G_OBJECT (drag), "gtk-tree-view-source-row"); if (ref) return gtk_tree_row_reference_get_path (ref); @@ -7304,7 +7304,7 @@ gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view) { GtkWidget *widget = GTK_WIDGET (tree_view); gdouble start_x, start_y, offset_x, offset_y; - GdkDragContext *context; + GdkDrag *drag; TreeViewDragInfo *di; GtkTreePath *path = NULL; gint button; @@ -7361,13 +7361,13 @@ gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view) gtk_gesture_set_state (GTK_GESTURE (tree_view->priv->drag_gesture), GTK_EVENT_SEQUENCE_CLAIMED); - context = gtk_drag_begin_with_coordinates (widget, - gtk_gesture_get_device (GTK_GESTURE (tree_view->priv->drag_gesture)), - gtk_drag_source_get_target_list (widget), - di->source_actions, - start_x, start_y); + drag = gtk_drag_begin_with_coordinates (widget, + gtk_gesture_get_device (GTK_GESTURE (tree_view->priv->drag_gesture)), + gtk_drag_source_get_target_list (widget), + di->source_actions, + start_x, start_y); - set_source_row (context, model, path); + set_source_row (drag, model, path); out: if (path) @@ -7379,7 +7379,7 @@ gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view) static void gtk_tree_view_drag_begin (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkTreeView *tree_view; GtkTreePath *path = NULL; @@ -7412,10 +7412,9 @@ gtk_tree_view_drag_begin (GtkWidget *widget, if (!path) return; - row_pix = gtk_tree_view_create_row_drag_icon (tree_view, - path); + row_pix = gtk_tree_view_create_row_drag_icon (tree_view, path); - gtk_drag_set_icon_paintable (context, row_pix, tree_view->priv->press_start_x + 1, 1); + gtk_drag_set_icon_paintable (drag, row_pix, tree_view->priv->press_start_x + 1, 1); g_object_unref (row_pix); gtk_tree_path_free (path); @@ -7423,7 +7422,7 @@ gtk_tree_view_drag_begin (GtkWidget *widget, static void gtk_tree_view_drag_end (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { GtkTreeView *tree_view = GTK_TREE_VIEW (widget); @@ -7434,7 +7433,7 @@ gtk_tree_view_drag_end (GtkWidget *widget, /* Default signal implementations for the drag signals */ static void gtk_tree_view_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data) { GtkTreeView *tree_view; @@ -7454,7 +7453,7 @@ gtk_tree_view_drag_data_get (GtkWidget *widget, if (di == NULL) return; - source_row = get_source_row (context); + source_row = get_source_row (drag); if (source_row == NULL) return; @@ -7485,7 +7484,7 @@ gtk_tree_view_drag_data_get (GtkWidget *widget, static void gtk_tree_view_drag_data_delete (GtkWidget *widget, - GdkDragContext *context) + GdkDrag *drag) { TreeViewDragInfo *di; GtkTreeModel *model; @@ -7503,17 +7502,16 @@ gtk_tree_view_drag_data_delete (GtkWidget *widget, if (di == NULL) return; - source_row = get_source_row (context); + source_row = get_source_row (drag); if (source_row == NULL) return; - gtk_tree_drag_source_drag_data_delete (GTK_TREE_DRAG_SOURCE (model), - source_row); + gtk_tree_drag_source_drag_data_delete (GTK_TREE_DRAG_SOURCE (model), source_row); gtk_tree_path_free (source_row); - set_source_row (context, NULL, NULL); + set_source_row (drag, NULL, NULL); } static void @@ -7670,7 +7668,7 @@ static GdkDragAction gtk_tree_view_get_action (GtkWidget *treeview, GdkDrop *drop) { - GdkDragContext *drag = gdk_drop_get_drag (drop); + GdkDrag *drag = gdk_drop_get_drag (drop); GtkWidget *source_widget = gtk_drag_get_source_widget (drag); GdkDragAction actions; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 234c1302dd..b1a91174d3 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -1743,7 +1743,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) /** * GtkWidget::drag-begin: * @widget: the object which received the signal - * @context: the drag context + * @context: the drag context * * The ::drag-begin signal is emitted on the drag source when a drag is * started. A typical reason to connect to this signal is to set up a @@ -1761,7 +1761,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 1, - GDK_TYPE_DRAG_CONTEXT); + GDK_TYPE_DRAG); /** * GtkWidget::drag-end: @@ -1780,7 +1780,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 1, - GDK_TYPE_DRAG_CONTEXT); + GDK_TYPE_DRAG); /** * GtkWidget::drag-data-delete: @@ -1800,7 +1800,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 1, - GDK_TYPE_DRAG_CONTEXT); + GDK_TYPE_DRAG); /** * GtkWidget::drag-failed: @@ -1824,7 +1824,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) _gtk_boolean_handled_accumulator, NULL, _gtk_marshal_BOOLEAN__OBJECT_ENUM, G_TYPE_BOOLEAN, 2, - GDK_TYPE_DRAG_CONTEXT, + GDK_TYPE_DRAG, GTK_TYPE_DRAG_RESULT); /** @@ -1982,7 +1982,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) NULL, NULL, _gtk_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2, - GDK_TYPE_DRAG_CONTEXT, + GDK_TYPE_DRAG, GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE); /** diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 5989923f66..5c240d0fa2 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -293,15 +293,15 @@ struct _GtkWidgetClass GdkEvent *event); /* Source side drag signals */ - void (* drag_begin) (GtkWidget *widget, - GdkDragContext *context); + void (* drag_begin) (GtkWidget *widget, + GdkDrag *drag); void (* drag_end) (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); void (* drag_data_get) (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data); void (* drag_data_delete) (GtkWidget *widget, - GdkDragContext *context); + GdkDrag *drag); /* Target side drag signals */ void (* drag_leave) (GtkWidget *widget, @@ -318,7 +318,7 @@ struct _GtkWidgetClass GdkDrop *drop, GtkSelectionData *selection_data); gboolean (* drag_failed) (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkDragResult result); /* Signals used only for keybindings */ diff --git a/tests/testdnd.c b/tests/testdnd.c index 53fb07788b..0f517dea92 100644 --- a/tests/testdnd.c +++ b/tests/testdnd.c @@ -314,7 +314,7 @@ target_drag_motion (GtkWidget *widget, gint y) { GtkWidget *source_widget; - GdkDragContext *drag; + GdkDrag *drag; char *s; if (!have_drag) @@ -418,7 +418,7 @@ label_drag_data_received (GtkWidget *widget, void source_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, gpointer data) { @@ -565,7 +565,7 @@ popsite_leave (GtkWidget *widget, void source_drag_data_delete (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { g_print ("Delete the data!\n"); diff --git a/tests/testdnd2.c b/tests/testdnd2.c index 613caa8c8c..b94362e57c 100644 --- a/tests/testdnd2.c +++ b/tests/testdnd2.c @@ -39,7 +39,7 @@ enum { static void image_drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GdkPaintable *paintable; @@ -65,7 +65,7 @@ image_drag_begin (GtkWidget *widget, hot_y = size; break; } - gtk_drag_set_icon_paintable (context, paintable, hot_x, hot_y); + gtk_drag_set_icon_paintable (drag, paintable, hot_x, hot_y); g_object_unref (paintable); } @@ -80,7 +80,9 @@ drag_widget_destroyed (GtkWidget *image, gpointer data) } static void -window_drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data) +window_drag_end (GtkWidget *widget, + GdkDrag *drag, + gpointer data) { GtkWidget *window = data; @@ -90,7 +92,7 @@ window_drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data) static void window_drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GdkPaintable *paintable; @@ -114,7 +116,7 @@ window_drag_begin (GtkWidget *widget, else g_print ("reusing drag widget\n"); - gtk_drag_set_icon_widget (context, image, 0, 0); + gtk_drag_set_icon_widget (drag, image, 0, 0); if (hotspot == CENTER) g_signal_connect (widget, "drag-end", G_CALLBACK (window_drag_end), image); @@ -153,7 +155,7 @@ update_dest_target_list (GtkWidget *image) void image_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, gpointer data) { @@ -264,7 +266,7 @@ make_image2 (const gchar *icon_name, int hotspot) static void spinner_drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GtkWidget *spinner; @@ -274,25 +276,25 @@ spinner_drag_begin (GtkWidget *widget, "visible", TRUE, "active", TRUE, NULL); - gtk_drag_set_icon_widget (context, spinner, 0, 0); - g_object_set_data (G_OBJECT (context), "spinner", spinner); + gtk_drag_set_icon_widget (drag, spinner, 0, 0); + g_object_set_data (G_OBJECT (drag), "spinner", spinner); } static void spinner_drag_end (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GtkWidget *spinner; g_print ("GtkWidget::drag-end\n"); - spinner = g_object_get_data (G_OBJECT (context), "spinner"); + spinner = g_object_get_data (G_OBJECT (drag), "spinner"); gtk_widget_destroy (spinner); } static gboolean spinner_drag_failed (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkDragResult result, gpointer data) { @@ -309,7 +311,7 @@ spinner_drag_failed (GtkWidget *widget, void spinner_drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, gpointer data) { diff --git a/tests/testentryicons.c b/tests/testentryicons.c index 3395c879ae..bbc8eeb4bd 100644 --- a/tests/testentryicons.c +++ b/tests/testentryicons.c @@ -10,19 +10,19 @@ clear_pressed (GtkEntry *entry, gint icon, gpointer data) static void drag_begin_cb (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer user_data) { gint pos; pos = gtk_entry_get_current_icon_drag_source (GTK_ENTRY (widget)); if (pos != -1) - gtk_drag_set_icon_name (context, "dialog-information", 2, 2); + gtk_drag_set_icon_name (drag, "dialog-information", 2, 2); } static void drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *data, gpointer user_data) { diff --git a/tests/testimage.c b/tests/testimage.c index 4001bd67fb..2e2d5da50b 100644 --- a/tests/testimage.c +++ b/tests/testimage.c @@ -20,19 +20,19 @@ static void drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GtkWidget *image = GTK_WIDGET (data); GdkPaintable *paintable; paintable = gtk_image_get_paintable (GTK_IMAGE (image)); - gtk_drag_set_icon_paintable (context, paintable, -2, -2); + gtk_drag_set_icon_paintable (drag, paintable, -2, -2); } void drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, gpointer data) { @@ -46,7 +46,7 @@ drag_data_get (GtkWidget *widget, static void drag_data_received (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, guint info, guint32 time, diff --git a/tests/testlist3.c b/tests/testlist3.c index 13c8a94e5a..2f6aba8450 100644 --- a/tests/testlist3.c +++ b/tests/testlist3.c @@ -6,7 +6,7 @@ static const char *entries[] = { static void drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { GtkWidget *row; @@ -19,7 +19,7 @@ drag_begin (GtkWidget *widget, paintable = gtk_widget_paintable_new (row); gtk_widget_translate_coordinates (widget, row, 0, 0, &x, &y); - gtk_drag_set_icon_paintable (context, paintable, -x, -y); + gtk_drag_set_icon_paintable (drag, paintable, -x, -y); g_object_unref (paintable); } @@ -27,7 +27,7 @@ drag_begin (GtkWidget *widget, void drag_data_get (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, GtkSelectionData *selection_data, gpointer data) { diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c index 5771896128..a0b321eb41 100644 --- a/tests/testnotebookdnd.c +++ b/tests/testnotebookdnd.c @@ -93,7 +93,7 @@ on_page_reordered (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpoi static void on_notebook_drag_begin (GtkWidget *widget, - GdkDragContext *context, + GdkDrag *drag, gpointer data) { guint page_num; @@ -101,7 +101,7 @@ on_notebook_drag_begin (GtkWidget *widget, page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (widget)); if (page_num > 2) - gtk_drag_set_icon_name (context, + gtk_drag_set_icon_name (drag, (page_num % 2) ? "help-browser" : "process-stop", 0, 0); } |