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

commit50cd40203cb608fe7c89a1d3a8603ec5fae7f9a5
parentee4351ece6
authorIsaac Freund <[email protected]>
date2023-12-31 10:53
output-management: work around wlroots crash

 deps/zig-wlroots |  2 +-
 river/Root.zig   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/deps/zig-wlroots b/deps/zig-wlroots
index 96dfdc1..9901da0 160000
--- a/deps/zig-wlroots
+++ b/deps/zig-wlroots
@@ -1 +1 @@
-Subproject commit 96dfdc14e99468f4aa6560c8397cd4d0eb0c2827
+Subproject commit 9901da0c3b1a393248a13cc81bc282cfac8d687f
diff --git a/river/Root.zig b/river/Root.zig
index b0c1d8d..a3bd35a 100644
--- a/river/Root.zig
+++ b/river/Root.zig
@@ -770,6 +770,17 @@ fn processOutputConfig(
         var proposed_state = wlr.Output.State.init();
         head.state.apply(&proposed_state);
 
+        // Work around a division by zero in the wlroots drm backend.
+        // See https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3791
+        // TODO(wlroots) remove this workaround after 0.17.2 is out.
+        if (output.wlr_output.isDrm() and
+            proposed_state.committed.mode and
+            proposed_state.mode_type == .custom and
+            proposed_state.custom_mode.refresh == 0)
+        {
+            proposed_state.custom_mode.refresh = 60000;
+        }
+
         switch (action) {
             .test_only => {
                 if (!wlr_output.testState(&proposed_state)) success = false;