aboutsummaryrefslogtreecommitdiff
path: root/src/wl/output
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-08-22 20:52:30 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2025-08-22 20:52:30 +0200
commit07c3f2e8f82c55ed191f72fa5e9f3935b1913f98 (patch)
tree48b4ce0e9029efeb9da6f6f95f4ae798d14df14d /src/wl/output
parent956ecb061b1862a4b632c8d5d6b6fa4318e1f640 (diff)
add first sketch of wl.compositor
Diffstat (limited to 'src/wl/output')
-rw-r--r--src/wl/output/root.zig28
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(?)", .{});
}
}