diff --git a/river/Output.zig b/river/Output.zig index 010e6d4..2319f43 100644 --- a/river/Output.zig +++ b/river/Output.zig @@ -95,6 +95,8 @@ mode: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleMode), frame: wl.Listener(*wlr.OutputDamage) = wl.Listener(*wlr.OutputDamage).init(handleFrame), pub fn init(self: *Self, wlr_output: *wlr.Output) !void { + assert(!wlr_output.isNoop()); + // Some backends don't have modes. DRM+KMS does, and we need to set a mode // before we can use the output. The mode is a tuple of (width, height, // refresh rate), and each monitor supports only a specific set of modes. We @@ -119,34 +121,24 @@ pub fn init(self: *Self, wlr_output: *wlr.Output) !void { self.damage.events.frame.add(&self.frame); - if (wlr_output.isNoop()) { - // A noop output is always 0 x 0 - self.usable_box = .{ - .x = 0, - .y = 0, - .width = 0, - .height = 0, - }; - } else { - // Ensure that a cursor image at the output's scale factor is loaded - // for each seat. - var it = server.input_manager.seats.first; - while (it) |node| : (it = node.next) { - const seat = &node.data; - seat.cursor.xcursor_manager.load(wlr_output.scale) catch - std.log.scoped(.cursor).err("failed to load xcursor theme at scale {}", .{wlr_output.scale}); - } - - const effective_resolution = self.getEffectiveResolution(); - self.usable_box = .{ - .x = 0, - .y = 0, - .width = effective_resolution.width, - .height = effective_resolution.height, - }; - - self.setTitle(); + // Ensure that a cursor image at the output's scale factor is loaded + // for each seat. + var it = server.input_manager.seats.first; + while (it) |node| : (it = node.next) { + const seat = &node.data; + seat.cursor.xcursor_manager.load(wlr_output.scale) catch + std.log.scoped(.cursor).err("failed to load xcursor theme at scale {}", .{wlr_output.scale}); } + + const effective_resolution = self.getEffectiveResolution(); + self.usable_box = .{ + .x = 0, + .y = 0, + .width = effective_resolution.width, + .height = effective_resolution.height, + }; + + self.setTitle(); } pub fn getLayer(self: *Self, layer: zwlr.LayerShellV1.Layer) *std.TailQueue(LayerSurface) { diff --git a/river/Root.zig b/river/Root.zig index 3d443b0..a74d0ee 100644 --- a/river/Root.zig +++ b/river/Root.zig @@ -94,16 +94,20 @@ pub fn init(self: *Self) !void { const transaction_timer = try event_loop.addTimer(*Self, handleTransactionTimeout, self); errdefer transaction_timer.remove(); + const noop_wlr_output = try server.noop_backend.noopAddOutput(); self.* = .{ .output_layout = output_layout, .output_manager = try wlr.OutputManagerV1.create(server.wl_server), .power_manager = try wlr.OutputPowerManagerV1.create(server.wl_server), .transaction_timer = transaction_timer, - .noop_output = undefined, + .noop_output = .{ + .wlr_output = noop_wlr_output, + // TODO: find a good way to not create a wlr.OutputDamage for the noop output + .damage = try wlr.OutputDamage.create(noop_wlr_output), + .usable_box = .{ .x = 0, .y = 0, .width = 0, .height = 0 }, + }, }; - - const noop_wlr_output = try server.noop_backend.noopAddOutput(); - try self.noop_output.init(noop_wlr_output); + noop_wlr_output.data = @ptrToInt(&self.noop_output); server.backend.events.new_output.add(&self.new_output); self.output_manager.events.apply.add(&self.manager_apply); @@ -113,14 +117,6 @@ pub fn init(self: *Self) !void { } pub fn deinit(self: *Self) void { - // Need to remove these listeners as the noop output will be destroyed with - // the noop backend triggering the destroy event. However, - // Output.handleDestroy is not intended to handle the noop output being - // destroyed. - self.noop_output.destroy.link.remove(); - self.noop_output.frame.link.remove(); - self.noop_output.mode.link.remove(); - self.output_layout.destroy(); self.transaction_timer.remove(); }