aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2023-12-05 11:02:17 +0100
committerIsaac Freund <mail@isaacfreund.com>2023-12-05 11:06:27 +0100
commitdeb671bec82a771d1904c5dce897186faf5cfcf9 (patch)
treeb7f58165a3218c8b4b6d933062b10c519a5fb191
parentd207e08dab2fa5fe4a231c7dce038e5980238a6c (diff)
downloadriver-deb671bec82a771d1904c5dce897186faf5cfcf9.tar.gz
river-deb671bec82a771d1904c5dce897186faf5cfcf9.tar.xz
Output: fix initial commit for wayland backend
Also add some more logging
-rw-r--r--river/Output.zig31
1 files changed, 25 insertions, 6 deletions
diff --git a/river/Output.zig b/river/Output.zig
index 165ff10..a51201e 100644
--- a/river/Output.zig
+++ b/river/Output.zig
@@ -195,25 +195,44 @@ pub fn create(wlr_output: *wlr.Output) !void {
if (!wlr_output.initRender(server.allocator, server.renderer)) return error.InitRenderFailed;
- // If the list of modes for the output is empty or if no mode in the list of modes works,
- // we can't enable the output automatically.
+ // If no standard mode for the output works we can't enable the output automatically.
// It will stay disabled unless the user configures a custom mode which works.
- if (wlr_output.preferredMode()) |preferred_mode| {
+ //
+ // For the Wayland backend, the list of modes will be empty and it is possible to
+ // enable the output without setting a mode.
+ {
var state = wlr.Output.State.init();
defer state.finish();
- state.setMode(preferred_mode);
state.setEnabled(true);
+ if (wlr_output.preferredMode()) |preferred_mode| {
+ state.setMode(preferred_mode);
+ }
+
if (!wlr_output.commitState(&state)) {
+ log.err("initial output commit with preferred mode failed, trying all modes", .{});
+
// It is important to try other modes if the preferred mode fails
// which is reported to be helpful in practice with e.g. multiple
// high resolution monitors connected through a usb dock.
var it = wlr_output.modes.iterator(.forward);
while (it.next()) |mode| {
- if (mode == preferred_mode) continue;
state.setMode(mode);
- if (wlr_output.commitState(&state)) break;
+ if (wlr_output.commitState(&state)) {
+ log.info("initial output commit succeeded with mode {}x{}@{}mHz", .{
+ mode.width,
+ mode.height,
+ mode.refresh,
+ });
+ break;
+ } else {
+ log.err("initial output commit failed with mode {}x{}@{}mHz", .{
+ mode.width,
+ mode.height,
+ mode.refresh,
+ });
+ }
}
}
}