]> Pileus Git - ~andy/gtk/blob - gdk/gdkdnd.c
gdk/: fully remove gdkalias hacks
[~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 #include <gdkdnd.h>
29 #include <gdkdrawable.h>
30 #include <gdkdisplay.h>
31
32
33 /**
34  * SECTION:dnd
35  * @title: Drag And Drop
36  * @short_description: Functions for controlling drag and drop handling
37  *
38  * These functions provide a low level interface for drag and drop.
39  * The X backend of GDK supports both the Xdnd and Motif drag and drop
40  * protocols transparently, the Win32 backend supports the WM_DROPFILES
41  * protocol.
42  *
43  * GTK+ provides a higher level abstraction based on top of these functions,
44  * and so they are not normally needed in GTK+ applications.
45  * See the <link linkend="gtk-Drag-and-Drop">Drag and Drop</link> section of
46  * the GTK+ documentation for more information.
47  */
48
49 /**
50  * gdk_drag_find_window:
51  * @context: a #GdkDragContext.
52  * @drag_window: a window which may be at the pointer position, but
53  *      should be ignored, since it is put up by the drag source as an icon.
54  * @x_root: the x position of the pointer in root coordinates.
55  * @y_root: the y position of the pointer in root coordinates.
56  * @dest_window: (out): location to store the destination window in.
57  * @protocol: (out): location to store the DND protocol in.
58  *
59  * Finds the destination window and DND protocol to use at the
60  * given pointer position.
61  *
62  * This function is called by the drag source to obtain the 
63  * @dest_window and @protocol parameters for gdk_drag_motion().
64  **/
65 void
66 gdk_drag_find_window (GdkDragContext  *context,
67                       GdkWindow       *drag_window,
68                       gint             x_root,
69                       gint             y_root,
70                       GdkWindow      **dest_window,
71                       GdkDragProtocol *protocol)
72 {
73   gdk_drag_find_window_for_screen (context, drag_window,
74                                    gdk_drawable_get_screen (context->source_window),
75                                    x_root, y_root, dest_window, protocol);
76 }
77
78 /**
79  * gdk_drag_get_protocol:
80  * @xid: the windowing system id of the destination window.
81  * @protocol: location where the supported DND protocol is returned.
82  * 
83  * Finds out the DND protocol supported by a window.
84  * 
85  * Return value: the windowing system specific id for the window where
86  *    the drop should happen. This may be @xid or the id of a proxy
87  *    window, or zero if @xid doesn't support Drag and Drop.
88  **/
89 GdkNativeWindow
90 gdk_drag_get_protocol (GdkNativeWindow  xid,
91                        GdkDragProtocol *protocol)
92 {
93   return gdk_drag_get_protocol_for_display (gdk_display_get_default (), xid, protocol);
94 }
95
96 /**
97  * gdk_drag_context_list_targets:
98  * @context: a #GdkDragContext
99  *
100  * Retrieves the list of targets of the context.
101  *
102  * Return value: a #GList of targets
103  *
104  * Since: 2.22
105  **/
106 GList *
107 gdk_drag_context_list_targets (GdkDragContext *context)
108 {
109   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
110
111   return context->targets;
112 }
113
114 /**
115  * gdk_drag_context_get_actions:
116  * @context: a #GdkDragContext
117  *
118  * Determines the bitmask of actions proposed by the source if
119  * gdk_drag_context_suggested_action() returns GDK_ACTION_ASK.
120  *
121  * Return value: the #GdkDragAction flags
122  *
123  * Since: 2.22
124  **/
125 GdkDragAction
126 gdk_drag_context_get_actions (GdkDragContext *context)
127 {
128   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_ACTION_DEFAULT);
129
130   return context->actions;
131 }
132
133 /**
134  * gdk_drag_context_get_suggested_action:
135  * @context: a #GdkDragContext
136  *
137  * Determines the suggested drag action of the context.
138  *
139  * Return value: a #GdkDragAction value
140  *
141  * Since: 2.22
142  **/
143 GdkDragAction
144 gdk_drag_context_get_suggested_action (GdkDragContext *context)
145 {
146   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
147
148   return context->suggested_action;
149 }
150
151 /**
152  * gdk_drag_context_get_selected_action:
153  * @context: a #GdkDragContext
154  *
155  * Determines the action chosen by the drag destination.
156  *
157  * Return value: a #GdkDragAction value
158  *
159  * Since: 2.22
160  **/
161 GdkDragAction
162 gdk_drag_context_get_selected_action (GdkDragContext *context)
163 {
164   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
165
166   return context->action;
167 }
168
169 /**
170  * gdk_drag_context_get_source_window:
171  * @context: a #GdkDragContext
172  *
173  * Returns the #GdkWindow where the DND operation started.
174  *
175  * Return value: (transfer none): a #GdkWindow
176  *
177  * Since: 2.22
178  **/
179 GdkWindow *
180 gdk_drag_context_get_source_window (GdkDragContext *context)
181 {
182   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
183
184   return context->source_window;
185 }