$ show hyprwm/Hyprland
Hyprland is a dynamic tiling Wayland compositor written in modern C++. It implements a wide range of Wayland protocols (XDG shell, layer shell, screencopy, input methods, color management, etc.) and provides a full desktop environment with OpenGL rendering, blur effects, animations, and Lua-based configuration. The architecture is a monolithic compositor with modular internal components: a protocol layer, desktop state management, layout algorithms (dwindle, master, scrolling, floating, Lua custom), input handling, rendering pipeline (pass elements, blur providers, window transformers), and IPC via Unix sockets. It includes a plugin system (hyprpm) and a test harness (hyprtester) for integration testing. The codebase demonstrates high craftsmanship with reusable patterns like an event bus, signal/slot system, typed config values, damage ring, and promise-based async IPC. It is actively maintained with frequent commits and a large community.
The LLM identified 5 files worth highlighting for reuse:
A generic event bus that allows components to emit and subscribe to typed events without direct coupling. Events are registered as static members of a central bus object, and listeners are managed via RAII handles. This pattern is reusable in any event-driven application and demonstrates clean separation of concerns.
An efficient damage tracking structure for compositor output. It maintains a ring of damage regions across multiple buffer ages, allowing the compositor to compute the minimal region to repaint each frame. The implementation is self-contained and could be extracted for any rendering system that needs per-frame damage accumulation.
Base class for a type-safe config value system. Each config value type (int, float, bool, string, color, gradient, etc.) inherits from IValue and implements serialization, validation, and refresh callbacks. The system uses a registry for caching and supports deprecation and dynamic updates. This pattern is reusable for any application needing a flexible, typed configuration framework.
A composable match engine for window and layer rules. It combines multiple sub-engines (regex, bool, int, workspace, tag) using logical operators (AND, OR, NOT). Each sub-engine is a separate class implementing a common interface, making the system extensible and reusable for any rule-based matching scenario.
A lightweight promise/future implementation for asynchronous IPC responses. It provides a CPromise class that can be resolved with a value or error, and a CPromiseResolver for the producer side. The implementation is header-only and uses std::function for callbacks, making it easy to extract and use in any C++ project needing deferred results.