aboutsummaryrefslogtreecommitdiff
path: root/src/wl/registry.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-08-27 20:34:57 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2025-08-27 20:34:57 +0200
commited0ec55697b11fa54ff661bc6c250398a096f85a (patch)
tree117508816bd25e04e4f8f97c7ffa1cb9d7573dfa /src/wl/registry.zig
parentf0f2124949056e3008416dcd089766a2ef69a08b (diff)
update Object.Ref to be a struct
Diffstat (limited to 'src/wl/registry.zig')
-rw-r--r--src/wl/registry.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/wl/registry.zig b/src/wl/registry.zig
index 0939d17..2c15c67 100644
--- a/src/wl/registry.zig
+++ b/src/wl/registry.zig
@@ -12,7 +12,7 @@ pub const Events = wayland.EventSet(Self, .{
});
pub const Request = union(enum) {
- bind: struct { u32, []const u8, u32, u32 },
+ bind: struct { u32, []const u8, u32, wayland.Object.Ref },
};
pub const GlobalHandler = struct {
@@ -33,13 +33,13 @@ pub fn init(
) !void {
self.* = .{
.handlers = handlers,
- .handle = 2,
+ .handle = .registry,
};
try self.objects.append(allocator, null);
try self.objects.append(allocator, wayland.Object.from_self(display));
try self.objects.append(allocator, wayland.Object.from_self(self));
- display.handle = 1;
+ display.handle = .display;
try display.request(display, .{ .get_registry = .{ self.handle } });
}
@@ -56,26 +56,26 @@ pub fn add_object(
for (self.objects.items[1..], 1..) |obj, index| {
if (obj == null) {
self.objects.items[index] = object;
- return index;
+ return .{ .id = @truncate(index) };
}
}
try self.objects.append(allocator, object);
- return self.objects.items.len - 1;
+ return .{ .id = @truncate(self.objects.items.len - 1) };
}
-pub fn disable_object(self: *Self, id: usize) void {
- if (self.objects.items[id]) |*object| {
+pub fn disable_object(self: *Self, handle: wayland.Object.Ref) void {
+ if (self.objects.items[handle.id]) |*object| {
object.disable();
}
}
-pub fn release_object(self: *Self, id: u32) void {
- self.objects.items[id] = null;
+pub fn release_object(self: *Self, handle: wayland.Object.Ref) void {
+ self.objects.items[handle.id] = null;
}
-pub fn get(self: *Self, handle: usize) ?*wayland.Object {
- if (self.objects.items[handle]) |*objects| {
+pub fn get_by_id(self: *Self, id: u32) ?*wayland.Object {
+ if (self.objects.items[id]) |*objects| {
return objects;
}
return null;
@@ -96,7 +96,7 @@ fn global(
name,
interface,
version,
- @truncate(object_ref),
+ object_ref,
} });
}
}