23extern Atom fl_XdndAware;
24extern Atom fl_XdndSelection;
25extern Atom fl_XdndEnter;
26extern Atom fl_XdndTypeList;
27extern Atom fl_XdndPosition;
28extern Atom fl_XdndLeave;
29extern Atom fl_XdndDrop;
30extern Atom fl_XdndStatus;
31extern Atom fl_XdndActionCopy;
32extern Atom fl_XdndFinished;
33extern Atom fl_XdndURIList;
34extern Atom fl_XaUtf8String;
36extern char fl_i_own_selection[2];
37extern char *fl_selection_buffer[2];
39extern void fl_sendClientMessage(Window window, Atom message,
48static int dnd_aware(Window& window) {
49 Atom actual;
int format;
unsigned long count, remaining;
50 unsigned char *data = 0;
51 XGetWindowProperty(fl_display, window, fl_XdndAware,
54 &count, &remaining, &data);
56 if (actual == XA_ATOM && format==32 && count && data)
57 ret = int(*(Atom*)data);
58 if (data) { XFree(data); data = 0; }
62static int grabfunc(
int event) {
67extern int (*fl_local_grab)(int);
70static int local_handle(
int event,
Fl_Window* window) {
72 Fl::e_x = Fl::e_x_root-window->
x();
73 Fl::e_y = Fl::e_y_root-window->
y();
75 fl_local_grab = grabfunc;
83 fl_local_grab = grabfunc;
84 Window target_window = 0;
86 int dndversion = 4;
int dest_x, dest_y;
87 XSetSelectionOwner(fl_display, fl_XdndSelection, fl_message_window, fl_event_time);
91 Window new_window = 0;
int new_version = 0;
93 for (Window child = RootWindow(fl_display, fl_screen);;) {
94 Window root;
unsigned int junk3;
95 XQueryPointer(fl_display, child, &root, &child,
96 &e_x_root, &e_y_root, &dest_x, &dest_y, &junk3);
98 if (!new_window && (new_version = dnd_aware(root))) new_window = root;
102 if ((new_local_window = fl_find(child)))
break;
103 if ((new_version = dnd_aware(new_window)))
break;
106 if (new_window != target_window) {
109 }
else if (dndversion) {
110 fl_sendClientMessage(target_window, fl_XdndLeave, source_window);
112 dndversion = new_version;
113 target_window = new_window;
114 local_window = new_local_window;
117 }
else if (dndversion) {
125 if ((!strncmp(fl_selection_buffer[0],
"file:///", 8) ||
126 !strncmp(fl_selection_buffer[0],
"ftp://", 6) ||
127 !strncmp(fl_selection_buffer[0],
"http://", 7) ||
128 !strncmp(fl_selection_buffer[0],
"https://", 8) ||
129 !strncmp(fl_selection_buffer[0],
"ipp://", 6) ||
130 !strncmp(fl_selection_buffer[0],
"ldap:", 5) ||
131 !strncmp(fl_selection_buffer[0],
"mailto:", 7) ||
132 !strncmp(fl_selection_buffer[0],
"news:", 5) ||
133 !strncmp(fl_selection_buffer[0],
"smb://", 6)) &&
134 !strchr(fl_selection_buffer[0],
' ') &&
135 strstr(fl_selection_buffer[0],
"\r\n")) {
137 fl_sendClientMessage(target_window, fl_XdndEnter, source_window, dndversion<<24,
138 fl_XdndURIList, fl_XaUtf8String, XA_STRING);
141 fl_sendClientMessage(target_window, fl_XdndEnter, source_window, dndversion<<24,
142 fl_XaUtf8String, XA_STRING, 0);
148 }
else if (dndversion) {
149 fl_sendClientMessage(target_window, fl_XdndPosition, source_window,
150 0, (e_x_root<<16)|e_y_root, fl_event_time,
157 fl_i_own_selection[0] = 1;
159 }
else if (dndversion) {
160 fl_sendClientMessage(target_window, fl_XdndDrop, source_window,
162 }
else if (target_window) {
165 msg.type = ButtonPress;
166 msg.window = target_window;
167 msg.root = RootWindow(fl_display, fl_screen);
169 msg.time = fl_event_time+1;
172 msg.x_root = Fl::e_x_root;
173 msg.y_root = Fl::e_y_root;
175 msg.button = Button2;
176 XSendEvent(fl_display, target_window, False, 0L, (XEvent*)&msg);
179 msg.type = ButtonRelease;
180 XSendEvent(fl_display, target_window, False, 0L, (XEvent*)&msg);
@ FL_CURSOR_MOVE
4-pointed arrow or hand.
Definition Enumerations.H:1054
@ FL_CURSOR_DEFAULT
the default cursor, usually an arrow.
Definition Enumerations.H:1047
@ FL_DND_LEAVE
The mouse has moved out of the widget.
Definition Enumerations.H:409
@ FL_RELEASE
A mouse button has been released.
Definition Enumerations.H:242
@ FL_DND_RELEASE
The user has released the mouse button dropping data into the widget.
Definition Enumerations.H:415
@ FL_DND_DRAG
The mouse has been moved inside a widget while dragging data.
Definition Enumerations.H:405
@ FL_DND_ENTER
The mouse has been moved to point at this widget.
Definition Enumerations.H:399
This widget produces an actual window.
Definition Fl_Window.H:57
void cursor(Fl_Cursor)
Changes the cursor for this window.
Definition fl_cursor.cxx:111
static int wait()
Waits until "something happens" and then returns.
Definition Fl.cxx:670
static void paste(Fl_Widget &receiver, int source, const char *type=Fl::clipboard_plain_text)
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:535
static int handle(int, Fl_Window *)
Handle events from the window system.
Definition Fl.cxx:1295
static Fl_Widget * pushed()
Gets the widget that is being pushed.
Definition Fl.H:844
static Fl_Widget * belowmouse()
Gets the widget that is below the mouse.
Definition Fl.H:840
static Fl_Window * first_window()
Returns the first top-level window in the list of shown() windows.
Definition Fl.cxx:755