Attachment "tk-clipboard-reassert-ownership-trunk.patch" to
ticket [e94c8bc8]
added by
orgads
2026-09-17 19:16:23.
--- generic/tkClipboard.c
+++ generic/tkClipboard.c
@@ -278,14 +278,18 @@
dispPtr->clipTargetPtr = NULL;
/*
- * Reclaim the clipboard selection if we lost it.
+ * Reclaim the clipboard selection. Ownership is re-asserted even when this
+ * application already holds it: selection bridges (Xwayland/Wayland
+ * compositors, RDP and VNC servers) learn about clipboard changes only
+ * from the XFixes SetSelectionOwnerNotify event that XSetSelectionOwner
+ * generates. Skipping the redundant claim means the second and every
+ * subsequent copy from the same application is never propagated, even
+ * though the X11 side remains perfectly consistent.
*/
- if (!dispPtr->clipboardActive) {
- Tk_OwnSelection(dispPtr->clipWindow, dispPtr->clipboardAtom,
- ClipboardLostSel, dispPtr);
- dispPtr->clipboardActive = 1;
- }
+ Tk_OwnSelection(dispPtr->clipWindow, dispPtr->clipboardAtom,
+ ClipboardLostSel, dispPtr);
+ dispPtr->clipboardActive = 1;
dispPtr->clipboardAppPtr = winPtr->mainPtr;
return TCL_OK;
}
@@ -340,7 +344,8 @@
if (dispPtr->clipboardAppPtr != winPtr->mainPtr) {
Tk_ClipboardClear(interp, tkwin);
- } else if (!dispPtr->clipboardActive) {
+ } else {
+ /* Re-assert ownership; see the comment in Tk_ClipboardClear. */
Tk_OwnSelection(dispPtr->clipWindow, dispPtr->clipboardAtom,
ClipboardLostSel, dispPtr);
dispPtr->clipboardActive = 1;