29#include <FL/Fl_Window.H>
34extern Atom fl_XdndAware;
35extern Atom fl_XdndSelection;
36extern Atom fl_XdndEnter;
37extern Atom fl_XdndTypeList;
38extern Atom fl_XdndPosition;
39extern Atom fl_XdndLeave;
40extern Atom fl_XdndDrop;
41extern Atom fl_XdndStatus;
42extern Atom fl_XdndActionCopy;
43extern Atom fl_XdndFinished;
45extern Atom fl_XdndURIList;
46extern Atom fl_XaUtf8String;
48extern char fl_i_own_selection[2];
49extern char *fl_selection_buffer[2];
51extern void fl_sendClientMessage(Window window, Atom message,
60static int dnd_aware(Window& window) {
61 Atom actual;
int format;
unsigned long count, remaining;
62 unsigned char *data = 0;
63 XGetWindowProperty(fl_display, window, fl_XdndAware,
66 &count, &remaining, &data);
67 if (actual == XA_ATOM && format==32 && count && data)
68 return int(*(Atom*)data);
72static int grabfunc(
int event) {
77extern int (*fl_local_grab)(int);
80static int local_handle(
int event,
Fl_Window* window) {
82 Fl::e_x = Fl::e_x_root-window->x();
83 Fl::e_y = Fl::e_y_root-window->y();
85 fl_local_grab = grabfunc;
93 fl_local_grab = grabfunc;
94 Window target_window = 0;
95 Fl_Window* local_window = 0;
96 int dndversion = 4;
int dest_x, dest_y, old_dest_x, old_dest_y;
98 old_dest_y = old_dest_x = -1;
100 XSetSelectionOwner(fl_display, fl_XdndSelection, fl_message_window, fl_event_time);
107 Window new_window = 0;
int new_version = 0;
108 Fl_Window* new_local_window = 0;
109 for (Window child = RootWindow(fl_display, fl_screen);;) {
110 Window root;
unsigned int junk3;
111 XQueryPointer(fl_display, child, &root, &child,
112 &e_x_root, &e_y_root, &dest_x, &dest_y, &junk3);
114 if (!new_window && (new_version = dnd_aware(root))) new_window = root;
118 if ((new_local_window = fl_find(child)))
break;
119 if ((new_version = dnd_aware(new_window)))
break;
122 if (new_window != target_window) {
125 }
else if (dndversion) {
126 fl_sendClientMessage(target_window, fl_XdndLeave, source_window);
128 dndversion = new_version;
129 target_window = new_window;
130 local_window = new_local_window;
133 }
else if (dndversion) {
141 if ((!strncmp(fl_selection_buffer[0],
"file:///", 8) ||
142 !strncmp(fl_selection_buffer[0],
"ftp://", 6) ||
143 !strncmp(fl_selection_buffer[0],
"http://", 7) ||
144 !strncmp(fl_selection_buffer[0],
"https://", 8) ||
145 !strncmp(fl_selection_buffer[0],
"ipp://", 6) ||
146 !strncmp(fl_selection_buffer[0],
"ldap:", 5) ||
147 !strncmp(fl_selection_buffer[0],
"mailto:", 7) ||
148 !strncmp(fl_selection_buffer[0],
"news:", 5) ||
149 !strncmp(fl_selection_buffer[0],
"smb://", 6)) &&
150 !strchr(fl_selection_buffer[0],
' ') &&
151 strstr(fl_selection_buffer[0],
"\r\n")) {
153 fl_sendClientMessage(target_window, fl_XdndEnter, source_window,
154 dndversion<<24, fl_XdndURIList, XA_STRING, 0);
157 fl_sendClientMessage(target_window, fl_XdndEnter, source_window,
158 dndversion<<24, fl_XaUtf8String, 0, 0);
163 if ( old_dest_x != dest_x || old_dest_y != dest_y )
167 }
else if (dndversion) {
168 fl_sendClientMessage(target_window, fl_XdndPosition, source_window,
169 0, (e_x_root<<16)|e_y_root, fl_event_time,
180 fl_i_own_selection[0] = 1;
182 }
else if (dndversion) {
184 fl_sendClientMessage(target_window, fl_XdndDrop, source_window,
187 }
else if (target_window) {
190 msg.type = ButtonPress;
191 msg.window = target_window;
192 msg.root = RootWindow(fl_display, fl_screen);
194 msg.time = fl_event_time+1;
197 msg.x_root = Fl::e_x_root;
198 msg.y_root = Fl::e_y_root;
200 msg.button = Button2;
201 XSendEvent(fl_display, target_window, False, 0L, (XEvent*)&msg);
204 msg.type = ButtonRelease;
205 XSendEvent(fl_display, target_window, False, 0L, (XEvent*)&msg);
@ FL_CURSOR_MOVE
4-pointed arrow.
Definition Enumerations.H:887
@ FL_CURSOR_DEFAULT
the default cursor, usually an arrow.
Definition Enumerations.H:880
@ FL_DND_LEAVE
The mouse has moved out of the widget.
Definition Enumerations.H:297
@ FL_RELEASE
A mouse button has been released.
Definition Enumerations.H:130
@ FL_DND_RELEASE
The user has released the mouse button dropping data into the widget.
Definition Enumerations.H:303
@ FL_DND_DRAG
The mouse has been moved inside a widget while dragging data.
Definition Enumerations.H:293
@ FL_DND_ENTER
The mouse has been moved to point at this widget.
Definition Enumerations.H:287
This widget produces an actual window.
Definition Fl_Window.H:58
void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE)
Changes the cursor for this window.
Definition fl_cursor.cxx:283
static int wait()
Waits until "something happens" and then returns.
Definition Fl.cxx:605
static void paste(Fl_Widget &receiver, int source)
Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver.
static int dnd()
Initiate a Drag And Drop operation.
Definition fl_dnd_win32.cxx:526
static int handle(int, Fl_Window *)
Handle events from the window system.
Definition Fl.cxx:1120
static Fl_Widget * pushed()
Gets the widget that is being pushed.
Definition Fl.H:706
static Fl_Widget * belowmouse()
Gets the widget that is below the mouse.
Definition Fl.H:702
static Fl_Window * first_window()
Returns the first top-level window in the list of shown() windows.
Definition Fl.cxx:697