read the clipboard asynchronously

getClipboardText() used to open a pipe, ask the selection owner for
the text and poll it with a 500 ms deadline, so every paste blocked the
UI thread (TextBox calls it directly) and a slow owner meant a visible
hang.

The selection is now fetched in the background: when the selection
changes, the backend requests the text into a non-blocking pipe and
getClipboardText() only returns the buffer, which the event loop fills
in as the data arrives. Pasting no longer blocks, and a source that
never answers simply leaves the previous buffer in place.

Also clears the advertised MIME list when a new selection offer
arrives, so a request is never made with MIME types of a previous
owner.
This commit is contained in:
alexei-zebra 2026-10-09 01:48:53 +03:00
parent 6a5e485bca
commit d9794afa67
No known key found for this signature in database
GPG key ID: D19D450AC3D9A80E
3 changed files with 42 additions and 23 deletions

View file

@ -212,6 +212,7 @@ void on_display_error() {
}
void WaylandInput::pollEvents(bool waitForRefresh) {
updateClipboard();
beginFrame();
dispatch(waitForRefresh);
if (window) {