[Feature Request] Clipboard: set "text/plain;charset=utf-8" on the xwayland side if exposed by the source
Created by: zickgraf
Original Issue:
I have the following issue: When copying from a GTK application running in wayland and pasting into a GTK application running in xwayland, suddenly all line endings are of the type \r\n
instead of the original \n
. As a real-life example one can copy from gedit running in wayland to gvim (via the register unnamedplus) running in xwayland.
I have done a bit of research and have found the following:
When copying text from a GTK TextView to the clipboard, there are multiple targets available, among them UTF8_STRING
and text/plain;charset=utf-8
. Both contain the string stored as UTF-8 but there is a slight difference: UTF8_STRING
stores linebreaks as \n
whereas text/plain;charset=utf-8
stores linebreaks as \r\n
. This normalization to CRLF happens in https://gitlab.gnome.org/GNOME/gtk/blob/b64a4031006e29a9e54bccf85ff4a82251507307/gtk/gtkselection.c#L555. When pasting from text/plain;charset=utf-8
, the result is normalized back to \n
again: https://gitlab.gnome.org/GNOME/gtk/blob/b64a4031006e29a9e54bccf85ff4a82251507307/gtk/gtkselection.c#L629. The problem is that wlroots seems to sync text/plain;charset=utf-8
on the wayland side to UTF8_STRING
on the xwayland side, so when pasting on the xwayland side the renormalization to \n
does not happen.
Is there a reason why text/plain;charset=utf-8
is synced to UTF8_STRING
instead of simply text/plain;charset=utf-8
again?