mirror of
https://github.com/fltk/fltk.git
synced 2026-05-29 20:45:33 +08:00
X11: update XDND protocol from version 4 to 5 (#988)
Some applications insist on sending XDND protocol version 5 and rejected (ignored) FLTK as DND receiver because we allowed only protocol version 4. Known apps: Google Chrome and Chromium. This commit enables XDND protocol version 5 in FLTK programs as DND receiver.
This commit is contained in:
+14
-9
@@ -580,7 +580,6 @@ void open_display_i(Display* d) {
|
|||||||
fl_XdndStatus = XInternAtom(d, "XdndStatus", 0);
|
fl_XdndStatus = XInternAtom(d, "XdndStatus", 0);
|
||||||
fl_XdndActionCopy = XInternAtom(d, "XdndActionCopy", 0);
|
fl_XdndActionCopy = XInternAtom(d, "XdndActionCopy", 0);
|
||||||
fl_XdndFinished = XInternAtom(d, "XdndFinished", 0);
|
fl_XdndFinished = XInternAtom(d, "XdndFinished", 0);
|
||||||
fl_XdndEnter = XInternAtom(d, "XdndEnter", 0);
|
|
||||||
fl_XdndURIList = XInternAtom(d, "text/uri-list", 0);
|
fl_XdndURIList = XInternAtom(d, "text/uri-list", 0);
|
||||||
fl_Xatextplainutf = XInternAtom(d, "text/plain;charset=UTF-8",0);
|
fl_Xatextplainutf = XInternAtom(d, "text/plain;charset=UTF-8",0);
|
||||||
fl_Xatextplainutf2 = XInternAtom(d, "text/plain;charset=utf-8",0); // Firefox/Thunderbird needs this - See STR#2930
|
fl_Xatextplainutf2 = XInternAtom(d, "text/plain;charset=utf-8",0); // Firefox/Thunderbird needs this - See STR#2930
|
||||||
@@ -1471,13 +1470,19 @@ int fl_handle(const XEvent& thisevent)
|
|||||||
}
|
}
|
||||||
Fl::e_number = old_event;
|
Fl::e_number = old_event;
|
||||||
// Detect if this paste is due to Xdnd by the property name (I use
|
// Detect if this paste is due to Xdnd by the property name (I use
|
||||||
// XA_SECONDARY for that) and send an XdndFinished message. It is not
|
// XA_SECONDARY for that) and send an XdndFinished message.
|
||||||
// clear if this has to be delayed until now or if it can be done
|
// This has to be delayed until now rather than sending it immediately
|
||||||
// immediately after calling XConvertSelection.
|
// after calling XConvertSelection because we need to send the success
|
||||||
if (fl_xevent->xselection.property == XA_SECONDARY &&
|
// status (retval) and the performed action to the sender - at least
|
||||||
fl_dnd_source_window) {
|
// since XDND protocol version 5 (see docs).
|
||||||
fl_sendClientMessage(fl_dnd_source_window, fl_XdndFinished,
|
// [FIXME: is the condition below really correct?]
|
||||||
fl_xevent->xselection.requestor);
|
|
||||||
|
if (fl_xevent->xselection.property == XA_SECONDARY && fl_dnd_source_window) {
|
||||||
|
fl_sendClientMessage(fl_dnd_source_window, // send to window
|
||||||
|
fl_XdndFinished, // XdndFinished message
|
||||||
|
fl_xevent->xselection.requestor, // data.l[0] target window
|
||||||
|
retval ? 1 : 0, // data.l[1] Bit 0: 1 = success
|
||||||
|
retval ? fl_dnd_action : None); // data.l[2] action performed
|
||||||
fl_dnd_source_window = 0; // don't send a second time
|
fl_dnd_source_window = 0; // don't send a second time
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2686,7 +2691,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make it receptive to DnD:
|
// Make it receptive to DnD:
|
||||||
long version = 4;
|
Atom version = 5; // max. XDND protocol version we understand
|
||||||
XChangeProperty(fl_display, xp->xid, fl_XdndAware,
|
XChangeProperty(fl_display, xp->xid, fl_XdndAware,
|
||||||
XA_ATOM, sizeof(int)*8, 0, (unsigned char*)&version, 1);
|
XA_ATOM, sizeof(int)*8, 0, (unsigned char*)&version, 1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user