From a46436e58beaaa322c082af5e886f96fd31d7a08 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 30 Aug 2025 15:49:18 +0200 Subject: Use mix-in design for interface abstraction. --- src/wl/output/root.zig | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'src/wl/output/root.zig') diff --git a/src/wl/output/root.zig b/src/wl/output/root.zig index 61c1798..9cffd43 100644 --- a/src/wl/output/root.zig +++ b/src/wl/output/root.zig @@ -30,40 +30,22 @@ pub const Info = struct { description: []const u8, }; -pub var instances: std.ArrayListUnmanaged(*Self) = .empty; staging: Info = undefined, info: ?Info = null, -handle: wayland.Object.Ref, - -pub fn init( - self: *Self, - ctx: wayland.Context, -) !void { - self.* = .{ - .handle = try ctx.display.registry.add_object( - ctx.allocator, - wayland.Object.from_self(self), - ), - }; -} -pub fn deinit(self: *Self, display: *wl.Display) !void { - display.request(self, .{ .release = void{} }); -} +handle: wayland.Object.Ref, +init: wayland.Object.interface.Init(Self) = .{}, +pub var globals: wayland.Object.interface.Global(Self) = .init; pub const handler: wl.Registry.GlobalHandler = .{ .interface = "wl_output", .version = 4, - .handler = register, + .handler = globals.register, }; -fn register(ctx: wayland.Context) ?wayland.Object.Ref { - const output = ctx.allocator.create(Self) catch return null; - output.init(ctx) catch return null; - - instances.append(ctx.allocator, output) catch return null; - return output.handle; +pub fn deinit(self: *Self, display: *wl.Display) !void { + display.request(self, .{ .release = void{} }); } fn geometry( -- cgit v1.2.3-70-g09d2