aboutsummaryrefslogtreecommitdiff
path: root/src/wl/surface.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/wl/surface.zig')
-rw-r--r--src/wl/surface.zig105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/wl/surface.zig b/src/wl/surface.zig
new file mode 100644
index 0000000..7b5116e
--- /dev/null
+++ b/src/wl/surface.zig
@@ -0,0 +1,105 @@
+const std = @import("std");
+const wayland = @import("../root.zig");
+const wl = wayland.wl;
+
+const Self = @This();
+
+pub const Request = union(enum) {
+ destroy: void,
+ attach: struct { ?wayland.Object.Ref, u32, u32 },
+ damage: struct { u32, u32, u32, u32 },
+ frame: struct { wayland.Object.Ref },
+ set_opaque_region: struct { ?wayland.Object.Ref },
+ set_input_region: struct { ?wayland.Object.Ref },
+ commit: void,
+ set_buffer_transform: struct { wl.Output.Format },
+ set_buffer_scale: struct { u32 },
+ damage_buffer: struct { u32, u32, u32, u32 },
+ offset: struct { i32, i32 },
+};
+
+pub const Events = wayland.EventSet(Self, .{
+ enter,
+ leave,
+ preferred_buffer_scale_announced,
+ preferred_buffer_transform_announced,
+});
+
+handle: wayland.Object.Ref,
+preferred_buffer_scale: u32 = 1,
+preferred_buffer_transform: wl.Output.Transform = .normal,
+
+pub fn init(
+ self: *Self,
+ ctx: *const wayland.Context,
+) !void {
+ self.* = .{
+ .handle = try ctx.display.registry.add_object(
+ ctx.allocator,
+ wayland.Object.from_self(self),
+ ),
+ };
+}
+
+pub fn deinit(
+ self: *Self,
+ ctx: *const wayland.Context,
+) void {
+ ctx.display.registry.disable_object(self.handle);
+}
+
+fn enter(
+ self: *Self,
+ ctx: *const wayland.Context,
+ output: *wayland.Object,
+) void {
+ _ = self;
+ _ = ctx;
+ _ = output;
+ // TODO: implement
+}
+
+fn leave(
+ self: *Self,
+ ctx: *const wayland.Context,
+ output: *wayland.Object,
+) void {
+ _ = self;
+ _ = ctx;
+ _ = output;
+ // TODO: implement
+}
+
+fn preferred_buffer_scale_announced(
+ self: *Self,
+ ctx: *const wayland.Context,
+ factor: u32,
+) void {
+ _ = ctx;
+ self.preferred_buffer_scale = factor;
+}
+
+
+fn preferred_buffer_transform_announced(
+ self: *Self,
+ ctx: *const wayland.Context,
+ transform: wl.Output.Transform,
+) void {
+ _ = ctx;
+ self.preferred_buffer_transform = transform;
+}
+
+pub fn format(
+ self: *const Self,
+ comptime fmt: []const u8,
+ options: std.fmt.FormatOptions,
+ writer: anytype,
+) !void {
+ _ = fmt;
+ _ = options;
+
+ try writer.print("wl.surface {{ preferred_scale = {}, preferred_transform = {s} }}", .{
+ self.preferred_buffer_scale,
+ @tagName(self.preferred_buffer_transform),
+ });
+}