From e827e6fa21d6f435cde32b758bce69693e823f63 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 18 Mar 2020 22:37:23 +0530 Subject: [PATCH] X11: Allow drag and drop of text/plain in addition to text/uri-list Fixes #2441 --- docs/changelog.rst | 3 +++ glfw/x11_init.c | 2 ++ glfw/x11_platform.h | 2 ++ glfw/x11_window.c | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5abfae47e..2d1ebdc80 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -77,6 +77,9 @@ To update |kitty|, :doc:`follow the instructions `. - Workaround for bug in less that causes colors to reset at wrapped lines (:iss:`2381`) +- X11: Allow drag and drop of text/plain in addition to text/uri-list + (:iss:`2441`) + - Dont strip :code:`&` and :code:`-` from the end of URLs (:iss:`2436`) - Fix ``@selection`` placeholder not working with launch command (:iss:`2417`) diff --git a/glfw/x11_init.c b/glfw/x11_init.c index dc18fd5aa..f83eda9a1 100644 --- a/glfw/x11_init.c +++ b/glfw/x11_init.c @@ -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 diff --git a/glfw/x11_platform.h b/glfw/x11_platform.h index 806e125e5..b39eea612 100644 --- a/glfw/x11_platform.h +++ b/glfw/x11_platform.h @@ -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; diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 0a007d841..2999e45a6 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -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; } }