Bug 424855 - Firefox (wayland) and klipper aren't interacting correctly
Summary: Firefox (wayland) and klipper aren't interacting correctly
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-wayland-nested (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-31 10:32 UTC by David Edmundson
Modified: 2023-01-20 13:08 UTC (History)
4 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 David Edmundson 2020-07-31 10:32:20 UTC
firefox on copy:
-> send_selection(nullptr);
-> send_selection(some_offer);


klipper:
selection(nil)

->create offer with the old text
->send_selection(new  offer)

then we have two things  hitting the compositor at once:
 - firefox with the new contents
 - kipper re-posting the old contents
 

Our compositor is naive and just does last content received is the best which is now a race, but more often that not is klipper re-pasting the old contents that gets received last and "wins". The rest are cancelled. 

I don't know what a good fix for this is.
Comment 1 Nate Graham 2020-08-01 19:42:12 UTC
Can confirm.
Comment 2 Méven Car 2020-08-03 14:54:16 UTC
Seems to have duplicate:
https://bugs.kde.org/show_bug.cgi?id=424731
Comment 3 David Edmundson 2020-08-03 15:20:29 UTC
Following this up further.

Firefox isn't quite sending

-> send_selection(nullptr);
-> send_selection(some_offer);

It's actually sending

wl_data_offer@oldOffer.destroy()
before creating the new offer for the new clipboard

It's kwayland-server that's tracking the old offer resource being destroyed and sending that the selection has changed to nil.
Comment 4 David Edmundson 2020-08-03 16:24:20 UTC
Brainstorming I have solutions, but none which are great.

1) Introduce a whole new fencing protocol, kwin will only accept data from wlr_data_control if the fence is up-to-date showing it has the latest clipboard

2) Introduce some only-replace-empty flag on the set_selection from klipper. SeatInterface will then only apply it if the current clipboard (as it sees it) is empty.

Potentially we could abuse a mime type to signify this without protocol changes, which shouldn't take too long to roll out.


For now I'll make a unit test for this case in kwayland so we have a starting point and can think of other ideas.
Comment 5 Andrey 2020-08-03 16:28:52 UTC
I wonder if this related or not:
"Can't copy/paste from any app to Plasma panel's fields"
https://bugs.kde.org/show_bug.cgi?id=424519
Comment 6 m.orly97 2023-01-20 10:56:33 UTC
I'm still affected by this issue: if I open Firefox and copy something, it is saved into Klipper, but if I try to copy again Klipper's history is not updated correctly.

Firefox version: 109.0
Plasma version: 5.26.5
Kernel version: 6.1.7-arch1-1
Comment 7 Vlad Zahorodnii 2023-01-20 12:24:22 UTC
This sounds like bug 464509
Comment 8 m.orly97 2023-01-20 13:08:38 UTC
(In reply to Vlad Zahorodnii from comment #7)
> This sounds like bug 464509

You're right, thanks!