Oxidized Frames: Rust Window Manager

Traditional window managers (X11-based or C-written Wayland compositors) often suffer from two extremes: they are either incredibly fast but prone to segfaults (C), or highly extensible but sluggish and resource-heavy (Lua/Python). I needed a daily driver that offered absolute memory safety without sacrificing the raw performance required for high-refresh-rate window management.

Selected Rust as the core implementation language, leveraging the Smithay library for Wayland plumbing and the 'fearless concurrency' model for handling asynchronous input events.

C / C++ (using wlroots)

Pros
  • The industry standard for Wayland compositors
  • Widest hardware compatibility
Cons
  • Manual memory management leads to frequent 'ghost' crashes
  • Harder to manage complex state (e.g., dynamic tiling trees) safely

Haskell (XMonad style)

Pros
  • Extremely expressive for layout logic
  • Strong type system
Cons
  • Garbage collection pauses can cause 'stutter' during window animations
  • Steep learning curve for community contributions

Rust provides the 'safety-without-overhead' profile essential for a core OS component. By using Rust's ownership model, I can represent the window tree—a notoriously difficult data structure to manage—without fearing use-after-free bugs. Furthermore, the performance matches C, but the modern tooling (Cargo) and ecosystem allow for faster iteration on features like IPC and hot-reloading.

Additional Context

The project was born out of a desire to move away from the aging X11 protocol while avoiding the instability of early Wayland implementations. By building on Rust, I was able to treat the window manager not just as a tool, but as a reliable piece of infrastructure.

The core challenge involved managing the Z-Order and Focus State. In many C-based managers, a pointer error in the focus logic can crash the entire graphical session. In this implementation, I utilized Rust’s Enums and Pattern Matching to handle window states, ensuring that it is logically impossible to have a window that is simultaneously ‘hidden’ and ‘focused.‘

High-Performance IPC

I implemented a custom IPC (Inter-Process Communication) protocol using Unix Domain Sockets. This allows external scripts to query the WM state or trigger layout changes. Because Rust’s serde ecosystem is so robust, the overhead for serializing window metadata into JSON for third-party bars (like Waybar) is negligible, maintaining that < 1% CPU target even under heavy workspace switching.