Bug 459389 - Copy and paste do not work in Wayland when using some text editors in konsole and some applications
Summary: Copy and paste do not work in Wayland when using some text editors in konsole...
Status: REOPENED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.27.2
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-19 12:27 UTC by Zesko
Modified: 2024-04-11 06:49 UTC (History)
12 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zesko 2022-09-19 12:27:34 UTC
SUMMARY

Copy and paste do not work from some text editors (e.g: "vim" or "micro") in Konsole to other some applications e.g: kate
But copy history can not be saved in System Tray Clipboard too when copying any text in "micro" or "vim" in Konsole.

STEPS TO REPRODUCE
1. Switch to Wayland
2. Open some text editors in konsole. e.g. "Vim" or "Micro"
3. Copy any text from "Vim" or "Micro" to some applications e.g. "Kate"

OBSERVED RESULT
Copy and paste do not work (because of  bad communication between Wayland, X11 and Xwayland ? )

EXPECTED RESULT
I checked Gnome Wayland that has no issue, but KDE Wayland has this issue.

SOFTWARE/OS VERSIONS
Operating System: Manjaro Linux
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.19.9-1-MANJARO (64-bit)
Graphics Platform: Wayland
Comment 1 Zesko 2022-09-19 12:31:44 UTC
Copy & paste (Shared Clipboard) does not work from KDE Wayland in my host to KDE Wayland in Virtualbox. 
It does not work from Virtualbox to my host too. But Gnome Wayland has no issue with shared clipboard.
Comment 2 Nate Graham 2022-09-22 18:53:33 UTC
How is X11/XWayland involved here? You didn't force Konsole to run under XWayland, did you? I ask because Konsole and Kate are fully Wayland native so the paste should be going:

wayland app <----> wayland compositor <----> wayland app

Which is much simpler and less error-prone than when XWayland is involved.
Comment 3 Zesko 2022-09-22 19:45:22 UTC
(In reply to Nate Graham from comment #2)
> How is X11/XWayland involved here? You didn't force Konsole to run under
> XWayland, did you? I ask because Konsole and Kate are fully Wayland native
> so the paste should be going:
> 
> wayland app <----> wayland compositor <----> wayland app
> 
> Which is much simpler and less error-prone than when XWayland is involved.

Thanks for the reply!

I did not force Konsole to run under XWayland. It run under native Wayland for sure without using "QT_QPA_PLATFORM=xcb".

I did not mean: Konsole (Wayland) <----> Wayland compositor <----> Kate (Wayland)
But I mean:  Run "micro" as text editor in Konsole (Wayland) <----> Wayland compositor <----> Kate (Wayland) , that does not work
Comment 4 A. R. Kristiansen 2022-09-25 10:34:49 UTC
In the Wayland session, I am experiencing that copying text and links in Firefox Wayland do NOT appear on my Klipper clipboard, however when running Firefox under xwayland, it works like normal and anything I copy appears on my clipboard.
Been experiencing this since before 5.25 released, but was unsure whether that was a Firefox bug or not and didn't get around to looking into it. Does that essentially confirm this bug? Leaving it at reported just in case I'm wrong..
Comment 5 A. R. Kristiansen 2022-09-26 09:12:08 UTC
Should add that whatever I copy in Firefox stays within Firefox, as if it has its own sandboxed clipboard.
Comment 6 Nate Graham 2022-09-26 16:58:53 UTC
It sounds like your clipboard isn't working at all... are there any apps across which it does work?
Comment 7 A. R. Kristiansen 2022-09-26 18:31:09 UTC
(In reply to Nate Graham from comment #6)
> are there any apps across which it does work?

Yes, seemingly everything, be it XWayland or Wayland native software. Just tested and it works in Konversation, Discord (XWayland), Konsole. Tutanota, Signal and Telegram also all work, those are running as Wayland apps.

Oh actually while writing this comment I just noticed, that it works in Firefox Wayland when copying page contents, it's the URL I can't copy, which is odd... Copying any text on this page shows up on my clipboard manager, copying the URL from the URL bar (in Firefox Wayland of course) just doesn't get sent to Klipper.
Comment 8 Vlad Zahorodnii 2022-09-26 21:09:46 UTC
If you uninstall both xclip and xsel and leave only wl-clipboard installed, does clipboard work in micro?
Comment 9 Zesko 2022-09-27 06:20:42 UTC
(In reply to Vlad Zahorodnii from comment #8)
> If you uninstall both xclip and xsel and leave only wl-clipboard installed,
> does clipboard work in micro?

wl-clipboard was already installed.
I have no xsel and uninstalled xclip today, then Micro can not be opened after reboot, but it only shows black and blank (No text) in Konsole.
Comment 10 Zesko 2022-09-27 06:26:20 UTC
> wl-clipboard was already installed.
> I have no xsel and uninstalled xclip today, then Micro can not be opened
> after reboot, but it only shows black and blank (No text) in Konsole.

Update:

Micro appears with text and works fine with wl-clipboard when Klipper (System Tray Clipboard) is not empty!

If Klipper (System Tray Clipboard) is EMPTY, then Micro can not be opened.
Comment 11 Zesko 2022-09-27 06:49:15 UTC
(In reply to Zesko from comment #1)
> Copy & paste (Shared Clipboard) does not work from KDE Wayland in my host to
> KDE Wayland in Virtualbox. 
> It does not work from Virtualbox to my host too. But Gnome Wayland has no
> issue with shared clipboard.

I noticed that some shared-clipboard works, some shared-clipboard does not work:

Shared-clipboard does not work if:
- Kate in KDE Wayland in VirtualBox -------> any applications in same KDE Wayland in Host.
- Any applications in KDE Wayland in VirtualBox <------- Kate in same KDE Wayland in Host.


Shared-clipboard works if:
- Copy any URL in Firefox in KDE Wayland in VirtualBox --------> any applications in KDE Wayland in Host, it appears in Klipper too.
- Any applications in KDE Wayland in VirtualBox <--------  Copy any URL in Firefox in KDE Wayland in Host.
Comment 12 Zamundaaa 2022-09-27 08:54:19 UTC
If you set the clipboard option of micro to "terminal", does it work properly then? It not working through X11 calls is expected as no X11 window is focused.

Afaik VirtualBox is still only using X11 in the guest for clipboard integration as well, so it's also expected that it won't work properly - it works with Firefox because that's still running through Xwayland by default, but it won't work with native Wayland apps.

Micro hanging while klipper is empty is most likely caused by wl-paste hanging until it can paste something. Other than possibly making Klipper always keep an empty clipboard entry around I don't think we can do anything against that, it's something wl-clipboard needs to handle
Comment 13 Iyán Méndez Veiga 2022-10-06 09:39:31 UTC
I appear to have this issue only with KeePassXC running as wayland native.

Relevant bug upstream: https://github.com/keepassxreboot/keepassxc/issues/8492#issuecomment-1265963567

There you can find one workaround that surprisingly works, and probably can give a hint on the origin of the issue. Copy anything from the app itself, and after doing that paste works again. Can anyone reproduce this behavior with other apps?
Comment 14 Bug Janitor Service 2023-03-02 17:22:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3735
Comment 15 Vlad Zahorodnii 2023-03-03 12:32:30 UTC
Git commit 46cad20ea861567d325a8f8fee74cd6e42278f61 by Vlad Zahorodnii, on behalf of David Edmundson.
Committed on 03/03/2023 at 11:25.
Pushed by vladz into branch 'master'.

wayland: Cancel selections if set without focus

Otherwise we confused clients in the following situation:
Client A sets selection, but due to timing has lost focus
User copies something in client B
Client later tries to paste in client A.
Client A still thinks it owns the selection so does nothing.

M  +10   -2    src/wayland/seat_interface.cpp

https://invent.kde.org/plasma/kwin/commit/46cad20ea861567d325a8f8fee74cd6e42278f61
Comment 16 Bug Janitor Service 2023-03-03 12:32:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3741
Comment 17 Vlad Zahorodnii 2023-03-03 17:52:11 UTC
Git commit 4bb1000377ca798544727a7fdae68b8cb4d3ff53 by Vlad Zahorodnii, on behalf of David Edmundson.
Committed on 03/03/2023 at 17:41.
Pushed by vladz into branch 'Plasma/5.27'.

wayland: Cancel selections if set without focus

Otherwise we confused clients in the following situation:
Client A sets selection, but due to timing has lost focus
User copies something in client B
Client later tries to paste in client A.
Client A still thinks it owns the selection so does nothing.


(cherry picked from commit 46cad20ea861567d325a8f8fee74cd6e42278f61)

M  +10   -2    src/wayland/seat_interface.cpp

https://invent.kde.org/plasma/kwin/commit/4bb1000377ca798544727a7fdae68b8cb4d3ff53
Comment 18 Zesko 2023-03-04 10:53:04 UTC
https://github.com/bugaevc/wl-clipboard/issues/149#issuecomment-1454687844

The issue would be related to Kwin Wayland, which does not work with wl-clipboard together.

But Gnome Wayland has no issue with that.
Comment 19 Bug Janitor Service 2023-08-10 08:50:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4313
Comment 20 David Edmundson 2023-08-11 06:57:02 UTC
Git commit 169257416e5a545349d0a39184d41c9531572b6b by David Edmundson.
Committed on 11/08/2023 at 08:47.
Pushed by davidedmundson into branch 'master'.

wayland: Send data device selections to data control on bind even if null

Specification for data control states:
"The first selection event is sent upon binding the
wlr_data_control_device object."

This differs to other data devices.

M  +2    -6    src/wayland/seat_interface.cpp

https://invent.kde.org/plasma/kwin/-/commit/169257416e5a545349d0a39184d41c9531572b6b
Comment 21 Bug Janitor Service 2023-08-11 07:22:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4318
Comment 22 Vlad Zahorodnii 2023-08-22 07:37:35 UTC
Git commit e8769ea8aaabe162213f9292ef51aa453f74d1f2 by Vlad Zahorodnii, on behalf of David Edmundson.
Committed on 22/08/2023 at 09:27.
Pushed by vladz into branch 'Plasma/5.27'.

wayland: Send data device selections to data control on bind even if null

Specification for data control states:
"The first selection event is sent upon binding the
wlr_data_control_device object."

This differs to other data devices.


(cherry picked from commit 169257416e5a545349d0a39184d41c9531572b6b)

M  +2    -6    src/wayland/seat_interface.cpp

https://invent.kde.org/plasma/kwin/-/commit/e8769ea8aaabe162213f9292ef51aa453f74d1f2
Comment 23 Leszek Lesner 2023-10-12 13:13:40 UTC
I think this is still an issue. I tried copying stuff from konsole to chromium or vivaldi. Both should run in wayland and its not always working. Sometimes I have to multiple times copy from konsole for it to even appear in klipper. Maybe it has something to do with tmux running on the terminal but I use the right click copy function or CTRL+Shift+C which should use Konsole's copy process.
Comment 24 Loren 2023-11-19 22:14:15 UTC
The bug is active for a few years now and never went away! this is the most annoying KDE bug that exists! should be priority number one as copy and paste is trivial for everyday use! I use KDE Neon with Wayland on 2 laptops and both are doing same thing.  Hope this will get fixed in 6.0.0!
Comment 25 Leszek Lesner 2024-03-07 12:02:37 UTC
I narrowed down the issue for me to XWayland clients (apps running in XWayland) suffering from this issue. Restarting XWayland helps there or copying something in a XWayland client to clipboard again to make it able to paste again. For now I fixed my browsers by starting them in Wayland mode (Vivaldi, Chromium & Firefox) and that fixes the issue for me. 

Maybe others can check if thats the case for them too.
Comment 26 Nate Graham 2024-03-08 21:47:16 UTC
Is that happening in 6.0 as well? Would you mind checking?
Comment 27 Zesko 2024-03-09 12:38:53 UTC
(In reply to Nate Graham from comment #26)
> Is that happening in 6.0 as well? Would you mind checking?

(In reply to Zesko from comment #3)
> But I mean:  Run "micro" as text editor in Konsole (Wayland) <----> Wayland compositor <----> Kate (Wayland) , that does not work

I checked Plasma 6.0.1 on two different devices. I confirmed this fixed the issue. Thank you!

However, there is another known issue:  
Copy text from Kate (Wayland) in Plasma 6.0 in VM (QEMU/KVM) <----->  Kate (Wayland) in Plasma 6.0 in my host. That does not work.
Comment 28 Lorenzo Bettini 2024-03-15 12:45:20 UTC
I confirm; but this has been marked as resolved?
Comment 29 Zesko 2024-03-15 14:48:42 UTC
(In reply to Lorenzo Bettini from comment #28)
> I confirm; but this has been marked as resolved?

How to reproduce your issue?

I have no problem copying any text from any text editor for example "micro" in Konsole (Wayland) <--------> Kate (Wayland)  on the same host except VM. 
This requires a dependency “wl-clipboard” for that.
Comment 30 Lorenzo Bettini 2024-03-15 18:30:18 UTC
(In reply to Zesko from comment #29)
> (In reply to Lorenzo Bettini from comment #28)
> > I confirm; but this has been marked as resolved?
> 
> How to reproduce your issue?
> 
> I have no problem copying any text from any text editor for example "micro"
> in Konsole (Wayland) <--------> Kate (Wayland)  on the same host except VM. 
> This requires a dependency “wl-clipboard” for that.

Sorry, I wasn't clear: I cannot copy and paste from host to VM and vice-versa, when the VM is KDE Wayland.
Comment 31 Yevhen Popok 2024-04-10 21:32:41 UTC
I have the same issue on Fedora 40 and QEMU/KVM-based virtual machines (started with Virt Manager or Gnome Boxes) .
(In reply to Lorenzo Bettini from comment #30)
> I cannot copy and paste from host to VM and
> vice-versa, when the VM is KDE Wayland.

Same here. I'm using Fedora 40 and QEMU/KVM-based virtual machines (Virt Manager / Virt Viewer / Gnome Boxes).
Can we please re-open this issue? Seems like it's not resolved.
Comment 32 Zesko 2024-04-11 06:49:40 UTC
(In reply to Lorenzo Bettini from comment #30)
> Sorry, I wasn't clear: I cannot copy and paste from host to VM and

(In reply to Yevhen Popok from comment #31)
> I have the same issue on Fedora 40 and QEMU/KVM-based virtual machines

There are two directional (bidirectional) clipboard share: 
You need to install "wl-clipboard" 

* Copy text from Kate (Wayland) on KDE host to Kate (Wayland) on KDE VM, that works!

* Copy text from Kate (Wayland) on KDE VM to Kate (Wayland) on KDE host, that does not work.

(In reply to Yevhen Popok from comment #31)
> Can we please re-open this issue? Seems like it's not resolved.

I re-open it.