Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to MagicInput are documented here. The project follows [Sema

### Added

- **Magic windows (preview): show a Mac window on the PC.** In the Mac's menu bar menu, **Show Front Window on <PC>** opens a live copy of the window in front on the PC (or run `magicinput stream`, `--app Safari` for a given app). Click, scroll and type in the copy and it happens in the window on the Mac; close the copy, or choose **Stop Showing the Window**, to end it. The first time, allow MagicInput under Screen & System Audio Recording in the Mac's Privacy & Security settings. Pictures go over as JPEGs at up to 30 frames a second, only when the window changes, on a connection of their own.
- **AirDrop to the PC.** Files AirDropped to the Mac move on to the PC's Downloads folder (and show in Explorer) when you were working on the PC: the pointer is there, or the PC's own keyboard or mouse was used more recently than the Mac's. Set `airdrop = "always"` or `"never"` in the Mac's config file to change that. They travel encrypted over a connection of their own, so the pointer stays smooth. The first time, macOS asks to let MagicInput access the Downloads folder. Both computers need this version.

## [0.5.0] - 2026-10-19
Expand Down
106 changes: 106 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ wry = "0.57.0"
[target."cfg(windows)".dependencies]
windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_UI_WindowsAndMessaging", "Win32_UI_Input_KeyboardAndMouse", "Win32_Graphics_Gdi", "Win32_System_LibraryLoader", "Win32_UI_HiDpi", "Win32_System_Threading", "Win32_System_SystemInformation", "Win32_UI_Shell", "Win32_System_Registry", "Win32_Storage_Packaging_Appx"] }
windows = { version = "0.62", features = ["ApplicationModel"] }
zune-jpeg = "0.5"
zune-core = "0.5"

[target.'cfg(target_os = "macos")'.dependencies]
block2 = "0.6"
dispatch2 = "0.3"
jpeg-encoder = { version = "0.7.1", features = ["simd"] }
objc2 = "0.6"
objc2-app-kit = { version = "0.3", features = ["NSBitmapImageRep", "NSButton", "NSControl", "NSFontDescriptor", "NSGraphics", "NSGraphicsContext", "NSImage", "NSImageRep", "NSResponder", "NSScreen", "NSStatusBarButton", "NSStatusItem", "NSView", "NSWorkspace", "block2", "objc2-core-foundation"] }
objc2-app-kit = { version = "0.3", features = ["NSBitmapImageRep", "NSButton", "NSControl", "NSFontDescriptor", "NSGraphics", "NSGraphicsContext", "NSImage", "NSImageRep", "NSResponder", "NSRunningApplication", "NSScreen", "NSStatusBarButton", "NSStatusItem", "NSView", "NSWorkspace", "block2", "objc2-core-foundation"] }
objc2-core-foundation = "0.3"
objc2-core-media = "0.3"
objc2-core-video = "0.3"
objc2-foundation = { version = "0.3", features = ["NSString", "NSArray", "NSGeometry", "NSEnumerator", "NSURL", "NSDictionary", "NSData"] }
objc2-screen-capture-kit = "0.3"

[profile.release]
strip = true
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Your Mac's keyboard and trackpad are right there, and so is the PC's monitor. Ma
| Arrange like System Settings | Drag the PC next to your displays, iPad (Sidecar) included, and move the iPad itself. The pointer crosses only where the screens touch, at the matching height. |
| Keyboard follows the click | No keyboard on the PC? Click into a text field with its own mouse and keep typing on the Mac keyboard (and the other way round). |
| Copy and paste across | Copied text follows the pointer to the other computer. |
| Magic windows (preview) | Show a Mac window on the PC from the menu bar, and use it there: clicks, scrolling and typing go back to the Mac. |
| AirDrop to the PC | AirDrop from your iPhone to the Mac while you're working on the PC, and the file lands in the PC's Downloads folder. |
| Mac shortcuts on the PC | ⌘C copies on Windows (Ctrl and ⌘ swap automatically; can be turned off). |
| Private and local | Finds the other computer on your network by itself. Encrypted end to end, paired with a short code, refuses anything outside your local network. No account, no cloud, no telemetry. |
Expand Down
1 change: 1 addition & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ After the handshake both sides exchange `Hello` (name, OS, protocol version, scr
| `Focus` | The sender was clicked with its own mouse: send your keys here (keyboard follows the click). |
| `Layout` | The arrangement changed; the newest one wins. |
| `Ping` | Keep-alive every second when idle; a silent link is dropped after 5 s. |
| `Stream`, `Frame`, `Data`, `Pointer` | Magic windows, on a connection of their own opened with `Stream` instead of a hello. The Mac (`magicinput stream`, its own process) captures one window with ScreenCaptureKit and sends each new picture as a JPEG (`Frame`, then `Data` pieces); the PC shows it in a window of the service and sends back `Pointer` (points from the window's top left), `Button`, `Wheel` and `Key`, which the Mac plays into the window. Both sides ping when idle. |
| `Offer`, `Answer`, `Data`, `Received` | A file AirDropped to the Mac, on a connection of its own (opened with `Offer` instead of a hello, so a big file never holds up the pointer). The PC takes it if the Mac's user is working on the PC, or if the PC was used more recently; the Mac removes its copy after `Received`. |

Bursts of movement are merged before sending. On the receiving side, movement that arrives later than usual (Wi-Fi often holds packets) is queued, together with anything behind it, and replayed at double speed, so the pointer glides instead of jumping and clicks still land in the right place.
Expand Down
4 changes: 3 additions & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub enum LocalEvent {

pub struct Peer {
pub name: String,
pub addr: Option<std::net::IpAddr>,
pub os: Os,
pub side_hint: Option<Side>,
/// Its screens, in logical units.
Expand Down Expand Up @@ -636,6 +637,7 @@ impl Core {
crate::status::Status {
peer: st.peer.as_ref().map(|p| p.name.clone()),
peer_os: st.peer.as_ref().map(|p| format!("{:?}", p.os)),
peer_addr: st.peer.as_ref().and_then(|p| p.addr).map(|a| a.to_string()),
side: st.side.map(|s| format!("{s:?}").to_lowercase()),
controlling: mode == REMOTE,
controlled: mode == CONTROLLED,
Expand Down Expand Up @@ -789,7 +791,7 @@ mod tests {
fn connected(has_keyboard: bool) -> (Core, crossbeam_channel::Receiver<Msg>) {
let (tx, rx) = crossbeam_channel::unbounded();
let core = Core::new(Config { has_keyboard, ..Config::default() }, tx);
core.on_connect(Peer { name: "PC".into(), os: Os::Windows, side_hint: None, screens: vec![], layout: None, layout_time: 0 });
core.on_connect(Peer { name: "PC".into(), addr: None, os: Os::Windows, side_hint: None, screens: vec![], layout: None, layout_time: 0 });
(core, rx)
}

Expand Down
46 changes: 34 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ mod platform;
mod proto;
mod service;
mod status;
#[cfg(target_os = "macos")]
mod stream;
pub mod ui;
#[cfg(windows)]
mod viewer;

use std::io::IsTerminal;

Expand Down Expand Up @@ -64,6 +68,12 @@ enum Cmd {
Uninstall,
/// Show the business license, or activate a license key from your download page
License { key: Option<String> },
/// Show this Mac's front window on the other computer, until its copy there is closed
Stream {
/// Show a window of this app instead (part of its name)
#[arg(long)]
app: Option<String>,
},
}

/// `settings` opens the settings window. Each program passes how: the window itself (Mac, and
Expand Down Expand Up @@ -137,7 +147,30 @@ pub fn main_with(settings: fn(bool)) {
Ok(m) => println!("{m}"),
Err(e) => exit(&e),
},
Cmd::Stream { app } => {
init_log("magicinput-stream.log");
#[cfg(target_os = "macos")]
if let Err(e) = stream::run(app) {
exit(&e);
}
#[cfg(not(target_os = "macos"))]
exit(&format!("Showing windows on the other computer works from a Mac for now{}", app.map(|a| format!(" ({a})")).unwrap_or_default()));
}
}
}

/// Log to the terminal, or (started from the menu bar or Finder) to `file` next to the config.
fn init_log(file: &str) {
let mut logger = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"));
logger.format_target(false);
if !std::io::stderr().is_terminal() {
if let Ok(f) = std::fs::File::create(Config::path().with_file_name(file)) {
logger.target(env_logger::Target::Pipe(Box::new(f)));
}
} else {
logger.format_timestamp(None);
}
logger.init();
}

/// Run the background service (what `magicinput run` does).
Expand All @@ -152,18 +185,7 @@ pub fn packaged() -> bool {
}

fn run(mut cfg: Config) {
let mut logger = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"));
logger.format_target(false);
// Started from Finder/Explorer: no terminal to print to, so log next to the config.
if !std::io::stderr().is_terminal() {
let path = Config::path().with_file_name("magicinput.log");
if let Ok(f) = std::fs::File::create(&path) {
logger.target(env_logger::Target::Pipe(Box::new(f)));
}
} else {
logger.format_timestamp(None);
}
logger.init();
init_log("magicinput.log");

if cfg.code.is_empty() {
cfg.code = config::new_code();
Expand Down
Loading
Loading