windowed
A minimal, zero-dependency cross-platform windowing library for Windows (Win32) and Linux (X11).
No GPU context, no retained scene graph — just a window, an event loop, and raw window handles you can hand off to a renderer like wgpu, ash, or softbuffer.
Platform support
| OS | Backend |
|---|---|
| Windows 10 / 11 | Win32 |
| Linux | X11 |
| macOS | ❌ Not yet implemented |
Quick start
# Cargo.toml
[]
= { = "." }
use ;
Run the bundled example:
WindowConfig
new // sets title, defaults: 800×600, resizable
.size // inner (client area) size in physical pixels
.position // initial top-left screen position (optional)
.resizable; // lock window size
Events
| Event | Description |
|---|---|
CloseRequested |
User clicked the × button or pressed Alt+F4 |
Resized { width, height } |
Window was resized |
FocusGained / FocusLost |
Keyboard focus changed |
KeyDown(Key) / KeyUp(Key) |
Physical key pressed / released |
CharInput(char) |
Translated character (use for text input) |
MouseMove { x, y } |
Cursor moved inside the window |
MouseDown { button, x, y } |
Mouse button pressed |
MouseUp { button, x, y } |
Mouse button released |
MouseWheel { delta } |
Scroll wheel — positive = up/forward |
RedrawRequested |
Window should be redrawn |
KeyDown vs CharInput
- Use
KeyDown/KeyUpfor game controls and hotkeys (physical keys, layout-independent). - Use
CharInputfor text fields (accounts for key-repeat, dead keys, and locale).
ControlFlow
Returned from the event callback to drive the loop:
| Value | Behaviour |
|---|---|
Continue |
Wait for the next OS event (default, CPU-friendly) |
Poll |
Drain events then immediately emit RedrawRequested — use for real-time rendering |
WarpAndPoll(x, y) |
Warp cursor to (x, y) in window coordinates and switch to polling — use for FPS / captured mouse |
Exit |
Stop the event loop and return from Window::run |
Window methods
window.request_redraw; // queue a RedrawRequested event
window.set_title;
window.inner_size; // → (width, height) in physical pixels
window.set_cursor_visible; // hide / show the OS cursor
window.warp_mouse; // move cursor to window-local coordinates
Raw window handles
Window implements HasWindowHandle and HasDisplayHandle from the raw-window-handle crate, so you can pass it directly to wgpu, softbuffer, ash, or any other renderer that accepts those traits.
Dependencies
| Crate | Used on |
|---|---|
raw-window-handle |
All platforms |
License
MIT — see LICENSE for details.
Copyright © 2025 Patrick Reese (Retroboi64)
Made with 🖤 by Retroboi64