annotate gui/wm/wsxdnd.c @ 36084:64825e4a3fed

Remove pointless code. The URL dialog widget will be destroyed after a selection has been made, and urlEntries will be freed and rebuilt every time the URL dialog widget is created (newly). So it makes no sense to prepend any data to the GList that never will be used.
author ib
date Mon, 29 Apr 2013 11:21:23 +0000
parents afb55738b1b7
children eed2fb870f43
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 "ws.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include "wsxdnd.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30 #include <X11/Xatom.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
31
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 25619
diff changeset
32 #include "mp_msg.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 25619
diff changeset
33 #include "help_mp.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35 #define XDND_VERSION 3L
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
37 Atom XA_XdndAware;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
38 Atom XA_XdndEnter;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
39 Atom XA_XdndLeave;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
40 Atom XA_XdndDrop;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
41 Atom XA_XdndPosition;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
42 Atom XA_XdndStatus;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
43 Atom XA_XdndActionCopy;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
44 Atom XA_XdndSelection;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
45 Atom XA_XdndFinished;
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
46 Atom XA_XdndTypeList;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48 Atom atom_support;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 void wsXDNDInitialize(void)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
53 XA_XdndAware = XInternAtom(wsDisplay, "XdndAware", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
54 XA_XdndEnter = XInternAtom(wsDisplay, "XdndEnter", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
55 XA_XdndLeave = XInternAtom(wsDisplay, "XdndLeave", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
56 XA_XdndDrop = XInternAtom(wsDisplay, "XdndDrop", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
57 XA_XdndPosition = XInternAtom(wsDisplay, "XdndPosition", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
58 XA_XdndStatus = XInternAtom(wsDisplay, "XdndStatus", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
59 XA_XdndActionCopy = XInternAtom(wsDisplay, "XdndActionCopy", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
60 XA_XdndSelection = XInternAtom(wsDisplay, "XdndSelection", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
61 XA_XdndFinished = XInternAtom(wsDisplay, "XdndFinished", False);
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
62 XA_XdndTypeList = XInternAtom(wsDisplay, "XdndTypeList", False);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64
35656
f2093dc82b5f Cosmetic: Rename wsTWindow wsWindow.
ib
parents: 35631
diff changeset
65 void wsXDNDMakeAwareness(wsWindow* win) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 long int xdnd_version = XDND_VERSION;
35631
d0231540cdbd Cosmetic: Harmonize parameter names.
ib
parents: 34470
diff changeset
67 XChangeProperty (wsDisplay, win->WindowID, XA_XdndAware, XA_ATOM,
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 32, PropModeAppend, (char *)&xdnd_version, 1);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70
35656
f2093dc82b5f Cosmetic: Rename wsTWindow wsWindow.
ib
parents: 35631
diff changeset
71 void wsXDNDClearAwareness(wsWindow* win) {
35631
d0231540cdbd Cosmetic: Harmonize parameter names.
ib
parents: 34470
diff changeset
72 XDeleteProperty (wsDisplay, win->WindowID, XA_XdndAware);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 #define MAX_DND_FILES 64
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 Bool
35656
f2093dc82b5f Cosmetic: Rename wsTWindow wsWindow.
ib
parents: 35631
diff changeset
77 wsXDNDProcessSelection(wsWindow* win, XEvent *event)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 Atom ret_type;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 int ret_format;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 unsigned long ret_items;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 unsigned long remain_byte;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 char * delme;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 XEvent xevent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
85
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
86 Window selowner = XGetSelectionOwner(wsDisplay,XA_XdndSelection);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 XGetWindowProperty(wsDisplay, event->xselection.requestor,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 event->xselection.property,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 0, 65536, True, atom_support, &ret_type, &ret_format,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91 &ret_items, &remain_byte, (unsigned char **)&delme);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
93 /*send finished*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94 memset (&xevent, 0, sizeof(xevent));
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 xevent.xany.type = ClientMessage;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 xevent.xany.display = wsDisplay;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 xevent.xclient.window = selowner;
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
98 xevent.xclient.message_type = XA_XdndFinished;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 xevent.xclient.format = 32;
35631
d0231540cdbd Cosmetic: Harmonize parameter names.
ib
parents: 34470
diff changeset
100 XDND_FINISHED_TARGET_WIN(&xevent) = win->WindowID;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 XSendEvent(wsDisplay, selowner, 0, 0, &xevent);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 if (!delme){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_WS_DDNothing );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 return False;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 /* Handle dropped files */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 char * retain = delme;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 char * files[MAX_DND_FILES];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 int num = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 while(retain < delme + ret_items) {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 if (!strncmp(retain,"file:",5)) {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 /* add more 2 chars while removing 5 is harmless */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 retain+=5;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 /* add the "retain" to the list */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121 files[num++]=retain;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 /* now check for special characters */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126 int newone = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 while(retain < (delme + ret_items)){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 if(*retain == '\r' || *retain == '\n'){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 *retain=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 newone = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 } else {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 if (newone)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 retain++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 if (num >= MAX_DND_FILES)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
142
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143 /* Handle the files */
35759
afb55738b1b7 Cosmetic: Replace DandD by DND.
ib
parents: 35666
diff changeset
144 if(win->DNDHandler){
afb55738b1b7 Cosmetic: Replace DandD by DND.
ib
parents: 35666
diff changeset
145 win->DNDHandler(num,files);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149 free(delme);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153 Bool
34470
571201af959c Remove unused parameter from wsXDNDProcessClientMessage().
ib
parents: 33758
diff changeset
154 wsXDNDProcessClientMessage(XClientMessageEvent *event)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 /* test */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 /*{
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 char * name = XGetAtomName(wsDisplay, event->message_type);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 printf("Got %s\n",name);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 XFree(name);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161 }*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
163 if (event->message_type == XA_XdndEnter) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 Atom ok = XInternAtom(wsDisplay, "text/uri-list", False);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 atom_support = None;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166 if ((event->data.l[1] & 1) == 0){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 int index;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
168 for(index = 0; index <= 2 ; index++){
33757
9198f711233e Use proper cast in comparison.
ib
parents: 29263
diff changeset
169 if ((Atom) event->data.l[2+index] == ok) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170 atom_support = ok;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173 if (atom_support == None) {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_WS_NotAFile );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176 } else {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 /* need to check the whole list here */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
178 unsigned long ret_left = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 int offset = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180 Atom* ret_buff;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 Atom ret_type;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182 int ret_format;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
183 unsigned long ret_items;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 /* while there is data left...*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
186 while(ret_left && atom_support == None){
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
187 XGetWindowProperty(wsDisplay,event->data.l[0],XA_XdndTypeList,
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188 offset,256,False,XA_ATOM,&ret_type,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189 &ret_format,&ret_items,&ret_left,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 (unsigned char**)&ret_buff);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
191
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 /* sanity checks...*/
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193 if(ret_buff == NULL || ret_type != XA_ATOM || ret_format != 8*sizeof(Atom)){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 XFree(ret_buff);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 /* now chek what we've got */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 {
33758
fdf7cfbd2922 Use same data types for index variable and loop test variable.
ib
parents: 33757
diff changeset
199 unsigned long i;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200 for(i=0; i<ret_items; i++){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201 if(ret_buff[i] == ok){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 atom_support = ok;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 /* maybe next time ... */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208 XFree(ret_buff);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 offset += 256;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
214
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
215 if (event->message_type == XA_XdndLeave) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
216 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
218
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
219 if (event->message_type == XA_XdndDrop) {
33757
9198f711233e Use proper cast in comparison.
ib
parents: 29263
diff changeset
220 if ((Window) event->data.l[0] != XGetSelectionOwner(wsDisplay, XA_XdndSelection)){
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
221 puts("Wierd selection owner... QT?");
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
222 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
223 if (atom_support != None) {
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
224 XConvertSelection(wsDisplay, XA_XdndSelection, atom_support,
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
225 XA_XdndSelection, event->window,
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
226 CurrentTime);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
227 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
230
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
231 if (event->message_type == XA_XdndPosition) {
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
232 Window srcwin = event->data.l[0];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
233 if (atom_support == None){
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
234 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
235 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237 /* send response */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
238 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239 XEvent xevent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 memset (&xevent, 0, sizeof(xevent));
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241 xevent.xany.type = ClientMessage;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242 xevent.xany.display = wsDisplay;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
243 xevent.xclient.window = srcwin;
25619
20f549053410 Fix illegal identifier, names starting with _ and uppercase are reserved.
diego
parents: 23077
diff changeset
244 xevent.xclient.message_type = XA_XdndStatus;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
245 xevent.xclient.format = 32;
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
246
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
247 XDND_STATUS_TARGET_WIN (&xevent) = event->window;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
248 XDND_STATUS_WILL_ACCEPT_SET (&xevent, True);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
249 XDND_STATUS_WANT_POSITION_SET(&xevent, True);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
250 /* actually need smth real here */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
251 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
252 XDND_STATUS_ACTION(&xevent) = XA_XdndActionCopy;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
253
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
254 XSendEvent(wsDisplay, srcwin, 0, 0, &xevent);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
255 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
256 return True;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
257 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26458
diff changeset
258
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
259 return False;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
260 }