git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit9ac5fee215c8b658ff11d810e9272b9d9ecb7f80
parentbb5e1b3481
authorIsaac Freund <[email protected]>
date2025-12-01 16:08
Output: never send 0 Output dimensions

This is invalid according to the protocol.

This can happen currently due to a race if there are multiple outputs
present with the Wayland backend.

 river/Output.zig | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/river/Output.zig b/river/Output.zig
index b138643..bffff9b 100644
--- a/river/Output.zig
+++ b/river/Output.zig
@@ -197,6 +197,10 @@ pub fn create(wlr_output: *wlr.Output) !void {
     output.scheduled.state = .enabled;
     if (wlr_output.preferredMode()) |preferred_mode| {
         output.scheduled.mode = .{ .standard = preferred_mode };
+    } else {
+        // Use a reasonable default so we can assert(mode != .none) for enabled
+        // outputs in manageStart().
+        output.scheduled.mode = .{ .custom = .{ .width = 1280, .height = 720, .refresh = 0 } };
     }
 
     server.wm.dirtyWindowing();
@@ -233,6 +237,9 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) v
 pub fn manageStart(output: *Output) void {
     switch (output.scheduled.state) {
         .enabled, .disabled_soft => {
+            // We cannot send 0 width/height to the window manager client.
+            assert(output.scheduled.mode != .none);
+
             const wlr_output = output.wlr_output.?;
 
             output.layer_shell.manageStart();