annotate gui/wm/wsxdnd.c @ 36961:127804c3452d

Remove unnecessary #include.
author ib
date Mon, 24 Mar 2014 11:09:05 +0000
parents eed2fb870f43
children 1236a692d0c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35666
01ac3cd2f101 Cosmetic: Relocate and revise comments on code origin.
ib
parents: 35656
diff changeset
17 *
01ac3cd2f101 Cosmetic: Relocate and revise comments on code origin.
ib
parents: 35656
diff changeset
18 * based on: WindowMaker implementation,
01ac3cd2f101 Cosmetic: Relocate and revise comments on code origin.
ib
parents: 35656
diff changeset
19 * adopted for MPlayer
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
20 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 #include <X11/Xlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 #include "wsxdnd.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29 #include <X11/Xatom.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 25619
diff changeset
31 #include "mp_msg.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 25619
diff changeset
32 #include "help_mp.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34 #define XDND_VERSION 3L
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
36 Atom XA_XdndAware;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
37 Atom XA_XdndEnter;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
38 Atom XA_XdndLeave;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
39 Atom XA_XdndDrop;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
40 Atom XA_XdndPosition;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
41 Atom XA_XdndStatus;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
42 Atom XA_XdndActionCopy;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
43 Atom XA_XdndSelection;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
44 Atom XA_XdndFinished;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
45 Atom XA_XdndTypeList;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47 Atom atom_support;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49 void wsXDNDInitialize(void)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
52 XA_XdndAware = XInternAtom(wsDisplay, "XdndAware", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
53 XA_XdndEnter = XInternAtom(wsDisplay, "XdndEnter", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
54 XA_XdndLeave = XInternAtom(wsDisplay, "XdndLeave", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
55 XA_XdndDrop = XInternAtom(wsDisplay, "XdndDrop", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
56 XA_XdndPosition = XInternAtom(wsDisplay, "XdndPosition", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
57 XA_XdndStatus = XInternAtom(wsDisplay, "XdndStatus", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
58 XA_XdndActionCopy = XInternAtom(wsDisplay, "XdndActionCopy", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
59 XA_XdndSelection = XInternAtom(wsDisplay, "XdndSelection", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
60 XA_XdndFinished = XInternAtom(wsDisplay, "XdndFinished", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
61 XA_XdndTypeList = XInternAtom(wsDisplay, "XdndTypeList", False);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63
35656
f2093dc82b5f Cosmetic: Rename wsTWindow wsWindow.
ib
parents: 35631
diff changeset
64 void wsXDNDMakeAwareness(wsWindow* win) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 long int xdnd_version = XDND_VERSION;
35631
d0231540cdbd Cosmetic: Harmonize parameter names.
ib
parents: 34470
diff changeset
66 XChangeProperty (wsDisplay, win->WindowID, XA_XdndAware, XA_ATOM,
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 32, PropModeAppend, (char *)&xdnd_version, 1);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69
35656
f2093dc82b5f Cosmetic: Rename wsTWindow wsWindow.
ib
parents: 35631
diff changeset
70 void wsXDNDClearAwareness(wsWindow* win) {
35631
d0231540cdbd Cosmetic: Harmonize parameter names.
ib
parents: 34470
diff changeset
71 XDeleteProperty (wsDisplay, win->WindowID, XA_XdndAware);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 #define MAX_DND_FILES 64
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 Bool
35656
f2093dc82b5f Cosmetic: Rename wsTWindow wsWindow.
ib
parents: 35631
diff changeset
76 wsXDNDProcessSelection(wsWindow* win, XEvent *event)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 Atom ret_type;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 int ret_format;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 unsigned long ret_items;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 unsigned long remain_byte;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 char * delme;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 XEvent xevent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
85 Window selowner = XGetSelectionOwner(wsDisplay,XA_XdndSelection);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87 XGetWindowProperty(wsDisplay, event->xselection.requestor,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 event->xselection.property,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 0, 65536, True, atom_support, &ret_type, &ret_format,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 &ret_items, &remain_byte, (unsigned char **)&delme);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92 /*send finished*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
93 memset (&xevent, 0, sizeof(xevent));
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94 xevent.xany.type = ClientMessage;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 xevent.xany.display = wsDisplay;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 xevent.xclient.window = selowner;
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
97 xevent.xclient.message_type = XA_XdndFinished;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
98 xevent.xclient.format = 32;
35631
d0231540cdbd Cosmetic: Harmonize parameter names.
ib
parents: 34470
diff changeset
99 XDND_FINISHED_TARGET_WIN(&xevent) = win->WindowID;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100 XSendEvent(wsDisplay, selowner, 0, 0, &xevent);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 if (!delme){
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 35759
diff changeset
103 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_GUI_MSG_DragAndDropNothing );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 return False;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 /* Handle dropped files */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 char * retain = delme;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 char * files[MAX_DND_FILES];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 int num = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 while(retain < delme + ret_items) {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 if (!strncmp(retain,"file:",5)) {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 /* add more 2 chars while removing 5 is harmless */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 retain+=5;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 /* add the "retain" to the list */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 files[num++]=retain;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 /* now check for special characters */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125 int newone = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126 while(retain < (delme + ret_items)){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 if(*retain == '\r' || *retain == '\n'){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 *retain=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 newone = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 } else {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 if (newone)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 retain++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138 if (num >= MAX_DND_FILES)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
141
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 /* Handle the files */
35759
afb55738b1b7 Cosmetic: Replace DandD by DND.
ib
parents: 35666
diff changeset
143 if(win->DNDHandler){
afb55738b1b7 Cosmetic: Replace DandD by DND.
ib
parents: 35666
diff changeset
144 win->DNDHandler(num,files);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 free(delme);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 Bool
34470
571201af959c Remove unused parameter from wsXDNDProcessClientMessage().
ib
parents: 33758
diff changeset
153 wsXDNDProcessClientMessage(XClientMessageEvent *event)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 /* test */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 /*{
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 char * name = XGetAtomName(wsDisplay, event->message_type);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 printf("Got %s\n",name);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 XFree(name);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 }*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
162 if (event->message_type == XA_XdndEnter) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163 Atom ok = XInternAtom(wsDisplay, "text/uri-list", False);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 atom_support = None;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 if ((event->data.l[1] & 1) == 0){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166 int index;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 for(index = 0; index <= 2 ; index++){
33757
9198f711233e Use proper cast in comparison.
ib
parents: 29263
diff changeset
168 if ((Atom) event->data.l[2+index] == ok) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 atom_support = ok;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 if (atom_support == None) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 35759
diff changeset
173 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_GUI_MSG_NotAFile0 );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 } else {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176 /* need to check the whole list here */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 unsigned long ret_left = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
178 int offset = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 Atom* ret_buff;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180 Atom ret_type;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 int ret_format;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182 unsigned long ret_items;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
183
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184 /* while there is data left...*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 while(ret_left && atom_support == None){
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
186 XGetWindowProperty(wsDisplay,event->data.l[0],XA_XdndTypeList,
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187 offset,256,False,XA_ATOM,&ret_type,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188 &ret_format,&ret_items,&ret_left,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 (unsigned char**)&ret_buff);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
190
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191 /* sanity checks...*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 if(ret_buff == NULL || ret_type != XA_ATOM || ret_format != 8*sizeof(Atom)){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193 XFree(ret_buff);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 /* now chek what we've got */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 {
33758
fdf7cfbd2922 Use same data types for index variable and loop test variable.
ib
parents: 33757
diff changeset
198 unsigned long i;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
199 for(i=0; i<ret_items; i++){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200 if(ret_buff[i] == ok){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201 atom_support = ok;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206 /* maybe next time ... */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 XFree(ret_buff);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208 offset += 256;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
213
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
214 if (event->message_type == XA_XdndLeave) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
215 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
216 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
217
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
218 if (event->message_type == XA_XdndDrop) {
33757
9198f711233e Use proper cast in comparison.
ib
parents: 29263
diff changeset
219 if ((Window) event->data.l[0] != XGetSelectionOwner(wsDisplay, XA_XdndSelection)){
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
220 puts("Wierd selection owner... QT?");
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
221 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
222 if (atom_support != None) {
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
223 XConvertSelection(wsDisplay, XA_XdndSelection, atom_support,
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
224 XA_XdndSelection, event->window,
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
225 CurrentTime);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
226 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
227 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
229
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
230 if (event->message_type == XA_XdndPosition) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
231 Window srcwin = event->data.l[0];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
232 if (atom_support == None){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
233 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
234 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
235
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236 /* send response */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
238 XEvent xevent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239 memset (&xevent, 0, sizeof(xevent));
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 xevent.xany.type = ClientMessage;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241 xevent.xany.display = wsDisplay;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242 xevent.xclient.window = srcwin;
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
243 xevent.xclient.message_type = XA_XdndStatus;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
244 xevent.xclient.format = 32;
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
245
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
246 XDND_STATUS_TARGET_WIN (&xevent) = event->window;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
247 XDND_STATUS_WILL_ACCEPT_SET (&xevent, True);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
248 XDND_STATUS_WANT_POSITION_SET(&xevent, True);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
249 /* actually need smth real here */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
250 XDND_STATUS_RECT_SET(&xevent, 0, 0, 1024,768);
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
251 XDND_STATUS_ACTION(&xevent) = XA_XdndActionCopy;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
252
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
253 XSendEvent(wsDisplay, srcwin, 0, 0, &xevent);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
254 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
255 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
256 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
257
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
258 return False;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
259 }