From 58497161c05ec73b0756433169897c166a35b5a0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 30 Dec 2022 22:20:43 +0530 Subject: [PATCH] X11: When pasting text/plain try UTF8_STRING first then text/plain/charset=utf-8 Fixes #5842 Also fixes pasting from GTK+2 applications like leafpad. --- glfw/x11_window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 451636d2a..cf304afab 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -2946,11 +2946,12 @@ _glfwPlatformGetClipboard(GLFWClipboardType clipboard_type, const char* mime_typ } size_t count = 0; if (strcmp(mime_type, "text/plain") == 0) { - // we need to do this because GTK/GNOME is developed by morons - // they convert text/plain to DOS line endings + // UTF8_STRING is what xclip uses by default, and there are people out there that expect to be able to paste from it with a single read operation. See https://github.com/kovidgoyal/kitty/issues/5842 + // Also ancient versions of GNOME use DOS line endings even for text/plain;charset=utf-8. See https://github.com/kovidgoyal/kitty/issues/5528#issuecomment-1325348218 + atoms[count++] = _glfw.x11.UTF8_STRING; + // we need to do this because GTK/GNOME is moronic they convert text/plain to DOS line endings, see // https://gitlab.gnome.org/GNOME/gtk/-/issues/2307 atoms[count++] = atom_for_mime("text/plain;charset=utf-8").atom; - atoms[count++] = _glfw.x11.UTF8_STRING; atoms[count++] = atom_for_mime("text/plain").atom; atoms[count++] = XA_STRING; } else {