Repository navigation
viewer: paste PNG screenshots to Mac over the native clipboard channel - #167
Zhenqiang-Weng wants to merge 10 commits into
Conversation
Negotiate public.png and use confirmed one-based data blocks on TEXT_DATA_CHANNEL. Delay Cmd+V until every block is acknowledged, and cancel on focus changes or failure. Keep image reads on demand and preserve existing text behavior. Validate on upstream v0.2.48 with 315 base and 213 SDL tests, isolated X11/INCR checks, and byte-identical PNG reception on the official Mac host. The user confirmed direct Ctrl+V pastes the screenshot.
|
Thanks, this is the native approach I hoped for #164, and the protocol table with the one-based block index finding is very helpful. The diff looks well scoped: the paste is explicit, there is no polling, it is bounded (32 MiB, PNG structure check), it cancels on focus loss, and logs carry only sizes and counts. CI is green. A few small things before merging:
@codex review 🤖 Generated with Claude Code |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Thanks for the review. Both requested changes are addressed in 8cbce37:
Validation: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99555349e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mut child=tokio::process::Command::new("wl-paste").args(["--no-newline","--type","image/png"]) | ||
| .stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::null()).kill_on_drop(true).spawn().map_err(|_|())?; |
There was a problem hiding this comment.
Preserve text paste when the optional Wayland reader is absent
On a native-Wayland SDL viewer connected to a Mac, a machine without wl-paste can still synchronize text through the existing SDL backend, but every Command+V now calls this reader. The missing executable makes spawn() fail, which reaches the Err(()) arm in Window::poll and discards the shortcut even for a text-only clipboard. Since wl-clipboard is only a suggested package in packaging/deb/build-deb.sh, this breaks ordinary paste on supported installations. Disable the image gate or preserve the normal key path when the optional PNG reader is unavailable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 84cba30. Missing or non-executable optional wl-paste now returns the ordinary no-image result, so SDL's text/key path is replayed. Other read/transfer errors still suppress a failed image paste. Added a regression using a nonexistent helper path, plus the no-reader paste fallback; no real clipboard is accessed.
| if let Ok(Some(text))=backend.read().await {state.last=Some(text);} | ||
| if request.reply.is_closed(){continue} | ||
| let id=state.next(); | ||
| match state.rich.offer_png(id,request.data){ |
There was a problem hiding this comment.
Re-offer identical text copied after an image paste
If text T was synchronized, a PNG is pasted, and the user then copies T again, state.last remains T although offer_png cleared the rich state's text and installed the image. SyncState::local(T) therefore discards the new selection as a duplicate, leaving the PNG on the Mac so a normal Command+V pastes the old image instead of the newly copied text. A focused state test reproduces the missing second text offer. Make deduplication selection/format-aware so that suppressing a mixed selection's text does not also suppress later text-only copies.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 84cba30. PNG offers now invalidate the previous text value and record the local clipboard selection generation. Reads of the same mixed selection remain suppressed, while a later SDL clipboard update allows even identical text to be offered again. The image request also carries its generation and is rejected if the selection has changed before the offer. Added a state regression for text T → PNG/mixed selection → the same text T copied again.
| if let Some(result)=finished { | ||
| let mut pending=self.paste.take().unwrap(); | ||
| match result { | ||
| Ok(true)=>{self.clipboard_dirty=false;prefix.extend(image_paste_keys(input));forward.extend(std::mem::take(&mut pending.events).into_iter().filter(|e|!paste_key(e)));self.notice=None;redraw=true;}, |
There was a problem hiding this comment.
Preserve later V keystrokes when replaying buffered input
If the user releases the paste shortcut and continues typing while PNG acknowledgements are pending, pending.events contains that subsequent typing as well as the original shortcut. Filtering with paste_key removes every V key-down/up regardless of modifiers or position, so typing value during the transfer is replayed as alue after the image paste. Suppress only the original paste keystroke and its associated release/repeats, rather than every later V event.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 84cba30. Replay now removes only the initial paste V press and tracks its remaining repeats/release, including when the release arrives in a later poll. Subsequent fresh V presses are preserved. A dummy-SDL regression verifies that typing the full word value during the transfer produces Cmd+V followed by all five letters, with balanced key state.
| Event::Quit{..}|Event::ClipboardUpdate{..}|Event::MouseButtonDown{..}| | ||
| Event::Window{win_event:WindowEvent::FocusLost|WindowEvent::Close,..}| | ||
| Event::KeyDown{scancode:Some(sdl2::keyboard::Scancode::Escape),..})); | ||
| if cancel && self.paste.take().is_some(){prefix.extend(input.release_all());self.notice=None;redraw=true;} |
There was a problem hiding this comment.
Cancel newly started pastes on later events in the same batch
If SDL batches the paste shortcut and a subsequent click on another remote input target into the same poll, this cancellation pre-pass runs while self.paste is still None. The event loop then creates PendingPaste for the shortcut and forwards the click without cancelling that new transfer; when acknowledgements arrive, Command+V is sent into the newly clicked target. Apply cancellation during event processing too, including to a transfer created earlier in the same batch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 84cba30. The cancellation pre-pass is retained for already completed transfers, and cancellation is also checked while processing each event. This covers a pending paste created earlier in the same batch, before a click, focus loss, clipboard change, Escape, or local menu shortcut. The dummy-SDL test exercises these batches and verifies that no delayed V press is sent.
|
Addressed all four Codex findings in 84cba30 and replied in each review thread:
Added regressions for the missing helper, text → PNG → identical text, the full word Local validation passed: 316 base tests, 217 SDL viewer tests, and the release SDL viewer build. All six CI jobs for 84cba30 are now green. The four review threads contain the fix details for re-review. |
|
Thanks, the README move and the non-failing name match in 8cbce37 look good, and so do your replies on the review threads. Requesting a re-review of the current head (84cba30) before merging: @codex review 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 84cba306f0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for event in events { | ||
| // The pre-pass protects an already finished transfer; this also | ||
| // cancels one started by an earlier event in this same SDL batch. | ||
| if cancels_paste(&event) && self.paste.take().is_some(){prefix.extend(input.release_all());self.notice=None;redraw=true;} |
There was a problem hiding this comment.
Balance queued modifiers when cancelling a same-batch paste
If SDL batches Ctrl-down, V-down, V-up, Ctrl-up, click, the new cancellation check drops the buffered key-ups while Ctrl-down is still only in forward. input.release_all() therefore sees no pressed Ctrl, and translate_actions subsequently sends Ctrl-down followed by the click. The click becomes a Ctrl-click, and the remote modifier remains held until later reconciliation despite having been physically released. Preserve event ordering when cancelling a newly started paste so queued presses are translated before their cancellation releases.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9f066e7. Events queued before the paste shortcut are now translated in order before creating PendingPaste. A same-batch cancellation therefore sees those modifier presses in Input, and emits their releases before forwarding the click. Added a dummy-SDL regression for Ctrl-down, V-down, V-up, Ctrl-up, click, also covering right Command. It asserts press → release → mouse press/release ordering, no V press, and no remaining held input. The regression failed before the fix and passes now.
| match result { | ||
| Ok(true)=>{self.clipboard_dirty=false;prefix.extend(image_paste_keys(input));self.paste_key_held=true;forward.extend(std::mem::take(&mut pending.events).into_iter().skip(1).filter(|e|!suppress_paste_key(&mut self.paste_key_held,e)));self.notice=None;redraw=true;}, | ||
| Ok(false)=>{forward.append(&mut pending.events);self.notice=None;redraw=true;}, | ||
| Err(())=>{prefix.extend(input.release_all());self.notice=Some((crate::i18n::s("图片粘贴失败,请重新复制截图后重试", "Image paste failed; copy the screenshot and try again").into(),std::time::Instant::now()+std::time::Duration::from_secs(5)));redraw=true;}, |
There was a problem hiding this comment.
Replay unrelated buffered keys when an image paste fails
If the user releases the paste shortcut and continues typing while PNG acknowledgements are pending, a transfer failure or timeout reaches this branch with that subsequent typing still in pending.events. Unlike either success branch, the error branch discards the entire buffer when pending is dropped, so unrelated text disappears even though focus and the clipboard selection have not changed. Suppress the failed paste shortcut, but replay the subsequent buffered input rather than silently losing it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9f066e7. Success and failure now share the same extraction of subsequent events: only the initial paste V and its remaining repeats/release are consumed. On failure, other buffered input is replayed after releasing prior held keys, while the failure notice remains and no paste shortcut is emitted. Added regressions for both an explicit error and a closed completion channel, verifying that the full subsequently typed value is preserved and key state is balanced. Both reproduced the loss before this fix. Focus/selection changes still cancel replay to avoid typing into a different target.
|
Thanks for requesting the re-review. Both new findings are addressed in 9f066e7, with replies in the corresponding threads:
Both new regressions failed on the preceding code and pass with this fix. Full local validation passed: 316 base tests, 219 SDL viewer tests, and the release SDL viewer build. All six CI jobs for 9f066e7 are green. Ready for re-review. |
|
Thanks for addressing the latest findings in 9f066e7. Requesting a re-review of this head: @codex review 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f066e7c8d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| match result { | ||
| Ok(true)=>{self.clipboard_dirty=false;prefix.extend(image_paste_keys(input));forward.extend(pending.following_events(&mut self.paste_key_held));self.notice=None;redraw=true;}, | ||
| Ok(false)=>{forward.append(&mut pending.events);self.notice=None;redraw=true;}, | ||
| Err(())=>{prefix.extend(input.release_all());forward.extend(pending.following_events(&mut self.paste_key_held));self.notice=Some((crate::i18n::s("图片粘贴失败,请重新复制截图后重试", "Image paste failed; copy the screenshot and try again").into(),std::time::Instant::now()+std::time::Duration::from_secs(5)));redraw=true;}, |
There was a problem hiding this comment.
Keep queued paste retries behind the image barrier
If a user retries Command/Win+V while a PNG transfer is pending and the transfer then fails or times out before installing the image, following_events preserves that second shortcut. This branch forwards it directly to translate_actions, which restores Command from keymod and sends Command+V without passing through image_paste::prepare. The failed transfer can therefore paste the previous remote clipboard despite the failure notice. Suppress queued paste chords on failure or route them back through the image gate while continuing to replay ordinary typing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 1b00c49. Failed transfers now suppress queued Ctrl/Command+V retries together with their held-V repeats and releases, including releases arriving in a later SDL poll. Ordinary subsequent typing, including a plain V, is still replayed. The queue-overflow cancellation path uses the same filtering, including when the retry itself is the overflowing event. Successful image transfers and the no-PNG text path keep their existing behavior.
Both new regression tests failed before the fix and pass afterward. They cover left/right Ctrl and Command, explicit failure, a closed completion channel, successful/no-PNG completion, V held across polls, repeated retries, and retries both inside and at the buffer limit. Full validation: 316 base tests, 224 SDL viewer tests, and the release viewer build passed.
| if pending.events.len()<256 {pending.events.push(event);}else{self.paste=None;prefix.extend(input.release_all());} | ||
| continue |
There was a problem hiding this comment.
Replay buffered typing when the paste queue fills
If a slow image read or transfer remains pending long enough to accumulate 256 keyboard events—roughly 128 typed characters—this overflow branch drops PendingPaste, including all unrelated typing already buffered, and the following continue also discards the overflowing event. None of that input reaches the remote even though focus and selection are unchanged, bypassing the failure replay above. Keep the bounded cap, but handle overflow as a failed paste and replay the non-paste input rather than silently discarding the buffer.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This was independently reproduced and fixed in 5c4da2b while the review of 9f066e7 was running; that fix is included in the current head. The overflow path cancels the image transfer, replays the buffered non-paste input and the overflowing event, and shows a notice instead of silently discarding typing. The buffer remains bounded.
The reproduction previously forwarded only 73 of 200 typed characters; it now forwards all 200. Regression coverage includes 126, 127, 128, 200, and 1,000 characters plus 260 repeats of the original held V. Commit 1b00c49 additionally suppresses queued paste retries in this cancellation path, as requested in the other finding. The current head passes 316 base tests, 224 SDL viewer tests, and the release build.
|
Additional independent testing found one more input-loss case, fixed in 5c4da2b: when an image transfer remains pending and subsequent typing exceeds the 256-event buffer, the old cancellation path discarded buffered characters. A deterministic reproduction typed 200 On overflow, the viewer now cancels the image paste, releases held input, and replays all subsequent typing, including the event that reaches the limit. Only the original paste V press/repeats/release are suppressed. The buffer remains bounded, and a localized notice explains that the image paste was cancelled while typing was preserved. Regression tests cover 126, 127, 128, 200, and 1,000 characters, plus 260 repeats of the original held V. The 200-character reproduction now forwards all 200. Independent validation also passed:
After #168 landed, I merged current main in 4125aa3 and resolved the overlapping SDL integration. The combined tree passes 316 base tests, 222 SDL viewer tests, and the release viewer build. All six CI jobs for this head have started and are still running. These additional checks used synthetic data and isolated SDL/X11 displays; they do not represent a new end-to-end Mac clipboard test. |
|
Thanks for 5c4da2b and 1b00c49 (overflow replay and suppressing queued paste retries after a failure). Requesting a re-review of the current head 1b00c49: @codex review 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b00c49b08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let Some(pending)=self.paste.as_mut(){if matches!(event,Event::KeyDown{..}|Event::KeyUp{..}){ | ||
| if pending.events.len()<256 {pending.events.push(event);}else{ |
There was a problem hiding this comment.
Preserve wheel ordering behind buffered modifier releases
When Ctrl/Command+V starts a PNG transfer, the modifier-down is flushed before creating PendingPaste. If the user then releases that modifier and scrolls before completion, the key-up is buffered here but MouseWheel is neither buffered nor a cancels_paste event, so translate_actions sends the scroll while the remote modifier is still held. Applications with modifier-wheel bindings can therefore zoom or perform another modified action instead of scrolling. Keep wheel events ordered behind the buffered key transitions, or cancel and release the pending paste before forwarding them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 2d805f1. MouseWheel events now join the same bounded queue as keyboard transitions while image paste is pending. They cannot overtake an earlier modifier release; replay preserves the order on success, no-PNG fallback, and transfer failure. If the queue fills, image paste is cancelled and the buffered scrolling is replayed along with subsequent typing, including the overflowing wheel event.
Both new regression tests failed before this change and pass afterward. They cover left/right Ctrl and Command, same-batch and separate-batch events, success/no-PNG/error/closed-worker completion (32 combinations), and 260 wheel events reaching the queue limit. The tests inspect the remote key state at each scroll: the first is unmodified after the paste modifier is released, and a later deliberate Shift+wheel retains Shift. Scroll direction/order, ordinary V typing, and balanced releases are checked as well.
Full local validation passed: 316 base tests, 226 SDL viewer tests, and the release viewer build. The preceding head's six CI jobs were green; CI for this update is starting. Testing used synthetic events in isolated SDL windows.
|
Thanks for 2d805f1 (keeping wheel events ordered behind buffered key transitions, with regression tests). Requesting a re-review of the current head 2d805f1: @codex review 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d805f1717
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let Some(pending)=self.paste.as_mut(){if matches!(event,Event::KeyDown{..}|Event::KeyUp{..}|Event::MouseWheel{..}){ | ||
| if pending.events.len()<256 {pending.events.push(event);}else{ |
There was a problem hiding this comment.
Restore still-held modifiers when replaying queued wheels
If a user keeps Ctrl/Command held after the initial paste and scrolls before the PNG completes, the new queue contains no modifier-down for that already-held key. On success, image_paste_keys() releases it before replay; failure and overflow also call release_all(). Since translate_actions() only reconciles modifiers on non-modifier key-downs, the wheel is replayed as an unmodified scroll rather than the intended modified action. Preserve the wheel's event-time modifier state across the paste barrier. The added tests release the paste modifier before scrolling, so they do not cover this case.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and addressed in 41b8f2f. I extracted the paste input buffer and physical-modifier tracking into paste_input.rs. Each wheel carries a snapshot derived from the ordered SDL keyboard events, independently of the remote Input state that atomic paste or cancellation releases. Translation restores that snapshot before the wheel. The tracker also covers a wheel arriving in the same poll that consumes completion, plus the event that overflows the queue; it does not query SDL's final modifier state after a batch.
The expanded regression failed on 2d805f1 and now passes. It checks the actual remote held-key set for 96 combinations: left/right Ctrl/Command, held/released modifiers, three batching/completion timings, and success/no-PNG/error/closed-worker outcomes. It also checks intentional Shift+wheel and balanced final releases. The overflow test now covers all four modifiers held/released with 260 wheel events.
Full validation passed: 316 base tests, 226 SDL viewer tests, and the release build. Tests use synthetic events in isolated SDL windows.
| if let Some(result)=finished { | ||
| let mut pending=self.paste.take().unwrap(); | ||
| match result { | ||
| Ok(true)=>{self.clipboard_dirty=false;prefix.extend(image_paste_keys(input));forward.extend(pending.following_events(&mut self.paste_key_held,false));self.notice=None;redraw=true;}, |
There was a problem hiding this comment.
Apply the image-paste mapping to successful queued Ctrl+V retries
If Ctrl+V is pressed again while a PNG transfer is pending and that transfer succeeds, following_events(..., false) retains the second chord, but this branch sends it directly to translate_actions(). Only the original shortcut goes through image_paste_keys(), so the queued retry becomes native Mac Control+V rather than Command+V, unlike the same shortcut pressed after completion. It therefore does not perform the advertised image paste and can invoke a different host action. Apply the image-paste mapping to queued paste chords, or coalesce retries, instead of replaying them as raw control input.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 41b8f2f by coalescing retries for the same PNG transfer. The extracted input buffer uses one rule for the original paste and queued retries: PNG success emits exactly one balanced Command+V, while failure emits none. Their V repeats/releases are consumed even across later polls; unrelated typing, including plain V, is preserved. No-PNG fallback retains the ordinary text/key path. Both READMEs and the clipboard documentation now state the coalescing behavior.
The successful-retry regression failed before this change and now passes for left/right Ctrl/Command, success/failure/closed-worker/no-PNG results, and V released before or after completion. It now inspects the held modifiers at each V press and asserts exactly one Command+V on PNG success, rather than checking only key counts. Full local validation: 316 base tests, 226 SDL viewer tests, and release build passed.
|
Thanks for 41b8f2f (wheel events now carry a physical-modifier snapshot, and queued Ctrl+V retries coalesce into one balanced Command+V on success). Requesting a re-review of the current head 41b8f2f: @codex review 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41b8f2f041
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // keyboard stream, never from SDL's final state after polling a batch. | ||
| if let Event::KeyDown{keymod,..}|Event::KeyUp{keymod,..}=event{self.0=*keymod;} | ||
| if matches!(event,Event::Window{win_event:sdl2::event::WindowEvent::FocusLost,..}){self.0=Mod::NOMOD;} | ||
| matches!(event,Event::MouseWheel{..}).then_some(self.0) |
There was a problem hiding this comment.
Restore held modifiers before post-paste mouse clicks
On a Mac session, if Ctrl+V completes while Ctrl remains physically held, clicking in a later poll without an intervening key press or wheel event sends a plain click rather than the expected Ctrl-click/context-menu action. image_paste_keys() has released remote Ctrl, but this predicate attaches modifier snapshots only to wheels, and translate_input() does not otherwise reconcile modifiers for mouse-button events. Include mouse-button events in physical modifier reconciliation so completing an image paste does not change the meaning of subsequent clicks.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 8674f66. MouseButtonDown and MouseButtonUp now carry the same event-time physical modifier snapshot as wheel events. The existing input translation restores that snapshot before the button transition, with focus and view-only guards preserved.
Both new regressions failed on 41b8f2f and pass after this change. The integration test consumes PNG completion in an earlier poll, then clicks without an intervening key press or wheel; it checks the remote held-key set at both button transitions. Its 120 cases cover left/right Ctrl/Command, held/released modifiers, all three buttons, and success/error/worker closure/no-PNG/click-cancellation outcomes. A separate test checks button down/up independently, Shift+Alt combinations, and focus/view-only suppression.
Local validation passed: 316 base tests, 228 SDL viewer tests, and the release build. All input fixtures are synthetic and isolated from a live remote session. The new GitHub CI run is in progress.
Carry event-time physical modifier snapshots on mouse-button presses and releases as well as wheels. This preserves Ctrl/Command clicks after an atomic image paste releases the remote keys. Cover successful, failed, closed, text-fallback and cancelled transfers, held/released left/right Ctrl/Command, and all three buttons. Also check both button transitions with Shift/Alt combinations and focus/view-only guards.
|
Thanks for 8674f66 (mouse button transitions now carry the physical-modifier snapshot, so a held Ctrl/Command is restored before post-paste clicks). Requesting a re-review of the current head 8674f66: @codex review 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8674f664d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| // A wheel must not overtake buffered modifier releases and become | ||
| // an unintended Ctrl/Command-wheel action on the remote host. | ||
| if let Some(pending)=self.paste.as_mut(){if matches!(event,Event::KeyDown{..}|Event::KeyUp{..}|Event::MouseWheel{..}){ |
There was a problem hiding this comment.
Preserve pointer position when replaying buffered wheels
In a Mac viewer session, if the user scrolls over pane A while a PNG transfer is pending and then moves the pointer over pane B without clicking, this branch buffers the wheel but forwards MouseMotion immediately. When the transfer completes, translate_input() replays the wheel through Input::scroll(), which sends only deltas, so the scroll occurs at the remote pointer's newer position over B instead of A. Keep pointer motion ordered with delayed wheels, or capture and restore each wheel's event-time position before replaying it.
Useful? React with 👍 / 👎.
PNG screenshots copied on Linux can now be pasted into an official Mac host with Ctrl+V or Command/Win+V. The viewer reads the image on the explicit paste action, uses the existing TEXT_DATA_CHANNEL format negotiation and data blocks, and sends a balanced Command+V only after all blocks are acknowledged. This is built into the viewer and does not use the independent-session companion, LD_PRELOAD adapter, remote file/terminal tools, or a separate image switch.
Refs #164. A relevant interoperability finding: the official Mac acknowledged zero-based PNG blocks but did not apply the image. Using one-based indices produced a byte-identical, decodable PNG on its pasteboard. The format is id 0 named public.png with raw PNG bytes; the protocol note records the observed shapes and test evidence. Existing text encoding and the official launcher layout are preserved.
The initial scope is Linux→Mac PNG (32 MiB maximum). X11/XWayland reads use an unmapped native requestor with INCR support. SDL2 native Wayland uses wl-paste only when the user explicitly pastes; this fallback still needs compositor-specific acceptance, and focus loss cancels the paste. There is no periodic image polling, reverse image sync, or file clipboard support in this PR.
Validation on current main (v0.2.48):
Tests cover ACK correlation/completeness, malformed/oversized PNG rejection, text compatibility, focus cancellation and balanced modifier release. Test fixtures are synthetic; no clipboard contents, official binaries/assets, credentials or device details are included.