aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortiosgz <alamica@protonmail.com>2022-07-10 08:57:53 +0000
committerIsaac Freund <mail@isaacfreund.com>2022-07-10 19:17:15 +0200
commitbc610c8b829904335298bde38dc9d8bc44a67aec (patch)
tree442c084b4ff1aaa5b28c771634f74e25d2223091
parent403eca90a5956a62259dc252ca0dbcd332790580 (diff)
downloadriver-bc610c8b829904335298bde38dc9d8bc44a67aec.tar.gz
river-bc610c8b829904335298bde38dc9d8bc44a67aec.tar.xz
Output: retry other modes if preferred fails
In cases like multiple hi-res monitors connected through a USB dock, the preferred mode can fail to work. Such an output was then ignored by river, which made it impossible to even set another mode manually. Sway has been reported to solve this issue, so let's employ their solution and fall back to another mode if possible.
-rw-r--r--river/Output.zig17
1 files changed, 14 insertions, 3 deletions
diff --git a/river/Output.zig b/river/Output.zig
index 0cc86c2..ac69dd7 100644
--- a/river/Output.zig
+++ b/river/Output.zig
@@ -105,10 +105,21 @@ pub fn init(self: *Self, wlr_output: *wlr.Output) !void {
// refresh rate), and each monitor supports only a specific set of modes. We
// just pick the monitor's preferred mode, a more sophisticated compositor
// would let the user configure it.
- if (wlr_output.preferredMode()) |mode| {
- wlr_output.setMode(mode);
+ if (wlr_output.preferredMode()) |preferred_mode| {
+ wlr_output.setMode(preferred_mode);
wlr_output.enable(true);
- try wlr_output.commit();
+ wlr_output.commit() catch |err| {
+ var it = wlr_output.modes.iterator(.forward);
+ while (it.next()) |mode| {
+ if (mode == preferred_mode) continue;
+ wlr_output.setMode(mode);
+ wlr_output.commit() catch continue;
+ // This mode works, use it
+ break;
+ } else {
+ return err;
+ }
+ };
}
self.* = .{