~novakane/zelbar

299b2b3e3e242df9ad0fd03a8032ced8cf863eb5 — Hugo Machet 8 months ago e404000
Backend: Cleanup global interfaces versions
2 files changed, 11 insertions(+), 6 deletions(-)

M build.zig
M src/Backend.zig
M build.zig => build.zig +3 -3
@@ 60,11 60,11 @@ pub fn build(b: *Builder) !void {

    exe.addPackagePath("flags", "common/flags.zig");

    scanner.generate("wl_compositor", 5);
    scanner.generate("wl_compositor", 4);
    scanner.generate("wl_shm", 1);
    scanner.generate("wl_output", 4);
    scanner.generate("wl_seat", 8);
    scanner.generate("zwlr_layer_shell_v1", 4);
    scanner.generate("wl_seat", 5);
    scanner.generate("zwlr_layer_shell_v1", 3);

    const wayland = std.build.Pkg{
        .name = "wayland",

M src/Backend.zig => src/Backend.zig +8 -3
@@ 728,10 728,13 @@ fn registry_event(backend: *Backend, registry: *wl.Registry, event: wl.Registry.
    switch (event) {
        .global => |ev| {
            if (std.cstr.cmp(ev.interface, wl.Compositor.getInterface().name) == 0) {
                backend.compositor = try registry.bind(ev.name, wl.Compositor, 5);
                // Version 4 required for wl_surface.damage_buffer.
                if (ev.version < 4) fatal_version(wl.Compositor, ev.version, 4);
                backend.compositor = try registry.bind(ev.name, wl.Compositor, 4);
            } else if (std.cstr.cmp(ev.interface, wl.Shm.getInterface().name) == 0) {
                backend.shm = try registry.bind(ev.name, wl.Shm, 1);
            } else if (std.cstr.cmp(ev.interface, wl.Output.getInterface().name) == 0) {
                // Version 4 required for wl_output.name.
                if (ev.version < 4) fatal_version(wl.Output, ev.version, 4);

                const wl_output = try registry.bind(ev.name, wl.Output, 4);


@@ 743,9 746,10 @@ fn registry_event(backend: *Backend, registry: *wl.Registry, event: wl.Registry.
                try node.data.init(wl_output, ev.name);
                backend.outputs.prepend(node);
            } else if (std.cstr.cmp(ev.interface, wl.Seat.getInterface().name) == 0) {
                // Version 5 required for wl_seat.release.
                if (ev.version < 5) fatal_version(wl.Seat, ev.version, 5);

                const wl_seat = try registry.bind(ev.name, wl.Seat, 8);
                const wl_seat = try registry.bind(ev.name, wl.Seat, 5);
                errdefer wl_seat.release();

                const node = try ctx.gpa.create(std.SinglyLinkedList(Seat).Node);


@@ 754,8 758,9 @@ fn registry_event(backend: *Backend, registry: *wl.Registry, event: wl.Registry.
                try node.data.init(wl_seat, ev.name);
                backend.seats.prepend(node);
            } else if (std.cstr.cmp(ev.interface, zwlr.LayerShellV1.getInterface().name) == 0) {
                // Version 3 required for layer_shell.destroy();
                if (ev.version < 3) fatal_version(zwlr.LayerShellV1, ev.version, 3);
                backend.layer_shell = try registry.bind(ev.name, zwlr.LayerShellV1, 4);
                backend.layer_shell = try registry.bind(ev.name, zwlr.LayerShellV1, 3);
            }
        },
        .global_remove => |ev| {