elfmz / far2l

Linux port of FAR v2
GNU General Public License v2.0
1.78k stars 173 forks source link

Copy-Paste between far2l wx and Telegram Desktop not working under Wayland on Ubuntu 23.10 #2053

Closed unxed closed 7 months ago

unxed commented 7 months ago

Originally noticed here: https://github.com/elfmz/far2l/issues/1350#issuecomment-1236309956

Possibly related issue: https://github.com/elfmz/far2l/issues/1658#issuecomment-1546643541

Workaround 1: https://github.com/elfmz/far2l/issues/1350#issuecomment-1443347317

Workaround 2: Run

GDK_BACKEND=x11 far2l

(source: https://github.com/elfmz/far2l/issues/1350#issuecomment-1492587632)

Workaround 3: Use kitty or any other OSC52-supporting terminal (like Windows Terminal, for example) and TTY or TTY|X far2l backend. Don't forget to enable OSC52 in far2l in Options -> Interface settings.

Workaround 4: https://github.com/elfmz/far2l/issues/1658#issuecomment-1546638648

Steps to reproduce:

  1. Install Ubuntu 23.10
  2. Install far2l-gui from ppa
  3. Run far2l
  4. Download, unpack and run Telegram Desktop
  5. Copy any string from Telegram Desktop to clipboard
  6. Try to paste in far2l
unxed commented 7 months ago

@elfmz can we use ttyx for clipboard access on Wayland systems if xwayland and ttyx are available until upstream bug is fixed?

unxed commented 7 months ago

Corresponding Telegram Desktop issue: https://bugs.telegram.org/c/37976 https://github.com/telegramdesktop/tdesktop/issues/27569

unxed commented 7 months ago

From wxWidgets bug tracker:

OK, this happens because we request STRING format but Telegram only provides data in text/plain;charset=utf-8 and text/plain formats (for comparison, most of the other programs, including e.g. Firefox from which I'm posting this or Vim where I'm actually typing this, include those as well as STRING, TEXT, COMPOUND_TEXT and UTF8_STRING).

Anyhow, the fix should be straightforward, we should accept data in text/plain format as text too. I'll try to find time to implement this.

From Telegram Desktop bug tracker:

I think this info would be more valuable to Qt. All tdesktop does is instantiates a QTextEdit and Qt provides the menu with the default actions, shortcut handling and etc.

unxed commented 7 months ago

Corresponding Qt issue: https://bugreports.qt.io/browse/QTBUG-123176

unxed commented 7 months ago

Exact reason:


~/far2l/far2l/_build/install$ wl-paste -l
text/plain;charset=utf-8
text/plain

~/far2l/far2l/_build/install$ xclip -o -t TARGETS
text/plain;charset=utf-8
text/plain
UTF8_STRING
STRING
TARGETS
TIMESTAMP

wx know nothing about text/plain;charset=utf-8 type. xWayland does some kind of conversion to UTF8_STRING that is ok for wx

unxed commented 7 months ago

Same bug with GNOME Text editor: https://gitlab.gnome.org/GNOME/gnome-text-editor/-/issues/657

btw, @elfmz can we work it around by providing support for text/plain;charset=utf-8 format on our side?

unxed commented 7 months ago

Same bug with qBittorrent: https://github.com/qbittorrent/qBittorrent/issues/20547

unxed commented 7 months ago

Same bug with KDE default text editor: https://bugs.kde.org/show_bug.cgi?id=483459

unxed commented 7 months ago

Fix for wx: https://github.com/wxWidgets/wxWidgets/pull/24400

unxed commented 7 months ago

Workaround on our side: https://github.com/elfmz/far2l/pull/2070

atolismesh commented 7 months ago

Проверил под native Ubuntu 23.10 + Wayland.

export WXTRACE="clipboard"
FAR2L_STD=~/far2l.log ./far2l --notty 

Копирование из телеграмма в fa2l gui заработало:

OpenClipboard
13:43:48: Trace: (clipboard) Checking if format UTF8_STRING is available
13:43:48: Trace: (clipboard) Received available formats for clipboard CLIPBOARD
13:43:48: Trace: (clipboard)   text/plain
13:43:48: Trace: (clipboard)   text/plain;charset=utf-8
13:43:48: Trace: (clipboard) Checking if format STRING is available
13:43:48: Trace: (clipboard) Received available formats for clipboard CLIPBOARD
13:43:48: Trace: (clipboard)   text/plain
13:43:48: Trace: (clipboard)   text/plain;charset=utf-8
13:43:48: Trace: (clipboard) GetData(): format not found
13:43:48: Trace: (clipboard) Checking if format text/plain;charset=utf-8 is available
13:43:48: Trace: (clipboard) Received available formats for clipboard CLIPBOARD
13:43:48: Trace: (clipboard)   text/plain
13:43:48: Trace: (clipboard)   text/plain;charset=utf-8
13:43:48: Trace: (clipboard) Requesting format text/plain;charset=utf-8
13:43:48: Trace: (clipboard) Received selection text/plain;charset=utf-8, len=304
OnClipboardGetData(13) - found MIME-compatible text format
CloseClipboard without data

Копирование из fa2l gui в телеграмм заработало:

13:45:05: Trace: (clipboard) Adding support for text/plain;charset=utf-8
13:45:05: Trace: (clipboard) Adding support for STRING
13:45:05: Trace: (clipboard) Adding support for UTF8_STRING
wxTheClipboard->SetData - OK
13:45:05: Trace: (clipboard) Clipboard data requested
13:45:05: Trace: (clipboard) clipboard data in format text/plain;charset=utf-8, GtkSelectionData is target=text/plain;charset=utf-8 type=ATOM selection=CLIPBOARD timestamp=0
13:45:05: Trace: (clipboard) Valid clipboard data of size 73 found

OpenClipboard
13:45:08: Trace: (clipboard) Checking if format UTF8_STRING is available
13:45:08: Trace: (clipboard) Received available formats for clipboard CLIPBOARD
13:45:08: Trace: (clipboard)   TIMESTAMP
13:45:08: Trace: (clipboard)   TARGETS
13:45:08: Trace: (clipboard)   MULTIPLE
13:45:08: Trace: (clipboard)   TIMESTAMP
13:45:08: Trace: (clipboard)   text/plain;charset=utf-8
13:45:08: Trace: (clipboard)   STRING
13:45:08: Trace: (clipboard)   UTF8_STRING
13:45:08: Trace: (clipboard) Requesting format UTF8_STRING
13:45:08: Trace: (clipboard) Clipboard data requested
13:45:08: Trace: (clipboard) clipboard data in format UTF8_STRING, GtkSelectionData is target=UTF8_STRING type=NONE selection=CLIPBOARD timestamp=0
13:45:08: Trace: (clipboard) Valid clipboard data of size 73 found
13:45:08: Trace: (clipboard) Received selection UTF8_STRING, len=73
OnClipboardGetData(13) - found wx-compatible text format
13:45:08: Trace: (clipboard) Checking if format FAR_VerticalBlock_Unicode is available
13:45:08: Trace: (clipboard) Received available formats for clipboard CLIPBOARD
13:45:08: Trace: (clipboard)   TIMESTAMP
13:45:08: Trace: (clipboard)   TARGETS
13:45:08: Trace: (clipboard)   MULTIPLE
13:45:08: Trace: (clipboard)   TIMESTAMP
13:45:08: Trace: (clipboard)   text/plain;charset=utf-8
13:45:08: Trace: (clipboard)   STRING
13:45:08: Trace: (clipboard)   UTF8_STRING
CloseClipboard without data
unxed commented 7 months ago

На всякий случай уточню, что речь идёт о проверке фикса из #2070

unxed commented 7 months ago

Copying from far2l GUI to Telegram Desktop (as well as to any other app) still not work under Wayland on wslg, though, even after 1e7b2a74fc6ae3a36bf9249d1cef560cb0a91369. Maybe wslg bug?

See https://github.com/elfmz/far2l/issues/1658

unxed commented 7 months ago

В чате пишут: https://t.me/far2l_ru/17086

Бага с вставкой именно в телегу (у меня x11 desktop) из любого текста последнего мастера far2l (хоть имени файла по Ctrl-Ins, хоть фрагмента из редактора) вставленное завершается непонятным концевым символом: FarEng.hlf.m4 (который не виден при просмотре, но есть при редактировании в телеге)

Проверил со старой февральской версией far2l (до последних фиксов) - вставляет без этого символа FarEng.hlf.m4

Возможно из-за including ending NUL char в https://github.com/elfmz/far2l/commit/ca3ccdcac00f5c6d6228596ec9aa5f255a9cc8ec

Проверьте, у кого есть время, проявляется ли у вас.

unxed commented 7 months ago

Также из чата про этот лишний символ:

В far2m это прослеживается, начиная от коммита 17 марта. Соответственно в far2l это произошло очень незадолго до этого.

unxed commented 3 months ago

@atolismesh просьбочка перепроверить ещё раз, не сломалось ли чего.

unxed commented 3 months ago

После недавних исправлений проблемы с буфером обмена под Wayland должны были уйти. У кого они оставались, перепроверьте, пожалуйста.

After recent fixes, problems with the clipboard under Wayland should have gone away. Whoever had them, please check now.

unxed commented 2 months ago

Там ещё в wsl[g] обнаружились проблемы с кодировками при работе с буфером обмена. Поправили. У кого такое было, перепроверьте, пожалуйста, на свежем мастере.

In wsl[g] were discovered problems with encodings when working with the clipboard. They are now fixed. If anyone has had such problems, please check again in recent master.