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: wayland.Context, ) !void { self.* = .{ .handle = try ctx.display.registry.add_object( ctx.allocator, wayland.Object.from_self(self), ), }; } pub fn deinit( self: *Self, ctx: wayland.Context, ) void { ctx.display.registry.disable_object(self.handle); } fn enter( self: *Self, ctx: wayland.Context, output: *wayland.Object, ) void { _ = self; _ = ctx; _ = output; // TODO: implement } fn leave( self: *Self, ctx: wayland.Context, output: *wayland.Object, ) void { _ = self; _ = ctx; _ = output; // TODO: implement } fn preferred_buffer_scale_announced( self: *Self, ctx: wayland.Context, factor: u32, ) void { _ = ctx; self.preferred_buffer_scale = factor; } fn preferred_buffer_transform_announced( self: *Self, ctx: 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), }); }