diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-08-22 20:12:56 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-08-22 20:12:56 +0200 |
| commit | 956ecb061b1862a4b632c8d5d6b6fa4318e1f640 (patch) | |
| tree | f00adc9bfced275f280239b25a2b2ae15f57765b /src/wl/callback.zig | |
| parent | 33e1de2710fe44512440e0e6055578d67dab330c (diff) | |
object refactor and add wl output
Now the Object is held by the registry instead of the struct
its referencing and the struct only has a `handle` which is a usize.
Diffstat (limited to 'src/wl/callback.zig')
| -rw-r--r-- | src/wl/callback.zig | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/wl/callback.zig b/src/wl/callback.zig index 0e7ea5b..c17e190 100644 --- a/src/wl/callback.zig +++ b/src/wl/callback.zig @@ -9,23 +9,26 @@ const Self = @This(); pub const Events = wayland.EventSet(Self, .{done}); is_done: *bool, -interface: wayland.Object, +handle: wayland.Object.Ref, pub fn init( self: *Self, - allocator: std.mem.Allocator, - display: *wl.Display, + ctx: *wayland.Context, is_done: *bool, ) !void { self.is_done = is_done; - self.interface = wayland.Object.from_self(self); - try display.registry.add_object(allocator, &self.interface); - std.debug.print("ids {any}\n", .{display.registry.objects.items}); - std.debug.print("callback #{?}\n", .{self.interface.id}); - try display.request(display, .{ .sync = .{&self.interface} }); + self.handle = try ctx.display.registry.add_object( + ctx.allocator, + wayland.Object.from_self(self), + ); + try ctx.display.request(ctx.display, .{ .sync = .{self.handle} }); } +pub fn deinit(self: *Self, ctx: *wayland.Context) void { + ctx.display.registry.disable_object(self.handle); +} + fn done(self: *Self, ctx: *wayland.Context, value: u32) void { _ = value; _ = ctx; |