2 * Copyright © 2010 Intel Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 #include "gdkdndprivate.h"
23 #include "gdkinternals.h"
24 #include "gdkproperty.h"
25 #include "gdkprivate-wayland.h"
26 #include "gdkdisplay-wayland.h"
30 #define GDK_TYPE_WAYLAND_DRAG_CONTEXT (gdk_wayland_drag_context_get_type ())
31 #define GDK_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContext))
32 #define GDK_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
33 #define GDK_IS_WAYLAND_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
34 #define GDK_IS_WAYLAND_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG_CONTEXT))
35 #define GDK_WAYLAND_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG_CONTEXT, GdkWaylandDragContextClass))
37 typedef struct _GdkWaylandDragContext GdkWaylandDragContext;
38 typedef struct _GdkWaylandDragContextClass GdkWaylandDragContextClass;
40 struct _GdkWaylandDragContext
42 GdkDragContext context;
45 struct _GdkWaylandDragContextClass
47 GdkDragContextClass parent_class;
50 static GList *contexts;
52 G_DEFINE_TYPE (GdkWaylandDragContext, gdk_wayland_drag_context, GDK_TYPE_DRAG_CONTEXT)
55 gdk_wayland_drag_context_finalize (GObject *object)
57 GdkDragContext *context = GDK_DRAG_CONTEXT (object);
59 contexts = g_list_remove (contexts, context);
61 G_OBJECT_CLASS (gdk_wayland_drag_context_parent_class)->finalize (object);
65 gdk_wayland_drag_context_find_window (GdkDragContext *context,
66 GdkWindow *drag_window,
70 GdkDragProtocol *protocol)
76 gdk_wayland_drag_context_drag_motion (GdkDragContext *context,
77 GdkWindow *dest_window,
78 GdkDragProtocol protocol,
81 GdkDragAction suggested_action,
82 GdkDragAction possible_actions,
89 gdk_wayland_drag_context_drag_abort (GdkDragContext *context,
95 gdk_wayland_drag_context_drag_drop (GdkDragContext *context,
100 /* Destination side */
103 gdk_wayland_drag_context_drag_status (GdkDragContext *context,
104 GdkDragAction action,
110 gdk_wayland_drag_context_drop_reply (GdkDragContext *context,
117 gdk_wayland_drag_context_drop_finish (GdkDragContext *context,
124 gdk_wayland_drag_context_drop_status (GdkDragContext *context)
130 gdk_wayland_drag_context_get_selection (GdkDragContext *context)
136 gdk_wayland_drag_context_init (GdkWaylandDragContext *context)
138 contexts = g_list_prepend (contexts, context);
142 gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
144 GObjectClass *object_class = G_OBJECT_CLASS (klass);
145 GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
147 object_class->finalize = gdk_wayland_drag_context_finalize;
149 context_class->find_window = gdk_wayland_drag_context_find_window;
150 context_class->drag_status = gdk_wayland_drag_context_drag_status;
151 context_class->drag_motion = gdk_wayland_drag_context_drag_motion;
152 context_class->drag_abort = gdk_wayland_drag_context_drag_abort;
153 context_class->drag_drop = gdk_wayland_drag_context_drag_drop;
154 context_class->drop_reply = gdk_wayland_drag_context_drop_reply;
155 context_class->drop_finish = gdk_wayland_drag_context_drop_finish;
156 context_class->drop_status = gdk_wayland_drag_context_drop_status;
157 context_class->get_selection = gdk_wayland_drag_context_get_selection;
161 _gdk_wayland_window_get_drag_protocol (GdkWindow *window, GdkWindow **target)
167 _gdk_wayland_window_register_dnd (GdkWindow *window)
172 _gdk_wayland_window_drag_begin (GdkWindow *window,
176 GdkDragContext *context;
178 context = (GdkDragContext *) g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
180 gdk_drag_context_set_device (context, device);