X11: Allow drag and drop of text/plain in addition to text/uri-list

Fixes #2441
This commit is contained in:
Kovid Goyal
2020-03-18 22:37:23 +05:30
parent 342f0981d8
commit e827e6fa21
4 changed files with 11 additions and 0 deletions

2
glfw/x11_init.c vendored
View File

@@ -385,6 +385,8 @@ static bool initExtensions(void)
_glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
_glfw.x11.XdndTypeList = XInternAtom(_glfw.x11.display, "XdndTypeList", False);
_glfw.x11.text_uri_list = XInternAtom(_glfw.x11.display, "text/uri-list", False);
_glfw.x11.text_plain = XInternAtom(_glfw.x11.display, "text/plain", False);
_glfw.x11.text_plain_utf8 = XInternAtom(_glfw.x11.display, "text/plain;charset=utf-8", False);
// ICCCM, EWMH and Motif window property atoms
// These can be set safely even without WM support

2
glfw/x11_platform.h vendored
View File

@@ -267,6 +267,8 @@ typedef struct _GLFWlibraryX11
Atom XdndSelection;
Atom XdndTypeList;
Atom text_uri_list;
Atom text_plain;
Atom text_plain_utf8;
// Selection (clipboard) atoms
Atom TARGETS;

4
glfw/x11_window.c vendored
View File

@@ -1478,6 +1478,10 @@ static void processEvent(XEvent *event)
{
_glfw.x11.xdnd.format = _glfw.x11.text_uri_list;
break;
} else if (formats[i] == _glfw.x11.text_plain_utf8 && (_glfw.x11.xdnd.format == None || _glfw.x11.xdnd.format == _glfw.x11.text_plain)) {
_glfw.x11.xdnd.format = _glfw.x11.text_plain_utf8;
} else if (formats[i] == _glfw.x11.text_plain && _glfw.x11.xdnd.format == None) {
_glfw.x11.xdnd.format = _glfw.x11.text_plain;
}
}