Repository navigation
Add standalone clipboard change watchers - #242
Open
aymanbagabas wants to merge 3 commits into
Open
aymanbagabas wants to merge 3 commits into
aymanbagabas wants to merge 3 commits into
Conversation
Observe native selection events on X11 and Wayland, and poll native change counters on macOS and Windows. Keep notifications coalesced and separate from clipboard payload transfers. Expose blocking and timed waits with explicit stop and joined Drop lifecycles. Document unsupported protocols and add native examples, protocol fixtures, and Linux validation tooling. Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Run the ignored native watcher test explicitly in the existing test matrix. This checks native counter changes, external clipboard writes, clear, stop, and drop on both hosted platforms. Document the CI coverage alongside the native test command. Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
A shutdown race allows a late poll error after the terminal Stopped event.
1 open finding
What changed in this PR
Adds standalone clipboard change notifications without reading payloads or acquiring existing clipboard backend locks.
Changes:
- Introduces coalesced events, blocking/timed waits, and joined shutdown.
- Adds Windows, macOS, X11, and Wayland backends.
- Includes documentation, examples, tests, and native validation tools.
| File | Description |
|---|---|
| tools/test_watchers_linux.sh | Validates isolated X11 and Wayland behavior. |
| tests/watcher.rs | Tests native changes and external writers. |
| src/watcher/x11.rs | Watches XFixes selection notifications. |
| src/watcher/windows.rs | Checks clipboard sequence numbers. |
| src/watcher/wayland.rs | Watches data-control events; adds protocol fixtures. |
| src/watcher/macos.rs | Checks pasteboard change counts. |
| src/watcher/linux.rs | Selects the Linux watcher backend. |
| src/watcher.rs | Defines watcher API, lifecycle, and unit tests. |
| src/lib.rs | Exports watcher types. |
| README.md | Documents usage and platform limitations. |
| examples/watch.rs | Demonstrates watching and self-testing. |
| Cargo.toml | Enables required protocol dependencies. |
| Cargo.lock | Records direct Wayland dependencies. |
| .github/workflows/test.yml | Runs native watcher integration tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Only the first stopped transition can record an error. Preserve any pending error, but discard failures from a poll that finishes after an explicit stop has already won the transition. Add a regression that blocks a poll, observes Stopped, then releases the poll with an error. Subsequent waits must still return Stopped. Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add a standalone ClipboardWatcher with an initial event, coalesced changes, blocking/timed waits, terminal error reporting, and joined stop/drop. The watcher does not read clipboard payloads or acquire the existing clipboard backend locks.
Backends use Windows/macOS native change counters, XFixes on X11, and ext/wlr data-control selection events on Wayland. Missing required extensions return explicit unsupported errors. Document the 50-ms checks, coalescing, first-seat Wayland scope, and ownership-notification limits.
Include a runnable example, native integration checks, protocol fixtures, and Linux validation tools.
Validation: macOS unit/doctests and native watcher test with external pbcopy passed. Linux Xvfb and headless Sway tests passed, including external changes, clear, stop, examples, and disconnection. Protocol fixtures cover ext/wlr identical-MIME changes, empty selections, revocation, and seat removal. Rust 1.71 checks/tests, Linux/Windows cross-checks, formatting, and platform Clippy passed.
Native Windows execution and an actual ext-data-control compositor remain to validate; Sway covered wlr and fixtures covered ext. This is an independent API proposal against master.