annotate Gui/wm/wsxdnd.c @ 7092:8e9607c5897e

- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org> - wsXDNDProcessSelection return Truae fix - add url list saving support from Morten Volden <mvolden@tdcadsl.dk> - fix bug's in this patches - fix some memleak and bug
author pontscho
date Mon, 26 Aug 2002 22:20:58 +0000
parents 7242f1840f8d
children fad0147bd3aa
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;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
25 Atom _XA_XdndTypeList;
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
26
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
27 Atom atom_support;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
28
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
29 void wsXDNDInitialize()
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
32 _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
33 _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
34 _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
35 _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
36 _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
37 _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
38 _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
39 _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
40 _XA_XdndFinished = XInternAtom(wsDisplay, "XdndFinished", False);
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
41 _XA_XdndTypeList = XInternAtom(wsDisplay, "XdndTypeList", False);
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
42 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
43
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
44 void wsXDNDMakeAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
45 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
46 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
47 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
48 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
49
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
50 void wsXDNDClearAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
51 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
52 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
53
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
54 #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
55 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
56 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
57 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
58 Atom ret_type;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
59 int ret_format;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
60 unsigned long ret_items;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
61 unsigned long remain_byte;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
62 char * delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
63 XEvent xevent;
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 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
66
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
67 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
68 event->xselection.property,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
69 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
70 &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
71
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
72 /*send finished*/
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
73 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
74 xevent.xany.type = ClientMessage;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
75 xevent.xany.display = wsDisplay;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
76 xevent.xclient.window = selowner;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
77 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
78 xevent.xclient.format = 32;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
79 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
80 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
81
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
82 if (!delme){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
83 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
84 return False;
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
87 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
88 /* Handle dropped files */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
89 char * retain = delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
90 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
91 int num = 0;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
92
6967
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);
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
129 return True;
6967
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
132 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
133 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
134 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
135 /* test */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
136 /*{
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
137 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
138 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
139 XFree(name);
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
142 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
143 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
144 atom_support = None;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
145 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
146 int index;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
147 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
148 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
149 atom_support = ok;
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 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
152 if (atom_support == None) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
153 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
154 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
155 } else {
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
156 /* need to check the whole list here */
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
157 unsigned long ret_left = 1;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
158 int offset = 0;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
159 Atom* ret_buff;
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
160 Atom ret_type;
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
161 unsigned long ret_format,ret_items;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
162 /* while there is data left...*/
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
163 while(ret_left){
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
164 XGetWindowProperty(wsDisplay,event->data.l[0],_XA_XdndTypeList,
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
165 offset,256,False,XA_ATOM,&ret_type,
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
166 &ret_format,&ret_items,&ret_left,
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
167 (unsigned char**)&ret_buff);
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
168
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
169 /* sanity checks...*/
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
170 if(ret_buff == NULL || ret_type != XA_ATOM || ret_format != 8*sizeof(Atom)){
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
171 XFree(ret_buff);
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
172 break;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
173 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
174 /* now chek what we've got */
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
175 {
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
176 int i;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
177 for(i=0; i<ret_items; i++){
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
178 if(ret_buff[i] == ok){
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
179 atom_support = ok;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
180 break;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
181 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
182 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
183 /* found it ! */
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
184 if (atom_support != None)
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
185 break;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
186 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
187 /* maybe next time ... */
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
188 XFree(ret_buff);
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
189 offset += 256;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
190 }
6967
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 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
193 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
194
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
195 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
196 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
197 }
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 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
200 if (event->data.l[0] != XGetSelectionOwner(wsDisplay, _XA_XdndSelection)){
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
201 puts("Wierd selection owner... QT?");
6967
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 if (atom_support != None) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
204 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
205 _XA_XdndSelection, event->window,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
206 CurrentTime);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
207 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
208 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
209 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
210
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
211 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
212 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
213 if (atom_support == None){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
214 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
215 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
216
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
217 /* send response */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
218 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
219 XEvent xevent;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
220 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
221 xevent.xany.type = ClientMessage;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
222 xevent.xany.display = wsDisplay;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
223 xevent.xclient.window = srcwin;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
224 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
225 xevent.xclient.format = 32;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
226
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
227 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
228 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
229 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
230 /* 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
231 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
232 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
233
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
234 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
235 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
236 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
237 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
238
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
239 return False;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
240 }