Skip to content

Magic windows (preview): show a Mac window on the PC - #10

Closed
betoxf wants to merge 2 commits into
feat/airdrop-to-pcfrom
feat/magic-windows
Closed

betoxf wants to merge 2 commits into
feat/airdrop-to-pcfrom
feat/magic-windows

Conversation

@betoxf

@betoxf betoxf commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #9 (which is stacked on #8).

What changes

Show a Mac window on the PC, and use it there. In the Mac's menu bar menu, Show Front Window on opens a live copy of the window in front on the PC (also magicinput stream, or magicinput stream --app Safari). Clicking, scrolling and typing in the copy happen in the real window on the Mac. Closing the copy, or Stop Showing the Window, ends it.

  • Mac (src/stream.rs, its own process so the service stays lean): ScreenCaptureKit captures the window at one pixel per point, up to 30 frames a second, and only sends a picture when the window changes. Each picture goes over as a JPEG (quality 70) on a connection of its own (Stream instead of a hello, then Frame + Data). If the network falls behind, older pictures are skipped. Pointer, Button, Wheel and Key coming back are played into the window, and the app is brought forward on a click. Anything still held is let go at the end. It follows the window when it moves or resizes, and stops when the window closes.
  • PC (src/viewer.rs, in the service): a plain window, with pictures decoded by zune-jpeg and drawn with StretchDIBits. It comes to the front, resizes with the Mac window, and sends back what's done in it, with pointer positions in points of the Mac window. Keys held when it loses focus are released. One copy at a time.
  • Both sides ping when idle. The control connection is unchanged.

Validation

  • cargo test: 20 passed. cargo check --target x86_64-pc-windows-gnu: no warnings.
  • PC side on the real PC, using the ignored show_test_picture test (a moving 640x400 test picture sent from the Mac): the copy opened in front of a full-size app, and the picture rendered correctly at 150% scaling (checked by screenshot). A scripted click and the A key in the copy came back to the Mac as Pointer { 320, 188.7 }, Button Left down/up and Key 0x04 down/up.
  • Real capture on the real Mac and PC, after allowing Screen & System Audio Recording: magicinput stream --app Calculator, started from Finder, put a live copy of Calculator in front on the PC. Typing 7, 4, 2 into the copy on the PC made the Mac's Calculator show 742, and the copy updated right away (checked by screenshot).
  • magicinput stream gets the PC's address from the service's status file (new peer_addr). Its own mDNS search found nothing when it was started through Launch Services.

Known limits (preview)

  • JPEG, not video: about 50–150 KB per changed frame at one pixel per point. H.264 through VideoToolbox would cut that a lot.
  • Resizing the copy on the PC doesn't resize the Mac window yet. Clicks land at the window's screen position, so a window covered by another one is brought forward first.
  • Because the copy lives in the service (which runs with administrator rights), input from non-elevated automation on the PC can't reach it. Real mice and keyboards can.

🤖 Generated with Claude Code

betoxf and others added 2 commits October 25, 2026 01:16
`magicinput stream` (and the Mac menu bar item "Show Front Window on <PC>")
captures the front window with ScreenCaptureKit at one pixel per point, sends
each new picture as a JPEG over a connection of its own (Stream instead of a
hello, then Frame + Data), and plays the Pointer, Button, Wheel and Key
messages coming back into the window. It runs as its own process and ends
when the copy is closed or the window goes away.

The PC shows the copy in a plain window of the service (decoded with
zune-jpeg, drawn with StretchDIBits), brings it to the front, resizes it when
the Mac window does, and sends what's done in it back. Both sides ping when
idle. An ignored test (show_test_picture) streams a moving test picture to the
other computer for checking the PC side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The service now publishes the connected computer's address in its status
file, and `magicinput stream` uses it instead of its own network search
(which found nothing when started from the menu bar). The search stays as a
fallback, with a longer wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@betoxf
betoxf marked this pull request as ready for review October 24, 2026 16:26
@betoxf

betoxf commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Closing: we're not shipping window streaming for now. The branch stays in case we come back to it.

@betoxf betoxf closed this Oct 24, 2026
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.

1 participant