diff options
Diffstat (limited to 'src/wl/output/root.zig')
| -rw-r--r-- | src/wl/output/root.zig | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/wl/output/root.zig b/src/wl/output/root.zig index fca2ecc..ce2169f 100644 --- a/src/wl/output/root.zig +++ b/src/wl/output/root.zig @@ -30,7 +30,7 @@ pub const Info = struct { description: []const u8, }; -var outputs: std.ArrayListUnmanaged(*Self) = .empty; +pub var instances: std.ArrayListUnmanaged(*Self) = .empty; staging: Info = undefined, info: ?Info = null, @@ -38,12 +38,11 @@ handle: wayland.Object.Ref, pub fn init( self: *Self, - allocator: std.mem.Allocator, - display: *wl.Display, + ctx: *wayland.Context, ) !void { self.* = .{ - .handle = try display.registry.add_object( - allocator, + .handle = try ctx.display.registry.add_object( + ctx.allocator, wayland.Object.from_self(self), ), }; @@ -59,10 +58,11 @@ pub const handler: wl.Registry.GlobalHandler = .{ .handler = register, }; -pub fn register(ctx: *wayland.Context) ?wayland.Object.Ref { +fn register(ctx: *wayland.Context) ?wayland.Object.Ref { const output = ctx.allocator.create(Self) catch return null; - output.init(ctx.allocator, ctx.display) catch return null; - outputs.append(ctx.allocator, output) catch return null; + output.init(ctx) catch return null; + + instances.append(ctx.allocator, output) catch return null; return output.handle; } @@ -132,14 +132,6 @@ fn description(self: *Self, ctx: *wayland.Context, d: []const u8) !void { @memcpy(@constCast(self.staging.description), d); } -pub fn get(index: usize) *Self { - return outputs.items[index]; -} - -pub fn all() []*Self { - return outputs.items; -} - pub fn format( self: *const Self, comptime fmt: []const u8, @@ -149,8 +141,8 @@ pub fn format( _ = fmt; _ = options; if (self.info) |info| { - try writer.print("output({s}) [ {} ]", .{ info.name, info.mode}); + try writer.print("wl.output({s}) [ {} ]", .{ info.name, info.mode}); } else { - try writer.print("output(?)", .{}); + try writer.print("wl.output(?)", .{}); } } |