Add C++20 RAII wrapper around wlroots 0.20 + scenefx

Wraps wlroots' C ABI behind owning types (Display, Backend, Compositor,
Output, XdgShell/Toplevel, Seat/Cursor/Keyboard, Scene/Node/Tree) with
wl_signal -> std::function callbacks. Links the scenefx effect engine and
ships a wlr::fx animation helper. Includes a runnable tinywl-style compositor
and a scene/blur demo.

License: AGPL-3.0-only.
This commit is contained in:
AstralZX
2026-08-29 09:12:28 +02:00
commit 89cbf733b3
20 changed files with 2008 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <functional>
#include "wlr/display.hpp"
#include "wlr/signals.hpp"
#include "wlr/compositor.hpp"
namespace wlr {
class Backend {
public:
explicit Backend(Display& display, bool headless = false) {
m_backend = wlr_backend_autocreate(display.event_loop(), nullptr);
}
~Backend() {
m_newOutput.disconnect();
m_newInput.disconnect();
if (m_backend)
wlr_backend_destroy(m_backend);
}
Backend(const Backend&) = delete;
Backend& operator=(const Backend&) = delete;
struct wlr_backend* raw() const { return m_backend; }
explicit operator bool() const { return m_backend != nullptr; }
bool start() { return wlr_backend_start(m_backend); }
// cb receives struct wlr_output*
void on_new_output(std::function<void(void*)> cb) {
m_newOutput.connect(&m_backend->events.new_output, std::move(cb));
}
// cb receives struct wlr_input_device*
void on_new_input(std::function<void(void*)> cb) {
m_newInput.connect(&m_backend->events.new_input, std::move(cb));
}
private:
struct wlr_backend* m_backend;
SignalSink m_newOutput;
SignalSink m_newInput;
};
}