1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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: 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),
});
}
|