aboutsummaryrefslogtreecommitdiff
path: root/src/wl/buffer.zig
blob: ae52196890a95a7a10b7c8c78e66b285cef196dd (plain)
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
const std = @import("std");
const wayland = @import("../root.zig");
const wl = wayland.wl;

pub fn Buffer(fmt: wl.Shm.Format) type {
    return struct {
        const Self = @This();

        pub const Request = union(enum) {
            destroy: void,
        };

        pub const Events = wayland.EventSet(Self, .{});

        handle: wayland.Object.Ref = .null,
        init: wayland.Object.interface.Init(Self) = .{},

        data: []wl.Shm.Format.Pixel(fmt),
        width: usize,
        height: usize,

        pub fn format(
            self: *const Self,
            comptime f: []const u8,
            options: std.fmt.FormatOptions,
            writer: anytype,
        ) !void {
            _ = f;
            _ = options;

            try writer.print("wl.buffer<{s}> {{ {}x{} }}", .{
                @tagName(fmt),
                self.width,
                self.height
            });
        }
    };
}