Bug 373907

Summary: Implement Wayland Primary Selection Protocol (middle-click paste)
Product: [Frameworks and Libraries] kwayland Reporter: Kevin Kofler <kevin.kofler>
Component: serverAssignee: Martin Flöser <mgraesslin>
Status: RESOLVED FIXED    
Severity: wishlist CC: argonel, aspotashev, beckerbela+kdebug, bernie, blizzz, bugs, bugseforuns, bugtracker+kde, contact, creideiki+kdebugs, cruzki123, dennis.lissov, edoubrayrie, foss, germano.massullo, glenn.coombs, goeran, greg.martyn, guy.carmin, jansen, jappleii, jkt, jordanleppert, kai.kasurinen, kde, kdebugs, kilian, kleagg, lilydjwg, m.weghorn, maggu2810, marcan, matej, meven.car, meven29, mg05182-kde, nate, notuxius, nvsr384, ostroffjh, p3ybnyhv, rdieter, rocketraman, s, schultzern, silvio.frischi, smc+kdebugs, theivorytower, tlinux, yvan.broccard, zeekec, zicronsoft
Priority: NOR Keywords: wayland
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
URL: https://bugs.kde.org/show_bug.cgi?id=373907
Latest Commit: Version Fixed In: 5.20
Sentry Crash Report:

Description Kevin Kofler 2016-12-19 19:24:18 UTC
KWin 5.8.4 does not currently implement the Wayland Primary Selection Protocol:
https://lists.freedesktop.org/archives/wayland-devel/2016-February/027101.html

It needs to be implemented for middle-click paste to work on Wayland. At least one other compositor (GNOME's Mutter) already implements that protocol.
Comment 1 Martin Flöser 2016-12-19 20:57:41 UTC
This is not yet an upstream standard and not part of Wayland-protocols
Comment 2 Peter Schmidt 2017-04-24 00:23:43 UTC
I too desire this feature.  This doesn't appear to be completely broken, though.  I noticed any text I select (regardless of source) will middle-click-paste in Xwayland programs.  In other words, I can select text from a Wayland-native program and middle-click-paste in a Xwayland program, but not in another Wayland-native program.

At the very least, I would like it if there was an implementation not backward compatible with Xwayland.  Something is better than nothing.
Comment 3 Alexander Mentyu 2017-08-23 08:35:14 UTC
Primary selection copy/pasting isn't working neither between Wayland-to-Wayland apps nor between XWayland-to-Wayland apps for me in:

Distribution: KDE neon Developer Edition Unstable Branches
KDE Plasma Version: 5.10.90
KDE Frameworks Version: 5.37.0
Qt Version: 5.9.1
Kernel Version: 4.10.0-32-generic
Comment 4 Hector Martin 2017-08-27 17:44:27 UTC
I get the feeling that if KDE won't push forward on upstreaming this then nobody will. GNOME seems quite happy using it as a nonstandard protocol.
Comment 5 Edward Oubrayrie 2017-10-15 22:25:34 UTC
The protocol is available at https://git.gnome.org/browse/mutter/tree/src/wayland/protocol/gtk-primary-selection.xml

It seems that main kwin developper is against this feature: In https://blog.martin-graesslin.com/blog/2016/07/synchronizing-the-x11-and-wayland-clipboard/ comments he says:
"Doesn’t address the useability problems I see with the primary selection. Also does not even address the security issues [...] has it never happened to you that you copied from the wrong clipboard? You selected something and then pasted with ctrl+v? That’s part of the usability problem. Another problem is that it only works for text and you never know whether it worked or not. You will know once you paste. Not before."

So, for now I would not hold my breath, even though I agree with #4.
Comment 6 jansen 2018-01-17 11:11:59 UTC
Primary selection copy/paste is a feature that I heavily rely on. I would be delighted if it could be implemented.

I cannot understand the usability issues Martin Graesslin sees in the X11 behavior. I also do not see any discoverability issues - like with console keyboard shortcuts (CTRL-k, CTRL-w etc.) you either know about them or you do not. I do that think that this is a valid reason to not implement such functionality.

I tried KDE on Wayland only today (OpenSUSE Tumbleweed) and even though there were some seemingly more severe problems (like the whole GUI turning black and completely freezing when I tried to change my primary display in my 3-monitor-setup) the missing middle-click copy/paste was the final nail in the coffin that made me go back to KWin/X11.

I might be able to live without it - but I do not want to ;-)
And since for me everything works with KWin/X11 I will avoid Wayland for now.

Just my $0.02...
Comment 7 Shawn Rutledge 2018-01-26 08:21:24 UTC
I agree, it's too useful to give up this feature.

AFAIK nobody wrote a Qt bug about it until now:

https://bugreports.qt.io/browse/QTBUG-66008
Comment 8 argonel 2018-04-06 20:32:32 UTC
Someone's asked about the status on wayland-devel[1], which seems to be the first discussion of the protocol since the 2016 thread linked in comment 1.

Between this and the the 49.7 day bug in Qt on X11[2]  rendering the clipboard and primary unusable, there's no winning.

[1] https://lists.freedesktop.org/archives/wayland-devel/2018-April/037748.html
[2] https://bugreports.qt.io/browse/QTBUG-65145
Comment 9 John Apple II 2018-07-17 07:35:28 UTC
I agree with people - I love KDE, and Wayland seems really fast, but I use this feature constantly and I've been trying to use Wayland with multiple Konsole terminals up with multiple sessions - this is painful without the normal copy/paste features.  I'm going to have to move back to X11 tomorrow, sadly, because I cannot work well without it.
Comment 10 Martin Flöser 2018-07-17 14:45:24 UTC
(In reply to John Apple II from comment #9)
> I agree with people - I love KDE, and Wayland seems really fast, but I use
> this feature constantly and I've been trying to use Wayland with multiple
> Konsole terminals up with multiple sessions - this is painful without the
> normal copy/paste features.  I'm going to have to move back to X11 tomorrow,
> sadly, because I cannot work well without it.

Just run Konsole as an X11 window...
Comment 11 imraro 2018-07-17 14:49:18 UTC
...and all other applications. And keep wayland for plasmashell only.
Comment 12 Peter Schmidt 2018-07-17 15:35:05 UTC
That's not an acceptable answer.  That's no different than that classic problem of the iPhone user who was getting poor reception when holding his phone in a certain way and Apple told him "just don't hold it like that".

You're defeating the purpose of running Wayland when you run your Wayland-compatible programs in XWayland.  Not only is [plasmashell's] Wayland not stable enough to make that effort worth-while, but you're just adding unnecessary overhead.
Comment 13 imraro 2018-07-17 18:53:09 UTC
That was sarcasm.
Comment 14 Martin Flöser 2018-07-17 19:52:09 UTC
erm, I don't want to say anything. But running all apps on XWayland is part of our short term strategy, see: https://blog.martin-graesslin.com/blog/2018/03/unsetting-qt_qpa_platform-environment-variable-by-default/

If you want to use Wayland and at the same time don't miss some features of X11 I think that's a totally possible way. I'm using this combination for years.
Comment 15 Gaël de Chalendar (aka Kleag) 2018-08-07 23:59:27 UTC
Apart from a kmail crash at startup, this is the only thing that will keep me away from Wayland at this time.
This is probably the basic feature that makes my desktop so much more usable than other ones.
Comment 16 imraro 2018-12-21 08:19:19 UTC
Wayland Protocols 1.17 Brings Explicit Synchronization & Primary Selection: https://www.phoronix.com/scan.php?page=news_item&px=Wayland-Protocols-1.17-Released
Comment 17 Glenn Coombs 2019-01-04 11:04:38 UTC
I just tried out a Wayland session on KDE Neon for the first time today.  Everything seems to work well apart from using the middle mouse button to paste.

I don't want to discuss the merits of having 2 separate paste sources like X11 has (clipboard and primary selection) but it seems crazy to me that I can select a word in Konsole using the mouse but have to use the keyboard (Ctrl-Shift-V) to paste what I just selected.

Is there no option to have the middle mouse click perform the same action as pressing Ctrl-Shift-V ?  I don't really care if it only uses the one Wayland Clipboard source and ignores the X11 primary selection but not being able to middle button paste is a show stopper for me.
Comment 18 Kevin Kofler 2019-01-04 12:42:20 UTC
Uh, please don't do that (pasting from the regular clipboard with middle click). If you implement the middle-click paste, please implement it right (with a separate primary selection), anything else would be really confusing and annoying. The primary selection protocol has been adopted by Wayland upstream, all that is needed is implementing it.
Comment 19 Martin Flöser 2019-01-04 16:35:56 UTC
The protocol exists now. We will eventually add support for it, but it will take time. At doesn't support it yet, so there's no need to rush.
Comment 20 Martin Flöser 2019-01-04 16:36:14 UTC
(In reply to Martin Flöser from comment #19)
> The protocol exists now. We will eventually add support for it, but it will
> take time. At doesn't support it yet, so there's no need to rush.

Qt Not at
Comment 21 Patrick Silva 2019-05-10 13:26:08 UTC
Qt 5.14 alpha supports the protocol \o/
Comment 22 foss 2019-06-07 03:50:16 UTC
(In reply to Martin Flöser from comment #1)
> This is not yet an upstream standard and not part of Wayland-protocols

Now it seems to be: https://github.com/wayland-project/wayland-protocols/blob/master/unstable/primary-selection/primary-selection-unstable-v1.xml
Comment 23 foss 2019-06-07 03:56:52 UTC
(In reply to udevnull from comment #22)
> (In reply to Martin Flöser from comment #1)
> > This is not yet an upstream standard and not part of Wayland-protocols
> 
> Now it seems to be:
> https://github.com/wayland-project/wayland-protocols/blob/master/unstable/
> primary-selection/primary-selection-unstable-v1.xml

Related QTBUG: https://bugreports.qt.io/browse/QTBUG-66008
Comment 24 Christoph Feck 2019-06-25 16:54:20 UTC
Did anyone have a chance to test Qt 5.14 (dev) builds? The question is, if besides support in Qt something else needs to be added/changed in KDE code.
Comment 25 Martin Flöser 2019-06-25 18:32:34 UTC
(In reply to Christoph Feck from comment #24)
> Did anyone have a chance to test Qt 5.14 (dev) builds? The question is, if
> besides support in Qt something else needs to be added/changed in KDE code.

We need to implement the protocol in kwayland and add support in KWin.
Comment 26 Hector Martin 2019-11-11 03:00:53 UTC
Is anyone planning on looking at this now that Qt has support? It's basically the only thing stopping me from using Wayland...
Comment 27 Méven Car 2019-11-11 16:48:57 UTC
This is on our radar and indeed we can take advantage of Qt fixing https://bugreports.qt.io/browse/QTBUG-66008.
We have a benevolent developer that is willing to implement this, when he gets time to work on it but we still have to wait for Qt 5.14 to be released (end of November) and become Plasma dependency.
This won't be the case for Plasma 5.18 as it will be an LTS version based on Qt 5.12 LTS.
You can see our current progress on this at https://phabricator.kde.org/T11601
Comment 28 Gaël de Chalendar (aka Kleag) 2020-01-15 14:11:34 UTC
I subscribed to the Phabricator task. Again, I will not be able to switch from X11 without that feature.