annotate Gui/wm/wsxdnd.c @ 6967:0fa27966ac47

add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
author pontscho
date Sun, 11 Aug 2002 13:12:38 +0000
parents
children 7242f1840f8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
1 /* Took WindowMaker implementation and adopted for MPlayer */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
2
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
3
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
4 #include <X11/Xlib.h>
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
5 #include "ws.h"
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
6 #include "wsxdnd.h"
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
7
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
8 #include <stdlib.h>
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
9 #include <string.h>
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
10
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
11 #include <X11/Xatom.h>
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
12
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
13
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
14 #define XDND_VERSION 3L
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
15
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
16 Atom _XA_XdndAware;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
17 Atom _XA_XdndEnter;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
18 Atom _XA_XdndLeave;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
19 Atom _XA_XdndDrop;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
20 Atom _XA_XdndPosition;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
21 Atom _XA_XdndStatus;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
22 Atom _XA_XdndActionCopy;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
23 Atom _XA_XdndSelection;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
24 Atom _XA_XdndFinished;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
25
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
26 Atom atom_support;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
27
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
28 void wsXDNDInitialize()
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
29 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
30
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
31 _XA_XdndAware = XInternAtom(wsDisplay, "XdndAware", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
32 _XA_XdndEnter = XInternAtom(wsDisplay, "XdndEnter", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
33 _XA_XdndLeave = XInternAtom(wsDisplay, "XdndLeave", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
34 _XA_XdndDrop = XInternAtom(wsDisplay, "XdndDrop", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
35 _XA_XdndPosition = XInternAtom(wsDisplay, "XdndPosition", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
36 _XA_XdndStatus = XInternAtom(wsDisplay, "XdndStatus", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
37 _XA_XdndActionCopy = XInternAtom(wsDisplay, "XdndActionCopy", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
38 _XA_XdndSelection = XInternAtom(wsDisplay, "XdndSelection", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
39 _XA_XdndFinished = XInternAtom(wsDisplay, "XdndFinished", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
40 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
41
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
42 void wsXDNDMakeAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
43 long int xdnd_version = XDND_VERSION;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
44 XChangeProperty (wsDisplay, window->WindowID, _XA_XdndAware, XA_ATOM,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
45 32, PropModeAppend, (char *)&xdnd_version, 1);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
46 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
47
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
48 void wsXDNDClearAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
49 XDeleteProperty (wsDisplay, window->WindowID, _XA_XdndAware);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
50 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
51
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
52 #define MAX_DND_FILES 64
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
53 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
54 wsXDNDProcessSelection(wsTWindow* wnd, XEvent *event)
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
55 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
56 Atom ret_type;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
57 int ret_format;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
58 unsigned long ret_items;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
59 unsigned long remain_byte;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
60 char * delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
61 XEvent xevent;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
62
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
63 Window selowner = XGetSelectionOwner(wsDisplay,_XA_XdndSelection);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
64
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
65 XGetWindowProperty(wsDisplay, event->xselection.requestor,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
66 event->xselection.property,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
67 0, 65536, True, atom_support, &ret_type, &ret_format,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
68 &ret_items, &remain_byte, (unsigned char **)&delme);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
69
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
70 /*send finished*/
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
71 memset (&xevent, 0, sizeof(xevent));
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
72 xevent.xany.type = ClientMessage;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
73 xevent.xany.display = wsDisplay;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
74 xevent.xclient.window = selowner;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
75 xevent.xclient.message_type = _XA_XdndFinished;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
76 xevent.xclient.format = 32;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
77 XDND_FINISHED_TARGET_WIN(&xevent) = wnd->WindowID;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
78 XSendEvent(wsDisplay, selowner, 0, 0, &xevent);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
79
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
80 if (!delme){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
81 printf("D&D: Nothing returned!\n");
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
82 return False;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
83 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
84
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
85 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
86 /* Handle dropped files */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
87 char * retain = delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
88 char * files[MAX_DND_FILES];
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
89 int num = 0;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
90 /*
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
91 printf("Got: %s\n",delme);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
92 */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
93 while(retain < delme + ret_items) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
94 if (!strncmp(retain,"file:",5)) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
95 /* add more 2 chars while removing 5 is harmless */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
96 retain+=5;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
97 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
98
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
99 /* add the "retain" to the list */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
100 files[num++]=retain;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
101
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
102
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
103 /* now check for special characters */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
104 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
105 int newone = 0;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
106 while(retain < (delme + ret_items)){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
107 if(*retain == '\r' || *retain == '\n'){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
108 *retain=0;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
109 newone = 1;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
110 } else {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
111 if (newone)
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
112 break;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
113 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
114 retain++;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
115 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
116 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
117
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
118 if (num >= MAX_DND_FILES)
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
119 break;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
120 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
121
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
122 /* Handle the files */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
123 if(wnd->DandDHandler){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
124 wnd->DandDHandler(num,files);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
125 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
126 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
127
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
128 free(delme);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
129 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
130
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
131 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
132 wsXDNDProcessClientMessage(wsTWindow* wnd, XClientMessageEvent *event)
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
133 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
134 /* test */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
135 /*{
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
136 char * name = XGetAtomName(wsDisplay, event->message_type);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
137 printf("Got %s\n",name);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
138 XFree(name);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
139 }*/
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
140
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
141 if (event->message_type == _XA_XdndEnter) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
142 Atom ok = XInternAtom(wsDisplay, "text/uri-list", False);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
143 atom_support = None;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
144 if ((event->data.l[1] & 1) == 0){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
145 int index;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
146 for(index = 0; index <= 2 ; index++){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
147 if (event->data.l[2+index] == ok) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
148 atom_support = ok;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
149 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
150 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
151 if (atom_support == None) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
152 printf("This doesn't seem as a file...\n");
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
153 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
154 } else {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
155 /* FIXME: need something else here */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
156 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
157 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
158 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
159
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
160 if (event->message_type == _XA_XdndLeave) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
161 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
162 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
163
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
164 if (event->message_type == _XA_XdndDrop) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
165 if (event->data.l[0] != XGetSelectionOwner(wsDisplay, _XA_XdndSelection)){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
166 puts("wierd selection owner? QT?");
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
167 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
168 if (atom_support != None) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
169 XConvertSelection(wsDisplay, _XA_XdndSelection, atom_support,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
170 _XA_XdndSelection, event->window,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
171 CurrentTime);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
172 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
173 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
174 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
175
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
176 if (event->message_type == _XA_XdndPosition) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
177 Window srcwin = event->data.l[0];
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
178 if (atom_support == None){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
179 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
180 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
181
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
182 /* send response */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
183 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
184 XEvent xevent;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
185 memset (&xevent, 0, sizeof(xevent));
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
186 xevent.xany.type = ClientMessage;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
187 xevent.xany.display = wsDisplay;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
188 xevent.xclient.window = srcwin;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
189 xevent.xclient.message_type = _XA_XdndStatus;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
190 xevent.xclient.format = 32;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
191
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
192 XDND_STATUS_TARGET_WIN (&xevent) = event->window;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
193 XDND_STATUS_WILL_ACCEPT_SET (&xevent, True);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
194 XDND_STATUS_WANT_POSITION_SET(&xevent, True);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
195 /* actually need smth real here */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
196 XDND_STATUS_RECT_SET(&xevent, 0, 0, 1024,768);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
197 XDND_STATUS_ACTION(&xevent) = _XA_XdndActionCopy;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
198
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
199 XSendEvent(wsDisplay, srcwin, 0, 0, &xevent);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
200 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
201 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
202 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
203
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
204 return False;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
205 }