still working on migrating to the new SceneNodeData

This commit is contained in:
Harrison DiAmbrosio 2025-12-13 00:30:42 -05:00
parent 7a619ab770
commit 1039e3a800
7 changed files with 148 additions and 123 deletions

View file

@ -1,22 +1,25 @@
/// The root of Mezzaluna is, you guessed it, the root of many of the systems mez needs:
/// - Managing outputs
/// -
const Root = @This();
const std = @import("std");
const wl = @import("wayland").server.wl;
const wlr = @import("wlroots");
const Output = @import("Output.zig");
const View = @import("View.zig");
const Utils = @import("Utils.zig");
const server = &@import("main.zig").server;
const gpa = std.heap.c_allocator;
const Output = @import("Output.zig");
const View = @import("View.zig");
const LayerSurface = @import("LayerSurface.zig");
const SceneNodeData = @import("SceneNodeData.zig").SceneNodeData;
const Utils = @import("Utils.zig");
xdg_toplevel_decoration_manager: *wlr.XdgDecorationManagerV1,
scene: *wlr.Scene,
waiting_room: *wlr.SceneTree,
scene_output_layout: *wlr.SceneOutputLayout,
@ -48,8 +51,16 @@ pub fn deinit(self: *Root) void {
while(it.next()) |node| {
if(node.data == null) continue;
const view: *View = @ptrCast(@alignCast(node.data.?));
view.deinit();
const scene_node_data: *SceneNodeData = @ptrCast(@alignCast(node.data.?));
switch(scene_node_data.*) {
.output => {
scene_node_data.output.deinit();
},
else => {
std.log.debug("The root has a child that is not an output", .{});
unreachable;
}
}
}
self.output_layout.destroy();
@ -62,7 +73,16 @@ pub fn viewById(self: *Root, id: u64) ?*View {
while(output_it.next()) |o| {
if(o.output.data == null) continue;
const output: *Output = @ptrCast(@alignCast(o.output.data.?));
const scene_node_data: *SceneNodeData = @ptrCast(@alignCast(o.output.data.?));
const output: *Output = switch (scene_node_data.*) {
.output => |output_ptr| output_ptr,
else => {
std.log.err("Incorrect scene node type found", .{});
unreachable;
}
};
var node_it = output.layers.content.children.iterator(.forward);
while(node_it.next()) |node| {