Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
output: let wlr_output_layout manage wl_output globals
Creating a wl_output global ourselves causes the wlroots xdg-output
implementation to hit an assertion failure. It's not worth fighting with
these APIs.
river/Output.zig | 12 +++++++-----
river/OutputManager.zig | 1 +
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/river/Output.zig b/river/Output.zig
index eb222db..a05b7ff 100644
--- a/river/Output.zig
+++ b/river/Output.zig
@@ -139,6 +139,7 @@ scheduled: State,
/// State sent to the wm in the latest manage sequence.
sent: State,
link_sent: wl.list.Link,
+sent_wl_output: bool = false,
/// State applied to the wlr_output and rendered.
current: State,
@@ -239,11 +240,12 @@ pub fn manageStart(output: *Output) void {
const pending = &output.scheduled;
const sent = &output.sent;
- if (new) {
- // Ensure that the wl_output global has been created,
- // this is a noop if it already has been.
- wlr_output.createGlobal(server.wl_server);
- output_v1.sendWlOutput(wlr_output.global.?.getName(output_v1.getClient()));
+ if (!output.sent_wl_output) {
+ // wl_output globals are created/destroyed by the wlroots output layout.
+ if (wlr_output.global) |global| {
+ output_v1.sendWlOutput(global.getName(output_v1.getClient()));
+ output.sent_wl_output = true;
+ }
}
const pending_width, const pending_height = pending.dimensions();
diff --git a/river/OutputManager.zig b/river/OutputManager.zig
index 03175cb..1426260 100644
--- a/river/OutputManager.zig
+++ b/river/OutputManager.zig
@@ -259,6 +259,7 @@ pub fn commitOutputState(om: *OutputManager) void {
},
.disabled_hard, .destroying => {
om.output_layout.remove(wlr_output);
+ output.sent_wl_output = false;
},
}
}