From 299b2b3e3e242df9ad0fd03a8032ced8cf863eb5 Mon Sep 17 00:00:00 2001 From: Hugo Machet Date: Tue, 6 Jun 2023 15:27:52 +0200 Subject: [PATCH] Backend: Cleanup global interfaces versions --- build.zig | 6 +++--- src/Backend.zig | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build.zig b/build.zig index 6ff206c..75a4c49 100644 --- a/build.zig +++ b/build.zig @@ -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", diff --git a/src/Backend.zig b/src/Backend.zig index 4e170a6..4fc0830 100644 --- a/src/Backend.zig +++ b/src/Backend.zig @@ -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| { -- 2.45.2