🪟 Snap windows into place with keyboard shortcuts — Rectangle for Windows.
Quick Start • Features • Hotkeys • Build • Architecture • Contributing
- Download the latest
windows-rectangle-*.exefrom the Releases page - Double-click to run — a blue square icon appears in the system tray
- Start snapping windows with
Ctrl + Alt + Arrow Keys
💡 Start on login: Drop a shortcut into
shell:startup🛑 Quit: Right-click the tray icon → Quit
| Feature | Description | |
|---|---|---|
| 🔲 | Halve Snapping | Snap windows to left / right / top / bottom half |
| 🔳 | Quarter Snapping | Pin windows to any corner of the screen |
| 🔁 | Multi-Monitor Cycling | Press the same direction again to jump to the next monitor |
| ⬆️ | Maximize & Restore | Toggle maximize, center, or restore previous size |
| 📐 | DPI Aware | Per-monitor DPI scaling — crisp on mixed displays |
| 🖥️ | System Tray | Menu lists every binding; clicks act on the last-focused window |
| 📦 | Portable | Single ~1–2 MB exe, no installer needed |
All shortcuts use the Ctrl + Alt modifier:
| Shortcut | Action | Repeat Behavior |
|---|---|---|
| Ctrl + Alt + ← | Halve Left | → Previous monitor |
| Ctrl + Alt + → | Halve Right | → Next monitor |
| Ctrl + Alt + ↑ | Halve Top | — |
| Ctrl + Alt + ↓ | Halve Bottom | — |
| Shortcut | Action |
|---|---|
| Ctrl + Alt + U | Quarter Top-Left |
| Ctrl + Alt + I | Quarter Top-Right |
| Ctrl + Alt + J | Quarter Bottom-Left |
| Ctrl + Alt + K | Quarter Bottom-Right |
| Shortcut | Action |
|---|---|
| Ctrl + Alt + Enter | Maximize / Restore toggle |
| Ctrl + Alt + C | Center window |
| Ctrl + Alt + R | Restore previous size |
Note: Hotkeys are currently hardcoded. A config file / settings GUI may come in a future release.
- Rust stable toolchain
- Target:
x86_64-pc-windows-msvc
cargo build --release --target x86_64-pc-windows-msvcThe binary lands at target\x86_64-pc-windows-msvc\release\windows-rectangle.exe.
You can verify the code compiles from any OS:
cargo check --target x86_64-pc-windows-msvcPlatform-agnostic logic is fully unit-tested and runs on any OS:
cargo test --libsrc/
├── geometry.rs # Pure rect math (halve, quarter, center)
├── adjacency.rs # Multi-monitor neighbor detection
├── cycle_state.rs # Repeat-press → next monitor logic
├── bindings.rs # Hotkey → Action mapping table
├── lib.rs # Public library crate
├── main.rs # Entry point
└── win/ # Win32 platform layer (cfg-gated)
├── monitor # EnumDisplayMonitors
├── window_ops # SetWindowPos, restore stack
├── foreground # Real foreground window cache
├── hotkey # RegisterHotKey / WM_HOTKEY
├── dispatcher # Action router with cycle state
└── tray # System tray icon & menu
Design principles:
- Pure-Rust geometry, adjacency, repeat-cycle state, and bindings — platform-agnostic and fully unit-tested
- Win32 modules gated under
#[cfg(target_os = "windows")] winithosts a hidden message window;RegisterHotKeypostsWM_HOTKEY;SetWinEventHook(EVENT_SYSTEM_FOREGROUND)caches the real foreground window so tray clicks dispatch to the prior app
📄 See
docs/plans/for the full design and implementation plan.
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feat/my-feature - Commit your changes:
git commit -m "feat: add my feature" - Push to the branch:
git push origin feat/my-feature - Open a Pull Request
Please make sure cargo test --lib passes before submitting.
This project is licensed under the MIT License.
Inspired by Rectangle for macOS · Built with ❤️ in Rust
