winit creates native windows and runs event loops in Rust, dispatching input and window events so higher-level GUI or graphics code can hook in.
Overview
winit is a Rust library for cross-platform window creation and event loop management. Applications first build an EventLoop, then create one or more Window instances and process events such as resize, keyboard input, pointer movement, and close requests.
It is intentionally low level: it does not render graphics itself. Instead it exposes raw window and display handles so callers or companion crates can attach OpenGL, Vulkan, DirectX, Metal, or similar contexts. Multi-window programs match events to windows by ID.
The library supports logical and physical coordinates and emits scale factor changes when a window moves between monitors or DPI settings change. Platform-specific behavior lives behind optional platform modules, with Cargo features for X11, Wayland, raw-window-handle versions, serde, and mint interoperability on Unix and other targets.
Event handling uses EventLoop::run_app rather than a polling iterator model, though a pump-events extension exists on some platforms for compatibility. winit sits as a foundation layer for game engines, custom UIs, and other Rust graphical tooling.
Key features
- Cross-platform event loop
- Window create and lifecycle
- Keyboard and pointer events
- Raw window handle access
- Multi-window support
- DPI and scale factor events
- X11 and Wayland backends
- Custom user events
Use cases
- Rust game window setup
- Custom GUI engine foundation
- Graphics API bootstrap
- Cross-platform desktop tooling
- Event-driven visual applications