Bug 506325

Summary: Text selection and primary clipboard malfunction on non-Qt applications
Product: [Plasma] plasmashell Reporter: witchhunter <witchhunterpro>
Component: Clipboard widget & pop-upAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: bugs_kde_org.5.kuru, fandrew, kdedev, nate, qydwhotmail, tomashnyk
Priority: NOR    
Version First Reported In: 6.4.0   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=502564
Latest Commit: Version Fixed/Implemented In: 6.5.0
Sentry Crash Report:
Attachments: Video of the bug
text_on_some_windows_cannot_be_selected

Description witchhunter 2025-06-28 20:51:28 UTC
SUMMARY

This bug occurs when user is trying to paste primary clipboard from non-Qt app to Qt one. 

Lets say there are two apps opened: KWrite and Meld. The user is working in KWrite, while Meld is located on the side. The user is then trying to select text from Meld and paste it in KWrite with middle click or shortcut (CTRL+SHIFT+INS default). It will work on the first occasion, but on the second occasion apps like Meld and Cherrytree will reject selection. Simply, if user starts to drag pointer for purpose of selecting text, no selection will occur. It will be skipped/rejected by the app. If user then try to paste in KWrite, secondary clipboard will be pasted. 

On the other side, if instead of Meld user is trying to use LibreOffice Writer, on second occasion selecting text will be accepted by Writer, but when trying to paste the primary clipboard to KWrite, secondary clipboard will be pasted instead. It appears that every second paste malfunction.

These bugs do not occur when user double-click to select a word. 
Furthermore, everything works fine if user, while working on KWrite, first click on Meld/Writer, thus make it active, and then starts to drag a cursor to select text.

STEPS TO REPRODUCE with Meld
1. Ensure the secondary clipboard contains some text
2. Open KWrite and Meld side by side
3. From KWrite directly click on Meld and drag cursor to select text
4. Paste primary clipboard to KWrite
5. Repeat 3. and 4.

OBSERVED RESULT
There will be no text selected within Meld on second occasion, but only secondary clipboard can be pasted in KWrite.

EXPECTED RESULT
There should be text selected within Meld on second occasion, but primary clipboard should be pasted in KWrite.

STEPS TO REPRODUCE with LibreOffice Writer
1. Ensure the secondary clipboard contains some text
2. Open KWrite and LibreOffice Writer side by side
3. From KWrite directly click on LibreOffice Writer and drag cursor to select text
4. Paste primary clipboard to KWrite
5. Repeat 3. and 4.

OBSERVED RESULT
Text will be text selected within LibreOffice Writer, but secondary clipboard will be pasted in KWrite.

EXPECTED RESULT
Text will be text selected within LibreOffice Writer, but primary clipboard should be pasted in KWrite.


SOFTWARE/OS VERSIONS
Operating System: EndeavourOS 
KDE Plasma Version: 6.4.1
KDE Frameworks Version: 6.15.0
Qt Version: 6.9.1
Kernel Version: 6.15.4-arch2-1 (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
I'm not sure if 6.4.0 is the first version this occurs, maybe even earlier.
Comment 1 witchhunter 2025-06-28 21:34:57 UTC
ADDENDUM: I forgot to mention that everything works fine with Firefox.
Comment 2 witchhunter 2025-07-14 20:35:47 UTC
UPDATE: Moved this bug here since it can only be reproduced while clipboard widget is enabled.

1) When disabling the widget from systray, selecting 'disabled' and pressing *OK* instead Apply causes plasmashell to crash. Same as enabling it, but also causes to append empty line in clipboard history. (Maybe even after system restart)

2) It seems the KWin Debug Console alters the paste output (sometimes when launched several times), while text is pasted mostly with LO Writer. Usually, it shows (and is pasted) only the first character.
Comment 3 andrew 2025-07-18 21:25:47 UTC
(In reply to witchhunter from comment #2)
> UPDATE: Moved this bug here since it can only be reproduced while clipboard
> widget is enabled.
> 
> 1) When disabling the widget from systray, selecting 'disabled' and pressing
> *OK* instead Apply causes plasmashell to crash. Same as enabling it, but
> also causes to append empty line in clipboard history. (Maybe even after
> system restart)
> 
> 2) It seems the KWin Debug Console alters the paste output (sometimes when
> launched several times), while text is pasted mostly with LO Writer.
> Usually, it shows (and is pasted) only the first character.

this could be the right path, i have similar problems until i clean the clipboard history from that widget
Comment 4 witchhunter 2025-07-20 09:44:17 UTC
(In reply to andrew from comment #3)
> this could be the right path, i have similar problems until i clean the
> clipboard history from that widget

Not really a workaround, since the moment clipboard is not empty the problems reappear. And even when clipboard is empty, what is stated in UPDATE comment still stands.
Comment 5 tomashnyk 2025-09-18 12:28:43 UTC
Created attachment 185045 [details]
Video of the bug

I think I have a reliable way to reproduce this.  It is quite finicky, I spend and hour trying to make it precise. I took a video of it that is attached.

STEPS TO REPRODUCE with LibreOffice Writer
1. Open Kate and LibreOffice Writer side by side
2. Write "First [ENTER] Second [Enter] blah" into Writer and ensure the secondary clipboard contains some text ("Blah") by selecting it and pressing CTRL+C - focus stays in Writer
3. In LibreOffice Writer and DRAG (!) cursor to select text ("FIRST"): DO NOT make any unnecessary clicks, DO not double click to select, DO NOT use keyboard arrow and CTRL to select, it only works with selection by mouse dragging
4. Paste primary clipboard to Kate with middle click or CTRL+SHIFT+INS ("Blah" is pasted)
5. From Kate go back to LibreOffice Writer (without clicking it first) and drag cursor to select some other text text ("SECOND") 
6. Paste primary clipboard to Kate with CTRL+SHIFT+INS "SECOND" is pasted)
7. Go back to 3. and you can repeat as long as you want (just make sure you do not click on Writer and possibly Kate before selecting)

Can anybody please confirm? It seems almost like some kind of race condition (I think I once reproduced it when two Kate windows were side by side, but there it was extremely tricky to trigger and maybe I was just hallucinating after all the clicking).

It depends on two things
A) how do I select (double click or drag?)
B) windows must not be clicked unnecessarily.

I have "Focus Follows Mouse" set, but with "Click to Focus" it seems to also accur.
Comment 6 tomashnyk 2025-09-18 12:32:40 UTC
One last thing: I do not have set Klipper to keep PRIMARY selection history (because of this bug: https://bugs.kde.org/show_bug.cgi?id=498894 ). I can confirm this does not happen when I disable Klipper.
Comment 7 Fushan Wen 2025-10-04 23:31:11 UTC
Cannot reproduce in 6.5. Maybe it's already fixed?
Comment 8 witchhunter 2025-10-05 18:56:24 UTC
(In reply to Fushan Wen from comment #7)
> Cannot reproduce in 6.5. Maybe it's already fixed?

Still reproducible in Neon Unstable. Tried it with different mouses.
The only thing different is that LibreOffice Writer in Neon is XWayland app, so the bug will not occur. But for Meld and Cherrytree is still valid.
Comment 9 tomashnyk 2025-10-16 12:00:41 UTC
I just built Plasma master and there, I cannot reproduce it because Libreoffice will not take into clipboard anything just by selection without pressing CTRL+C. I cannot recreate with Meld.
Comment 10 BOF 2025-10-16 13:04:07 UTC
I have the same issue. Yet I have no idea if this is caused by non-Qt / Qt apps. I only noticed that some applications (eg. LibreOffice) cause a problem.

Maybe a related bug from the LibreOffice bugtracker: https://bugs.documentfoundation.org/show_bug.cgi?id=165164
Comment 11 BOF 2025-10-16 13:08:26 UTC
(In reply to BOF from comment #10)
> I have the same issue. Yet I have no idea if this is caused by non-Qt / Qt
> apps. I only noticed that some applications (eg. LibreOffice) cause a
> problem.
> 
> Maybe a related bug from the LibreOffice bugtracker:
> https://bugs.documentfoundation.org/show_bug.cgi?id=165164

Also see the video that is attached to the bug report for LibreOffice: https://bugs.documentfoundation.org/attachment.cgi?id=199109
Comment 12 BOF 2025-10-16 13:08:53 UTC
Setting the bug to CONFIRMED as I seem to have the same issue
Comment 13 witchhunter 2025-10-17 20:53:07 UTC
(In reply to BOF from comment #10)
> I have the same issue. Yet I have no idea if this is caused by non-Qt / Qt
> apps. I only noticed that some applications (eg. LibreOffice) cause a
> problem.
> 
> Maybe a related bug from the LibreOffice bugtracker:
> https://bugs.documentfoundation.org/show_bug.cgi?id=165164


While your observation is probably relevant, this bug report is not about secondary clipboard(Ctrl+C), but primary(middle mouse click), so more likely resembles before-mentioned bug 502564. Though I cannot reproduce it with 
Version: 25.8.2.2 (X86_64) / LibreOffice Community; UI render: default; VCL: kf6 (cairo+wayland)

Since this seems to bring some CONFUSION, I tested it with default settings on 
EndeavourOS bare metal
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.19.0
Qt Version: 6.10.0
Kernel Version: 6.17.2-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12700H
Graphics Processor 1: Mesa Intel® Iris® Xe Graphics
Graphics Processor 2: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2
and, 
KDENeon Unstable VM (with shared memory/clipboard disabled)

Weird that others couldn't fully reproduce it, so perhaps video attachment would help. Notice the red title-bar which represents the active window.
Comment 14 witchhunter 2025-10-17 20:57:38 UTC
Created attachment 185872 [details]
text_on_some_windows_cannot_be_selected