A tiny Windows system-tray utility that lets you "pin" any window so it stays on top of other windows. Inspired by DeskPins, rewritten in Rust.
- Launch
pin.exe— a pin icon appears in the system tray. - Left-click the tray icon — your mouse cursor turns into a pin (
pin_off). You are now in selection mode. - Click any window — that window becomes topmost and a small pin badge (
pin_on) appears at the right side of its title bar, just left of the minimize button. - Click the pin badge — the window is unpinned and the badge disappears.
- Right-click the tray icon — opens a menu with
Unpin allandQuit. - In selection mode you can press Esc or right-click anywhere to cancel.
The pin badge follows the target window as you move/resize it (~60 fps).
Requires Rust stable, Windows target.
cargo build --releaseThe binary is at target/release/pin.exe.
Tagged releases are built by GitHub Actions. Pushing a v* tag builds the
Windows release binary, packages it as an MSI installer with WiX/cargo-wix, and
uploads pin-<tag>-windows-x64.msi to the GitHub Release.
Cross-compile from Linux/WSL works too:
rustup target add x86_64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-gnucargo testThere are ~20 unit tests covering icon decoding, geometry math, and pin-set state transitions; plus two Windows-only integration tests that exercise SetWindowPos/GetWindowLong against a real hidden window.
Run with logs:
set RUST_LOG=debug
cargo runsrc/
main.rs — entry point (just calls pin::run)
lib.rs — module declarations
app.rs — main message loop, owns PinnedSet/Tray/Picker
tray.rs — system-tray icon + right-click menu (tray-icon crate)
selection.rs — "selection mode": transparent capture window + SetSystemCursor
overlay.rs — floating pin_on badge: layered topmost window + 16ms timer
pinned.rs — OS-agnostic pin/unpin set (testable with FakeApi)
win.rs — Win32 thin wrapper + WindowApi trait for testability
resources.rs — embedded PNG/ICO + decode/resize/BGRA helpers
tests/
integration_pin.rs — Win32 round-trip test of WS_EX_TOPMOST
Key Win32 design choices (cross-referenced against DeskPins source for prior art):
- Selection mode: 1×1 transparent topmost popup +
SetCaptureto catch the click, plusSetSystemCursor/SystemParametersInfo(SPI_SETCURSORS)to swap the global cursor (the only reliably visible mechanism for a hidden popup). - Overlay:
WS_EX_LAYERED+UpdateLayeredWindowwith premultiplied BGRA so the transparent PNG renders correctly. A 16msSetTimerrepositions the badge over the target and re-appliesHWND_TOPMOSTif the target has been knocked off the topmost group. - No DLL injection / no global hooks — everything runs in one process via standard Win32 APIs.