Bug 519651 - Large screenshots (approx. more than 500KB) fail to paste from clipboard on Wayland
Summary: Large screenshots (approx. more than 500KB) fail to paste from clipboard on W...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kguiaddons
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 6.25.0
Platform: CachyOS Linux
: NOR minor
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-01 16:39 UTC by minimumheadroom
Modified: 2026-08-21 13:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.30
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description minimumheadroom 2026-05-01 16:39:18 UTC
When taking a full-screen or large screenshot with Spectacle on Wayland, the image appears in Klipper's clipboard history but cannot be pasted. Small screenshots work fine. Re-selecting the entry in Klipper's history makes it pasteable.
The issue is in kguiaddons/src/systemclipboard/waylandclipboard.cpp in DataControlOffer::readData(). The read side uses a 1-second poll timeout (poll(pfds, 1, 1000)), but for large images the source application needs time to encode the image before writing to the pipe. The write side already uses a 5-second timeout in safeWriteWithTimeout(), but the read side times out before the first byte arrives.

Step to reproduce:
Dual monitor or high resolution setup on Wayland
Take a full-screen screenshot with Spectacle
Try to paste, nothing pastes
Open Klipper history, select a different entry, re-select the screenshot. It now pastes.

THE FIX:
Change line 280 in waylandclipboard.cpp
- const int ready = poll(pfds, 1, 1000);
+ const int ready = poll (pfds, 1, 5000);

System info:
CachyOS, KDE Plasma 6.6.4, KDE Frameworks 6.25.0, dual 1080p monitors, Wayland

Thank you for all you do!
Comment 1 Bug Janitor Service 2026-07-24 11:26:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kguiaddons/-/merge_requests/228
Comment 2 Noah Davis 2026-08-13 13:04:21 UTC
Git commit fd4c6d1b7dfb77ecf43607ad49f17cebe1205f4b by Noah Davis, on behalf of Zhora Zmeykin.
Committed on 13/08/2026 at 13:04.
Pushed by ndavis into branch 'master'.

Reuse explicitly provided image data

Spectacle already encodes the image for the clipboard and puts both the ready-to-use `image/<preferred format>` bytes and the original QImage into QMimeData.

However, whenever an image is requested, `DataControlSource::ext_data_control_source_v1_send()` ignores the existing encoded representation and re-encodes the image using `QImage::save()`.

Re-encoding large screenshots as PNG can take more than a second. This happens after the receiver has requested the MIME type and opened the pipe, while `DataControlOffer::readData()` stops waiting if the first byte does not arrive within one second. The receiver then closes the pipe, and the screenshot may become unavailable for pasting or be stored as an empty Klipper entry.

On my laptop’s 3.1K display, this prevents the image from being stored in Klipper in time. This is a reduced-scope continuation of !206 although, to be honest, I only found that MR while preparing this one

Co-authored-by: Tom Ripley <discofan420@protonmail.com>

M  +10   -15   src/systemclipboard/waylandclipboard.cpp
M  +10   -17   src/systemclipboard/wlrwaylandclipboard.cpp

https://invent.kde.org/frameworks/kguiaddons/-/commit/fd4c6d1b7dfb77ecf43607ad49f17cebe1205f4b
Comment 3 Nate Graham 2026-08-21 13:25:13 UTC
Git commit 2e6078186e10bfb4882a7c8e4611e2d5d47a8862 by Nate Graham.
Committed on 21/08/2026 at 13:23.
Pushed by ngraham into branch 'Frameworks/6.24'.

Reuse explicitly provided image data

Spectacle already encodes the image for the clipboard and puts both the ready-to-use `image/<preferred format>` bytes and the original QImage into QMimeData.

However, whenever an image is requested, `DataControlSource::ext_data_control_source_v1_send()` ignores the existing encoded representation and re-encodes the image using `QImage::save()`.

Re-encoding large screenshots as PNG can take more than a second. This happens after the receiver has requested the MIME type and opened the pipe, while `DataControlOffer::readData()` stops waiting if the first byte does not arrive within one second. The receiver then closes the pipe, and the screenshot may become unavailable for pasting or be stored as an empty Klipper entry.

On my laptop’s 3.1K display, this prevents the image from being stored in Klipper in time. This is a reduced-scope continuation of !206 although, to be honest, I only found that MR while preparing this one

Co-authored-by: Tom Ripley <discofan420@protonmail.com>


(cherry picked from commit fd4c6d1b7dfb77ecf43607ad49f17cebe1205f4b)

c1d39270 Reuse explicitly provided image data
1e51cb51 Refactor image MIME type handling

Co-authored-by: Zhora Zmeykin <me@katze-942.ru>

M  +10   -15   src/systemclipboard/waylandclipboard.cpp
M  +10   -17   src/systemclipboard/wlrwaylandclipboard.cpp

https://invent.kde.org/frameworks/kguiaddons/-/commit/2e6078186e10bfb4882a7c8e4611e2d5d47a8862