]> Pileus Git - ~andy/gtk/blob - gdk/gdkdnd.c
Inclusion cleanups in sources
[~andy/gtk] / gdk / gdkdnd.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser 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.
8  *
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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #include "config.h"
28
29 #include "gdkdnd.h"
30
31 #include "gdkdisplay.h"
32 #include "gdkwindow.h"
33
34
35 /**
36  * SECTION:dnd
37  * @title: Drag And Drop
38  * @short_description: Functions for controlling drag and drop handling
39  *
40  * These functions provide a low level interface for drag and drop.
41  * The X backend of GDK supports both the Xdnd and Motif drag and drop
42  * protocols transparently, the Win32 backend supports the WM_DROPFILES
43  * protocol.
44  *
45  * GTK+ provides a higher level abstraction based on top of these functions,
46  * and so they are not normally needed in GTK+ applications.
47  * See the <link linkend="gtk-Drag-and-Drop">Drag and Drop</link> section of
48  * the GTK+ documentation for more information.
49  */
50
51 /**
52  * gdk_drag_find_window:
53  * @context: a #GdkDragContext.
54  * @drag_window: a window which may be at the pointer position, but
55  *      should be ignored, since it is put up by the drag source as an icon.
56  * @x_root: the x position of the pointer in root coordinates.
57  * @y_root: the y position of the pointer in root coordinates.
58  * @dest_window: (out): location to store the destination window in.
59  * @protocol: (out): location to store the DND protocol in.
60  *
61  * Finds the destination window and DND protocol to use at the
62  * given pointer position.
63  *
64  * This function is called by the drag source to obtain the 
65  * @dest_window and @protocol parameters for gdk_drag_motion().
66  **/
67 void
68 gdk_drag_find_window (GdkDragContext  *context,
69                       GdkWindow       *drag_window,
70                       gint             x_root,
71                       gint             y_root,
72                       GdkWindow      **dest_window,
73                       GdkDragProtocol *protocol)
74 {
75   gdk_drag_find_window_for_screen (context, drag_window,
76                                    gdk_window_get_screen (context->source_window),
77                                    x_root, y_root, dest_window, protocol);
78 }
79
80 /**
81  * gdk_drag_get_protocol:
82  * @xid: the windowing system id of the destination window.
83  * @protocol: location where the supported DND protocol is returned.
84  * 
85  * Finds out the DND protocol supported by a window.
86  * 
87  * Return value: the windowing system specific id for the window where
88  *    the drop should happen. This may be @xid or the id of a proxy
89  *    window, or zero if @xid doesn't support Drag and Drop.
90  **/
91 GdkNativeWindow
92 gdk_drag_get_protocol (GdkNativeWindow  xid,
93                        GdkDragProtocol *protocol)
94 {
95   return gdk_drag_get_protocol_for_display (gdk_display_get_default (), xid, protocol);
96 }
97
98 /**
99  * gdk_drag_context_list_targets:
100  * @context: a #GdkDragContext
101  *
102  * Retrieves the list of targets of the context.
103  *
104  * Return value: (transfer none) (element-type GdkAtom): a #GList of targets
105  *
106  * Since: 2.22
107  **/
108 GList *
109 gdk_drag_context_list_targets (GdkDragContext *context)
110 {
111   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
112
113   return context->targets;
114 }
115
116 /**
117  * gdk_drag_context_get_actions:
118  * @context: a #GdkDragContext
119  *
120  * Determines the bitmask of actions proposed by the source if
121  * gdk_drag_context_suggested_action() returns GDK_ACTION_ASK.
122  *
123  * Return value: the #GdkDragAction flags
124  *
125  * Since: 2.22
126  **/
127 GdkDragAction
128 gdk_drag_context_get_actions (GdkDragContext *context)
129 {
130   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_ACTION_DEFAULT);
131
132   return context->actions;
133 }
134
135 /**
136  * gdk_drag_context_get_suggested_action:
137  * @context: a #GdkDragContext
138  *
139  * Determines the suggested drag action of the context.
140  *
141  * Return value: a #GdkDragAction value
142  *
143  * Since: 2.22
144  **/
145 GdkDragAction
146 gdk_drag_context_get_suggested_action (GdkDragContext *context)
147 {
148   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
149
150   return context->suggested_action;
151 }
152
153 /**
154  * gdk_drag_context_get_selected_action:
155  * @context: a #GdkDragContext
156  *
157  * Determines the action chosen by the drag destination.
158  *
159  * Return value: a #GdkDragAction value
160  *
161  * Since: 2.22
162  **/
163 GdkDragAction
164 gdk_drag_context_get_selected_action (GdkDragContext *context)
165 {
166   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
167
168   return context->action;
169 }
170
171 /**
172  * gdk_drag_context_get_source_window:
173  * @context: a #GdkDragContext
174  *
175  * Returns the #GdkWindow where the DND operation started.
176  *
177  * Return value: (transfer none): a #GdkWindow
178  *
179  * Since: 2.22
180  **/
181 GdkWindow *
182 gdk_drag_context_get_source_window (GdkDragContext *context)
183 {
184   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
185
186   return context->source_window;
187 }