annotate Gui/wm/wsxdnd.c @ 15561:6e2c6d2553bd

disable preinit until it's fixed (it breaks -speed...codec is initialized with wrong samplerate)
author rfelker
date Tue, 24 May 2005 08:29:45 +0000
parents c30e193ac112
children 0e1471d9da74
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
14156
c30e193ac112 printf --> mp_msg conversion, less verbosity
diego
parents: 12068
diff changeset
14 #include "../../mp_msg.h"
c30e193ac112 printf --> mp_msg conversion, less verbosity
diego
parents: 12068
diff changeset
15 #include "../../help_mp.h"
6967
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 #define XDND_VERSION 3L
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
18
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
19 Atom _XA_XdndAware;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
20 Atom _XA_XdndEnter;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
21 Atom _XA_XdndLeave;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
22 Atom _XA_XdndDrop;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
23 Atom _XA_XdndPosition;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
24 Atom _XA_XdndStatus;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
25 Atom _XA_XdndActionCopy;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
26 Atom _XA_XdndSelection;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
27 Atom _XA_XdndFinished;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
28 Atom _XA_XdndTypeList;
6967
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 Atom atom_support;
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 void wsXDNDInitialize()
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
33 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
34
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
35 _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
36 _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
37 _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
38 _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
39 _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
40 _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
41 _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
42 _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
43 _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
44 _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
45 }
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 void wsXDNDMakeAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
48 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
49 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
50 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
51 }
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 void wsXDNDClearAwareness(wsTWindow* window) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
54 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
55 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
56
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
57 #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
58 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
59 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
60 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
61 Atom ret_type;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
62 int ret_format;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
63 unsigned long ret_items;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
64 unsigned long remain_byte;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
65 char * delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
66 XEvent xevent;
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 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
69
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
70 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
71 event->xselection.property,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
72 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
73 &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
74
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
75 /*send finished*/
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
76 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
77 xevent.xany.type = ClientMessage;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
78 xevent.xany.display = wsDisplay;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
79 xevent.xclient.window = selowner;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
80 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
81 xevent.xclient.format = 32;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
82 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
83 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
84
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
85 if (!delme){
14156
c30e193ac112 printf --> mp_msg conversion, less verbosity
diego
parents: 12068
diff changeset
86 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_WS_DDNothing );
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
87 return False;
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
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 /* Handle dropped files */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
92 char * retain = delme;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
93 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
94 int num = 0;
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
95
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
96 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
97 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
98 /* 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
99 retain+=5;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
100 }
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 /* 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
103 files[num++]=retain;
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
106 /* 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
107 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
108 int newone = 0;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
109 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
110 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
111 *retain=0;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
112 newone = 1;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
113 } else {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
114 if (newone)
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
115 break;
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 retain++;
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 }
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 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
122 break;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
123 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
124
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
125 /* Handle the files */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
126 if(wnd->DandDHandler){
12068
df423e2d71dc patch from Rune <runner@mail.tele.dk>
pontscho
parents: 8481
diff changeset
127 wnd->DandDHandler(num-1,files);
6967
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 }
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 free(delme);
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
132 return True;
6967
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
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
135 Bool
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
136 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
137 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
138 /* test */
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 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
141 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
142 XFree(name);
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
143 }*/
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
144
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
145 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
146 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
147 atom_support = None;
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[1] & 1) == 0){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
149 int index;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
150 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
151 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
152 atom_support = ok;
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 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
155 if (atom_support == None) {
14156
c30e193ac112 printf --> mp_msg conversion, less verbosity
diego
parents: 12068
diff changeset
156 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_WS_NotAFile );
6967
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
157 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
158 } else {
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
159 /* need to check the whole list here */
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
160 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
161 int offset = 0;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
162 Atom* ret_buff;
7092
8e9607c5897e - warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents: 6977
diff changeset
163 Atom ret_type;
7095
fad0147bd3aa - add dxr3 equ patch from "Szombathelyi [iso-8859-2] Gy«Órgy" <gyurco@freemail.hu>
pontscho
parents: 7092
diff changeset
164 int ret_format;
fad0147bd3aa - add dxr3 equ patch from "Szombathelyi [iso-8859-2] Gy«Órgy" <gyurco@freemail.hu>
pontscho
parents: 7092
diff changeset
165 unsigned long ret_items;
fad0147bd3aa - add dxr3 equ patch from "Szombathelyi [iso-8859-2] Gy«Órgy" <gyurco@freemail.hu>
pontscho
parents: 7092
diff changeset
166
6977
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
167 /* while there is data left...*/
8481
e4736a12c898 applied Gregory's patch
pontscho
parents: 7095
diff changeset
168 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
169 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
170 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
171 &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
172 (unsigned char**)&ret_buff);
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 /* sanity checks...*/
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
175 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
176 XFree(ret_buff);
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
177 break;
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 /* 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
180 {
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
181 int i;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
182 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
183 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
184 atom_support = ok;
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 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
188 }
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
189 /* maybe next time ... */
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
190 XFree(ret_buff);
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
191 offset += 256;
7242f1840f8d kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
pontscho
parents: 6967
diff changeset
192 }
6967
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 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
195 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
196
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
197 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
198 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
199 }
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 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
202 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
203 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
204 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
205 if (atom_support != None) {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
206 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
207 _XA_XdndSelection, event->window,
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
208 CurrentTime);
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 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
211 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
212
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
213 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
214 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
215 if (atom_support == None){
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
216 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
217 }
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 /* send response */
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
220 {
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
221 XEvent xevent;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
222 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
223 xevent.xany.type = ClientMessage;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
224 xevent.xany.display = wsDisplay;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
225 xevent.xclient.window = srcwin;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
226 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
227 xevent.xclient.format = 32;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
228
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
229 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
230 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
231 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
232 /* 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
233 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
234 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
235
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
236 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
237 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
238 return True;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
239 }
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
240
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
241 return False;
0fa27966ac47 add xdnd support (from Gregory Kovriga <gkovriga@techunix.technion.ac.il>) and fix -subdelay bug
pontscho
parents:
diff changeset
242 }