Root: fix faulty assertion, cleanup
Thanks to tiosgz for prompting me to look at this more closely. There doesn't seem to be any compelling reason to use the wlr_scene_output_layout helper, it's simpler to just make the two necessary SceneOutput.setPosition() calls manually. This will hopefully be refactored down to a single call eventually as well.
This commit is contained in:
		| @ -40,6 +40,7 @@ const View = @import("View.zig"); | |||||||
| const log = std.log.scoped(.output); | const log = std.log.scoped(.output); | ||||||
|  |  | ||||||
| wlr_output: *wlr.Output, | wlr_output: *wlr.Output, | ||||||
|  | scene_output: *wlr.SceneOutput, | ||||||
|  |  | ||||||
| /// For Root.all_outputs | /// For Root.all_outputs | ||||||
| all_link: wl.list.Link, | all_link: wl.list.Link, | ||||||
| @ -221,11 +222,14 @@ pub fn create(wlr_output: *wlr.Output) !void { | |||||||
|     var height: c_int = undefined; |     var height: c_int = undefined; | ||||||
|     wlr_output.effectiveResolution(&width, &height); |     wlr_output.effectiveResolution(&width, &height); | ||||||
|  |  | ||||||
|  |     const scene_output = try server.root.scene.createSceneOutput(wlr_output); | ||||||
|  |  | ||||||
|     const tree = try server.root.layers.outputs.createSceneTree(); |     const tree = try server.root.layers.outputs.createSceneTree(); | ||||||
|     const normal_content = try tree.createSceneTree(); |     const normal_content = try tree.createSceneTree(); | ||||||
|  |  | ||||||
|     output.* = .{ |     output.* = .{ | ||||||
|         .wlr_output = wlr_output, |         .wlr_output = wlr_output, | ||||||
|  |         .scene_output = scene_output, | ||||||
|         .all_link = undefined, |         .all_link = undefined, | ||||||
|         .active_link = undefined, |         .active_link = undefined, | ||||||
|         .tree = tree, |         .tree = tree, | ||||||
|  | |||||||
| @ -90,7 +90,6 @@ views: wl.list.Head(View, .link), | |||||||
| new_output: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleNewOutput), | new_output: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleNewOutput), | ||||||
|  |  | ||||||
| output_layout: *wlr.OutputLayout, | output_layout: *wlr.OutputLayout, | ||||||
| scene_output_layout: *wlr.SceneOutputLayout, |  | ||||||
| layout_change: wl.Listener(*wlr.OutputLayout) = wl.Listener(*wlr.OutputLayout).init(handleLayoutChange), | layout_change: wl.Listener(*wlr.OutputLayout) = wl.Listener(*wlr.OutputLayout).init(handleLayoutChange), | ||||||
|  |  | ||||||
| output_manager: *wlr.OutputManagerV1, | output_manager: *wlr.OutputManagerV1, | ||||||
| @ -134,8 +133,6 @@ pub fn init(self: *Self) !void { | |||||||
|     const outputs = try interactive_content.createSceneTree(); |     const outputs = try interactive_content.createSceneTree(); | ||||||
|     const xwayland_override_redirect = if (build_options.xwayland) try interactive_content.createSceneTree(); |     const xwayland_override_redirect = if (build_options.xwayland) try interactive_content.createSceneTree(); | ||||||
|  |  | ||||||
|     const scene_output_layout = try scene.attachOutputLayout(output_layout); |  | ||||||
|  |  | ||||||
|     _ = try wlr.XdgOutputManagerV1.create(server.wl_server, output_layout); |     _ = try wlr.XdgOutputManagerV1.create(server.wl_server, output_layout); | ||||||
|  |  | ||||||
|     const presentation = try wlr.Presentation.create(server.wl_server, server.backend); |     const presentation = try wlr.Presentation.create(server.wl_server, server.backend); | ||||||
| @ -176,7 +173,6 @@ pub fn init(self: *Self) !void { | |||||||
|         }, |         }, | ||||||
|         .views = undefined, |         .views = undefined, | ||||||
|         .output_layout = output_layout, |         .output_layout = output_layout, | ||||||
|         .scene_output_layout = scene_output_layout, |  | ||||||
|         .all_outputs = undefined, |         .all_outputs = undefined, | ||||||
|         .active_outputs = undefined, |         .active_outputs = undefined, | ||||||
|         .output_manager = try wlr.OutputManagerV1.create(server.wl_server), |         .output_manager = try wlr.OutputManagerV1.create(server.wl_server), | ||||||
| @ -364,14 +360,9 @@ pub fn activateOutput(root: *Self, output: *Output) void { | |||||||
|         // possible to handle after updating to 0.17. |         // possible to handle after updating to 0.17. | ||||||
|         @panic("TODO handle allocation failure here"); |         @panic("TODO handle allocation failure here"); | ||||||
|     }; |     }; | ||||||
|     const scene_output = root.scene.createSceneOutput(output.wlr_output) catch { |  | ||||||
|         // See above |  | ||||||
|         @panic("TODO handle allocation failure here"); |  | ||||||
|     }; |  | ||||||
|     root.scene_output_layout.addOutput(layout_output, scene_output); |  | ||||||
|  |  | ||||||
|     output.tree.node.setEnabled(true); |     output.tree.node.setEnabled(true); | ||||||
|     output.tree.node.setPosition(layout_output.x, layout_output.y); |     output.tree.node.setPosition(layout_output.x, layout_output.y); | ||||||
|  |     output.scene_output.setPosition(layout_output.x, layout_output.y); | ||||||
|  |  | ||||||
|     // If we previously had no outputs, move all views to the new output and focus it. |     // If we previously had no outputs, move all views to the new output and focus it. | ||||||
|     if (first) { |     if (first) { | ||||||
| @ -780,10 +771,14 @@ fn processOutputConfig( | |||||||
|                 if (wlr_output.commitState(&proposed_state)) { |                 if (wlr_output.commitState(&proposed_state)) { | ||||||
|                     if (head.state.enabled) { |                     if (head.state.enabled) { | ||||||
|                         // Just updates the output's position if it is already in the layout |                         // Just updates the output's position if it is already in the layout | ||||||
|                         // This can't fail if the output is already in the layout, which we know to be the case here. |                         _ = self.output_layout.add(output.wlr_output, head.state.x, head.state.y) catch { | ||||||
|                         _ = self.output_layout.add(output.wlr_output, head.state.x, head.state.y) catch unreachable; |                             std.log.err("out of memory", .{}); | ||||||
|  |                             success = false; | ||||||
|  |                             continue; | ||||||
|  |                         }; | ||||||
|                         output.tree.node.setEnabled(true); |                         output.tree.node.setEnabled(true); | ||||||
|                         output.tree.node.setPosition(head.state.x, head.state.y); |                         output.tree.node.setPosition(head.state.x, head.state.y); | ||||||
|  |                         output.scene_output.setPosition(head.state.x, head.state.y); | ||||||
|                         // Even though we call this in the output's handler for the mode event |                         // Even though we call this in the output's handler for the mode event | ||||||
|                         // it is necessary to call it here as well since changing e.g. only |                         // it is necessary to call it here as well since changing e.g. only | ||||||
|                         // the transform will require the dimensions of the background to be |                         // the transform will require the dimensions of the background to be | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user