Mercurial > mplayer.hg
comparison Gui/wm/wsxdnd.c @ 6977:7242f1840f8d
kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
author | pontscho |
---|---|
date | Sun, 11 Aug 2002 19:12:09 +0000 |
parents | 0fa27966ac47 |
children | 8e9607c5897e |
comparison
equal
deleted
inserted
replaced
6976:23c3cd12abe5 | 6977:7242f1840f8d |
---|---|
20 Atom _XA_XdndPosition; | 20 Atom _XA_XdndPosition; |
21 Atom _XA_XdndStatus; | 21 Atom _XA_XdndStatus; |
22 Atom _XA_XdndActionCopy; | 22 Atom _XA_XdndActionCopy; |
23 Atom _XA_XdndSelection; | 23 Atom _XA_XdndSelection; |
24 Atom _XA_XdndFinished; | 24 Atom _XA_XdndFinished; |
25 Atom _XA_XdndTypeList; | |
25 | 26 |
26 Atom atom_support; | 27 Atom atom_support; |
27 | 28 |
28 void wsXDNDInitialize() | 29 void wsXDNDInitialize() |
29 { | 30 { |
35 _XA_XdndPosition = XInternAtom(wsDisplay, "XdndPosition", False); | 36 _XA_XdndPosition = XInternAtom(wsDisplay, "XdndPosition", False); |
36 _XA_XdndStatus = XInternAtom(wsDisplay, "XdndStatus", False); | 37 _XA_XdndStatus = XInternAtom(wsDisplay, "XdndStatus", False); |
37 _XA_XdndActionCopy = XInternAtom(wsDisplay, "XdndActionCopy", False); | 38 _XA_XdndActionCopy = XInternAtom(wsDisplay, "XdndActionCopy", False); |
38 _XA_XdndSelection = XInternAtom(wsDisplay, "XdndSelection", False); | 39 _XA_XdndSelection = XInternAtom(wsDisplay, "XdndSelection", False); |
39 _XA_XdndFinished = XInternAtom(wsDisplay, "XdndFinished", False); | 40 _XA_XdndFinished = XInternAtom(wsDisplay, "XdndFinished", False); |
41 _XA_XdndTypeList = XInternAtom(wsDisplay, "XdndTypeList", False); | |
40 } | 42 } |
41 | 43 |
42 void wsXDNDMakeAwareness(wsTWindow* window) { | 44 void wsXDNDMakeAwareness(wsTWindow* window) { |
43 long int xdnd_version = XDND_VERSION; | 45 long int xdnd_version = XDND_VERSION; |
44 XChangeProperty (wsDisplay, window->WindowID, _XA_XdndAware, XA_ATOM, | 46 XChangeProperty (wsDisplay, window->WindowID, _XA_XdndAware, XA_ATOM, |
85 { | 87 { |
86 /* Handle dropped files */ | 88 /* Handle dropped files */ |
87 char * retain = delme; | 89 char * retain = delme; |
88 char * files[MAX_DND_FILES]; | 90 char * files[MAX_DND_FILES]; |
89 int num = 0; | 91 int num = 0; |
90 /* | 92 |
91 printf("Got: %s\n",delme); | |
92 */ | |
93 while(retain < delme + ret_items) { | 93 while(retain < delme + ret_items) { |
94 if (!strncmp(retain,"file:",5)) { | 94 if (!strncmp(retain,"file:",5)) { |
95 /* add more 2 chars while removing 5 is harmless */ | 95 /* add more 2 chars while removing 5 is harmless */ |
96 retain+=5; | 96 retain+=5; |
97 } | 97 } |
150 } | 150 } |
151 if (atom_support == None) { | 151 if (atom_support == None) { |
152 printf("This doesn't seem as a file...\n"); | 152 printf("This doesn't seem as a file...\n"); |
153 } | 153 } |
154 } else { | 154 } else { |
155 /* FIXME: need something else here */ | 155 /* need to check the whole list here */ |
156 int ret_left = 1; | |
157 int offset = 0; | |
158 Atom* ret_buff; | |
159 int ret_type,ret_format,ret_items; | |
160 /* while there is data left...*/ | |
161 while(ret_left){ | |
162 XGetWindowProperty(wsDisplay,event->data.l[0],_XA_XdndTypeList, | |
163 offset,256,False,XA_ATOM,&ret_type, | |
164 &ret_format,&ret_items,&ret_left, | |
165 (unsigned char**)&ret_buff); | |
166 | |
167 /* sanity checks...*/ | |
168 if(ret_buff == NULL || ret_type != XA_ATOM || ret_format != 8*sizeof(Atom)){ | |
169 XFree(ret_buff); | |
170 break; | |
171 } | |
172 /* now chek what we've got */ | |
173 { | |
174 int i; | |
175 for(i=0; i<ret_items; i++){ | |
176 if(ret_buff[i] == ok){ | |
177 atom_support = ok; | |
178 break; | |
179 } | |
180 } | |
181 /* found it ! */ | |
182 if (atom_support != None) | |
183 break; | |
184 } | |
185 /* maybe next time ... */ | |
186 XFree(ret_buff); | |
187 offset += 256; | |
188 } | |
156 } | 189 } |
157 return True; | 190 return True; |
158 } | 191 } |
159 | 192 |
160 if (event->message_type == _XA_XdndLeave) { | 193 if (event->message_type == _XA_XdndLeave) { |
161 return True; | 194 return True; |
162 } | 195 } |
163 | 196 |
164 if (event->message_type == _XA_XdndDrop) { | 197 if (event->message_type == _XA_XdndDrop) { |
165 if (event->data.l[0] != XGetSelectionOwner(wsDisplay, _XA_XdndSelection)){ | 198 if (event->data.l[0] != XGetSelectionOwner(wsDisplay, _XA_XdndSelection)){ |
166 puts("wierd selection owner? QT?"); | 199 puts("Wierd selection owner... QT?"); |
167 } | 200 } |
168 if (atom_support != None) { | 201 if (atom_support != None) { |
169 XConvertSelection(wsDisplay, _XA_XdndSelection, atom_support, | 202 XConvertSelection(wsDisplay, _XA_XdndSelection, atom_support, |
170 _XA_XdndSelection, event->window, | 203 _XA_XdndSelection, event->window, |
171 CurrentTime); | 204 CurrentTime); |