diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-07-25 08:09:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-25 08:09:56 +0200 |
commit | 233baf9208766dae80e2b03207993e4f612739b4 (patch) | |
tree | 97ffdc2e22701d644fbdad08afe89f362a7412bf | |
parent | 91bb4952e4f01d8a8fa729c2db2fb6beb5bce0ec (diff) | |
parent | 2f5b7f8777e06aa24cda3c33b5c4f1e1d2ba3b9f (diff) |
Merge pull request #9827 from sowfelicity/master-clipboard
Workaround to allow pasting unicode characters from X selection.
-rw-r--r-- | platform/x11/os_x11.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 3143f30f77..5bfe31b8c2 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1858,7 +1858,7 @@ void OS_X11::set_clipboard(const String &p_text) { XSetSelectionOwner(x11_display, XInternAtom(x11_display, "CLIPBOARD", 0), x11_window, CurrentTime); }; -static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard) { +static String _get_clipboard_impl(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard, Atom target) { String ret; @@ -1875,7 +1875,7 @@ static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_di }; if (Sown != None) { - XConvertSelection(x11_display, p_source, XA_STRING, selection, + XConvertSelection(x11_display, p_source, target, selection, x11_window, CurrentTime); XFlush(x11_display); while (true) { @@ -1915,6 +1915,18 @@ static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_di return ret; } +static String _get_clipboard(Atom p_source, Window x11_window, ::Display *x11_display, String p_internal_clipboard) { + String ret; + Atom utf8_atom = XInternAtom(x11_display, "UTF8_STRING", True); + if (utf8_atom != None) { + ret = _get_clipboard_impl(p_source, x11_window, x11_display, p_internal_clipboard, utf8_atom); + } + if (ret == "") { + ret = _get_clipboard_impl(p_source, x11_window, x11_display, p_internal_clipboard, XA_STRING); + } + return ret; +} + String OS_X11::get_clipboard() const { String ret; |