Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.7
-
None
Description
Calling QClipboard::ownsClipboard() on macOS always returns false, making it impossible/difficult to determine if the clipboard is ours or not. This is crucial for us at TigerVNC, as we need to know which direction to synchronise the clipboard.
The documentation states "Windows and macOS does not have the concept of ownership; the clipboard is a fully global resource so all applications are notified of changes.", but I don't think this is correct.
From Apple's documentation:
https://developer.apple.com/documentation/appkit/nspasteboard/1533544-changecount
The change count is also returned from clearContents and declareTypes:owner:. You can therefore record the value of changeCount at the time that you take ownership of the pasteboard and compare it with a later value to determine whether you still have ownership.
Qt also seems to use PasteboardSynchronize, which seems to be able to return the flag kPasteboardClientIsOwner. So perhaps even a second method to track ownership.
(ownsClipboard() also seems to work fine on Windows, so I don't think that part of the documentation is correct either).