Bug 463460 - gtk_clipboard_set_with_owner() does not work on kwin wayland
Summary: gtk_clipboard_set_with_owner() does not work on kwin wayland
Status: RESOLVED WAITINGFORINFO
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.26.4
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-25 18:02 UTC by Giovanni
Modified: 2022-12-26 11:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
GTK+ 3 example program to reproduce the bug. (3.26 KB, text/x-csrc)
2022-12-25 18:02 UTC, Giovanni
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni 2022-12-25 18:02:25 UTC
Created attachment 154820 [details]
GTK+ 3 example program to reproduce the bug.

Under kwin wayland, GTK+ 3 applications are unable to become clipboard owner via gtk_clipboard_set_with_owner() or provide data via callback.


STEPS TO REPRODUCE
Compile the attached cot.c file, instructions for compilations are at the beginning of the file.
Run "./cot" and then press the button on the main window. The application will try to become clipboard owner and provide a small string of text. But when you paste text in other windows, nothing is pasted, no clibpoard callbacks are called in cot.c.
See also this Remmina bug: https://gitlab.com/Remmina/Remmina/-/issues/2737
The example program shows that text is pasted with no problems under KDE+Xorg, GnomeShell+Wayland, GnomeShell+Xorg. But under KDE+Wayland text is not pasted to the destination application window.

OBSERVED RESULT
Nothing is pasted when the users try to paste. Callbacks of gtk_clipboard_set_with_owner() are not called.

EXPECTED RESULT
Application should become clipboard owner and provide clipboard content when the user pastes to another window.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KUbuntu 22.10 + backports PPA to have latest plasma (5.26.4)
Comment 1 David Edmundson 2022-12-26 10:27:10 UTC
"UTF8_STRING" is not a valid mimetype.

I can see kwin copy that, but no client will think it has readable clipboard contents. 
If I change your example to "text/plain" or "text/plain;charset=utf-8" it works as expected. 

The way mimetype's name themselves is a bit random. We do have a translation of text mime names for x11 applications in kwin, as well as some translations inside the Qt wayland backend to make apps use the right standard.

Presumably mutter has a translation layer for wayland apps too, which helps hide this? 
But ultimately this is still a client bug and should be fixed at the root.

Can you confirm that this resolves the real problem in Remina?
Comment 2 David Edmundson 2022-12-26 10:28:36 UTC
FYI: if you open krunner (alt+space) and type "kwin" you can get a kwin debug console. 
There is a tab called "Clipboard in there" which can view contents.
Comment 3 Giovanni 2022-12-26 11:54:01 UTC
Thank you, changing UTF8_STRING to text/plain;charset=utf-8 worked.
You saved me ! ;)

But I need to do more regression testing to ensure  text/plain;charset=utf8 works also on older (max 4-6 years) Xorg. If it does not work, the application (Remmina) should expose two different formats to the clipboard, I think.