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

const log = std.log.scoped(.callback);

const Self = @This();

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

is_done: *bool,
interface: wayland.Object,

pub fn init(
    self: *Self,
    allocator: std.mem.Allocator,
    display: *wl.Display,
    is_done: *bool,
) !void {
    self.is_done = is_done;
    self.interface = wayland.Object.from_self(self);
    try display.registry.add_object(allocator, &self.interface);
    std.debug.print("ids {any}\n", .{display.registry.objects.items});
    std.debug.print("callback #{?}\n", .{self.interface.id});
    try display.request(display, .{ .sync = .{&self.interface} });

}

fn done(self: *Self, ctx: *wayland.Context, value: u32) void {
    _ = value;
    _ = ctx;
    self.is_done.* = true;
}