annotate Gui/wm/wsxdnd.c @ 10425:82387bdeb8b7

more generated files
author diego
date Sun, 13 Jul 2003 23:30:28 +0000
parents e4736a12c898
children df423e2d71dc
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
7095
fad0147bd3aa - add dxr3 equ patch from "Szombathelyi [iso-8859-2] Gy«Órgy" <gyurco@freemail.hu>
pontscho
parents: 7092
diff changeset
8 #include <stdio.h>
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
9 #include <stdlib.h>
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
10 #include <string.h>
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
11
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
12 #include <X11/Xatom.h>
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
15 #define XDND_VERSION 3L
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
16
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
17 Atom _XA_XdndAware;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
18 Atom _XA_XdndEnter;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
19 Atom _XA_XdndLeave;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
20 Atom _XA_XdndDrop;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
21 Atom _XA_XdndPosition;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
22 Atom _XA_XdndStatus;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
23 Atom _XA_XdndActionCopy;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
24 Atom _XA_XdndSelection;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
25 Atom _XA_XdndFinished;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
26 Atom _XA_XdndTypeList;
6967
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 Atom atom_support;
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 void wsXDNDInitialize()
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
33 _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
34 _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
35 _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
36 _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
37 _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
38 _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
39 _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
40 _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
41 _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
42 _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
43 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
44
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
45 void wsXDNDMakeAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
46 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
47 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
48 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
49 }
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 void wsXDNDClearAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
52 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
53 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
54
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
55 #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
56 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
57 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
58 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
59 Atom ret_type;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
60 int ret_format;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
61 unsigned long ret_items;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
62 unsigned long remain_byte;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
63 char * delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
64 XEvent xevent;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
65
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
66 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
67
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
68 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
69 event->xselection.property,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
70 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
71 &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
72
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
73 /*send finished*/
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
74 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
75 xevent.xany.type = ClientMessage;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
76 xevent.xany.display = wsDisplay;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
77 xevent.xclient.window = selowner;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
78 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
79 xevent.xclient.format = 32;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
80 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
81 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
82
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
83 if (!delme){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
84 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
85 return False;
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 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
89 /* Handle dropped files */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
90 char * retain = delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
91 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
92 int num = 0;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
93
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
94 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
95 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
96 /* 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
97 retain+=5;
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
100 /* 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
101 files[num++]=retain;
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
104 /* 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
105 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
106 int newone = 0;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
107 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
108 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
109 *retain=0;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
110 newone = 1;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
111 } else {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
112 if (newone)
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
113 break;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
114 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
115 retain++;
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
119 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
120 break;
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
123 /* Handle the files */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
124 if(wnd->DandDHandler){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
125 wnd->DandDHandler(num,files);
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
129 free(delme);
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
130 return True;
6967
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
133 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
134 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
135 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
136 /* test */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
137 /*{
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
138 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
139 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
140 XFree(name);
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
143 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
144 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
145 atom_support = None;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
146 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
147 int index;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
148 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
149 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
150 atom_support = ok;
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 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
153 if (atom_support == None) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
154 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
155 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
156 } else {
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
157 /* need to check the whole list here */
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
158 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
159 int offset = 0;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
160 Atom* ret_buff;
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
161 Atom ret_type;
7095
fad0147bd3aa - add dxr3 equ patch from "Szombathelyi [iso-8859-2] Gy«Órgy" <gyurco@freemail.hu>
pontscho
parents: 7092
diff changeset
162 int ret_format;
fad0147bd3aa - add dxr3 equ patch from "Szombathelyi [iso-8859-2] Gy«Órgy" <gyurco@freemail.hu>
pontscho
parents: 7092
diff changeset
163 unsigned long ret_items;
fad0147bd3aa - add dxr3 equ patch from "Szombathelyi [iso-8859-2] Gy«Órgy" <gyurco@freemail.hu>
pontscho
parents: 7092
diff changeset
164
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
165 /* while there is data left...*/
8481
e4736a12c898 applied Gregory's patch
pontscho
parents: 7095
diff changeset
166 while(ret_left && atom_support == None){
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
167 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
168 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
169 &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
170 (unsigned char**)&ret_buff);
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
171
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
172 /* sanity checks...*/
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
173 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
174 XFree(ret_buff);
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
175 break;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
176 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
177 /* 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
178 {
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
179 int i;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
180 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
181 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
182 atom_support = ok;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
183 break;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
184 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
185 }
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 }