Skip to content

Defer clipboard inspection until focused - #2134

Open
gpertea wants to merge 1 commit into
TigerVNC:masterfrom
gpertea:defer-windows-clipboard
Open

Defer clipboard inspection until focused#2134
gpertea wants to merge 1 commit into
TigerVNC:masterfrom
gpertea:defer-windows-clipboard

Conversation

@gpertea

@gpertea gpertea commented Jul 25, 2026

Copy link
Copy Markdown

Summary

Defer plain-text clipboard inspection while the viewer is unfocused. TigerVNC already delays advertising the client clipboard until focus returns; this change also delays Fl::clipboard_contains() until that point.

This avoids unnecessary platform clipboard access from every unfocused viewer and prevents a transient failed format check from immediately being treated as a non-text clipboard.

Scope

This addresses the unfocused clipboard-inspection and contention path described in #2128. It does not change how FLTK delivers clipboard-change notifications, retry failed clipboard access, or recover notifications lost by the Windows clipboard-viewer chain.

The source != 0 check is retained, preserving the PRIMARY-selection behavior fixed by #2129.

Addresses #2128.

@CendioOssman CendioOssman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion.

I think we just add needless complexity and confusion by making this Windows-only. Please adjust the commit so that this behaviour is the standard one.

@gpertea
gpertea force-pushed the defer-windows-clipboard branch from 700f1c0 to 85ae1b5 Compare August 5, 2026 20:52
@gpertea gpertea changed the title defer Windows clipboard inspection until focused Defer clipboard inspection until focused Aug 5, 2026
@gpertea
gpertea force-pushed the defer-windows-clipboard branch from 85ae1b5 to 39ed1d4 Compare August 5, 2026 22:29
@gpertea

gpertea commented Aug 5, 2026

Copy link
Copy Markdown
Author

Thanks, agreed. I've removed the Windows-specific branch, so clipboard inspection is now deferred consistently across platforms. I also rebased onto current master while preserving the new PRIMARY-selection handling from #2129. Tested on Windows and headless X11/Linux.

@gpertea
gpertea requested a review from CendioOssman August 5, 2026 23:18
@gpertea
gpertea marked this pull request as draft August 6, 2026 04:15
@gpertea

gpertea commented Aug 6, 2026

Copy link
Copy Markdown
Author

Please hold off on reviewing this for now - I've converted the PR back to draft.

Further live testing exposed a remaining Windows clipboard failure. The patch addresses clipboard inspection/contention after a notification is received, but it does not address loss of notifications caused by FLTK’s Windows clipboard-viewer chain. I need to separate those behaviors and reassess the scope before requesting review again.

Clipboard notifications can arrive while another application is still updating the clipboard, causing the format check to fail and the viewer to discard the change.

When the viewer is unfocused, defer that inspection until focus returns. This avoids competing with clipboard producers while retaining the plain-text check added for remote applications.
@gpertea
gpertea force-pushed the defer-windows-clipboard branch from 39ed1d4 to 4c4a476 Compare August 6, 2026 15:02
@gpertea
gpertea marked this pull request as ready for review August 6, 2026 15:03
@gpertea

gpertea commented Aug 6, 2026

Copy link
Copy Markdown
Author

Further testing confirmed that this patch has a narrower scope than I initially thought: it avoids immediate clipboard inspection by an unfocused viewer, reducing contention and preventing a transient failed check from discarding a notification that was received.

However it does not address missed Windows clipboard notifications caused by FLTK's own clipboard-viewer chain. I've updated the PR description accordingly, rebased onto current master, preserved the #2129 behavior and tightened the clipboardSource assignment. So this is intended as a targeted improvement, not a complete fix for Windows clipboard reliability, which requires a platform specific fix in FLTK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows viewer opens the local clipboard on every clipboard change even when unfocused, causing intermittent clipboard contention with other apps

2 participants