1 /* |
|
2 * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 #ifdef HEADLESS |
|
27 #error This file should not be included in headless library |
|
28 #endif |
|
29 |
|
30 #include <X11/Intrinsic.h> |
|
31 |
|
32 #include "awt_p.h" |
|
33 |
|
34 /* For definition of MComponentPeerIDs */ |
|
35 #include "awt_Component.h" |
|
36 |
|
37 extern struct MComponentPeerIDs mComponentPeerIDs; |
|
38 |
|
39 /* DnD protocols */ |
|
40 |
|
41 typedef enum { |
|
42 NO_PROTOCOL, |
|
43 XDND_PROTOCOL, |
|
44 MOTIF_DND_PROTOCOL |
|
45 } Protocol; |
|
46 |
|
47 /* XDnD constants */ |
|
48 |
|
49 #define XDND_PROTOCOL_VERSION 5 |
|
50 /* XDnD compliance only requires supporting version 3 and up. */ |
|
51 #define XDND_MIN_PROTOCOL_VERSION 3 |
|
52 |
|
53 #define XDND_PROTOCOL_MASK 0xFF000000 |
|
54 #define XDND_PROTOCOL_SHIFT 24 |
|
55 #define XDND_DATA_TYPES_BIT 0x1 |
|
56 #define XDND_ACCEPT_DROP_FLAG 0x1 |
|
57 |
|
58 /* Motif DnD constants */ |
|
59 |
|
60 #define MOTIF_DND_PROTOCOL_VERSION 0 |
|
61 |
|
62 /* Suuported protocol styles */ |
|
63 #define MOTIF_PREFER_PREREGISTER_STYLE 2 |
|
64 #define MOTIF_PREFER_DYNAMIC_STYLE 4 |
|
65 #define MOTIF_DYNAMIC_STYLE 5 |
|
66 #define MOTIF_PREFER_RECEIVER_STYLE 6 |
|
67 |
|
68 #define MOTIF_MESSAGE_REASON_MASK 0x7F |
|
69 #define MOTIF_MESSAGE_SENDER_MASK 0x80 |
|
70 #define MOTIF_MESSAGE_FROM_RECEIVER 0x80 |
|
71 #define MOTIF_MESSAGE_FROM_INITIATOR 0 |
|
72 |
|
73 /* Info structure sizes */ |
|
74 #define MOTIF_INITIATOR_INFO_SIZE 8 |
|
75 #define MOTIF_RECEIVER_INFO_SIZE 16 |
|
76 |
|
77 /* Message flags masks and shifts */ |
|
78 #define MOTIF_DND_ACTION_MASK 0x000F |
|
79 #define MOTIF_DND_ACTION_SHIFT 0 |
|
80 #define MOTIF_DND_STATUS_MASK 0x00F0 |
|
81 #define MOTIF_DND_STATUS_SHIFT 4 |
|
82 #define MOTIF_DND_ACTIONS_MASK 0x0F00 |
|
83 #define MOTIF_DND_ACTIONS_SHIFT 8 |
|
84 |
|
85 /* message type constants */ |
|
86 #define TOP_LEVEL_ENTER 0 |
|
87 #define TOP_LEVEL_LEAVE 1 |
|
88 #define DRAG_MOTION 2 |
|
89 #define DROP_SITE_ENTER 3 |
|
90 #define DROP_SITE_LEAVE 4 |
|
91 #define DROP_START 5 |
|
92 #define DROP_FINISH 6 |
|
93 #define DRAG_DROP_FINISH 7 |
|
94 #define OPERATION_CHANGED 8 |
|
95 |
|
96 /* drop action constants */ |
|
97 #define MOTIF_DND_NOOP 0L |
|
98 #define MOTIF_DND_MOVE (1L << 0) |
|
99 #define MOTIF_DND_COPY (1L << 1) |
|
100 #define MOTIF_DND_LINK (1L << 2) |
|
101 |
|
102 /* drop site status constants */ |
|
103 #define MOTIF_NO_DROP_SITE 1 |
|
104 #define MOTIF_INVALID_DROP_SITE 2 |
|
105 #define MOTIF_VALID_DROP_SITE 3 |
|
106 |
|
107 /* Shared atoms */ |
|
108 |
|
109 extern Atom XA_WM_STATE; |
|
110 extern Atom XA_DELETE; |
|
111 |
|
112 /* XDnD atoms */ |
|
113 |
|
114 extern Atom XA_XdndAware; |
|
115 extern Atom XA_XdndProxy; |
|
116 |
|
117 extern Atom XA_XdndEnter; |
|
118 extern Atom XA_XdndPosition; |
|
119 extern Atom XA_XdndLeave; |
|
120 extern Atom XA_XdndDrop; |
|
121 extern Atom XA_XdndStatus; |
|
122 extern Atom XA_XdndFinished; |
|
123 |
|
124 extern Atom XA_XdndTypeList; |
|
125 extern Atom XA_XdndSelection; |
|
126 |
|
127 extern Atom XA_XdndActionCopy; |
|
128 extern Atom XA_XdndActionMove; |
|
129 extern Atom XA_XdndActionLink; |
|
130 extern Atom XA_XdndActionAsk; |
|
131 extern Atom XA_XdndActionPrivate; |
|
132 extern Atom XA_XdndActionList; |
|
133 |
|
134 /* Motif DnD atoms */ |
|
135 |
|
136 extern Atom _XA_MOTIF_DRAG_WINDOW; |
|
137 extern Atom _XA_MOTIF_DRAG_TARGETS; |
|
138 extern Atom _XA_MOTIF_DRAG_INITIATOR_INFO; |
|
139 extern Atom _XA_MOTIF_DRAG_RECEIVER_INFO; |
|
140 extern Atom _XA_MOTIF_DRAG_AND_DROP_MESSAGE; |
|
141 extern Atom XA_XmTRANSFER_SUCCESS; |
|
142 extern Atom XA_XmTRANSFER_FAILURE; |
|
143 extern Atom _XA_MOTIF_ATOM_0; |
|
144 |
|
145 extern unsigned char MOTIF_BYTE_ORDER; |
|
146 |
|
147 /* Motif DnD macros */ |
|
148 |
|
149 #define SWAP4BYTES(l) {\ |
|
150 struct {\ |
|
151 unsigned t :32;\ |
|
152 } bit32;\ |
|
153 char n, *tp = (char *) &bit32;\ |
|
154 bit32.t = l;\ |
|
155 n = tp[0]; tp[0] = tp[3]; tp[3] = n;\ |
|
156 n = tp[1]; tp[1] = tp[2]; tp[2] = n;\ |
|
157 l = bit32.t;\ |
|
158 } |
|
159 |
|
160 #define SWAP2BYTES(s) {\ |
|
161 struct {\ |
|
162 unsigned t :16;\ |
|
163 } bit16;\ |
|
164 char n, *tp = (char *) &bit16;\ |
|
165 bit16.t = s;\ |
|
166 n = tp[0]; tp[0] = tp[1]; tp[1] = n;\ |
|
167 s = bit16.t;\ |
|
168 } |
|
169 |
|
170 typedef struct DropSiteInfo { |
|
171 Widget tlw; |
|
172 jobject component; |
|
173 Boolean isComposite; |
|
174 uint32_t dsCnt; |
|
175 } DropSiteInfo; |
|
176 |
|
177 Boolean awt_dnd_init(Display* display); |
|
178 Boolean awt_dnd_ds_init(Display* display); |
|
179 |
|
180 Window get_awt_root_window(); |
|
181 |
|
182 /**************** checked_X* wrappers *****************************************/ |
|
183 unsigned char |
|
184 checked_XChangeProperty(Display* display, Window w, Atom property, Atom type, |
|
185 int format, int mode, unsigned char* data, |
|
186 int nelements); |
|
187 |
|
188 unsigned char |
|
189 checked_XGetWindowProperty(Display* display, Window w, Atom property, |
|
190 long long_offset, long long_length, Bool delete, |
|
191 Atom req_type, Atom* actual_type_return, |
|
192 int* actual_format_return, |
|
193 unsigned long* nitems_return, |
|
194 unsigned long* bytes_after_return, |
|
195 unsigned char** prop_return); |
|
196 |
|
197 unsigned char |
|
198 checked_XSendEvent(Display* display, Window w, Bool propagate, long event_mask, |
|
199 XEvent* event_send); |
|
200 |
|
201 unsigned char |
|
202 checked_XTranslateCoordinates(Display* display, Window src_w, Window dest_w, |
|
203 int src_x, int src_y, int* dest_x_return, |
|
204 int* dest_y_return, Window* child_return); |
|
205 |
|
206 unsigned char |
|
207 checked_XSelectInput(Display* display, Window w, long event_mask); |
|
208 /******************************************************************************/ |
|
209 |
|
210 jint xdnd_to_java_action(Atom action); |
|
211 Atom java_to_xdnd_action(jint action); |
|
212 |
|
213 jint motif_to_java_actions(unsigned char action); |
|
214 unsigned char java_to_motif_actions(jint action); |
|
215 |
|
216 void write_card8(void** p, CARD8 value); |
|
217 void write_card16(void** p, CARD16 value); |
|
218 void write_card32(void** p, CARD32 value); |
|
219 |
|
220 CARD8 read_card8(char* data, size_t offset); |
|
221 CARD16 read_card16(char* data, size_t offset, char byte_order); |
|
222 CARD32 read_card32(char* data, size_t offset, char byte_order); |
|
223 |
|
224 Window get_motif_window(Display* dpy); |
|
225 |
|
226 /*************************** TARGET LIST SUPPORT ***************************************/ |
|
227 |
|
228 int get_index_for_target_list(Display* dpy, Atom* targets, unsigned int num_targets); |
|
229 void get_target_list_for_index(Display* dpy, int index, Atom** targets, unsigned |
|
230 int* num_targets); |
|
231 |
|
232 /***************************************************************************************/ |
|
233 |
|
234 Boolean awt_dnd_process_event(XEvent* event); |
|
235 Boolean awt_dnd_ds_process_event(XEvent* event); |
|
236 Boolean awt_dnd_dt_process_event(XEvent* event); |
|
237 |
|
238 Window awt_dnd_ds_get_source_window(); |
|
239 |
|
240 /**************************** XEmbed server DnD support ***********************/ |
|
241 void set_proxy_mode_source_window(Window window); |
|
242 /******************************************************************************/ |
|