SUMMARY I'm in the process of migrating to KDE Wayland, and one thing I heavily rely upon is primary selection. I use it as part of my work in order to be able to quickly select part of the text in logs and then execute a Emacs function that parses and finds various locations based on it. However, on KDE Wayland primary selection in Emacs has inconsistent content. Further research showed that it isn't specific in any way to Emacs, but rather that in general there's some miscommunication about primary selection between X11 and Wayland apps. Below it is shown by using `xlip` as the simplest X11 utility for accessing "selection". STEPS TO REPRODUCE 1. On KDE Wayland, open Konsole, and select any text 2. Execute `xclip -selection clipboard -o` OBSERVED RESULT It prints anything but the text you just selected EXPECTED RESULT It should print the text you selected SOFTWARE/OS VERSIONS Linux/KDE Plasma: 6.1.0 KDE Plasma Version: 6.1.0 KDE Frameworks Version: 6.3.0 Qt Version: 6.7.1
It's expected that xclip doesn't work, since KWin intentionally doesn't update the X11 clipboard unless a X11 window is focused. You can use wl-paste --primary as a Wayland native alternative that acts as a clipboard manager to get privileged access.
(In reply to Zamundaaa from comment #1) > It's expected that xclip doesn't work, since KWin intentionally doesn't > update the X11 clipboard unless a X11 window is focused. You can use > wl-paste --primary as a Wayland native alternative that acts as a clipboard > manager to get privileged access. Should I create a separate report for Emacs then? Emacs definitely has a focused window when I'm trying to make it access primary clipboard.
Is the focused window using X11 or Wayland? If it's Wayland native, it does need to be reported to emacs. If not, it should work
(In reply to Zamundaaa from comment #3) > Is the focused window using X11 or Wayland? If it's Wayland native, it does > need to be reported to emacs. If not, it should work Just to clarify: by saying "focused window" you are talking about Emacs window, right? So, my non-minimal actual problem (that involves a focused X11 window, i.e. Emacs) is: select text in Wayland Konsole, and then focus Emacs and make it fetch the primary selection. That doesn't work. So I should create a separate report for that, right?
I meant the Emacs window, yes. FWIW I just tested this and it spits out the clipboard content... which is afaict expected, as you tell it to use the clipboard? "xclip -o" prints the selection. It does however only work if the selection is from a X11 window, it prints > xclip: Error: There is no owner for the PRIMARY selection when it's from a Wayland window. This might just be xclip being weird (as middle click paste works fine in Discord) but it might be a bug in KWin too
(In reply to Zamundaaa from comment #5) > I meant the Emacs window, yes. > > FWIW I just tested this and it spits out the clipboard content... which is > afaict expected, as you tell it to use the clipboard? > "xclip -o" prints the selection. > It does however only work if the selection is from a X11 window, it prints > > xclip: Error: There is no owner for the PRIMARY selection > when it's from a Wayland window. This might just be xclip being weird (as > middle click paste works fine in Discord) but it might be a bug in KWin too I'm sorry for confusion. Okay, so, should I maybe create a separate report (and have this one closed) that's using X11 Emacs specifically to fetch primary selection? I mean, from the discussion above it seems like an actual application with a window apparently might suit better. Btw, I just found one peculiar thing with Emacs: `middle-click` paste into Emacs works no problem. What does not, however, is accessing primary selection programmatically by evaluating `(gui-get-selection 'PRIMARY)`.
I'd appreciate any code pointers I might have a look at it in my spare time
Can you confirm if emacs is a wayland window or not. An easy test is to run xprop and hover over the emacs window. If it changes to a + icon, it's in xwayland.
Emacs is an X11 window. There's an experimental Wayland support aka "pure GTK3", but AFAIK it has problems on X11 (which is why it was never made default), so I'd prefer to stick to X11 build because I might have to switch between Wayland and X11.
FTR, I just tested same way on Gnome Wayland and X11 Emacs does see selection from Wayland Konsole, so it is something on the kwin's side.
Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone!
This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging Thank you for helping us make KDE software even better for everyone!
Oh, somehow I missed the previous notification. Yeah, all information has been provided, it's just that the status wasn't changed. So per notification, changing to REPORTED