RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
Finish migrating wlroots bindings to the in-tree facade
oxydizer24cac9239d78
diff --git a/AGENTS.md b/AGENTS.mdindex d7705ec..45a1f60 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -256,15 +256,13 @@ panel painting. The key rules:in comptime defaults.* `std.os.linux.*` return `-errno` in `usize` (`std.os.linux.errno`);`std.posix.system.*` are libc (`std.posix.errno`).-* zig-wlroots: `ext.*`/`wp.*` types need the protocol in `build.zig`'s- scanner. `ForeignToplevelHandleV1.event.Fullscreen.output` and- `ScreencopyFrameV1.buffer` can be NULL: read through `*const ?*T`.- `wlr.Pointer` is 8 bytes short: embed it in an extern wrapper- (`input/virtual.zig`) or `wlr_pointer_init` overwrites the next field.- `src/wlr/` is migrating `wlr.*` off this hand-mirrored dependency onto an- in-tree `@cImport` facade, one subsystem at a time, to stop depending on- zig-wlroots's own release cadence; read `src/wlr/AGENTS.md` before adding- a new wlr type or forwarding one off `old`.+* **wlroots bindings** live in `src/wlr/`, backed by one `@cImport` against+ the installed headers; read `src/wlr/AGENTS.md` before extending them.+ `ext.*`/`wp.*` Wayland types need their protocol in `build/protocols.zig`.+ Nullable outputs/buffers are represented explicitly. Full layout checks+ protect embedded input devices, so no extra Pointer padding is needed.+ `zig build test-wlroots` validates every exported binding and C input-device+ initialization; it also runs as part of `zig build test`.* Debug `main.gpa` is `DebugAllocator`: freed memory reads `0xaa…` (glibc`MALLOC_PERTURB_`: `0xa5…`), leaks print at exit in the compositor log. Freeprocess-lifetime caches in `main.start`'s defers; state workers read duringdiff --git a/TESTING.md b/TESTING.mdindex ef0eae1..ac869a7 100644--- a/TESTING.md+++ b/TESTING.md@@ -8,6 +8,10 @@ zig build testpython3 tests/<name>.py```+`zig build test-wlroots` checks the complete exported wlroots API against the+installed headers and tests embedded input-device lifecycles; it is included+in `zig build test`.+Run affected integration suites after building. Find suites and flags in[tests/](tests/) and build targets in [build/tests.zig](build/tests.zig).Compare failures with a clean HEAD worktree before calling them regressions.diff --git a/build.zig b/build.zigindex b4d598c..6a8ccff 100644--- a/build.zig+++ b/build.zig@@ -35,38 +35,26 @@ pub fn build(b: *std.Build) void {const wayland = protocols.module(b);const xkbcommon = b.dependency("xkbcommon", .{}).module("xkbcommon");const pixman = b.dependency("pixman", .{}).module("pixman");- const wlroots_dep = b.dependency("wlroots", .{}).module("wlroots");-- wlroots_dep.addImport("wayland", wayland);- wlroots_dep.addImport("xkbcommon", xkbcommon);- wlroots_dep.addImport("pixman", pixman);-- // Expose the wlroots include path from pkg-config to its @cImport calls.- wlroots_dep.resolved_target = target;- wlroots_dep.linkSystemLibrary("wlroots-0.20", .{});-- // In-tree facade over wlroots (src/wlr/AGENTS.md / top-level AGENTS.md's- // "zig-wlroots" note): migrates off zig-wlroots onto @cImport one- // subsystem at a time. Everything not yet migrated forwards to the real- // zig-wlroots module above, imported here as "old". Every existing user- // of the module named `wlroots` below gets the facade transparently.- const wlr_facade = b.createModule(.{ .root_source_file = b.path("src/wlr/wlr.zig") });- wlr_facade.addImport("old", wlroots_dep);+ // One header-backed module supplies every compositor wlroots binding.+ const wlr_facade = b.createModule(.{+ .root_source_file = b.path("src/wlr/wlr.zig"),+ .target = target,+ .optimize = optimize,+ .link_libc = true,+ });wlr_facade.addImport("wayland", wayland);wlr_facade.addImport("pixman", pixman);- wlr_facade.resolved_target = target;+ wlr_facade.addImport("xkbcommon", xkbcommon);wlr_facade.linkSystemLibrary("wlroots-0.20", .{});- // wlr/types/wlr_output_power_management_v1.h #includes its protocol's- // generated server header; wlroots doesn't install that header for- // consumers, so generate it the same way build/protocols.zig's scanner- // does internally, just emitting a C header instead of Zig bindings.- const output_power_protocol_header = blk: {+ // These public wlroots headers include protocol headers which wlroots+ // does not install. Generate them from the same XML as our Zig bindings.+ inline for (.{ "wlr-output-power-management-unstable-v1", "wlr-layer-shell-unstable-v1" }) |name| {const run = b.addSystemCommand(&.{ "wayland-scanner", "server-header" });- run.addFileArg(b.path("protocol/wlr-output-power-management-unstable-v1.xml"));- break :blk run.addOutputFileArg("wlr-output-power-management-unstable-v1-protocol.h");- };- wlr_facade.addIncludePath(output_power_protocol_header.dirname());+ run.addFileArg(b.path("protocol/" ++ name ++ ".xml"));+ const header = run.addOutputFileArg(name ++ "-protocol.h");+ wlr_facade.addIncludePath(header.dirname());+ }const wlroots = wlr_facade;diff --git a/build.zig.zon b/build.zig.zonindex e28ec89..910129c 100644--- a/build.zig.zon+++ b/build.zig.zon@@ -17,11 +17,6 @@.url = "https://www.leonerd.org.uk/code/libvterm/libvterm-0.3.3.tar.gz",.hash = "N-V-__8AAFwIBQAS1j3S14ozuJ18ebNtLQ-c5Kl6W4J7PoJt",},- // v0.20.1 is the current Zig 0.16-compatible release for wlroots 0.20.- .wlroots = .{- .url = "https://github.com/swaywm/zig-wlroots/archive/refs/tags/v0.20.1.tar.gz",- .hash = "wlroots-0.20.1-jmOlcqNVBAB3uB5oqBTzpRlwu-FmMyyZMVAWCe5kmcSt",- },.pixman = .{.url = "https://codeberg.org/ifreund/zig-pixman/archive/v0.3.0.tar.gz",.hash = "pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX",diff --git a/build/protocols.zig b/build/protocols.zigindex 24902f0..2eaa36f 100644--- a/build/protocols.zig+++ b/build/protocols.zig@@ -7,6 +7,12 @@ const Scanner = @import("wayland").Scanner;pub fn module(b: *std.Build) *std.Build.Module {const scanner = Scanner.create(b, .{});scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");+ scanner.addSystemProtocol("stable/linux-dmabuf/linux-dmabuf-v1.xml");+ scanner.generate("zwp_linux_dmabuf_v1", 5);+ scanner.addSystemProtocol("staging/ext-image-capture-source/ext-image-capture-source-v1.xml");+ scanner.generate("ext_output_image_capture_source_manager_v1", 1);+ scanner.addSystemProtocol("staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml");+ scanner.generate("ext_image_copy_capture_manager_v1", 1);scanner.addSystemProtocol("unstable/text-input/text-input-unstable-v3.xml");scanner.generate("zwp_text_input_manager_v3", 1);scanner.addSystemProtocol("staging/xdg-activation/xdg-activation-v1.xml");diff --git a/build/tests.zig b/build/tests.zigindex c0f04b6..9fea793 100644--- a/build/tests.zig+++ b/build/tests.zig@@ -95,6 +95,10 @@ pub fn addZig(ctx: Context, session: Session) ZigTests {const run_ipc_tests = b.addRunArtifact(ipc_tests);const test_step = b.step("test", "Run the project unit tests");+ const wlroots_tests = b.addTest(.{ .root_module = wlroots });+ const run_wlroots_tests = b.addRunArtifact(wlroots_tests);+ test_step.dependOn(&run_wlroots_tests.step);+ b.step("test-wlroots", "Check every exported wlroots binding against its C headers").dependOn(&run_wlroots_tests.step);const i18n_tests = b.addTest(.{ .root_module = i18n_mod });const run_i18n_tests = b.addRunArtifact(i18n_tests);test_step.dependOn(&run_i18n_tests.step);diff --git a/src/Input.zig b/src/Input.zigindex c1bdafe..20a4407 100644--- a/src/Input.zig+++ b/src/Input.zig@@ -322,8 +322,7 @@ pub fn init(input: *Input, server: *Server) Server.CompositorError!void {input.seat.events.request_set_primary_selection.add(&input.request_set_primary_selection);errdefer input.request_set_primary_selection.link.remove();- // Cursor hasn't migrated off zig-wlroots; see wlr.zig's `zig_wlroots` note.- input.cursor.attachOutputLayout(@ptrCast(server.output_layout));+ input.cursor.attachOutputLayout(server.output_layout);input.cursor_mgr.load(1) catch return error.XcursorCreateFailed;input.cursor.events.motion.add(&input.cursor_motion);input.cursor.events.motion_absolute.add(&input.cursor_motion_absolute);diff --git a/src/LayerSurface.zig b/src/LayerSurface.zigindex 14d4ccd..b6726b6 100644--- a/src/LayerSurface.zig+++ b/src/LayerSurface.zig@@ -20,13 +20,11 @@ output_destroy: wl.Listener(*wlr.Output) = .init(outputDestroyed),output_commit: wl.Listener(*wlr.Output.event.Commit) = .init(outputCommitted),pub fn create(server: *Server, layer: *wlr.LayerSurfaceV1) !void {- // LayerSurfaceV1 hasn't migrated off zig-wlroots, so layer.output is- // still zig-wlroots's own Output; cast both ways at this boundary.- const output: *wlr.Output = (if (layer.output) |o| @as(*wlr.Output, @ptrCast(o)) else null) orelse defaultOutput(server) orelse {+ const output: *wlr.Output = layer.output orelse defaultOutput(server) orelse {layer.destroy();return;};- layer.output = @ptrCast(output);+ layer.output = output;const self = try gpa.create(Self);errdefer gpa.destroy(self);const tree = try server.desktop_tree.createSceneTree();@@ -72,8 +70,7 @@ pub fn arrange(self: *Self) void {};self.tree.node.reparent(parent);var full: wlr.Box = undefined;- // LayerSurfaceV1 hasn't migrated off zig-wlroots; see create()'s cast.- const wlr_output: ?*wlr.Output = @ptrCast(self.layer.output);+ const wlr_output = self.layer.output;self.server.output_layout.getBox(wlr_output, &full);const output = Output.fromWlr(wlr_output.?);if (output) |out| if (out.idle_blanked) {@@ -125,7 +122,7 @@ fn place(self: *Self, full: *const wlr.Box, usable: *wlr.Box) void {if (self.layer.surface.mapped and state.exclusive_zone > 0) {const zone = state.exclusive_zone;- const edge = wlr_layer_surface_v1_get_exclusive_edge(self.layer);+ const edge = self.layer.getExclusiveEdge();if (edge.top) {usable.y +%= zone +% margin.top;usable.height -%= zone +% margin.top;@@ -141,7 +138,6 @@ fn place(self: *Self, full: *const wlr.Box, usable: *wlr.Box) void {usable.height = @max(usable.height, 0);}}-extern fn wlr_layer_surface_v1_get_exclusive_edge(surface: *wlr.LayerSurfaceV1) wlr.Edges;fn committed(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {const self: *Self = @fieldParentPtr("commit", listener);diff --git a/src/Output.zig b/src/Output.zigindex 70c293e..44d7b31 100644--- a/src/Output.zig+++ b/src/Output.zig@@ -20,19 +20,8 @@ const output_panels = @import("output/panels.zig");const output_wallpaper = @import("output/wallpaper.zig");const output_frame = @import("output/frame.zig");-pub extern fn wlr_color_transform_init_lut_3x1d(- dim: usize,- r: [*]const u16,- g: [*]const u16,- b: [*]const u16,-) ?*wlr.ColorTransform;--pub extern fn wlr_color_transform_unref(tr: *wlr.ColorTransform) void;--pub extern fn wlr_output_state_set_color_transform(- state: *wlr.Output.State,- tr: ?*wlr.ColorTransform,-) void;+pub const wlr_color_transform_init_lut_3x1d = wlr.color.transformInitLut3x1d;+pub const wlr_color_transform_unref = wlr.color.transformUnref;pub const ColorKey = struct {temperature: u16,@@ -239,7 +228,7 @@ pub fn create(server: *Server, wlr_output: *wlr.Output) !void {wlr_output.lockSoftwareCursors(true);log.info("{s}: software cursor ({s} virtual GPU)", .{ wlr_output.name, driver });}- output.vblank_timer =server.wl_server.getEventLoop().addTimer(*Output, handleVblank, output) catch null;+ output.vblank_timer = server.wl_server.getEventLoop().addTimer(*Output, handleVblank, output) catch null;errdefer if (output.vblank_timer) |timer| timer.remove();// Layout entry and scene output are addons on `wlr_output`. On error thediff --git a/src/Popup.zig b/src/Popup.zigindex 311b3f9..d71458f 100644--- a/src/Popup.zig+++ b/src/Popup.zig@@ -94,9 +94,7 @@ fn unconstrainToOutput(server: *Server, xdg_popup: *wlr.XdgPopup) void {windowConstraintBox(server, toplevel, ox, oy)elselayoutConstraintBox(server, ox, oy)) orelse return;- // XdgPopup hasn't migrated off zig-wlroots; see wlr.zig's- // assertSameLayout(Box, old.Box) for why this cast is safe.- xdg_popup.unconstrainFromBox(@ptrCast(&box));+ xdg_popup.unconstrainFromBox(&box);}/// Popups of layer surfaces live in layout space, like the output box.diff --git a/src/Server.zig b/src/Server.zigindex 4958888..e87862a 100644--- a/src/Server.zig+++ b/src/Server.zig@@ -114,10 +114,7 @@ output_renderer: *scene_output_mod.Renderer = undefined,read_fence: ?*explicit_sync.ReadFence = null,output_layout: *wlr.OutputLayout,-// Backend hasn't migrated off zig-wlroots yet, so its new_output signal-// still emits zig-wlroots's own Output (see src/wlr/wlr.zig's-// `zig_wlroots` note); server/outputs.zig's newOutput casts it back.-new_output: wl.Listener(*wlr.zig_wlroots.Output) = .init(newOutput),+new_output: wl.Listener(*wlr.Output) = .init(newOutput),shell: Shell,background_tree: *sn.Tree,@@ -641,9 +638,7 @@ pub fn init(server: *Server, scale: ?f32, icon_theme_cfg: icon_theme.Config, io:} else {log.info("init: explicit sync unavailable (renderer/backend lack timelines or disabled)", .{});}- // XdgOutputManagerV1 hasn't migrated off zig-wlroots; see wlr.zig's- // `zig_wlroots` note.- server.xdg_output_manager = wlr.XdgOutputManagerV1.create(server.wl_server, @ptrCast(server.output_layout)) catch return error.XdgOutputManagerCreateFailed;+ server.xdg_output_manager = wlr.XdgOutputManagerV1.create(server.wl_server, server.output_layout) catch return error.XdgOutputManagerCreateFailed;_ = wlr.Presentation.create(server.wl_server, server.backend, 2) catch return error.PresentationCreateFailed;server.capture_mgr = capture.Manager.create(server) catch |err| blk: {log.warn("init: could not create screen-capture manager, sharing disabled: {}", .{err});diff --git a/src/Switcher.zig b/src/Switcher.zigindex 64d46c0..4c193ab 100644--- a/src/Switcher.zig+++ b/src/Switcher.zig@@ -218,9 +218,7 @@ fn updatePreview(card: *Card, tl: *@import("Toplevel.zig")) void {card.pw = 0;if (tl.surface()) |surface| {if (surface.current.transform == .normal) if (surface.buffer) |buffer| {- // Surface hasn't migrated off zig-wlroots; see wlr.zig's- // assertSameLayout(FBox, old.FBox) for why this cast is safe.- surface.getBufferSourceBox(@ptrCast(&card.source));+ surface.getBufferSourceBox(&card.source);const sw: f32 = @floatFromInt(@max(1, surface.current.width));const sh: f32 = @floatFromInt(@max(1, surface.current.height));const fit = @min(208 / sw, 140 / sh);diff --git a/src/capture/manager.zig b/src/capture/manager.zigindex 3f5643f..677ef82 100644--- a/src/capture/manager.zig+++ b/src/capture/manager.zig@@ -241,14 +241,11 @@ pub const Manager = struct {/// wlroots copies in its own commit listener, so refusing means/// disconnecting the client first, as `handleNewSession` does.pub fn guardScreencopy(mgr: *Manager, output: *wlr.Output) void {- // ScreencopyFrameV1 hasn't migrated off zig-wlroots; see wlr.zig's- // `zig_wlroots` note.- const old_output: *wlr.zig_wlroots.Output = @ptrCast(output);const refuse = mgr.server.polkit_dialog != null or mgr.server.locker != null;var copying = false;var it = mgr.screencopy.frames.safeIterator(.forward);while (it.next()) |frame| {- if (frame.output != old_output or !copyRequested(frame)) continue;+ if (frame.output != output or !copyRequested(frame)) continue;if (refuse) {// Destroying the client frees its other frames too.frame.resource.getClient().destroy();@@ -295,10 +292,9 @@ fn monotonicMs() i64 {return @as(i64, ts.sec) * 1000 + @divTrunc(ts.nsec, 1_000_000);}-/// wlroots sets `buffer` on the copy request; zig-wlroots declares it non-null.+/// wlroots sets `buffer` when the client requests a copy.fn copyRequested(frame: *wlr.ScreencopyFrameV1) bool {- const buffer: *const ?*wlr.Buffer = @ptrCast(&frame.buffer);- return buffer.* != null;+ return frame.buffer != null;}/// Resolves a session's source back to the window it captures, if any@@ -336,9 +332,7 @@ const Session = struct {tracked.* = .{.manager = manager,.resource = session.resource,- // ExtImageCaptureSourceV1 hasn't migrated off zig-wlroots; see- // wlr.zig's `zig_wlroots` note.- .output = @ptrCast(session.source.toOutput()),+ .output = session.source.toOutput(),.window_id = if (findWindowSource(manager, session.source)) |ws| ws.window_id else null,};session.events.destroy.add(&tracked.destroy);diff --git a/src/capture/window_source.zig b/src/capture/window_source.zigindex 7cf0595..864c3e1 100644--- a/src/capture/window_source.zig+++ b/src/capture/window_source.zig@@ -50,13 +50,6 @@ const PassShape = extern struct {};extern fn rediwm_scene_pass_add_texture_shaped(pass: *wlr.RenderPass, options: *const wlr.RenderPass.TextureOptions, shape: *const PassShape) void;-// Not bound in the pinned zig-wlroots package; declared directly the same-// way every other binding file in that package declares its extern fns.-// Fills in the well-known CIE1931 xy chromaticities for a named primary set-// so `wlr.RenderPass.TextureOptions.primaries` isn't left pointing at-// uninitialized memory.-extern fn wlr_color_primaries_from_named(out: *wlr.color.Primaries, named: wlr.color.NamedPrimaries) void;-pub const WindowCaptureSource = struct {base: wlr.ExtImageCaptureSourceV1,manager: *@import("manager.zig").Manager,@@ -204,7 +197,7 @@ pub const WindowCaptureSource = struct {if (self.swapchain == null or self.swap_width != geom.width or self.swap_height != geom.height) {if (self.swapchain) |sc| sc.destroy();self.swapchain = null;- const format = pickFormat(server.renderer);+ const format = try pickFormat(server.renderer);self.swapchain = try wlr.Swapchain.create(server.allocator, geom.width, geom.height, @constCast(format));self.swap_width = geom.width;self.swap_height = geom.height;@@ -242,7 +235,7 @@ pub const WindowCaptureSource = struct {});var primaries: wlr.color.Primaries = undefined;- wlr_color_primaries_from_named(&primaries, .srgb);+ wlr.color.primariesFromNamed(&primaries, .srgb);var ctx: RenderCtx = .{.pass = pass,.renderer = server.renderer,@@ -294,9 +287,7 @@ pub const WindowCaptureSource = struct {var luminance_multiplier: f32 = 1.0;const options: wlr.RenderPass.TextureOptions = .{.texture = texture,- // RenderPass hasn't migrated off zig-wlroots; see wlr.zig's- // assertSameLayout(FBox, old.FBox) for why this cast is safe.- .src_box = @bitCast(scene_buffer.src_box),+ .src_box = scene_buffer.src_box,.dst_box = .{.x = sx - ctx.off_x,.y = sy - ctx.off_y,@@ -338,13 +329,14 @@ pub const WindowCaptureSource = struct {log.warn("window capture source (window {d}): copy_frame called with no rendered buffer", .{self.window_id});return;};- dst_frame.copyBuffer(buf, self.manager.server.renderer);+ // A failed copy reports failure and destroys the frame inside wlroots.+ if (!dst_frame.copyBuffer(buf, self.manager.server.renderer)) return;var now = Output.timestamp();dst_frame.ready(.normal, &now);}};-fn pickFormat(renderer: *wlr.Renderer) *const wlr.DrmFormat {- const set = renderer.getTextureFormats(renderer.render_buffer_caps).?;- return set.get(DRM_FORMAT_ARGB8888);+fn pickFormat(renderer: *wlr.Renderer) !*const wlr.DrmFormat {+ const set = renderer.getTextureFormats(renderer.render_buffer_caps) orelse return error.NoTextureFormats;+ return set.get(DRM_FORMAT_ARGB8888) orelse error.UnsupportedCaptureFormat;}diff --git a/src/foreign_toplevel.zig b/src/foreign_toplevel.zigindex ebe95ab..fdf6fe4 100644--- a/src/foreign_toplevel.zig+++ b/src/foreign_toplevel.zig@@ -76,10 +76,8 @@ pub const Handle = struct {self.outputelse if (toplevel.currentOutput()) |o| o.wlr_output else null;if (output != self.output) {- // ForeignToplevelHandleV1 hasn't migrated off zig-wlroots; see- // Server.zig's new_output for the same kind of crossing.- if (self.output) |o| handle.outputLeave(@ptrCast(o));- if (output) |o| handle.outputEnter(@ptrCast(o));+ if (self.output) |o| handle.outputLeave(o);+ if (output) |o| handle.outputEnter(o);self.output = output;}@@ -149,10 +147,7 @@ pub const Handle = struct {if (self.blocked() or self.toplevel.minimized) return;const toplevel = self.toplevel;if (event.fullscreen) {- // zig-wlroots declares this non-null; wlroots sends NULL when the- // client names no output.- const raw: *const ?*wlr.Output = @ptrCast(&event.output);- const requested = if (raw.*) |o| Output.fromWlr(o) else null;+ const requested = if (event.output) |o| Output.fromWlr(o) else null;if (requested) |output| {toplevel.setFullscreenOn(output);} else if (!toplevel.isFullscreen()) {diff --git a/src/input/axis.zig b/src/input/axis.zigindex 8f205c9..cb00bde 100644--- a/src/input/axis.zig+++ b/src/input/axis.zig@@ -17,12 +17,12 @@ pub fn cursorAxis(event: *wlr.Pointer.event.Axis,) void {const input: *Input = @fieldParentPtr("cursor_axis", listener);- if (input.blockedVirtual(event.device)) return;- if (input.zoom_device != event.device) {+ if (input.blockedVirtual(&event.pointer.base)) return;+ if (input.zoom_device != &event.pointer.base) {input.zoom_scroll.reset();input.wheel_debounce = .{ .{}, .{} };}- input.zoom_device = event.device;+ input.zoom_device = &event.pointer.base;var delta = event.delta;var delta_discrete = event.delta_discrete;if (event.source == .wheel and delta_discrete != 0) {diff --git a/src/input/buttons.zig b/src/input/buttons.zigindex 1159822..9d10ec7 100644--- a/src/input/buttons.zig+++ b/src/input/buttons.zig@@ -20,8 +20,8 @@ pub fn cursorButton(event: *wlr.Pointer.event.Button,) void {const input: *Input = @fieldParentPtr("cursor_button", listener);- if (input.blockedVirtual(event.device)) return;- input.processButton(event.device, event.button, event.state, event.time_msec);+ if (input.blockedVirtual(&event.pointer.base)) return;+ input.processButton(&event.pointer.base, event.button, event.state, event.time_msec);}pub fn processButton(diff --git a/src/input/motion.zig b/src/input/motion.zigindex 228f9e9..406b8ce 100644--- a/src/input/motion.zig+++ b/src/input/motion.zig@@ -21,7 +21,7 @@ pub fn cursorMotion(event: *wlr.Pointer.event.Motion,) void {const input: *Input = @fieldParentPtr("cursor_motion", listener);- if (input.blockedVirtual(event.device)) return;+ if (input.blockedVirtual(&event.pointer.base)) return;@import("../startup.zig").markFirstInput();if (input.server.idle) |im| im.notifyActivity(.pointer);@@ -32,7 +32,7 @@ pub fn cursorMotion(dy *= mult;if (input.server.locker != null or input.server.polkit_dialog != null) {- input.cursor.move(event.device, dx, dy);+ input.cursor.move(&event.pointer.base, dx, dy);input.lockClientMotion(event.time_msec);return;}@@ -41,7 +41,7 @@ pub fn cursorMotion(if (input.server.screenshot_selector.output == null and input.isPanModifierHeld() and input.active_buttons == 0 and !input.server.world.mini_map.dragging and !input.cursorOverTaskbar()) {const inhibited = if (input.pan_session) |sess| sess.inhibited and sess.trigger == .super_key else false;if (!inhibited) {- input.startPan(.super_key, event.device);+ input.startPan(.super_key, &event.pointer.base);}}}@@ -50,7 +50,7 @@ pub fn cursorMotion(if (input.pan_session) |*sess| if (!sess.inhibited) {const prev_x = input.cursor.x;const prev_y = input.cursor.y;- input.cursor.move(event.device, dx, dy);+ input.cursor.move(&event.pointer.base, dx, dy);const actual_dx = input.cursor.x - prev_x;const actual_dy = input.cursor.y - prev_y;@@ -65,7 +65,7 @@ pub fn cursorMotion(}const allowed = input.pointer_constraints.clientMotion(event.time_msec, dx, dy, event.unaccel_dx, event.unaccel_dy) orelse return;- input.cursor.move(event.device, allowed.dx, allowed.dy);+ input.cursor.move(&event.pointer.base, allowed.dx, allowed.dy);input.processCursorMotion(event.time_msec);input.pointer_constraints.sync();}@@ -75,12 +75,12 @@ pub fn cursorMotionAbsolute(event: *wlr.Pointer.event.MotionAbsolute,) void {const input: *Input = @fieldParentPtr("cursor_motion_absolute", listener);- if (input.blockedVirtual(event.device)) return;+ if (input.blockedVirtual(&event.pointer.base)) return;if (input.server.idle) |im| im.notifyActivity(.pointer);var x: f64 = undefined;var y: f64 = undefined;- input.cursor.absoluteToLayoutCoords(event.device, event.x, event.y, &x, &y);- input.layoutMotion(event.device, x, y, event.time_msec);+ input.cursor.absoluteToLayoutCoords(&event.pointer.base, event.x, event.y, &x, &y);+ input.layoutMotion(&event.pointer.base, x, y, event.time_msec);}/// Absolute pointer motion to a layout point: pointer devices, and touch anddiff --git a/src/input/tablet.zig b/src/input/tablet.zigindex 4031c75..7125a9c 100644--- a/src/input/tablet.zig+++ b/src/input/tablet.zig@@ -220,11 +220,11 @@ fn setCursor(listener: *wl.Listener(*wlr.TabletV2TabletTool.event.SetCursor), evfn handleAxis(listener: *wl.Listener(*wlr.Tablet.event.Axis), event: *wlr.Tablet.event.Axis) void {const self: *Self = @fieldParentPtr("axis", listener);const tool = self.toolFor(event.tool) orelse return;- const tablet = self.findTablet(event.device) orelse return;+ const tablet = self.findTablet(&event.tablet.base) orelse return;if (self.input.server.idle) |im| im.notifyActivity(.tablet);const axes = event.updated_axes;if (axes.x or axes.y) {- self.moveTool(tablet, tool, event.device, if (axes.x) event.x else std.math.nan(f64), if (axes.y) event.y else std.math.nan(f64), event.dx, event.dy, event.time_msec);+ self.moveTool(tablet, tool, &event.tablet.base, if (axes.x) event.x else std.math.nan(f64), if (axes.y) event.y else std.math.nan(f64), event.dx, event.dy, event.time_msec);}if (axes.tilt_x) tool.tilt_x = event.tilt_x;if (axes.tilt_y) tool.tilt_y = event.tilt_y;@@ -241,7 +241,7 @@ fn handleAxis(listener: *wl.Listener(*wlr.Tablet.event.Axis), event: *wlr.Tabletfn handleProximity(listener: *wl.Listener(*wlr.Tablet.event.Proximity), event: *wlr.Tablet.event.Proximity) void {const self: *Self = @fieldParentPtr("proximity", listener);const tool = self.toolFor(event.tool) orelse return;- const tablet = self.findTablet(event.device) orelse return;+ const tablet = self.findTablet(&event.tablet.base) orelse return;if (event.state == .out) {self.leaveClient(tool);self.leavePointer(tool, event.time_msec);@@ -250,9 +250,9 @@ fn handleProximity(listener: *wl.Listener(*wlr.Tablet.event.Proximity), event: *}if (self.input.server.idle) |im| im.notifyActivity(.tablet);if (tool.relative()) {- self.moveTool(tablet, tool, event.device, std.math.nan(f64), std.math.nan(f64), 0, 0, event.time_msec);+ self.moveTool(tablet, tool, &event.tablet.base, std.math.nan(f64), std.math.nan(f64), 0, 0, event.time_msec);} else {- self.moveTool(tablet, tool, event.device, event.x, event.y, 0, 0, event.time_msec);+ self.moveTool(tablet, tool, &event.tablet.base, event.x, event.y, 0, 0, event.time_msec);}}@@ -260,7 +260,7 @@ fn handleTip(listener: *wl.Listener(*wlr.Tablet.event.Tip), event: *wlr.Tablet.econst self: *Self = @fieldParentPtr("tip", listener);const input = self.input;const tool = self.toolFor(event.tool) orelse return;- const tablet = self.findTablet(event.device) orelse return;+ const tablet = self.findTablet(&event.tablet.base) orelse return;if (event.state == .down) {if (input.server.idle) |im| {if (im.state != .active) {@@ -270,7 +270,7 @@ fn handleTip(listener: *wl.Listener(*wlr.Tablet.event.Tip), event: *wlr.Tablet.e}im.notifyActivity(.tablet);}- if (tool.route == .none) self.moveTool(tablet, tool, event.device, event.x, event.y, 0, 0, event.time_msec);+ if (tool.route == .none) self.moveTool(tablet, tool, &event.tablet.base, event.x, event.y, 0, 0, event.time_msec);tool.tip_down = true;switch (tool.route) {.client => {@@ -279,8 +279,8 @@ fn handleTip(listener: *wl.Listener(*wlr.Tablet.event.Tip), event: *wlr.Tablet.e},else => {tool.route = .pointer;- tool.device = event.device;- input.processButton(event.device, Input.btn_left, .pressed, event.time_msec);+ tool.device = &event.tablet.base;+ input.processButton(&event.tablet.base, Input.btn_left, .pressed, event.time_msec);input.seat.pointerNotifyFrame();},}@@ -296,10 +296,10 @@ fn handleTip(listener: *wl.Listener(*wlr.Tablet.event.Tip), event: *wlr.Tablet.e.client => {if (tool.v2) |v2| v2.notifyUp();// Lifted over another surface: hand the tool to it now.- self.moveTool(tablet, tool, event.device, std.math.nan(f64), std.math.nan(f64), 0, 0, event.time_msec);+ self.moveTool(tablet, tool, &event.tablet.base, std.math.nan(f64), std.math.nan(f64), 0, 0, event.time_msec);},.pointer => {- input.processButton(event.device, Input.btn_left, .released, event.time_msec);+ input.processButton(&event.tablet.base, Input.btn_left, .released, event.time_msec);input.seat.pointerNotifyFrame();},.none => {},@@ -325,8 +325,8 @@ fn handleButton(listener: *wl.Listener(*wlr.Tablet.event.Button), event: *wlr.Taif (pressed == (tool.held_buttons & bit != 0)) return;tool.held_buttons ^= bit;tool.route = .pointer;- tool.device = event.device;- input.processButton(event.device, pointerButton(bit), if (pressed) .pressed else .released, event.time_msec);+ tool.device = &event.tablet.base;+ input.processButton(&event.tablet.base, pointerButton(bit), if (pressed) .pressed else .released, event.time_msec);input.seat.pointerNotifyFrame();}diff --git a/src/input/text_input.zig b/src/input/text_input.zigindex a7e25ba..959b59c 100644--- a/src/input/text_input.zig+++ b/src/input/text_input.zig@@ -56,9 +56,8 @@ pub fn destroy(self: *Self) void {gpa.destroy(self);}-extern fn wlr_input_device_get_virtual_keyboard(device: *wlr.InputDevice) ?*wlr.VirtualKeyboardV1;pub fn isVirtual(device: *wlr.InputDevice) bool {- return wlr_input_device_get_virtual_keyboard(device) != null;+ return device.getVirtualKeyboard() != null;}pub fn keyboardGrab(self: *Self, keyboard: *wlr.Keyboard) ?*wlr.InputMethodV2.KeyboardGrab {@@ -67,7 +66,7 @@ pub fn keyboardGrab(self: *Self, keyboard: *wlr.Keyboard) ?*wlr.InputMethodV2.Keinput.open_wifi != null or input.open_battery != null or input.open_calendar != null or input.open_start_menu != null or (if (input.open_control_center) |cc| cc.hasKeyboardFocus() else false) or input.open_power_menu != null) return null;const method = self.method orelse return null;const grab = self.grab orelse return null;- if (wlr_input_device_get_virtual_keyboard(&keyboard.base)) |virtual| {+ if (keyboard.base.getVirtualKeyboard()) |virtual| {// IMEs reinject unhandled keys with their own virtual keyboard.// Sending those back into the grab would create an infinite loop.if (virtual.resource.getClient() == method.resource.getClient()) return null;@@ -397,10 +396,7 @@ pub fn updatePopups(self: *Self) void {y = layout.y;scale *= self.server.world.camera.zoom();} else if (wlr.LayerSurfaceV1.tryFromWlrSurface(surface.getRootSurface()) == null) break :visible false;- // TextInputV3 hasn't migrated off zig-wlroots, so- // cursor_rectangle is still its own Box type; match it here- // instead of casting, since only .x/.y/.width are read below.- const rect = if (input.active_features.cursor_rectangle) input.current.cursor_rectangle else @TypeOf(input.current.cursor_rectangle){ .x = 0, .y = 0, .width = surface.current.width, .height = surface.current.height };+ const rect = if (input.active_features.cursor_rectangle) input.current.cursor_rectangle else wlr.Box{ .x = 0, .y = 0, .width = surface.current.width, .height = surface.current.height };// Rectangle coordinates are client-controlled signed 32-bit values.// Zoom and adding the scene origin can exceed that range.const rx: i64 = @intFromFloat(@round(x + @as(f64, @floatFromInt(rect.x)) * scale));@@ -418,10 +414,7 @@ pub fn updatePopups(self: *Self) void {const relative = wlr.Box{ .x = wireCoordinate(rx - px), .y = wireCoordinate(ry - py), .width = wireCoordinate(rw), .height = wireCoordinate(rh) };if (popup.last_rectangle == null or !std.meta.eql(popup.last_rectangle.?, relative)) {var box = relative;- // InputPopupSurfaceV2 hasn't migrated off zig-wlroots; see- // wlr.zig's assertSameLayout(Box, old.Box) for why this- // cast is safe.- popup.popup.sendTextInputRectangle(@ptrCast(&box));+ popup.popup.sendTextInputRectangle(&box);popup.last_rectangle = relative;}break :visible true;diff --git a/src/input/touch.zig b/src/input/touch.zigindex 8a3922d..ebee6b2 100644--- a/src/input/touch.zig+++ b/src/input/touch.zig@@ -94,7 +94,7 @@ pub fn remap(self: *Self) void {fn mapDevice(self: *Self, device: *wlr.InputDevice) void {const touch = device.toTouch();- const wanted: ?[]const u8 = if (touch.output_name[0] != 0) std.mem.span(touch.output_name) else null;+ const wanted: ?[]const u8 = if (touch.output_name) |name| (if (name[0] != 0) std.mem.span(name) else null) else null;var target: ?*Output = null;var it = self.input.server.outputs.iterator(.forward);while (it.next()) |output| {@@ -106,8 +106,7 @@ fn mapDevice(self: *Self, device: *wlr.InputDevice) void {target = output;}}- // Cursor hasn't migrated off zig-wlroots; see wlr.zig's `zig_wlroots` note.- self.input.cursor.mapInputToOutput(device, if (target) |t| @ptrCast(t.wlr_output) else null);+ self.input.cursor.mapInputToOutput(device, if (target) |t| t.wlr_output else null);}fn handleDestroy(listener: *wl.Listener(*wlr.InputDevice), _: *wlr.InputDevice) void {@@ -144,7 +143,7 @@ fn handleDown(listener: *wl.Listener(*wlr.Touch.event.Down), event: *wlr.Touch.eif (self.find(event.touch_id)) |stale| self.endPoint(stale, event.time_msec, true);if (self.point_count == max_points) return;- var point: Point = .{ .id = event.touch_id, .device = event.device, .route = .ignored };+ var point: Point = .{ .id = event.touch_id, .device = &event.touch.base, .route = .ignored };defer {self.points[self.point_count] = point;self.point_count += 1;@@ -160,7 +159,7 @@ fn handleDown(listener: *wl.Listener(*wlr.Touch.event.Down), event: *wlr.Touch.evar lx: f64 = undefined;var ly: f64 = undefined;- input.cursor.absoluteToLayoutCoords(event.device, event.x, event.y, &lx, &ly);+ input.cursor.absoluteToLayoutCoords(&event.touch.base, event.x, event.y, &lx, &ly);if (self.emulating == null and input.directInputReachesClients()) {const hit = scene_data.hitTest(server, lx, ly);if (input.clientTarget(hit, lx, ly)) |target| {@@ -177,8 +176,8 @@ fn handleDown(listener: *wl.Listener(*wlr.Touch.event.Down), event: *wlr.Touch.eif (self.emulating != null or input.seat.touchNumPoints() > 0) return;self.emulating = event.touch_id;point.route = .pointer;- input.layoutMotion(event.device, lx, ly, event.time_msec);- input.processButton(event.device, Input.btn_left, .pressed, event.time_msec);+ input.layoutMotion(&event.touch.base, lx, ly, event.time_msec);+ input.processButton(&event.touch.base, Input.btn_left, .pressed, event.time_msec);input.seat.pointerNotifyFrame();}@@ -205,14 +204,14 @@ fn handleMotion(listener: *wl.Listener(*wlr.Touch.event.Motion), event: *wlr.Touif (input.server.idle) |im| im.notifyActivity(.touch);var lx: f64 = undefined;var ly: f64 = undefined;- input.cursor.absoluteToLayoutCoords(event.device, event.x, event.y, &lx, &ly);+ input.cursor.absoluteToLayoutCoords(&event.touch.base, event.x, event.y, &lx, &ly);switch (point.route) {.client => |anchor| {const local = anchor.local(input, lx, ly);input.seat.touchNotifyMotion(event.time_msec, event.touch_id, local.x, local.y);},.pointer => {- input.layoutMotion(event.device, lx, ly, event.time_msec);+ input.layoutMotion(&event.touch.base, lx, ly, event.time_msec);input.seat.pointerNotifyFrame();},.ignored => {},diff --git a/src/input/virtual.zig b/src/input/virtual.zigindex 8ca17a9..beda86b 100644--- a/src/input/virtual.zig+++ b/src/input/virtual.zig@@ -9,18 +9,6 @@ const Pointer = @import("../Pointer.zig");const log = std.log.scoped(.virtual_input);-pub const PointerImpl = extern struct {- name: [*:0]const u8,-};--pub const KeyboardImpl = extern struct {- name: [*:0]const u8,- led_update: ?*const fn (keyboard: *wlr.Keyboard, leds: u32) callconv(.c) void = null,-};--extern fn wlr_pointer_init(pointer: *wlr.Pointer, impl: *const PointerImpl, name: [*:0]const u8) void;-extern fn wlr_pointer_finish(pointer: *wlr.Pointer) void;-pub const KeyInfo = struct {evdev_keycode: u32,shift: bool,@@ -45,7 +33,7 @@ pub const Sequence = struct {pub const SyntheticKeyboard = struct {// wlroots retains the implementation pointer for the device lifetime.- const impl = KeyboardImpl{ .name = "synthetic-keyboard" };+ const impl = wlr.Keyboard.Impl{ .name = "synthetic-keyboard" };server: *Server,wlr_kbd: wlr.Keyboard = undefined,sym_map: std.AutoHashMap(xkb.Keysym, KeyInfo),@@ -66,7 +54,7 @@ pub const SyntheticKeyboard = struct {const keymap = xkb.Keymap.newFromNames(context, &.{ .rules = null, .model = null, .layout = "us", .variant = "", .options = "" }, .no_flags) orelse return error.KeyboardInitFailed;defer keymap.unref();- wlr.Keyboard.init(&synthetic.wlr_kbd, @ptrCast(&impl), "synthetic-keyboard");+ wlr.Keyboard.init(&synthetic.wlr_kbd, &impl, "synthetic-keyboard");errdefer wlr.Keyboard.finish(&synthetic.wlr_kbd);errdefer synthetic.sym_map.deinit();@@ -162,17 +150,11 @@ pub const SyntheticKeyboard = struct {};pub const SyntheticPointer = struct {- const impl = PointerImpl{ .name = "synthetic-pointer" };+ const impl = wlr.Pointer.Impl{ .name = "synthetic-pointer" };server: *Server,- wlr_ptr: CPointer = undefined,+ wlr_ptr: wlr.Pointer = undefined,allocator: std.mem.Allocator,- /// zig-wlroots 0.20.1's `wlr.Pointer` omits the C struct's trailing- /// `void *data` (336 vs 344 bytes), which `wlr_pointer_init` zeroes. The- /// extern wrapper keeps that write inside this field; it used to clear- /// `allocator.ptr`, which only libc malloc could ignore.- const CPointer = extern struct { base: wlr.Pointer, data: ?*anyopaque };-pub fn create(server: *Server, allocator: std.mem.Allocator) !*SyntheticPointer {const synthetic = try allocator.create(SyntheticPointer);errdefer allocator.destroy(synthetic);@@ -182,22 +164,22 @@ pub const SyntheticPointer = struct {.allocator = allocator,};- wlr_pointer_init(&synthetic.wlr_ptr.base, &impl, "synthetic-pointer");- errdefer wlr_pointer_finish(&synthetic.wlr_ptr.base);+ wlr.Pointer.init(&synthetic.wlr_ptr, &impl, "synthetic-pointer");+ errdefer wlr.Pointer.finish(&synthetic.wlr_ptr);- server.input.cursor.attachInputDevice(&synthetic.wlr_ptr.base.base);- try Pointer.create(&server.input, &synthetic.wlr_ptr.base.base);+ server.input.cursor.attachInputDevice(&synthetic.wlr_ptr.base);+ try Pointer.create(&server.input, &synthetic.wlr_ptr.base);return synthetic;}pub fn destroy(synthetic: *SyntheticPointer) void {- wlr_pointer_finish(&synthetic.wlr_ptr.base);+ wlr.Pointer.finish(&synthetic.wlr_ptr);synthetic.allocator.destroy(synthetic);}pub fn sendButton(synthetic: *SyntheticPointer, time_msec: u32, button: u32, state: wl.Pointer.ButtonState) void {- synthetic.server.input.processButton(&synthetic.wlr_ptr.base.base, button, state, time_msec);+ synthetic.server.input.processButton(&synthetic.wlr_ptr.base, button, state, time_msec);synthetic.server.input.seat.pointerNotifyFrame();}};diff --git a/src/ipc/handlers_state.zig b/src/ipc/handlers_state.zigindex 9ea3203..ea4c009 100644--- a/src/ipc/handlers_state.zig+++ b/src/ipc/handlers_state.zig@@ -63,9 +63,7 @@ pub fn handleStateRequest(};const surface = toplevel.surface() orelse return .{ .err = "WindowNotVisible" };var src_box: wlr.FBox = undefined;- // Surface hasn't migrated off zig-wlroots; see wlr.zig's- // assertSameLayout(FBox, old.FBox) for why this cast is safe.- surface.getBufferSourceBox(@ptrCast(&src_box));+ surface.getBufferSourceBox(&src_box);const geometry_box = toplevel.clientGeometry();const decorated = toplevel.hasServerDecorations();diff --git a/src/libinput.zig b/src/libinput.zigindex 7b1a304..beb6f88 100644--- a/src/libinput.zig+++ b/src/libinput.zig@@ -4,7 +4,7 @@// AGENTS.md, "Build and platform gotchas") so it's @cInclude'd directly rather than hand-declared.//// `wlr.InputDevice.getLibinputDevice()` returns a pointer to an opaque type-// private to zig-wlroots' own bindings; since it carries no fields on either+// from the wlroots facade's C import; since it carries no fields on either// side, a plain `@ptrCast` onto libinput.h's own `struct libinput_device*`// is safe and avoids needing to name that private type at all.const wlr = @import("wlroots");diff --git a/src/notifications_tests.zig b/src/notifications_tests.zigindex 9ef139f..a8f0521 100644--- a/src/notifications_tests.zig+++ b/src/notifications_tests.zig@@ -39,8 +39,7 @@ test "notifications unit: replaces_id, urgency, DND, lock suppression" {server.outputs.init();server.input.cursor = &dummy_cursor;- // Backend hasn't migrated off zig-wlroots; see Server.zig's new_output.- const wlr_out: *wlr.Output = @ptrCast(try backend.headlessAddOutput(1280, 720));+ const wlr_out = try backend.headlessAddOutput(1280, 720);var mode = wlr.Output.State.init();defer mode.finish();mode.setEnabled(true);diff --git a/src/osd.zig b/src/osd.zigindex 422a966..e088b15 100644--- a/src/osd.zig+++ b/src/osd.zig@@ -226,8 +226,7 @@ test "OSD is noninteractive, stays above lock covers, rescales and releases itsserver.overlay_tree = try fixture.nodes.tree.createSceneTree();server.lock_tree = try fixture.nodes.tree.createSceneTree();server.locker = null;- // Backend hasn't migrated off zig-wlroots; see Server.zig's new_output.- const output: *wlr.Output = @ptrCast(try backend.headlessAddOutput(1280, 720));+ const output = try backend.headlessAddOutput(1280, 720);var mode = wlr.Output.State.init();defer mode.finish();mode.setEnabled(true);@@ -282,8 +281,7 @@ test "OSD sound and brightness glides smoothly between levels" {server.overlay_tree = try fixture.nodes.tree.createSceneTree();server.lock_tree = try fixture.nodes.tree.createSceneTree();server.locker = null;- // Backend hasn't migrated off zig-wlroots; see Server.zig's new_output.- const output: *wlr.Output = @ptrCast(try backend.headlessAddOutput(1280, 720));+ const output = try backend.headlessAddOutput(1280, 720);var mode = wlr.Output.State.init();defer mode.finish();mode.setEnabled(true);diff --git a/src/output/frame.zig b/src/output/frame.zigindex 8d314a7..e543c0d 100644--- a/src/output/frame.zig+++ b/src/output/frame.zig@@ -10,7 +10,6 @@ const anim = @import("ui").anim;const glass = @import("../glass.zig");const stats = @import("../ipc/stats.zig");const wlr_color_transform_unref = Output.wlr_color_transform_unref;-const wlr_output_state_set_color_transform = Output.wlr_output_state_set_color_transform;const log = std.log.scoped(.output);const CursorState = Output.CursorState;const syncLayout = Output.syncLayout;@@ -20,9 +19,9 @@ const timestamp = Output.timestamp;pub fn commitFrameState(output: *Output, state: *wlr.Output.State) bool {if (output.color.pending) {var copy = state.*;- wlr_output_state_set_color_transform(©, output.color.transform);+ copy.setColorTransform(output.color.transform);if (output.wlr_output.testState(©)) {- wlr_output_state_set_color_transform(state, output.color.transform);+ state.setColorTransform(output.color.transform);} else {output.color.status = .rejected;output.color.pending = false;diff --git a/src/output/layout.zig b/src/output/layout.zigindex a3d828e..2e9b1b0 100644--- a/src/output/layout.zig+++ b/src/output/layout.zig@@ -321,9 +321,7 @@ pub fn syncLayout(server: *Server) void {var layers = server.layer_surfaces.iterator(.forward);while (layers.next()) |layer| {if (!layer.layer.initialized) continue;- // LayerSurfaceV1 hasn't migrated off zig-wlroots; see- // LayerSurface.zig's create() for the same crossing.- const out = fromWlr(@ptrCast(layer.layer.output orelse continue)) orelse continue;+ const out = fromWlr(layer.layer.output orelse continue) orelse continue;if (!out.idle_blanked and !out.user_disabled) layer.arrange();}recomputeWorldBounds(server);diff --git a/src/output_management.zig b/src/output_management.zigindex 00c7a04..e03d199 100644--- a/src/output_management.zig+++ b/src/output_management.zig@@ -48,9 +48,7 @@ pub const Manager = struct {const config = wlr.OutputConfigurationV1.create() catch return;var it = self.server.outputs.iterator(.forward);while (it.next()) |output| {- // OutputConfigurationV1 hasn't migrated off zig-wlroots; see- // wlr.zig's `zig_wlroots` note.- const head = wlr.OutputConfigurationV1.Head.create(config, @ptrCast(output.wlr_output)) catch {+ const head = wlr.OutputConfigurationV1.Head.create(config, output.wlr_output) catch {config.destroy();return;};@@ -95,9 +93,7 @@ pub const Manager = struct {// Validate and backend-test everything before changing anything.var heads = config.heads.iterator(.forward);while (heads.next()) |head| {- // OutputConfigurationV1 hasn't migrated off zig-wlroots; see- // wlr.zig's `zig_wlroots` note.- const output = Output.fromWlr(@ptrCast(head.state.output)) orelse return false;+ const output = Output.fromWlr(head.state.output) orelse return false;const p = diff(self.server, output, &head.state);if (isEmpty(p)) continue;p.validate() catch return refuse(output, "invalid settings");@@ -105,9 +101,7 @@ pub const Manager = struct {if (!head.state.enabled or !output.wlr_output.enabled) continue;var state = wlr.Output.State.init();defer state.finish();- // OutputHeadV1 hasn't migrated off zig-wlroots; see wlr.zig's- // `zig_wlroots` note.- head.state.apply(@ptrCast(&state));+ head.state.apply(&state);if (!output.wlr_output.testState(&state)) return refuse(output, "rejected by the backend");}if (!commit) return true;@@ -115,9 +109,7 @@ pub const Manager = struct {for ([_]Phase{ .enable, .change, .disable }) |phase| {heads = config.heads.iterator(.forward);while (heads.next()) |head| {- // OutputConfigurationV1 hasn't migrated off zig-wlroots; see- // wlr.zig's `zig_wlroots` note.- const output = Output.fromWlr(@ptrCast(head.state.output)) orelse return false;+ const output = Output.fromWlr(head.state.output) orelse return false;const p = phase.select(diff(self.server, output, &head.state));if (isEmpty(p)) continue;output.applyAndPersist(p) catch |err| {@@ -159,12 +151,9 @@ fn isEmpty(p: Patch) bool {}fn findHead(config: *wlr.OutputConfigurationV1, output: *wlr.Output) ?*wlr.OutputConfigurationV1.Head {- // OutputConfigurationV1 hasn't migrated off zig-wlroots; see wlr.zig's- // `zig_wlroots` note.- const old_output: *wlr.zig_wlroots.Output = @ptrCast(output);var it = config.heads.iterator(.forward);while (it.next()) |head| {- if (head.state.output == old_output) return head;+ if (head.state.output == output) return head;}return null;}diff --git a/src/panel_buffer.zig b/src/panel_buffer.zigindex 915d411..13d04ca 100644--- a/src/panel_buffer.zig+++ b/src/panel_buffer.zig@@ -13,8 +13,6 @@ const geometry = @import("geometry.zig");const panel_present = @import("panel_present.zig");const panel_paint = @import("panel_paint.zig");-extern "c" fn wlr_buffer_finish(buffer: *wlr.Buffer) void;-pub const PanelBuffer = struct {base: wlr.Buffer,width: i32,@@ -164,7 +162,7 @@ pub const PanelBuffer = struct {fn destroyBuffer(base: *wlr.Buffer) callconv(.c) void {// wlroots 0.20 leaves this to the producer. Notify texture wrappers// before pooling/freeing storage, so they cannot retain a stale source.- wlr_buffer_finish(base);+ base.finish();const buf: *PanelBuffer = @fieldParentPtr("base", base);if (buf.sensitive) {std.crypto.secureZero(u32, buf.storage);diff --git a/src/server/outputs.zig b/src/server/outputs.zigindex cfcf6b5..5aaba9b 100644--- a/src/server/outputs.zig+++ b/src/server/outputs.zig@@ -8,10 +8,8 @@ const Output = @import("../Output.zig");const geometry = @import("../geometry.zig");const log = std.log.scoped(.compositor);-pub fn newOutput(listener: *wl.Listener(*wlr.zig_wlroots.Output), old_output: *wlr.zig_wlroots.Output) void {+pub fn newOutput(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {const server: *Server = @fieldParentPtr("new_output", listener);- // Backend hasn't migrated off zig-wlroots; see Server.zig's new_output.- const wlr_output: *wlr.Output = @ptrCast(old_output);// wlroots' own `wlr_ext_image_capture_source_v1_create_with_scene_node`// (capture/manager.zig, stage 3 window capture) creates a privatediff --git a/src/session/client_lock.zig b/src/session/client_lock.zigindex 60a5578..8b3a229 100644--- a/src/session/client_lock.zig+++ b/src/session/client_lock.zig@@ -227,9 +227,7 @@ pub const ClientLock = struct {fn handleNewSurface(listener: *wl.Listener(*wlr.SessionLockSurfaceV1), lock_surface: *wlr.SessionLockSurfaceV1) void {const self: *ClientLock = @fieldParentPtr("new_surface", listener);- // SessionLockSurfaceV1 hasn't migrated off zig-wlroots; see- // wlr.zig's `zig_wlroots` note.- const output = Output.fromWlr(@ptrCast(lock_surface.output)) orelse return;+ const output = Output.fromWlr(lock_surface.output) orelse return;const surface = gpa.create(Surface) catch return;const tree = output.lock_view.tree.createSceneSubsurfaceTree(lock_surface.surface) catch {gpa.destroy(surface);diff --git a/src/session/idle.zig b/src/session/idle.zigindex 5892e33..69dacea 100644--- a/src/session/idle.zig+++ b/src/session/idle.zig@@ -390,9 +390,7 @@ pub const IdleManager = struct {return .{ .visible = false, .reason = "unmapped layer surface" };}if (layer.layer.output) |out| {- // LayerSurfaceV1 hasn't migrated off zig-wlroots; see- // LayerSurface.zig's create() for the same crossing.- if (Output.fromWlr(@ptrCast(out))) |output| {+ if (Output.fromWlr(out)) |output| {if (output.isLogicallyEnabled()) {return .{ .visible = true, .reason = "visible layer surface" };}diff --git a/src/session/lock_tests.zig b/src/session/lock_tests.zigindex 8693cb8..56aa600 100644--- a/src/session/lock_tests.zig+++ b/src/session/lock_tests.zig@@ -240,8 +240,7 @@ test "lock covers new outputs and follows layout and mode changes without UI" {server.output_layout = output_layout;server.lock_tree = try fixture.nodes.tree.createSceneTree();for (0..2) |i| {- // Backend hasn't migrated off zig-wlroots; see Server.zig's new_output.- const output: *wlr.Output = @ptrCast(try backend.headlessAddOutput(1280, 720));+ const output = try backend.headlessAddOutput(1280, 720);var state = wlr.Output.State.init();defer state.finish();state.setEnabled(true);diff --git a/src/startup_tasks.zig b/src/startup_tasks.zigindex 1cde8df..0e46582 100644--- a/src/startup_tasks.zig+++ b/src/startup_tasks.zig@@ -14,8 +14,6 @@ step: usize = 0,complete: bool = false,failure: ?anyerror = null,-extern fn wlr_backend_is_libinput(backend: *wlr.Backend) bool;-pub fn start(self: *Tasks, server: *Server) !void {self.server = server;startup.markBackendStart();@@ -40,11 +38,11 @@ pub fn start(self: *Tasks, server: *Server) !void {}fn startDisplayBackend(backend: *wlr.Backend, self: *Tasks) void {- self.startSelectedBackend(backend, wlr_backend_is_libinput(backend), false);+ self.startSelectedBackend(backend, backend.isLibinput(), false);}fn startInputBackend(backend: *wlr.Backend, self: *Tasks) void {- self.startSelectedBackend(backend, wlr_backend_is_libinput(backend), true);+ self.startSelectedBackend(backend, backend.isLibinput(), true);}fn startSelectedBackend(self: *Tasks, backend: *wlr.Backend, is_input: bool, input_stage: bool) void {@@ -125,15 +123,20 @@ test "staged backends retain multi ownership and only start in their own stage"_ = try display.headlessAddOutput(32, 32);_ = try input.headlessAddOutput(32, 32);const Observer = struct {- // Backend hasn't migrated off zig-wlroots; see Server.zig's new_output.- listener: wl.Listener(*wlr.zig_wlroots.Output) = .init(newOutput),+ listener: wl.Listener(*wlr.Output) = .init(newOutput),count: usize = 0,- fn newOutput(listener: *wl.Listener(*wlr.zig_wlroots.Output), _: *wlr.zig_wlroots.Output) void {+ backends: usize = 0,+ fn newOutput(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {const self: *@This() = @fieldParentPtr("listener", listener);self.count += 1;}+ fn countBackend(backend: *wlr.Backend, self: *@This()) void {+ if (backend.isHeadless()) self.backends += 1;+ }};var observer: Observer = .{};+ multi.multiForEachBackend(*Observer, Observer.countBackend, &observer);+ try std.testing.expectEqual(@as(usize, 2), observer.backends);multi.events.new_output.add(&observer.listener);defer observer.listener.link.remove();var tasks: Tasks = .{};diff --git a/src/toplevel/info.zig b/src/toplevel/info.zigindex 8dde4d5..ac5d38d 100644--- a/src/toplevel/info.zig+++ b/src/toplevel/info.zig@@ -121,9 +121,7 @@ pub fn surfaceScale(toplevel: *const Toplevel) f64 {pub fn clientSurfaceGeometry(toplevel: *const Toplevel) wlr.Box {if (toplevel.backend_gone) return .{ .x = 0, .y = 0, .width = 0, .height = 0 };return switch (toplevel.backend) {- // XdgSurface hasn't migrated off zig-wlroots; see wlr.zig's- // assertSameLayout(Box, old.Box) for why this cast is safe.- .xdg => |*adapter| @bitCast(adapter.xdg_toplevel.base.geometry),+ .xdg => |*adapter| adapter.xdg_toplevel.base.geometry,.xwayland => |*adapter| blk: {if (adapter.xsurface.surface) |s| {if (s.current.width > 0 and s.current.height > 0) {diff --git a/src/toplevel/layout.zig b/src/toplevel/layout.zigindex e73392a..35b0fbe 100644--- a/src/toplevel/layout.zig+++ b/src/toplevel/layout.zig@@ -309,9 +309,7 @@ pub fn sendTiled(toplevel: *Toplevel, edges: wlr.Edges) void {if (toplevel.backend_gone) return;switch (toplevel.backend) {// wlroots asserts an xdg_wm_base of version 2 or later (Shell.zig).- // XdgToplevel hasn't migrated off zig-wlroots; see wlr.zig's- // assertSameLayout(Edges, old.Edges) for why this cast is safe.- .xdg => |*adapter| _ = adapter.xdg_toplevel.setTiled(@bitCast(edges)),+ .xdg => |*adapter| _ = adapter.xdg_toplevel.setTiled(edges),.xwayland, .placeholder, .shell => {},}}diff --git a/src/wlr/AGENTS.md b/src/wlr/AGENTS.mdindex be587f2..871f391 100644--- a/src/wlr/AGENTS.md+++ b/src/wlr/AGENTS.md@@ -1,82 +1,49 @@-# src/wlr: the in-tree wlroots facade+# In-tree wlroots bindings-Replaces `zig-wlroots` one subsystem at a time with a module backed-directly by `@cImport` against the real wlroots headers, because-hand-mirroring wlroots' C ABI by hand (what zig-wlroots does) both lags-new Zig releases and risks silent layout bugs (`wlr.Pointer` was 8 bytes-short at one point, see the top-level AGENTS.md). `@cImport` ships inside-the compiler, so it tracks whatever Zig version is building the project-automatically, and the compiler reads the real struct layout instead of a-hand-typed copy of it.+`@import("wlroots")` resolves to `wlr.zig`, backed by the installed wlroots+0.20 headers. There is no zig-wlroots package dependency. Some API shapes+were adapted from that project; keep `LICENSE.zig-wlroots` and attribution.-## How it's wired+## Boundary and layouts-`wlr.zig` is what `@import("wlroots")` resolves to (set in `build.zig`).-It re-exports every `wlr.*` name the rest of the compositor uses. A-migrated type comes from this directory; everything else forwards-straight to the real zig-wlroots dependency, imported here as `old`-(`build.zig`'s `wlroots_dep`, still fetched via `build.zig.zon`). Callers-never see which side a type comes from.+* `c.zig` owns the single `@cImport`. Add headers there; separate imports+ create incompatible C type identities. `_FORTIFY_SOURCE` is undefined for+ translate-c compatibility in ReleaseSafe. The two uninstalled protocol C+ headers are generated by `wayland-scanner` in `build.zig`.+* Prefer raw C types where callers need no Zig methods or typed events.+ Otherwise declare a small `extern struct`, retyping Wayland fields as+ `wl.Signal(T)`, `wl.Listener(T)`, `wl.Resource` or `wl.list.Head(T, field)`.+ Every represented field must be checked against its real header type.+* `abi.assertFields` checks offsets, sizes, nested structs and event blocks.+ It permits an omitted tail only for objects allocated by wlroots and used+ through pointers. Use `abi.assertLayout` for objects embedded, allocated,+ or passed by value by Zig. Retain any required private storage using the+ C field's actual type (`@FieldType(c.wlr_foo, "WLR_PRIVATE")`), never a+ guessed padding count. Arrays also need their complete element stride.+* For anonymous C unions use an explicit field mapping and check each+ alternative. `signal.zig` also supplies the simpler checks used by the+ earlier adapters. C function/type name collisions need `c.struct_wlr_foo`.+* Signal payloads are a semantic contract; check their emitters and listeners.+ Equal signal layouts cannot verify the payload type. Preserve nullability+ from the header/lifecycle, especially optional output and buffer pointers.+* `abi.bind(fn (...) callconv(.c) Return, c.wlr_foo)` verifies the header+ signature and returns a real wrapper function, preserving method-call+ syntax. Raw function pointers do not work as Zig methods. Pointer retyping+ is allowed at this boundary; the owning type's layout checks validate its+ pointee. Callback signatures and by-value arguments are checked too.+* Enum/flag values must come from C constants or be explicitly checked.+ Use lazy `@import("wlr.zig").Type` references for mutually recursive types.+ Callers use the facade's types directly; do not reintroduce casts between+ two competing wlroots bindings or hand-declare wlroots extern functions.-`c.zig` holds the single `@cImport` block every migrated file imports-from. Keep it one block: translate-c assigns each header its own type-identities per `@cImport` call, so two separate `@cImport`s of the same-header produce two incompatible Zig types.+## Validation-## Adding a migrated type+`zig build test-wlroots` references every exported binding and exercises C+initialization/teardown of embedded Pointer/Keyboard objects with surrounding+canaries. It is included in `zig build test`. Keep new test cases in sibling+`*_tests.zig` files and import them from `wlr.zig`.-1. Add its header to `c.zig`'s `@cImport`.-2. If the type is a plain value with no pointers (`Box`, `Edges`-shaped- things): redeclare its fields so Zig's method-call sugar works- (`c.wlr_foo` is a foreign type you can't attach `pub fn`s to from this- file), call the real `wlr_foo_*` functions from the methods, and add- `assertFieldOffset`/`assertSameLayout` (`signal.zig`) for every field —- see `box.zig`.-3. If it has a `wl_signal`/`wl_resource`/`wl_list` field: same- redeclare-and-assert approach, but retype those fields as- zig-wayland's `wl.Signal(T)` / `wl.Resource` / `wl.list.Head(T, field)`- instead of the raw `@cImport` type, so `.add()`/`.get()`/`.emit()` work- on the result. This is safe only because `struct wl_signal` is one- `wl_list` and `struct wl_listener` is a `wl_list` plus a function- pointer, and always will be — that's what `assertSameLayout` is- checking, not a formality. Omit trailing private/`WLR_PRIVATE` fields- entirely rather than guessing their shape: you only ever handle this- type through a pointer wlroots itself allocated, so Zig never needs to- know its true size. See `output_power.zig`.-4. **Check who else takes or returns this type before wiring it into- `wlr.zig`.** Zig's `extern struct`s are nominally typed: a function- still on `old` that takes `*old.Box` will not accept a `*wlr.Box` built- from `c.zig`, even though the two are byte-for-byte identical. Add a- `comptime { assertSameLayout(NewType, old.OldType); }` next to the- migrated type's declaration in `wlr.zig` (see `Box`/`FBox`/`Edges`),- then `@ptrCast` (pointers) or `@bitCast` (value types passed by value,- e.g. `Edges`) at each of the handful of call sites that still cross- into an unmigrated function or signal — one line at each site, with a- comment pointing back at the assert. That assert is what makes the- cast provably safe, not a convention to trust blindly. This is almost- always cheaper than waiting for every referencing type to migrate- first: `Output`/`OutputLayout` crossed into `Backend` (the- `new_output` signal — see `wlr.zig`'s `zig_wlroots` re-export and- Server.zig/server/outputs.zig/startup_tasks.zig),- `ForeignToplevelHandleV1`, `Cursor`, `OutputConfigurationV1`,- `XdgSurface`/`XdgToplevel`, `LayerSurfaceV1`, `SessionLockSurfaceV1`,- and a few test files' direct `Backend.headlessAddOutput` calls — each- handled with one cast, not a bigger migration. Only wait when the- type is a signal/event *payload* type itself and nothing else, or the- crossing count looks larger than just migrating the other side too. A- protocol-generated header wlroots itself doesn't install (anything- under `wlr_types_*_v1.h` that `#include`s its own `*-protocol.h`)- needs that header generated at build time — see- `output_power_protocol_header` in `build.zig` for the- `wayland-scanner`-based pattern.-5. Before trusting a signal's payload type, check who actually connects- to it (`grep` for `.events.<name>.add(`) rather than assuming from the- header comment. `wlr_output`'s `frame`/`description`/`destroy`- signals carry the output itself as payload by convention, with no- comment saying so and no dedicated event struct — only- `damage`/`precommit`/`bind` (which nothing in RediWM connects to) were- safe to leave as placeholder `wl.Signal(void)`.-6. Build Debug and `-Doptimize=ReleaseSafe`, run `zig build test`, per the- top-level AGENTS.md. A pre-existing/environmental test failure doesn't- excuse skipping this: compare against a `git worktree` of the commit- before your change, per the top-level AGENTS.md, rather than assuming.+Build Debug and ReleaseSafe, then run the affected integration suites as+specified in the root `TESTING.md`. Use isolated headless sessions and compare+failures against a clean baseline. Protocol layout checks cannot replace+runtime input, capture, lock, output and surface lifecycle coverage.diff --git a/src/wlr/LICENSE.zig-wlroots b/src/wlr/LICENSE.zig-wlrootsnew file mode 100644index 0000000..6588f3b--- /dev/null+++ b/src/wlr/LICENSE.zig-wlroots@@ -0,0 +1,19 @@+Copyright 2020 Isaac Freund++Permission is hereby granted, free of charge, to any person obtaining a+copy of this software and associated documentation files (the "Software"),+to deal in the Software without restriction, including without limitation the+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or+sell copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.diff --git a/src/wlr/abi.zig b/src/wlr/abi.zignew file mode 100644index 0000000..bc6be21--- /dev/null+++ b/src/wlr/abi.zig@@ -0,0 +1,179 @@+//! Retype the C declarations at the single header boundary, checking their+//! ABI before exposing Zig's protocol enums, lists and method-friendly types.+const std = @import("std");++pub fn bind(comptime F: type, comptime function: anytype) F {+ @setEvalBranchQuota(100000);+ comptime assertFunction(F, @TypeOf(function));+ const signature = @typeInfo(F).@"fn";+ const params = signature.params;+ const Return = signature.return_type.?;+ // Actual function declarations preserve Zig's method-call syntax. A cast+ // function pointer alone would require a second implicit dereference.+ return switch (params.len) {+ 0 => struct {+ fn call() callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))();+ }+ }.call,+ 1 => struct {+ fn call(a0: params[0].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0);+ }+ }.call,+ 2 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1);+ }+ }.call,+ 3 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2);+ }+ }.call,+ 4 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3);+ }+ }.call,+ 5 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4);+ }+ }.call,+ 6 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?, a5: params[5].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4, a5);+ }+ }.call,+ 7 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?, a5: params[5].type.?, a6: params[6].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4, a5, a6);+ }+ }.call,+ 8 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?, a5: params[5].type.?, a6: params[6].type.?, a7: params[7].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4, a5, a6, a7);+ }+ }.call,+ 9 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?, a5: params[5].type.?, a6: params[6].type.?, a7: params[7].type.?, a8: params[8].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4, a5, a6, a7, a8);+ }+ }.call,+ 10 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?, a5: params[5].type.?, a6: params[6].type.?, a7: params[7].type.?, a8: params[8].type.?, a9: params[9].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);+ }+ }.call,+ 11 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?, a5: params[5].type.?, a6: params[6].type.?, a7: params[7].type.?, a8: params[8].type.?, a9: params[9].type.?, a10: params[10].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);+ }+ }.call,+ 12 => struct {+ fn call(a0: params[0].type.?, a1: params[1].type.?, a2: params[2].type.?, a3: params[3].type.?, a4: params[4].type.?, a5: params[5].type.?, a6: params[6].type.?, a7: params[7].type.?, a8: params[8].type.?, a9: params[9].type.?, a10: params[10].type.?, a11: params[11].type.?) callconv(.c) Return {+ return @as(*const F, @ptrCast(&function))(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);+ }+ }.call,+ else => @compileError("Add a wrapper arity for this wlroots declaration"),+ };+}++fn assertFunction(comptime A: type, comptime B: type) void {+ const a = @typeInfo(A).@"fn";+ const b = @typeInfo(B).@"fn";+ if (!std.meta.eql(a.calling_convention, b.calling_convention) or+ a.is_var_args != b.is_var_args or a.params.len != b.params.len)+ @compileError("C function signature changed: " ++ @typeName(A) ++ " / " ++ @typeName(B));+ for (a.params, b.params) |ap, bp| assertValue(ap.type.?, bp.type.?);+ assertValue(a.return_type.?, b.return_type.?);+}++fn pointerChild(comptime T: type) ?type {+ return switch (@typeInfo(T)) {+ .pointer => |p| p.child,+ .optional => |o| switch (@typeInfo(o.child)) {+ .pointer => |p| p.child,+ else => null,+ },+ else => null,+ };+}++pub fn assertValue(comptime A: type, comptime B: type) void {+ if (A == B) return;+ assertSize(A, B);+ if (pointerChild(A)) |ap| {+ const bp = pointerChild(B) orelse @compileError("C pointer changed: " ++ @typeName(B));+ if (@typeInfo(ap) == .@"fn" or @typeInfo(bp) == .@"fn") {+ if (@typeInfo(ap) != .@"fn" or @typeInfo(bp) != .@"fn")+ @compileError("C callback changed");+ assertFunction(ap, bp);+ }+ return;+ }+ const ai = @typeInfo(A);+ const bi = @typeInfo(B);+ switch (ai) {+ .@"enum" => |a| assertValue(a.tag_type, B),+ .int => switch (bi) {+ .int => {},+ .@"enum" => |b| assertValue(A, b.tag_type),+ .@"struct" => |b| if (b.layout != .@"packed") {+ @compileError("C integer changed");+ },+ else => @compileError("C integer changed: " ++ @typeName(B)),+ },+ .@"struct" => |a| {+ if (a.layout == .@"packed") {+ if (bi != .int and bi != .@"struct") @compileError("C bitmask changed");+ } else {+ assertFields(A, B);+ }+ },+ .array => |a| {+ const b = bi.array;+ if (a.len != b.len) @compileError("C array length changed");+ assertValue(a.child, b.child);+ },+ .@"union" => {}, // Union alternatives are checked by their owning adapter.+ .void, .float, .bool => if (std.meta.activeTag(ai) != std.meta.activeTag(bi)) {+ @compileError("C scalar changed");+ },+ else => @compileError("Unsupported C ABI type: " ++ @typeName(A)),+ }+}++fn assertSize(comptime A: type, comptime B: type) void {+ if (@sizeOf(A) != @sizeOf(B) or @alignOf(A) != @alignOf(B))+ @compileError("C ABI size/alignment changed: " ++ @typeName(A) ++ " / " ++ @typeName(B));+}++/// Check every represented field, including nested events and inline state.+/// A wlroots-owned object may omit its private tail. Use assertLayout for+/// objects allocated or passed by value by the compositor.+pub fn assertFields(comptime A: type, comptime B: type) void {+ @setEvalBranchQuota(100000);+ const fields = @typeInfo(A).@"struct".fields;+ // zig-wayland wraps wl_list in a typed Head with one embedded Link.+ if (fields.len == 1 and std.mem.eql(u8, fields[0].name, "link") and+ @hasField(B, "prev") and @hasField(B, "next"))+ {+ if (@offsetOf(A, "link") != 0) @compileError("Wayland list wrapper moved");+ assertValue(fields[0].type, B);+ return;+ }+ for (fields) |field| {+ if (!@hasField(B, field.name))+ @compileError("C field missing: " ++ @typeName(B) ++ "." ++ field.name);+ if (@offsetOf(A, field.name) != @offsetOf(B, field.name))+ @compileError("C field offset changed: " ++ @typeName(A) ++ "." ++ field.name);+ assertValue(field.type, @FieldType(B, field.name));+ }+}++pub fn assertLayout(comptime A: type, comptime B: type) void {+ assertSize(A, B);+ assertFields(A, B);+}diff --git a/src/wlr/addon.zig b/src/wlr/addon.zignew file mode 100644index 0000000..9022bd0--- /dev/null+++ b/src/wlr/addon.zig@@ -0,0 +1,42 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const AddonSet = extern struct {+ WLR_PRIVATE: @FieldType(c.wlr_addon_set, "WLR_PRIVATE"),++ const wlr_addon_set_init = abi.bind(fn (set: *AddonSet) callconv(.c) void, c.wlr_addon_set_init);+ pub const init = wlr_addon_set_init;++ const wlr_addon_set_finish = abi.bind(fn (set: *AddonSet) callconv(.c) void, c.wlr_addon_set_finish);+ pub const deinit = wlr_addon_set_finish;++ const wlr_addon_find = abi.bind(fn (set: *AddonSet, owner: ?*const anyopaque, impl: *const Addon.Interface) callconv(.c) ?*Addon, c.wlr_addon_find);+ pub const find = wlr_addon_find;+};++pub const Addon = extern struct {+ pub const Interface = extern struct {+ name: [*:0]const u8,+ destroy: *const fn (*Addon) callconv(.c) void,+ };++ impl: *const Interface,++ WLR_PRIVATE: @FieldType(c.wlr_addon, "WLR_PRIVATE"),++ const wlr_addon_init = abi.bind(fn (addon: *Addon, set: *AddonSet, owner: ?*const anyopaque, impl: *const Interface) callconv(.c) void, c.wlr_addon_init);+ pub const init = wlr_addon_init;++ const wlr_addon_finish = abi.bind(fn (addon: *Addon) callconv(.c) void, c.wlr_addon_finish);+ pub const deinit = wlr_addon_finish;+};++comptime {+ abi.assertLayout(AddonSet, c.wlr_addon_set);+ abi.assertLayout(Addon, c.wlr_addon);+ abi.assertLayout(Addon.Interface, c.wlr_addon_interface);+}diff --git a/src/wlr/allocator.zig b/src/wlr/allocator.zignew file mode 100644index 0000000..fd39598--- /dev/null+++ b/src/wlr/allocator.zig@@ -0,0 +1,37 @@+//! The allocator's public layout and lifecycle, backed by wlroots headers.+//! RediWM uses wlroots-created allocators; their implementation callbacks+//! remain C types because the compositor never supplies an implementation.+const wl = @import("wayland").server.wl;+const wlr = @import("wlr.zig");+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub const Allocator = extern struct {+ impl: *const c.wlr_allocator_interface,+ buffer_caps: u32,+ events: extern struct {+ destroy: wl.Signal(void),+ },++ pub fn autocreate(backend: *wlr.Backend, renderer: *wlr.Renderer) !*Allocator {+ const raw = c.wlr_allocator_autocreate(@ptrCast(backend), @ptrCast(renderer));+ return @as(?*Allocator, @ptrCast(raw)) orelse error.AllocatorCreateFailed;+ }++ pub fn destroy(allocator: *Allocator) void {+ c.wlr_allocator_destroy(@ptrCast(allocator));+ }++ comptime {+ const Real = c.wlr_allocator;+ assertSameLayout(Allocator, Real);+ for (@typeInfo(Allocator).@"struct".fields) |field| {+ assertFieldOffset(Allocator, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ const Events = @FieldType(Allocator, "events");+ assertFieldOffset(Events, @FieldType(Real, "events"), "destroy");+ assertSameLayout(@FieldType(Events, "destroy"), c.wl_signal);+ }+};diff --git a/src/wlr/backend.zig b/src/wlr/backend.zignew file mode 100644index 0000000..dc1ef46--- /dev/null+++ b/src/wlr/backend.zig@@ -0,0 +1,136 @@+//! Backend creation, output signals and multi-backend iteration, backed by+//! the installed wlroots headers. Resolve Output lazily through the facade:+//! Output contains a Backend pointer, so eagerly passing both through Types+//! would create a dependency loop.+const wl = @import("wayland").server.wl;+const wlr = @import("wlr.zig");+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub const Backend = extern struct {+ pub const OutputState = extern struct {+ output: *wlr.Output,+ base: wlr.Output.State,++ comptime {+ assertSameLayout(OutputState, c.wlr_backend_output_state);+ assertFieldOffset(OutputState, c.wlr_backend_output_state, "output");+ assertFieldOffset(OutputState, c.wlr_backend_output_state, "base");+ }+ };++ impl: *const c.wlr_backend_impl,+ buffer_caps: u32,+ features: extern struct {+ timeline: bool,+ },+ events: extern struct {+ destroy: wl.Signal(*Backend),+ new_input: wl.Signal(*wlr.InputDevice),+ new_output: wl.Signal(*wlr.Output),+ },++ pub fn autocreate(loop: *wl.EventLoop, session_ptr: ?*?*wlr.Session) !*Backend {+ const raw = c.wlr_backend_autocreate(@ptrCast(loop), @ptrCast(session_ptr));+ return @as(?*Backend, @ptrCast(raw)) orelse error.BackendCreateFailed;+ }++ pub fn start(backend: *Backend) !void {+ if (!c.wlr_backend_start(@ptrCast(backend))) return error.BackendStartFailed;+ }++ pub fn destroy(backend: *Backend) void {+ c.wlr_backend_destroy(@ptrCast(backend));+ }++ pub fn getDrmFd(backend: *Backend) c_int {+ return c.wlr_backend_get_drm_fd(@ptrCast(backend));+ }++ pub fn @"test"(backend: *Backend, states: []const OutputState) bool {+ return c.wlr_backend_test(@ptrCast(backend), @ptrCast(states.ptr), states.len);+ }++ pub fn commit(backend: *Backend, states: []const OutputState) bool {+ return c.wlr_backend_commit(@ptrCast(backend), @ptrCast(states.ptr), states.len);+ }++ pub fn createMulti(loop: *wl.EventLoop) !*Backend {+ const raw = c.wlr_multi_backend_create(@ptrCast(loop));+ return @as(?*Backend, @ptrCast(raw)) orelse error.BackendCreateFailed;+ }++ pub fn multiAdd(multi: *Backend, backend: *Backend) bool {+ return c.wlr_multi_backend_add(@ptrCast(multi), @ptrCast(backend));+ }++ pub fn multiForEachBackend(+ backend: *Backend,+ comptime T: type,+ comptime callback: fn (backend: *Backend, data: T) void,+ data: T,+ ) void {+ const Adapter = struct {+ fn call(raw: [*c]c.wlr_backend, context: ?*anyopaque) callconv(.c) void {+ callback(@ptrCast(raw), @ptrCast(@alignCast(context)));+ }+ };+ c.wlr_multi_for_each_backend(@ptrCast(backend), Adapter.call, data);+ }++ pub fn createHeadless(loop: *wl.EventLoop) !*Backend {+ const raw = c.wlr_headless_backend_create(@ptrCast(loop));+ return @as(?*Backend, @ptrCast(raw)) orelse error.BackendCreateFailed;+ }++ pub fn headlessAddOutput(backend: *Backend, width: c_uint, height: c_uint) !*wlr.Output {+ const raw = c.wlr_headless_add_output(@ptrCast(backend), width, height);+ return @as(?*wlr.Output, @ptrCast(raw)) orelse error.OutOfMemory;+ }++ pub fn isMulti(backend: *Backend) bool {+ return c.wlr_backend_is_multi(@ptrCast(backend));+ }++ pub fn isHeadless(backend: *Backend) bool {+ return c.wlr_backend_is_headless(@ptrCast(backend));+ }++ pub fn isDrm(backend: *Backend) bool {+ return c.wlr_backend_is_drm(@ptrCast(backend));+ }++ pub fn isWl(backend: *Backend) bool {+ return c.wlr_backend_is_wl(@ptrCast(backend));+ }++ pub fn isX11(backend: *Backend) bool {+ return c.wlr_backend_is_x11(@ptrCast(backend));+ }++ pub fn isLibinput(backend: *Backend) bool {+ return c.wlr_backend_is_libinput(@ptrCast(backend));+ }++ comptime {+ const Real = c.wlr_backend;+ assertSameLayout(Backend, Real);+ for (.{ "impl", "buffer_caps", "features", "events" }) |field| {+ assertFieldOffset(Backend, Real, field);+ }++ const Features = @FieldType(Backend, "features");+ const RealFeatures = @FieldType(Real, "features");+ assertSameLayout(Features, RealFeatures);+ assertFieldOffset(Features, RealFeatures, "timeline");++ const Events = @FieldType(Backend, "events");+ const RealEvents = @FieldType(Real, "events");+ assertSameLayout(Events, RealEvents);+ for (.{ "destroy", "new_input", "new_output" }) |field| {+ assertSameLayout(@FieldType(Events, field), c.wl_signal);+ assertFieldOffset(Events, RealEvents, field);+ }+ }+};diff --git a/src/wlr/bindings_tests.zig b/src/wlr/bindings_tests.zignew file mode 100644index 0000000..243e1e5--- /dev/null+++ b/src/wlr/bindings_tests.zig@@ -0,0 +1,38 @@+const std = @import("std");++test "all exported bindings match the installed headers" {+ @setEvalBranchQuota(100000);+ refAllDeclsRecursive(@import("wlr.zig"));+}++fn refAllDeclsRecursive(comptime T: type) void {+ inline for (comptime std.meta.declarations(T)) |decl| {+ const value = @field(T, decl.name);+ if (@TypeOf(value) == type) {+ switch (@typeInfo(value)) {+ .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(value),+ else => {},+ }+ }+ _ = &@field(T, decl.name);+ }+}++test "DRM format sets support empty storage and mutable removal" {+ const wlr = @import("wlr.zig");+ var formats: wlr.DrmFormatSet = std.mem.zeroes(wlr.DrmFormatSet);+ defer formats.finish();+ const argb8888: u32 = 0x34325241;+ const linear: u64 = 0;+ try std.testing.expect(formats.formats == null);+ try std.testing.expect(formats.get(argb8888) == null);+ try std.testing.expect(formats.add(argb8888, linear));+ try std.testing.expect(formats.has(argb8888, linear));+ const format = formats.get(argb8888).?;+ try std.testing.expectEqual(linear, format.modifiers.?[0]);+ try std.testing.expect(formats.remove(argb8888, linear));+ try std.testing.expect(!formats.has(argb8888, linear));+ formats.finish();+ try std.testing.expect(formats.formats == null);+ try std.testing.expectEqual(@as(usize, 0), formats.len);+}diff --git a/src/wlr/buffer.zig b/src/wlr/buffer.zignew file mode 100644index 0000000..7b95a95--- /dev/null+++ b/src/wlr/buffer.zig@@ -0,0 +1,118 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++const wlr = @import("wlr.zig");++const posix = @import("std").posix;+const wl = @import("wayland").server.wl;+const pixman = @import("pixman");++pub const ShmAttributes = extern struct {+ fd: c_int,+ format: u32,+ width: c_int,+ height: c_int,+ stride: c_int,+ offset: posix.off_t,+};++pub const BufferCap = enum(c_int) {+ data_ptr = c.WLR_BUFFER_CAP_DATA_PTR,+ dmabuf = c.WLR_BUFFER_CAP_DMABUF,+ shm = c.WLR_BUFFER_CAP_SHM,+};++pub const Buffer = extern struct {+ pub const data_ptr_access_flag = struct {+ pub const read = c.WLR_BUFFER_DATA_PTR_ACCESS_READ;+ pub const write = c.WLR_BUFFER_DATA_PTR_ACCESS_WRITE;+ };++ pub const Impl = extern struct {+ destroy: *const fn (buffer: *Buffer) callconv(.c) void,+ get_dmabuf: ?*const fn (buffer: *Buffer, attribs: *wlr.DmabufAttributes) callconv(.c) bool,+ get_shm: ?*const fn (buffer: *Buffer, attribs: *wlr.ShmAttributes) callconv(.c) bool,+ begin_data_ptr_access: ?*const fn (buffer: *Buffer, flags: u32, data: **anyopaque, format: *u32, stride: *usize) callconv(.c) bool,+ end_data_ptr_access: ?*const fn (buffer: *Buffer) callconv(.c) void,+ };++ pub const ResourceInterface = extern struct {+ name: [*:0]const u8,+ is_instance: *const fn (resource: *wl.Resource) callconv(.c) bool,+ from_resource: *const fn (resource: *wl.Resource) callconv(.c) ?*Buffer,+ };++ impl: *const Impl,++ width: c_int,+ height: c_int,++ dropped: bool,+ n_locks: usize,++ accessing_data_ptr: bool,++ events: extern struct {+ destroy: wl.Signal(void),+ release: wl.Signal(void),+ },++ addons: wlr.AddonSet,++ const wlr_buffer_init = abi.bind(fn (buffer: *Buffer, impl: *const Buffer.Impl, width: c_int, height: c_int) callconv(.c) void, c.wlr_buffer_init);+ pub const init = wlr_buffer_init;++ const wlr_buffer_finish = abi.bind(fn (buffer: *Buffer) callconv(.c) void, c.wlr_buffer_finish);+ pub const finish = wlr_buffer_finish;++ const wlr_buffer_drop = abi.bind(fn (buffer: *Buffer) callconv(.c) void, c.wlr_buffer_drop);+ pub const drop = wlr_buffer_drop;++ const wlr_buffer_lock = abi.bind(fn (buffer: *Buffer) callconv(.c) *Buffer, c.wlr_buffer_lock);+ pub const lock = wlr_buffer_lock;++ const wlr_buffer_unlock = abi.bind(fn (buffer: *Buffer) callconv(.c) void, c.wlr_buffer_unlock);+ pub const unlock = wlr_buffer_unlock;++ const wlr_buffer_get_dmabuf = abi.bind(fn (buffer: *Buffer, attribs: *wlr.DmabufAttributes) callconv(.c) bool, c.wlr_buffer_get_dmabuf);+ pub const getDmabuf = wlr_buffer_get_dmabuf;++ const wlr_buffer_get_shm = abi.bind(fn (buffer: *Buffer, attribs: *wlr.ShmAttributes) callconv(.c) bool, c.wlr_buffer_get_shm);+ pub const getShm = wlr_buffer_get_shm;++ const wlr_buffer_register_resource_interface = abi.bind(fn (iface: *const ResourceInterface) callconv(.c) void, c.wlr_buffer_register_resource_interface);+ pub const registerResourceInterface = wlr_buffer_register_resource_interface;++ const wlr_buffer_try_from_resource = abi.bind(fn (resource: *wl.Buffer) callconv(.c) ?*Buffer, c.wlr_buffer_try_from_resource);+ pub const tryFromWlBuffer = wlr_buffer_try_from_resource;++ const wlr_buffer_is_opaque = abi.bind(fn (buffer: *Buffer) callconv(.c) bool, c.wlr_buffer_is_opaque);+ pub const isOpaque = wlr_buffer_is_opaque;++ const wlr_buffer_begin_data_ptr_access = abi.bind(fn (buffer: *Buffer, flags: u32, data: **anyopaque, format: *u32, stride: *usize) callconv(.c) bool, c.wlr_buffer_begin_data_ptr_access);+ pub const beginDataPtrAccess = wlr_buffer_begin_data_ptr_access;++ const wlr_buffer_end_data_ptr_access = abi.bind(fn (buffer: *Buffer) callconv(.c) void, c.wlr_buffer_end_data_ptr_access);+ pub const endDataPtrAccess = wlr_buffer_end_data_ptr_access;+};++pub const ClientBuffer = extern struct {+ base: Buffer,++ texture: ?*wlr.Texture,+ source: ?*wlr.Buffer,++ WLR_PRIVATE: @FieldType(c.wlr_client_buffer, "WLR_PRIVATE"),++ const wlr_client_buffer_get = abi.bind(fn (buffer: *wlr.Buffer) callconv(.c) ?*ClientBuffer, c.wlr_client_buffer_get);+ pub const get = wlr_client_buffer_get;+};++comptime {+ abi.assertLayout(ShmAttributes, c.wlr_shm_attributes);+ abi.assertLayout(Buffer, c.wlr_buffer);+ abi.assertLayout(Buffer.Impl, c.wlr_buffer_impl);+ abi.assertLayout(Buffer.ResourceInterface, c.wlr_buffer_resource_interface);+ abi.assertLayout(ClientBuffer, c.wlr_client_buffer);+}diff --git a/src/wlr/c.zig b/src/wlr/c.zigindex 2e34348..70b6860 100644--- a/src/wlr/c.zig+++ b/src/wlr/c.zig@@ -5,6 +5,7 @@//! subsystem migrates; never @cImport a header a second time elsewhere.pub const c = @cImport({@cDefine("WLR_USE_UNSTABLE", {});+ @cUndef("_FORTIFY_SOURCE");@cInclude("wlr/util/box.h");@cInclude("wlr/util/edges.h");@cInclude("wlr/types/wlr_output_power_management_v1.h");@@ -17,10 +18,82 @@ pub const c = @cImport({@cInclude("wlr/types/wlr_pointer_constraints_v1.h");@cInclude("wlr/types/wlr_output.h");@cInclude("wlr/types/wlr_output_layout.h");+ @cInclude("wlr/types/wlr_output_management_v1.h");+ @cInclude("wlr/types/wlr_xdg_output_v1.h");+ @cInclude("wlr/backend.h");+ @cInclude("wlr/backend/multi.h");+ @cInclude("wlr/backend/libinput.h");+ @cInclude("wlr/backend/session.h");+ @cInclude("wlr/types/wlr_presentation_time.h");+ @cInclude("wlr/render/wlr_renderer.h");+ @cInclude("wlr/render/allocator.h");+ @cInclude("wlr/render/gles2.h");+ @cInclude("wlr/render/pixman.h");+ @cInclude("wlr/render/pass.h");+ @cInclude("wlr/render/wlr_texture.h");+ @cInclude("wlr/render/drm_format_set.h");// isDrm/isWl/isX11/isHeadless are backend-specific predicates, declared// in each backend's own header rather than wlr_output.h.@cInclude("wlr/backend/drm.h");@cInclude("wlr/backend/headless.h");@cInclude("wlr/backend/wayland.h");@cInclude("wlr/backend/x11.h");+ @cInclude("wlr/config.h");+ @cInclude("wlr/version.h");+ @cInclude("wlr/render/color.h");+ @cInclude("wlr/render/dmabuf.h");+ @cInclude("wlr/render/drm_syncobj.h");+ @cInclude("wlr/render/swapchain.h");+ @cInclude("wlr/types/wlr_buffer.h");+ @cInclude("wlr/util/addon.h");+ @cInclude("wlr/util/log.h");+ @cInclude("wlr/util/region.h");+ @cInclude("wlr/types/wlr_compositor.h");+ @cInclude("wlr/types/wlr_subcompositor.h");+ @cInclude("wlr/types/wlr_scene.h");+ @cInclude("wlr/types/wlr_xdg_shell.h");+ @cInclude("wlr/types/wlr_xdg_activation_v1.h");+ @cInclude("wlr/types/wlr_xdg_decoration_v1.h");+ @cInclude("wlr/types/wlr_layer_shell_v1.h");+ @cInclude("wlr/xwayland.h");+ @cInclude("wlr/types/wlr_data_device.h");+ @cInclude("wlr/types/wlr_data_control_v1.h");+ @cInclude("wlr/types/wlr_ext_data_control_v1.h");+ @cInclude("wlr/types/wlr_primary_selection.h");+ @cInclude("wlr/types/wlr_primary_selection_v1.h");+ @cInclude("wlr/types/wlr_ext_foreign_toplevel_list_v1.h");+ @cInclude("wlr/types/wlr_foreign_toplevel_management_v1.h");+ @cInclude("wlr/types/wlr_ext_image_capture_source_v1.h");+ @cInclude("wlr/types/wlr_ext_image_copy_capture_v1.h");+ @cInclude("wlr/types/wlr_session_lock_v1.h");+ @cInclude("wlr/types/wlr_screencopy_v1.h");+ @cInclude("wlr/types/wlr_linux_dmabuf_v1.h");+ @cInclude("wlr/types/wlr_linux_drm_syncobj_v1.h");+ @cInclude("wlr/types/wlr_single_pixel_buffer_v1.h");+ @cInclude("wlr/types/wlr_viewporter.h");+ @cInclude("wlr/interfaces/wlr_ext_image_capture_source_v1.h");+ @cInclude("wlr/interfaces/wlr_buffer.h");+ @cInclude("wlr/xwayland/shell.h");+ @cInclude("wlr/xwayland/server.h");+ @cInclude("wlr/types/wlr_seat.h");+ @cInclude("wlr/types/wlr_cursor.h");+ @cInclude("wlr/types/wlr_input_device.h");+ @cInclude("wlr/types/wlr_keyboard.h");+ @cInclude("wlr/types/wlr_pointer.h");+ @cInclude("wlr/types/wlr_touch.h");+ @cInclude("wlr/types/wlr_switch.h");+ @cInclude("wlr/types/wlr_tablet_tool.h");+ @cInclude("wlr/types/wlr_tablet_pad.h");+ @cInclude("wlr/types/wlr_tablet_v2.h");+ @cInclude("wlr/types/wlr_virtual_keyboard_v1.h");+ @cInclude("wlr/types/wlr_virtual_pointer_v1.h");+ @cInclude("wlr/types/wlr_pointer_gestures_v1.h");+ @cInclude("wlr/types/wlr_cursor_shape_v1.h");+ @cInclude("wlr/types/wlr_text_input_v3.h");+ @cInclude("wlr/types/wlr_input_method_v2.h");+ @cInclude("wlr/types/wlr_xcursor_manager.h");+ @cInclude("wlr/types/wlr_keyboard_group.h");+ @cInclude("wlr/xcursor.h");+ @cInclude("wlr/interfaces/wlr_keyboard.h");+ @cInclude("wlr/interfaces/wlr_pointer.h");});diff --git a/src/wlr/color.zig b/src/wlr/color.zignew file mode 100644index 0000000..74ceb43--- /dev/null+++ b/src/wlr/color.zig@@ -0,0 +1,72 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++const wlr = @import("wlr.zig");++pub const NamedPrimaries = enum(c_int) {+ srgb = c.WLR_COLOR_NAMED_PRIMARIES_SRGB,+ bt2020 = c.WLR_COLOR_NAMED_PRIMARIES_BT2020,+};++pub const TransferFunction = enum(c_int) {+ srgb = c.WLR_COLOR_TRANSFER_FUNCTION_SRGB,+ st2084_pq = c.WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ,+ ext_linear = c.WLR_COLOR_TRANSFER_FUNCTION_EXT_LINEAR,+ gamma22 = c.WLR_COLOR_TRANSFER_FUNCTION_GAMMA22,+ bt1886 = c.WLR_COLOR_TRANSFER_FUNCTION_BT1886,+};++pub const Encoding = enum(c_int) {+ none = c.WLR_COLOR_ENCODING_NONE,+ identity = c.WLR_COLOR_ENCODING_IDENTITY,+ bt709 = c.WLR_COLOR_ENCODING_BT709,+ fcc = c.WLR_COLOR_ENCODING_FCC,+ bt601 = c.WLR_COLOR_ENCODING_BT601,+ smpte240 = c.WLR_COLOR_ENCODING_SMPTE240,+ bt2020 = c.WLR_COLOR_ENCODING_BT2020,+ bt2020_cl = c.WLR_COLOR_ENCODING_BT2020_CL,+ ictcp = c.WLR_COLOR_ENCODING_ICTCP,+};++pub const Range = enum(c_int) {+ none = c.WLR_COLOR_RANGE_NONE,+ limited = c.WLR_COLOR_RANGE_LIMITED,+ full = c.WLR_COLOR_RANGE_FULL,+};++pub const Cie1931Xy = extern struct {+ x: f32,+ y: f32,+};++pub const Primaries = extern struct {+ red: Cie1931Xy,+ green: Cie1931Xy,+ blue: Cie1931Xy,+ white: Cie1931Xy,+};++pub const Luminances = extern struct {+ min: f32,+ max: f32,+ reference: f32,+};++comptime {+ abi.assertLayout(Cie1931Xy, c.wlr_color_cie1931_xy);+ abi.assertLayout(Primaries, c.wlr_color_primaries);+ abi.assertLayout(Luminances, c.wlr_color_luminances);+}++pub fn primariesFromNamed(out: *Primaries, named: NamedPrimaries) void {+ c.wlr_color_primaries_from_named(@ptrCast(out), @intCast(@intFromEnum(named)));+}++pub fn transformInitLut3x1d(dim: usize, r: [*]const u16, g: [*]const u16, b: [*]const u16) ?*@import("wlr.zig").ColorTransform {+ return c.wlr_color_transform_init_lut_3x1d(dim, r, g, b);+}++pub fn transformUnref(transform: *@import("wlr.zig").ColorTransform) void {+ c.wlr_color_transform_unref(transform);+}diff --git a/src/wlr/compositor.zig b/src/wlr/compositor.zignew file mode 100644index 0000000..57676e0--- /dev/null+++ b/src/wlr/compositor.zig@@ -0,0 +1,282 @@+//! Typed wlroots header adapter. API shapes adapted from zig-wlroots;+//! see LICENSE.zig-wlroots for its MIT license.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const posix = @import("std").posix;++const pixman = @import("pixman");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const Compositor = extern struct {+ global: *wl.Global,+ renderer: ?*wlr.Renderer,++ events: extern struct {+ new_surface: wl.Signal(*wlr.Surface),+ destroy: wl.Signal(*wlr.Compositor),+ },++ const wlr_compositor_create = abi.bind(fn (server: *wl.Server, version: u32, renderer: ?*wlr.Renderer) callconv(.c) ?*Compositor, c.wlr_compositor_create);+ pub fn create(server: *wl.Server, version: u32, renderer: ?*wlr.Renderer) !*Compositor {+ return wlr_compositor_create(server, version, renderer) orelse error.OutOfMemory;+ }++ const wlr_compositor_set_renderer = abi.bind(fn (compositor: *Compositor, renderer: ?*wlr.Renderer) callconv(.c) void, c.wlr_compositor_set_renderer);+ pub const setRenderer = wlr_compositor_set_renderer;+};++pub const Surface = extern struct {+ pub const State = extern struct {+ pub const Fields = packed struct(u32) {+ buffer: bool = false,+ surface_damage: bool = false,+ buffer_damage: bool = false,+ opaque_region: bool = false,+ input_region: bool = false,+ transform: bool = false,+ scale: bool = false,+ frame_callback_list: bool = false,+ viewport: bool = false,+ offset: bool = false,+ _: u22 = 0,+ };++ committed: Fields,+ seq: u32,++ buffer: ?*wlr.Buffer,+ dx: i32,+ dy: i32,+ surface_damage: pixman.Region32,+ buffer_damage: pixman.Region32,+ @"opaque": pixman.Region32,+ input: pixman.Region32,+ transform: wl.Output.Transform,+ scale: i32,+ frame_callback_list: wl.list.Head(wl.Callback, null),++ width: c_int,+ height: c_int,+ buffer_width: c_int,+ buffer_height: c_int,++ subsurfaces_below: wl.list.Head(wlr.Subsurface.ParentState, .link),+ subsurfaces_above: wl.list.Head(wlr.Subsurface.ParentState, .link),++ viewport: extern struct {+ has_src: bool,+ has_dst: bool,+ src: wlr.FBox,+ dst_width: c_int,+ dst_height: c_int,+ },++ cached_state_locks: usize,+ cached_state_link: wl.list.Link,++ synced: wl.Array,++ const wlr_surface_state_has_buffer = abi.bind(fn (state: *State) callconv(.c) bool, c.wlr_surface_state_has_buffer);+ pub const hasBuffer = wlr_surface_state_has_buffer;+ };++ pub const Role = extern struct {+ name: [*:0]const u8,+ no_object: bool = false,+ client_commit: ?*const fn (surface: *Surface) callconv(.c) void = null,+ commit: ?*const fn (surface: *Surface) callconv(.c) void = null,+ map: ?*const fn (surface: *Surface) callconv(.c) void = null,+ unmap: ?*const fn (surface: *Surface) callconv(.c) void = null,+ destroy: ?*const fn (surface: *Surface) callconv(.c) void = null,+ };++ pub const Output = extern struct {+ surface: *wlr.Surface,+ output: *wlr.Output,++ // Surface.current_outputs+ link: wl.list.Link,+ };++ pub const Synced = extern struct {+ pub const Impl = extern struct {+ state_size: usize,+ init_state: ?*const fn (state: *anyopaque) callconv(.c) void,+ finish_state: ?*const fn (state: *anyopaque) callconv(.c) void,+ move_state: ?*const fn (dst: *anyopaque, src: *anyopaque) callconv(.c) void,+ commit: ?*const fn (synced: *Synced) callconv(.c) void = null,+ };++ surface: *Surface,+ impl: *const Impl,+ /// wlr.Surface.synced+ link: wl.list.Link,+ index: usize,++ const wlr_surface_synced_init = abi.bind(fn (+ synced: *Synced,+ surface: *Surface,+ impl: *const Impl,+ pending: *anyopaque,+ current: *anyopaque,+ ) callconv(.c) bool, c.wlr_surface_synced_init);+ pub inline fn init(+ synced: *Synced,+ surface: *Surface,+ impl: *const Impl,+ pending: *anyopaque,+ current: *anyopaque,+ ) error{OutOfMemory}!void {+ if (!wlr_surface_synced_init(synced, surface, impl, pending, current)) {+ return error.OutOfMemory;+ }+ }++ const wlr_surface_synced_finish = abi.bind(fn (synced: *Synced) callconv(.c) void, c.wlr_surface_synced_finish);+ pub const deinit = wlr_surface_synced_finish;++ const wlr_surface_synced_get_state = abi.bind(fn (synced: *Synced, state: *const Surface.State) callconv(.c) *anyopaque, c.wlr_surface_synced_get_state);+ pub const getState = wlr_surface_synced_get_state;+ };++ resource: *wl.Surface,+ compositor: *wlr.Compositor,++ buffer: ?*wlr.ClientBuffer,++ buffer_damage: pixman.Region32,+ opaque_region: pixman.Region32,+ input_region: pixman.Region32,++ current: State,+ pending: State,++ cached: wl.list.Head(Surface.State, .cached_state_link),++ mapped: bool,++ role: ?*const Role,+ role_resource: ?*wl.Resource,++ events: extern struct {+ client_commit: wl.Signal(void),+ commit: wl.Signal(*wlr.Surface),+ map: wl.Signal(void),+ unmap: wl.Signal(void),+ new_subsurface: wl.Signal(*wlr.Subsurface),+ destroy: wl.Signal(*wlr.Surface),+ },++ current_outputs: wl.list.Head(Surface.Output, .link),++ addons: wlr.AddonSet,+ data: ?*anyopaque,++ const wlr_surface_set_role = abi.bind(fn (+ surface: *Surface,+ role: *const Role,+ error_resource: ?*wl.Resource,+ error_code: u32,+ ) callconv(.c) bool, c.wlr_surface_set_role);+ pub const setRole = wlr_surface_set_role;++ const wlr_surface_set_role_object = abi.bind(fn (surface: *Surface, role_resource: *wl.Resource) callconv(.c) void, c.wlr_surface_set_role_object);+ pub const setRoleObject = wlr_surface_set_role_object;++ const wlr_surface_map = abi.bind(fn (surface: *Surface) callconv(.c) void, c.wlr_surface_map);+ pub const map = wlr_surface_map;++ const wlr_surface_unmap = abi.bind(fn (surface: *Surface) callconv(.c) void, c.wlr_surface_unmap);+ pub const unmap = wlr_surface_unmap;++ const wlr_surface_has_buffer = abi.bind(fn (surface: *Surface) callconv(.c) bool, c.wlr_surface_has_buffer);+ pub const hasBuffer = wlr_surface_has_buffer;++ const wlr_surface_get_texture = abi.bind(fn (surface: *Surface) callconv(.c) ?*wlr.Texture, c.wlr_surface_get_texture);+ pub const getTexture = wlr_surface_get_texture;++ const wlr_surface_get_root_surface = abi.bind(fn (surface: *Surface) callconv(.c) *Surface, c.wlr_surface_get_root_surface);+ pub const getRootSurface = wlr_surface_get_root_surface;++ const wlr_surface_point_accepts_input = abi.bind(fn (surface: *Surface, sx: f64, sy: f64) callconv(.c) bool, c.wlr_surface_point_accepts_input);+ pub const pointAcceptsInput = wlr_surface_point_accepts_input;++ const wlr_surface_surface_at = abi.bind(fn (surface: *Surface, sx: f64, sy: f64, sub_x: *f64, sub_y: *f64) callconv(.c) ?*Surface, c.wlr_surface_surface_at);+ pub const surfaceAt = wlr_surface_surface_at;++ const wlr_surface_send_enter = abi.bind(fn (surface: *Surface, output: *wlr.Output) callconv(.c) void, c.wlr_surface_send_enter);+ pub const sendEnter = wlr_surface_send_enter;++ const wlr_surface_send_leave = abi.bind(fn (surface: *Surface, output: *wlr.Output) callconv(.c) void, c.wlr_surface_send_leave);+ pub const sendLeave = wlr_surface_send_leave;++ const wlr_surface_send_frame_done = abi.bind(fn (surface: *Surface, when: *const posix.timespec) callconv(.c) void, c.wlr_surface_send_frame_done);+ pub const sendFrameDone = wlr_surface_send_frame_done;++ const wlr_surface_get_extents = abi.bind(fn (surface: *Surface, box: *wlr.Box) callconv(.c) void, c.wlr_surface_get_extents);+ pub const getExtents = wlr_surface_get_extents;++ const wlr_surface_from_resource = abi.bind(fn (resource: *wl.Surface) callconv(.c) *Surface, c.wlr_surface_from_resource);+ pub const fromWlSurface = wlr_surface_from_resource;++ const wlr_surface_for_each_surface = abi.bind(fn (+ surface: *Surface,+ iterator: *const fn (surface: *Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void,+ user_data: ?*anyopaque,+ ) callconv(.c) void, c.wlr_surface_for_each_surface);+ pub inline fn forEachSurface(+ surface: *Surface,+ comptime T: type,+ comptime iterator: fn (surface: *Surface, sx: c_int, sy: c_int, data: T) void,+ data: T,+ ) void {+ wlr_surface_for_each_surface(+ surface,+ struct {+ fn wrapper(s: *Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void {+ iterator(s, sx, sy, @ptrCast(@alignCast(d)));+ }+ }.wrapper,+ data,+ );+ }++ const wlr_surface_get_effective_damage = abi.bind(fn (surface: *Surface, damage: *pixman.Region32) callconv(.c) void, c.wlr_surface_get_effective_damage);+ pub const getEffectiveDamage = wlr_surface_get_effective_damage;++ const wlr_surface_get_buffer_source_box = abi.bind(fn (surface: *Surface, box: *wlr.FBox) callconv(.c) void, c.wlr_surface_get_buffer_source_box);+ pub const getBufferSourceBox = wlr_surface_get_buffer_source_box;++ const wlr_surface_accepts_touch = abi.bind(fn (surface: *Surface, seat: *wlr.Seat) callconv(.c) bool, c.wlr_surface_accepts_touch);+ pub const acceptsTouch = wlr_surface_accepts_touch;++ const wlr_surface_accepts_tablet_v2 = abi.bind(fn (surface: *Surface, tablet: *wlr.TabletV2Tablet) callconv(.c) bool, c.wlr_surface_accepts_tablet_v2);+ pub const acceptsTabletV2 = wlr_surface_accepts_tablet_v2;++ const wlr_surface_lock_pending = abi.bind(fn (surface: *Surface) callconv(.c) u32, c.wlr_surface_lock_pending);+ pub const lockPending = wlr_surface_lock_pending;++ const wlr_surface_unlock_cached = abi.bind(fn (surface: *Surface, seq: u32) callconv(.c) void, c.wlr_surface_unlock_cached);+ pub const unlockCached = wlr_surface_unlock_cached;++ const wlr_surface_set_preferred_buffer_scale = abi.bind(fn (surface: *Surface, scale: i32) callconv(.c) void, c.wlr_surface_set_preferred_buffer_scale);+ pub const setPreferredBufferScale = wlr_surface_set_preferred_buffer_scale;++ const wlr_surface_set_preferred_buffer_transform = abi.bind(fn (surface: *Surface, transform: wl.Output.Transform) callconv(.c) void, c.wlr_surface_set_preferred_buffer_transform);+ pub const setPreferredBufferTransform = wlr_surface_set_preferred_buffer_transform;+};++comptime {+ @setEvalBranchQuota(10000);+ abi.assertFields(Compositor, c.wlr_compositor);+ abi.assertFields(Surface, c.wlr_surface);+ abi.assertLayout(Surface.State, c.wlr_surface_state);+ abi.assertLayout(Surface.Role, c.wlr_surface_role);+ abi.assertFields(Surface.Output, c.wlr_surface_output);+ abi.assertLayout(Surface.Synced, c.wlr_surface_synced);+ abi.assertLayout(Surface.Synced.Impl, c.wlr_surface_synced_impl);+}diff --git a/src/wlr/config.zig b/src/wlr/config.zignew file mode 100644index 0000000..10f93a3--- /dev/null+++ b/src/wlr/config.zig@@ -0,0 +1,16 @@+const c = @import("c.zig").c;++pub const has_drm_backend = c.WLR_HAS_DRM_BACKEND != 0;+pub const has_libinput_backend = c.WLR_HAS_LIBINPUT_BACKEND != 0;+pub const has_x11_backend = c.WLR_HAS_X11_BACKEND != 0;++pub const has_gles2_renderer = c.WLR_HAS_GLES2_RENDERER != 0;+pub const has_vulkan_renderer = c.WLR_HAS_VULKAN_RENDERER != 0;++pub const has_gbm_allocator = c.WLR_HAS_GBM_ALLOCATOR != 0;++pub const has_xwayland = c.WLR_HAS_XWAYLAND != 0;++pub const has_session = c.WLR_HAS_SESSION != 0;++pub const has_color_management = c.WLR_HAS_COLOR_MANAGEMENT != 0;diff --git a/src/wlr/cursor.zig b/src/wlr/cursor.zignew file mode 100644index 0000000..108f72e--- /dev/null+++ b/src/wlr/cursor.zig@@ -0,0 +1,105 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const Cursor = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_cursor);+ }++ pub const State = opaque {};++ state: *State,+ x: f64,+ y: f64,++ events: extern struct {+ motion: wl.Signal(*wlr.Pointer.event.Motion),+ motion_absolute: wl.Signal(*wlr.Pointer.event.MotionAbsolute),+ button: wl.Signal(*wlr.Pointer.event.Button),+ axis: wl.Signal(*wlr.Pointer.event.Axis),+ frame: wl.Signal(*Cursor),+ swipe_begin: wl.Signal(*wlr.Pointer.event.SwipeBegin),+ swipe_update: wl.Signal(*wlr.Pointer.event.SwipeUpdate),+ swipe_end: wl.Signal(*wlr.Pointer.event.SwipeEnd),+ pinch_begin: wl.Signal(*wlr.Pointer.event.PinchBegin),+ pinch_update: wl.Signal(*wlr.Pointer.event.PinchUpdate),+ pinch_end: wl.Signal(*wlr.Pointer.event.PinchEnd),+ hold_begin: wl.Signal(*wlr.Pointer.event.HoldBegin),+ hold_end: wl.Signal(*wlr.Pointer.event.HoldEnd),++ touch_up: wl.Signal(*wlr.Touch.event.Up),+ touch_down: wl.Signal(*wlr.Touch.event.Down),+ touch_motion: wl.Signal(*wlr.Touch.event.Motion),+ touch_cancel: wl.Signal(*wlr.Touch.event.Cancel),+ touch_frame: wl.Signal(void),++ tablet_tool_axis: wl.Signal(*wlr.Tablet.event.Axis),+ tablet_tool_proximity: wl.Signal(*wlr.Tablet.event.Proximity),+ tablet_tool_tip: wl.Signal(*wlr.Tablet.event.Tip),+ tablet_tool_button: wl.Signal(*wlr.Tablet.event.Button),+ },++ data: ?*anyopaque,++ const wlr_cursor_create = abi.bind(fn () callconv(.c) ?*Cursor, c.wlr_cursor_create);+ pub fn create() !*Cursor {+ return wlr_cursor_create() orelse error.OutOfMemory;+ }++ const wlr_cursor_destroy = abi.bind(fn (cur: *Cursor) callconv(.c) void, c.wlr_cursor_destroy);+ pub const destroy = wlr_cursor_destroy;++ const wlr_cursor_warp = abi.bind(fn (cur: *Cursor, dev: ?*wlr.InputDevice, lx: f64, ly: f64) callconv(.c) bool, c.wlr_cursor_warp);+ pub const warp = wlr_cursor_warp;++ const wlr_cursor_absolute_to_layout_coords = abi.bind(fn (cur: *Cursor, dev: ?*wlr.InputDevice, x: f64, y: f64, lx: *f64, ly: *f64) callconv(.c) void, c.wlr_cursor_absolute_to_layout_coords);+ pub const absoluteToLayoutCoords = wlr_cursor_absolute_to_layout_coords;++ const wlr_cursor_warp_closest = abi.bind(fn (cur: *Cursor, dev: ?*wlr.InputDevice, x: f64, y: f64) callconv(.c) void, c.wlr_cursor_warp_closest);+ pub const warpClosest = wlr_cursor_warp_closest;++ const wlr_cursor_warp_absolute = abi.bind(fn (cur: *Cursor, dev: ?*wlr.InputDevice, x: f64, y: f64) callconv(.c) void, c.wlr_cursor_warp_absolute);+ pub const warpAbsolute = wlr_cursor_warp_absolute;++ const wlr_cursor_move = abi.bind(fn (cur: *Cursor, dev: ?*wlr.InputDevice, delta_x: f64, delta_y: f64) callconv(.c) void, c.wlr_cursor_move);+ pub const move = wlr_cursor_move;++ const wlr_cursor_set_buffer = abi.bind(fn (cur: *Cursor, buffer: *wlr.Buffer, hotspot_x: i32, hotspot_y: i32, scale: f32) callconv(.c) void, c.wlr_cursor_set_buffer);+ pub const setBuffer = wlr_cursor_set_buffer;++ const wlr_cursor_unset_image = abi.bind(fn (cur: *Cursor) callconv(.c) void, c.wlr_cursor_unset_image);+ pub const unsetImage = wlr_cursor_unset_image;++ const wlr_cursor_set_xcursor = abi.bind(fn (cur: *Cursor, manager: *wlr.XcursorManager, name: [*:0]const u8) callconv(.c) void, c.wlr_cursor_set_xcursor);+ pub const setXcursor = wlr_cursor_set_xcursor;++ const wlr_cursor_set_surface = abi.bind(fn (cur: *Cursor, surface: ?*wlr.Surface, hotspot_x: i32, hotspot_y: i32) callconv(.c) void, c.wlr_cursor_set_surface);+ pub const setSurface = wlr_cursor_set_surface;++ const wlr_cursor_attach_input_device = abi.bind(fn (cur: *Cursor, dev: *wlr.InputDevice) callconv(.c) void, c.wlr_cursor_attach_input_device);+ pub const attachInputDevice = wlr_cursor_attach_input_device;++ const wlr_cursor_detach_input_device = abi.bind(fn (cur: *Cursor, dev: *wlr.InputDevice) callconv(.c) void, c.wlr_cursor_detach_input_device);+ pub const detachInputDevice = wlr_cursor_detach_input_device;++ const wlr_cursor_attach_output_layout = abi.bind(fn (cur: *Cursor, l: *wlr.OutputLayout) callconv(.c) void, c.wlr_cursor_attach_output_layout);+ pub const attachOutputLayout = wlr_cursor_attach_output_layout;++ const wlr_cursor_map_to_output = abi.bind(fn (cur: *Cursor, output: *wlr.Output) callconv(.c) void, c.wlr_cursor_map_to_output);+ pub const mapToOutput = wlr_cursor_map_to_output;++ const wlr_cursor_map_input_to_output = abi.bind(fn (cur: *Cursor, dev: *wlr.InputDevice, output: ?*wlr.Output) callconv(.c) void, c.wlr_cursor_map_input_to_output);+ pub const mapInputToOutput = wlr_cursor_map_input_to_output;++ const wlr_cursor_map_to_region = abi.bind(fn (cur: *Cursor, box: *const wlr.Box) callconv(.c) void, c.wlr_cursor_map_to_region);+ pub const mapToRegion = wlr_cursor_map_to_region;++ const wlr_cursor_map_input_to_region = abi.bind(fn (cur: *Cursor, dev: *wlr.InputDevice, box: *const wlr.Box) callconv(.c) void, c.wlr_cursor_map_input_to_region);+ pub const mapInputToRegion = wlr_cursor_map_input_to_region;+};diff --git a/src/wlr/cursor_shape_v1.zig b/src/wlr/cursor_shape_v1.zignew file mode 100644index 0000000..efed7ef--- /dev/null+++ b/src/wlr/cursor_shape_v1.zig@@ -0,0 +1,53 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const wp = wayland.server.wp;++pub const CursorShapeManagerV1 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_cursor_shape_manager_v1);+ }++ global: *wl.Global,++ events: extern struct {+ request_set_shape: wl.Signal(*event.RequestSetShape),+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ WLR_PRIVATE: @FieldType(c.wlr_cursor_shape_manager_v1, "WLR_PRIVATE"),++ pub const DeviceType = enum(c_int) {+ pointer = c.WLR_CURSOR_SHAPE_MANAGER_V1_DEVICE_TYPE_POINTER,+ tablet_tool = c.WLR_CURSOR_SHAPE_MANAGER_V1_DEVICE_TYPE_TABLET_TOOL,+ };++ pub const event = struct {+ pub const RequestSetShape = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_cursor_shape_manager_v1_request_set_shape_event);+ }++ seat_client: *wlr.Seat.Client,+ device_type: DeviceType,+ tablet_tool: ?*wlr.TabletV2TabletTool,+ serial: u32,+ shape: wp.CursorShapeDeviceV1.Shape,+ };+ };++ const wlr_cursor_shape_manager_v1_create = abi.bind(fn (server: *wl.Server, version: u32) callconv(.c) ?*CursorShapeManagerV1, c.wlr_cursor_shape_manager_v1_create);+ pub fn create(server: *wl.Server, version: u32) !*CursorShapeManagerV1 {+ return wlr_cursor_shape_manager_v1_create(server, version) orelse error.OutOfMemory;+ }++ const wlr_cursor_shape_v1_name = abi.bind(fn (shape: wp.CursorShapeDeviceV1.Shape) callconv(.c) [*:0]const u8, c.wlr_cursor_shape_v1_name);+ pub const shapeName = wlr_cursor_shape_v1_name;+};diff --git a/src/wlr/data_control_v1.zig b/src/wlr/data_control_v1.zignew file mode 100644index 0000000..cf0b22b--- /dev/null+++ b/src/wlr/data_control_v1.zig@@ -0,0 +1,41 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const DataControlManagerV1 = extern struct {+ global: *wl.Global,+ devices: wl.list.Head(DataControlDeviceV1, .link),++ events: extern struct {+ destroy: wl.Signal(*DataControlManagerV1),+ new_device: wl.Signal(*DataControlDeviceV1),+ },++ const wlr_data_control_manager_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*DataControlManagerV1, c.wlr_data_control_manager_v1_create);+ pub fn create(server: *wl.Server) !*DataControlManagerV1 {+ return wlr_data_control_manager_v1_create(server) orelse error.OutOfMemory;+ }+};++pub const DataControlDeviceV1 = extern struct {+ resource: *wl.Resource,+ manager: *DataControlManagerV1,+ /// DataControlManagerV1.devices+ link: wl.list.Link,++ seat: *wlr.Seat,+ selection_offer_resource: ?*wl.Resource,+ primary_selection_offer_resource: ?*wl.Resource,++ const wlr_data_control_device_v1_destroy = abi.bind(fn (device: *DataControlDeviceV1) callconv(.c) void, c.wlr_data_control_device_v1_destroy);+ pub const destroy = wlr_data_control_device_v1_destroy;+};++comptime {+ abi.assertFields(DataControlManagerV1, c.wlr_data_control_manager_v1);+ abi.assertFields(DataControlDeviceV1, c.wlr_data_control_device_v1);+}diff --git a/src/wlr/data_device.zig b/src/wlr/data_device.zignew file mode 100644index 0000000..8330484--- /dev/null+++ b/src/wlr/data_device.zig@@ -0,0 +1,173 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const DataDeviceManager = extern struct {+ global: *wl.Global,+ data_sources: wl.list.Head(wl.DataSource, null),++ events: extern struct {+ destroy: wl.Signal(*DataDeviceManager),+ },++ data: ?*anyopaque,++ const wlr_data_device_manager_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*DataDeviceManager, c.wlr_data_device_manager_create);+ pub fn create(server: *wl.Server) !*DataDeviceManager {+ return wlr_data_device_manager_create(server) orelse error.OutOfMemory;+ }+};++pub const DataOffer = extern struct {+ pub const Type = enum(c_int) {+ selection = c.WLR_DATA_OFFER_SELECTION,+ drag = c.WLR_DATA_OFFER_DRAG,+ };++ resource: *wl.DataOffer,+ source: ?*DataSource,+ type: Type,+ /// wlr.Seat.selection_offers, wlr.Seat.drag_offers+ link: wl.list.Link,++ actions: u32,+ preferred_action: wl.DataDeviceManager.DndAction.Enum,+ in_ask: bool,+};++pub const DataSource = extern struct {+ pub const Impl = extern struct {+ send: *const fn (source: *DataSource, mime_type: [*:0]const u8, fd: i32) callconv(.c) void,+ accept: ?*const fn (source: *DataSource, serial: u32, mime_type: ?[*:0]const u8) callconv(.c) void,+ destroy: ?*const fn (source: *DataSource) callconv(.c) void,+ dnd_drop: ?*const fn (source: *DataSource) callconv(.c) void,+ dnd_finish: ?*const fn (source: *DataSource) callconv(.c) void,+ dnd_action: ?*const fn (source: *DataSource, wl.DataDeviceManager.DndAction.Enum) callconv(.c) void,+ };++ impl: *const Impl,++ mime_types: wl.Array,+ actions: i32,++ accepted: bool,++ current_dnd_action: wl.DataDeviceManager.DndAction.Enum,+ compositor_action: u32,++ events: extern struct {+ destroy: wl.Signal(*DataSource),+ },++ const wlr_data_source_init = abi.bind(fn (source: *DataSource, impl: *const Impl) callconv(.c) void, c.wlr_data_source_init);+ pub const init = wlr_data_source_init;++ const wlr_data_source_send = abi.bind(fn (source: *DataSource, mime_type: [*:0]const u8, fd: i32) callconv(.c) void, c.wlr_data_source_send);+ pub const send = wlr_data_source_send;++ const wlr_data_source_accept = abi.bind(fn (source: *DataSource, serial: u32, mime_type: ?[*:0]const u8) callconv(.c) void, c.wlr_data_source_accept);+ pub const accept = wlr_data_source_accept;++ const wlr_data_source_destroy = abi.bind(fn (source: *DataSource) callconv(.c) void, c.wlr_data_source_destroy);+ pub const destroy = wlr_data_source_destroy;++ const wlr_data_source_dnd_drop = abi.bind(fn (source: *DataSource) callconv(.c) void, c.wlr_data_source_dnd_drop);+ pub const dndDrop = wlr_data_source_dnd_drop;++ const wlr_data_source_dnd_finish = abi.bind(fn (source: *DataSource) callconv(.c) void, c.wlr_data_source_dnd_finish);+ pub const dndFinish = wlr_data_source_dnd_finish;++ const wlr_data_source_dnd_action = abi.bind(fn (source: *DataSource, action: wl.DataDeviceManager.DndAction.Enum) callconv(.c) void, c.wlr_data_source_dnd_action);+ pub const dndAction = wlr_data_source_dnd_action;+};++pub const Drag = extern struct {+ pub const Icon = extern struct {+ drag: *Drag,+ surface: *wlr.Surface,++ events: extern struct {+ destroy: wl.Signal(*Drag.Icon),+ },++ data: ?*anyopaque,+ };++ pub const GrabType = enum(c_int) {+ keyboard = c.WLR_DRAG_GRAB_KEYBOARD,+ keyboard_pointer = c.WLR_DRAG_GRAB_KEYBOARD_POINTER,+ keyboard_touch = c.WLR_DRAG_GRAB_KEYBOARD_TOUCH,+ };++ pub const event = struct {+ pub const Motion = extern struct {+ drag: *Drag,+ time: u32,+ sx: f64,+ sy: f64,+ };++ pub const Drop = extern struct {+ drag: *Drag,+ time: u32,+ };+ };++ grab_type: GrabType,+ keyboard_grab: wlr.Seat.KeyboardGrab,+ pointer_grab: wlr.Seat.PointerGrab,+ touch_grab: wlr.Seat.TouchGrab,++ seat: *wlr.Seat,+ seat_client: *wlr.Seat.Client,+ focus_client: ?*wlr.Seat.Client,++ icon: ?*Drag.Icon,+ focus: ?*wlr.Surface,+ source: ?*DataSource,++ started: bool,+ dropped: bool,+ cancelling: bool,+ grab_touch_id: i32,+ touch_id: i32,++ events: extern struct {+ focus: wl.Signal(*Drag),+ motion: wl.Signal(*event.Motion),+ drop: wl.Signal(*event.Drop),+ destroy: wl.Signal(*Drag),+ },++ data: ?*anyopaque,++ const wlr_drag_create = abi.bind(fn (+ seat_client: *wlr.Seat.Client,+ source: ?*DataSource,+ icon_surface: ?*wlr.Surface,+ ) callconv(.c) ?*Drag, c.wlr_drag_create);+ pub fn create(+ seat_client: *wlr.Seat.Client,+ source: ?*DataSource,+ icon_surface: ?*wlr.Surface,+ ) !*Drag {+ return wlr_drag_create(seat_client, source, icon_surface) orelse error.OutOfMemory;+ }+};++comptime {+ abi.assertFields(DataDeviceManager, c.wlr_data_device_manager);+ abi.assertFields(DataOffer, c.wlr_data_offer);+ abi.assertFields(DataSource, c.wlr_data_source);+ @import("signal.zig").assertSameLayout(DataSource, c.wlr_data_source);+ abi.assertFields(DataSource.Impl, c.wlr_data_source_impl);+ @import("signal.zig").assertSameLayout(DataSource.Impl, c.wlr_data_source_impl);+ abi.assertFields(Drag, c.wlr_drag);+ abi.assertFields(Drag.Icon, c.wlr_drag_icon);+ abi.assertFields(Drag.event.Motion, c.wlr_drag_motion_event);+ abi.assertFields(Drag.event.Drop, c.wlr_drag_drop_event);+}diff --git a/src/wlr/dmabuf.zig b/src/wlr/dmabuf.zignew file mode 100644index 0000000..0f49de3--- /dev/null+++ b/src/wlr/dmabuf.zig@@ -0,0 +1,25 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++pub const DmabufAttributes = extern struct {+ width: i32,+ height: i32,+ format: u32,+ modifier: u64,++ n_planes: c_int,+ offset: [4]u32,+ stride: [4]u32,+ fd: [4]c_int,++ const wlr_dmabuf_attributes_finish = abi.bind(fn (attribs: *DmabufAttributes) callconv(.c) void, c.wlr_dmabuf_attributes_finish);+ pub const finish = wlr_dmabuf_attributes_finish;++ const wlr_dmabuf_attributes_copy = abi.bind(fn (dst: *DmabufAttributes, src: *const DmabufAttributes) callconv(.c) bool, c.wlr_dmabuf_attributes_copy);+ pub const copy = wlr_dmabuf_attributes_copy;+};++comptime {+ abi.assertLayout(DmabufAttributes, c.wlr_dmabuf_attributes);+}diff --git a/src/wlr/drm_format_set.zig b/src/wlr/drm_format_set.zignew file mode 100644index 0000000..42c247b--- /dev/null+++ b/src/wlr/drm_format_set.zig@@ -0,0 +1,45 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++pub const DrmFormat = extern struct {+ format: u32,+ len: usize,+ capacity: usize,+ modifiers: ?[*]u64,++ const wlr_drm_format_finish = abi.bind(fn (format: *DrmFormat) callconv(.c) void, c.wlr_drm_format_finish);+ pub const finish = wlr_drm_format_finish;+};++pub const DrmFormatSet = extern struct {+ len: usize,+ capacity: usize,+ formats: ?[*]DrmFormat,++ const wlr_drm_format_set_finish = abi.bind(fn (set: *DrmFormatSet) callconv(.c) void, c.wlr_drm_format_set_finish);+ pub const finish = wlr_drm_format_set_finish;++ const wlr_drm_format_set_get = abi.bind(fn (set: *const DrmFormatSet, format: u32) callconv(.c) ?*const DrmFormat, c.wlr_drm_format_set_get);+ pub const get = wlr_drm_format_set_get;++ const wlr_drm_format_set_remove = abi.bind(fn (set: *DrmFormatSet, format: u32, modifier: u64) callconv(.c) bool, c.wlr_drm_format_set_remove);+ pub const remove = wlr_drm_format_set_remove;++ const wlr_drm_format_set_has = abi.bind(fn (set: *const DrmFormatSet, format: u32, modifier: u64) callconv(.c) bool, c.wlr_drm_format_set_has);+ pub const has = wlr_drm_format_set_has;++ const wlr_drm_format_set_add = abi.bind(fn (set: *DrmFormatSet, format: u32, modifier: u64) callconv(.c) bool, c.wlr_drm_format_set_add);+ pub const add = wlr_drm_format_set_add;++ const wlr_drm_format_set_intersect = abi.bind(fn (dst: *DrmFormatSet, a: *const DrmFormatSet, b: *const DrmFormatSet) callconv(.c) bool, c.wlr_drm_format_set_intersect);+ pub const intersect = wlr_drm_format_set_intersect;++ const wlr_drm_format_set_union = abi.bind(fn (dst: *DrmFormatSet, a: *const DrmFormatSet, b: *const DrmFormatSet) callconv(.c) bool, c.wlr_drm_format_set_union);+ pub const @"union" = wlr_drm_format_set_union;+};++comptime {+ abi.assertLayout(DrmFormat, c.wlr_drm_format);+ abi.assertLayout(DrmFormatSet, c.wlr_drm_format_set);+}diff --git a/src/wlr/edges.zig b/src/wlr/edges.zigindex ce546a9..a446a3f 100644--- a/src/wlr/edges.zig+++ b/src/wlr/edges.zig@@ -9,3 +9,12 @@ pub const Edges = packed struct(u32) {right: bool = false,_: u28 = 0,};++comptime {+ const c = @import("c.zig").c;+ if (@as(u32, @bitCast(Edges{ .top = true })) != c.WLR_EDGE_TOP or+ @as(u32, @bitCast(Edges{ .bottom = true })) != c.WLR_EDGE_BOTTOM or+ @as(u32, @bitCast(Edges{ .left = true })) != c.WLR_EDGE_LEFT or+ @as(u32, @bitCast(Edges{ .right = true })) != c.WLR_EDGE_RIGHT)+ @compileError("wlroots edge bit values changed");+}diff --git a/src/wlr/ext_data_control_v1.zig b/src/wlr/ext_data_control_v1.zignew file mode 100644index 0000000..77c8d79--- /dev/null+++ b/src/wlr/ext_data_control_v1.zig@@ -0,0 +1,41 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const ExtDataControlManagerV1 = extern struct {+ global: *wl.Global,+ devices: wl.list.Head(ExtDataControlDeviceV1, .link),++ events: extern struct {+ destroy: wl.Signal(void),+ new_device: wl.Signal(*ExtDataControlDeviceV1),+ },++ const wlr_ext_data_control_manager_v1_create = abi.bind(fn (server: *wl.Server, version: u32) callconv(.c) ?*ExtDataControlManagerV1, c.wlr_ext_data_control_manager_v1_create);+ pub fn create(server: *wl.Server, version: u32) !*ExtDataControlManagerV1 {+ return wlr_ext_data_control_manager_v1_create(server, version) orelse error.OutOfMemory;+ }+};++pub const ExtDataControlDeviceV1 = extern struct {+ resource: *wl.Resource,+ manager: *ExtDataControlManagerV1,+ /// ExtDataControlManagerV1.devices+ link: wl.list.Link,++ seat: *wlr.Seat,+ selection_offer_resource: ?*wl.Resource,+ primary_selection_offer_resource: ?*wl.Resource,++ const wlr_ext_data_control_device_v1_destroy = abi.bind(fn (device: *ExtDataControlDeviceV1) callconv(.c) void, c.wlr_ext_data_control_device_v1_destroy);+ pub const destroy = wlr_ext_data_control_device_v1_destroy;+};++comptime {+ abi.assertFields(ExtDataControlManagerV1, c.wlr_ext_data_control_manager_v1);+ abi.assertFields(ExtDataControlDeviceV1, c.wlr_ext_data_control_device_v1);+}diff --git a/src/wlr/ext_image_capture_source_v1.zig b/src/wlr/ext_image_capture_source_v1.zignew file mode 100644index 0000000..79583fc--- /dev/null+++ b/src/wlr/ext_image_capture_source_v1.zig@@ -0,0 +1,174 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const posix = @import("std").posix;++const wayland = @import("wayland");+const wl = wayland.server.wl;++const pixman = @import("pixman");++pub const ExtImageCaptureSourceV1 = extern struct {+ pub const Interface = extern struct {+ start: ?*const fn (source: *ExtImageCaptureSourceV1, with_cursors: bool) callconv(.c) void,+ stop: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.c) void,+ request_frame: ?*const fn (source: *ExtImageCaptureSourceV1, schedule_frame: bool) callconv(.c) void,+ copy_frame: *const fn (+ source: *ExtImageCaptureSourceV1,+ dst_frame: *wlr.ExtImageCopyCaptureFrameV1,+ frame_event: *event.Frame,+ ) callconv(.c) void,+ get_pointer_cursor: ?*const fn (source: *ExtImageCaptureSourceV1, seat: *wlr.Seat) callconv(.c) *Cursor,+ };++ pub const event = struct {+ pub const Frame = extern struct {+ damage: *const pixman.Region32,+ };+ };++ impl: *const Interface,+ resources: wl.list.Head(wl.Resource, null),++ width: u32,+ height: u32,++ shm_formats: ?[*]u32,+ shm_formats_len: usize,++ dmabuf_device: posix.dev_t,+ dmabuf_formats: wlr.DrmFormatSet,++ events: extern struct {+ constraints_update: wl.Signal(void),+ frame: wl.Signal(*event.Frame),+ destroy: wl.Signal(void),+ },++ const wlr_ext_image_capture_source_v1_init = abi.bind(fn (source: *ExtImageCaptureSourceV1, impl: *const Interface) callconv(.c) void, c.wlr_ext_image_capture_source_v1_init);+ pub const init = wlr_ext_image_capture_source_v1_init;++ const wlr_ext_image_capture_source_v1_finish = abi.bind(fn (source: *ExtImageCaptureSourceV1) callconv(.c) void, c.wlr_ext_image_capture_source_v1_finish);+ pub const finish = wlr_ext_image_capture_source_v1_finish;++ const wlr_ext_image_capture_source_v1_create_resource = abi.bind(fn (+ source: *ExtImageCaptureSourceV1,+ client: *wl.Client,+ new_id: u32,+ ) callconv(.c) bool, c.wlr_ext_image_capture_source_v1_create_resource);+ pub const createResource = wlr_ext_image_capture_source_v1_create_resource;++ const wlr_ext_image_capture_source_v1_set_constraints_from_swapchain = abi.bind(fn (+ source: *ExtImageCaptureSourceV1,+ swapchain: *wlr.Swapchain,+ renderer: *wlr.Renderer,+ ) callconv(.c) bool, c.wlr_ext_image_capture_source_v1_set_constraints_from_swapchain);+ pub const setContraintsFromSwapchain = wlr_ext_image_capture_source_v1_set_constraints_from_swapchain;++ const wlr_ext_image_capture_source_v1_from_resource = abi.bind(fn (resource: *wl.Resource) callconv(.c) ?*ExtImageCaptureSourceV1, c.wlr_ext_image_capture_source_v1_from_resource);+ pub const fromResource = wlr_ext_image_capture_source_v1_from_resource;++ pub const Cursor = extern struct {+ base: ExtImageCaptureSourceV1,++ entered: bool,+ x: i32,+ y: i32,+ hotspot: extern struct {+ x: i32,+ y: i32,+ },++ events: extern struct {+ update: wl.Signal(void),+ },++ const wlr_ext_image_capture_source_v1_cursor_init = abi.bind(fn (source_cursor: *Cursor, impl: *const Interface) callconv(.c) void, c.wlr_ext_image_capture_source_v1_cursor_init);+ pub const init = wlr_ext_image_capture_source_v1_cursor_init;++ const wlr_ext_image_capture_source_v1_cursor_finish = abi.bind(fn (source_cursor: *Cursor) callconv(.c) void, c.wlr_ext_image_capture_source_v1_cursor_finish);+ pub const finish = wlr_ext_image_capture_source_v1_cursor_finish;+ };++ const wlr_output_try_from_ext_image_capture_source_v1 = abi.bind(fn (source: *ExtImageCaptureSourceV1) callconv(.c) ?*wlr.Output, c.wlr_output_try_from_ext_image_capture_source_v1);+ pub const toOutput = wlr_output_try_from_ext_image_capture_source_v1;++ const wlr_ext_image_capture_source_v1_create_with_scene_node = abi.bind(fn (+ node: *wlr.SceneNode,+ event_loop: *wl.EventLoop,+ allocator: *wlr.Allocator,+ renderer: *wlr.Renderer,+ ) callconv(.c) ?*ExtImageCaptureSourceV1, c.wlr_ext_image_capture_source_v1_create_with_scene_node);+ pub fn createWithSceneNode(+ node: *wlr.SceneNode,+ event_loop: *wl.EventLoop,+ allocator: *wlr.Allocator,+ renderer: *wlr.Renderer,+ ) !*ExtImageCaptureSourceV1 {+ return wlr_ext_image_capture_source_v1_create_with_scene_node(+ node,+ event_loop,+ allocator,+ renderer,+ ) orelse error.OutOfMemory;+ }+};++pub const ExtOutputImageCaptureSourceManagerV1 = extern struct {+ global: *wl.Global,++ const wlr_ext_output_image_capture_source_manager_v1_create = abi.bind(fn (+ server: *wl.Server,+ version: u32,+ ) callconv(.c) ?*ExtOutputImageCaptureSourceManagerV1, c.wlr_ext_output_image_capture_source_manager_v1_create);+ pub fn create(server: *wl.Server, version: u32) !*ExtOutputImageCaptureSourceManagerV1 {+ return wlr_ext_output_image_capture_source_manager_v1_create(server, version) orelse error.OutOfMemory;+ }+};++pub const ExtForeignToplevelImageCaptureSourceManagerV1 = extern struct {+ pub const Request = extern struct {+ toplevel_handle: *wlr.ExtForeignToplevelHandleV1,+ client: *wl.Client,++ const wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept = abi.bind(fn (+ request: *Request,+ source: *ExtImageCaptureSourceV1,+ ) callconv(.c) bool, c.wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept);+ pub const accept = wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept;+ };++ global: *wl.Global,++ events: extern struct {+ destroy: wl.Signal(void),+ new_request: wl.Signal(*Request),+ },++ const wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create = abi.bind(fn (+ server: *wl.Server,+ version: u32,+ ) callconv(.c) ?*ExtForeignToplevelImageCaptureSourceManagerV1, c.wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create);+ pub fn create(server: *wl.Server, version: u32) !*ExtForeignToplevelImageCaptureSourceManagerV1 {+ return wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(+ server,+ version,+ ) orelse error.OutOfMemory;+ }+};++comptime {+ abi.assertFields(ExtImageCaptureSourceV1, c.wlr_ext_image_capture_source_v1);+ @import("signal.zig").assertSameLayout(ExtImageCaptureSourceV1, c.wlr_ext_image_capture_source_v1);+ abi.assertFields(ExtImageCaptureSourceV1.Interface, c.wlr_ext_image_capture_source_v1_interface);+ @import("signal.zig").assertSameLayout(ExtImageCaptureSourceV1.Interface, c.wlr_ext_image_capture_source_v1_interface);+ abi.assertFields(ExtImageCaptureSourceV1.event.Frame, c.wlr_ext_image_capture_source_v1_frame_event);+ @import("signal.zig").assertSameLayout(ExtImageCaptureSourceV1.event.Frame, c.wlr_ext_image_capture_source_v1_frame_event);+ abi.assertFields(ExtImageCaptureSourceV1.Cursor, c.wlr_ext_image_capture_source_v1_cursor);+ @import("signal.zig").assertSameLayout(ExtImageCaptureSourceV1.Cursor, c.wlr_ext_image_capture_source_v1_cursor);+ abi.assertFields(ExtOutputImageCaptureSourceManagerV1, c.wlr_ext_output_image_capture_source_manager_v1);+ abi.assertFields(ExtForeignToplevelImageCaptureSourceManagerV1, c.wlr_ext_foreign_toplevel_image_capture_source_manager_v1);+ abi.assertFields(ExtForeignToplevelImageCaptureSourceManagerV1.Request, c.wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request);+}diff --git a/src/wlr/ext_image_copy_capture_v1.zig b/src/wlr/ext_image_copy_capture_v1.zignew file mode 100644index 0000000..07c3e9e--- /dev/null+++ b/src/wlr/ext_image_copy_capture_v1.zig@@ -0,0 +1,80 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const posix = @import("std").posix;++const wayland = @import("wayland");+const wl = wayland.server.wl;+const ext = wayland.server.ext;++const pixman = @import("pixman");++pub const ExtImageCopyCaptureManagerV1 = extern struct {+ global: *wl.Global,++ events: extern struct {+ new_session: wl.Signal(*ExtImageCopyCaptureSessionV1),+ },++ const wlr_ext_image_copy_capture_manager_v1_create = abi.bind(fn (+ display: *wl.Server,+ version: u32,+ ) callconv(.c) ?*ExtImageCopyCaptureManagerV1, c.wlr_ext_image_copy_capture_manager_v1_create);+ pub fn create(+ display: *wl.Server,+ version: u32,+ ) !*ExtImageCopyCaptureManagerV1 {+ return wlr_ext_image_copy_capture_manager_v1_create(display, version) orelse error.OutOfMemory;+ }+};++pub const ExtImageCopyCaptureSessionV1 = extern struct {+ resource: *wl.Resource,+ source: *wlr.ExtImageCaptureSourceV1,+ frame: ?*ExtImageCopyCaptureFrameV1,++ events: extern struct {+ destroy: wl.Signal(void),+ },+};++pub const ExtImageCopyCaptureFrameV1 = extern struct {+ resource: *wl.Resource,+ capturing: bool,+ buffer: ?*wlr.Buffer,+ buffer_damage: pixman.Region32,++ events: extern struct {+ destroy: wl.Signal(void),+ },++ const wlr_ext_image_copy_capture_frame_v1_ready = abi.bind(fn (+ frame: *ExtImageCopyCaptureFrameV1,+ transform: wl.Output.Transform,+ presentation_time: *const posix.timespec,+ ) callconv(.c) void, c.wlr_ext_image_copy_capture_frame_v1_ready);+ pub const ready = wlr_ext_image_copy_capture_frame_v1_ready;++ const wlr_ext_image_copy_capture_frame_v1_fail = abi.bind(fn (+ frame: *ExtImageCopyCaptureFrameV1,+ reason: ext.ImageCopyCaptureFrameV1.FailureReason,+ ) callconv(.c) void, c.wlr_ext_image_copy_capture_frame_v1_fail);+ pub const fail = wlr_ext_image_copy_capture_frame_v1_fail;++ const wlr_ext_image_copy_capture_frame_v1_copy_buffer = abi.bind(fn (+ frame: *ExtImageCopyCaptureFrameV1,+ src: *wlr.Buffer,+ renderer: *wlr.Renderer,+ ) callconv(.c) bool, c.wlr_ext_image_copy_capture_frame_v1_copy_buffer);+ /// False means wlroots reported failure and destroyed the frame.+ /// Only call ready() after a successful copy.+ pub const copyBuffer = wlr_ext_image_copy_capture_frame_v1_copy_buffer;+};++comptime {+ abi.assertFields(ExtImageCopyCaptureManagerV1, c.wlr_ext_image_copy_capture_manager_v1);+ abi.assertFields(ExtImageCopyCaptureSessionV1, c.wlr_ext_image_copy_capture_session_v1);+ abi.assertFields(ExtImageCopyCaptureFrameV1, c.wlr_ext_image_copy_capture_frame_v1);+}diff --git a/src/wlr/foreign_toplevel_list_v1.zig b/src/wlr/foreign_toplevel_list_v1.zignew file mode 100644index 0000000..e78293a--- /dev/null+++ b/src/wlr/foreign_toplevel_list_v1.zig@@ -0,0 +1,82 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wl = @import("wayland").server.wl;++pub const ExtForeignToplevelListV1 = extern struct {+ global: *wl.Global,+ resources: wl.list.Head(wl.Resource, null),+ toplevels: wl.list.Head(ExtForeignToplevelHandleV1, .link),++ events: extern struct {+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ const wlr_ext_foreign_toplevel_list_v1_create = abi.bind(fn (+ display: *wl.Server,+ version: u32,+ ) callconv(.c) ?*ExtForeignToplevelListV1, c.wlr_ext_foreign_toplevel_list_v1_create);+ pub fn create(+ display: *wl.Server,+ version: u32,+ ) !*ExtForeignToplevelListV1 {+ return wlr_ext_foreign_toplevel_list_v1_create(display, version) orelse error.OutOfMemory;+ }+};++pub const ExtForeignToplevelHandleV1 = extern struct {+ list: *ExtForeignToplevelListV1,+ resources: wl.list.Head(wl.Resource, null),+ link: wl.list.Link,++ title: ?[*:0]const u8,+ app_id: ?[*:0]const u8,+ identifier: [*:0]const u8,++ events: extern struct {+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ pub const State = extern struct {+ title: ?[*:0]const u8,+ app_id: ?[*:0]const u8,+ };++ const wlr_ext_foreign_toplevel_handle_v1_create = abi.bind(fn (+ list: *ExtForeignToplevelListV1,+ state: *const State,+ ) callconv(.c) ?*ExtForeignToplevelHandleV1, c.wlr_ext_foreign_toplevel_handle_v1_create);+ pub fn create(+ list: *ExtForeignToplevelListV1,+ state: *const State,+ ) !*ExtForeignToplevelHandleV1 {+ return wlr_ext_foreign_toplevel_handle_v1_create(list, state) orelse error.ToplevelHandleCreateFailed;+ }++ const wlr_ext_foreign_toplevel_handle_v1_from_resource = abi.bind(fn (+ resource: *wl.Resource,+ ) callconv(.c) ?*ExtForeignToplevelHandleV1, c.wlr_ext_foreign_toplevel_handle_v1_from_resource);+ pub const fromResource = wlr_ext_foreign_toplevel_handle_v1_from_resource;++ const wlr_ext_foreign_toplevel_handle_v1_destroy = abi.bind(fn (+ toplevel: *ExtForeignToplevelHandleV1,+ ) callconv(.c) void, c.wlr_ext_foreign_toplevel_handle_v1_destroy);+ pub const destroy = wlr_ext_foreign_toplevel_handle_v1_destroy;++ const wlr_ext_foreign_toplevel_handle_v1_update_state = abi.bind(fn (+ toplevel: *ExtForeignToplevelHandleV1,+ state: *const State,+ ) callconv(.c) void, c.wlr_ext_foreign_toplevel_handle_v1_update_state);+ pub const updateState = wlr_ext_foreign_toplevel_handle_v1_update_state;+};++comptime {+ abi.assertFields(ExtForeignToplevelListV1, c.wlr_ext_foreign_toplevel_list_v1);+ abi.assertFields(ExtForeignToplevelHandleV1, c.wlr_ext_foreign_toplevel_handle_v1);+ abi.assertFields(ExtForeignToplevelHandleV1.State, c.wlr_ext_foreign_toplevel_handle_v1_state);+ @import("signal.zig").assertSameLayout(ExtForeignToplevelHandleV1.State, c.wlr_ext_foreign_toplevel_handle_v1_state);+}diff --git a/src/wlr/foreign_toplevel_management_v1.zig b/src/wlr/foreign_toplevel_management_v1.zignew file mode 100644index 0000000..02ce06d--- /dev/null+++ b/src/wlr/foreign_toplevel_management_v1.zig@@ -0,0 +1,146 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const std = @import("std");+const wl = @import("wayland").server.wl;++pub const ForeignToplevelManagerV1 = extern struct {+ event_loop: *wl.EventLoop,+ global: *wl.Global,+ resources: wl.list.Head(wl.Resource, null),+ toplevels: wl.list.Head(ForeignToplevelHandleV1, .link),++ events: extern struct {+ destroy: wl.Signal(*ForeignToplevelManagerV1),+ },++ data: ?*anyopaque,++ const wlr_foreign_toplevel_manager_v1_create = abi.bind(fn (wl_server: *wl.Server) callconv(.c) ?*ForeignToplevelManagerV1, c.wlr_foreign_toplevel_manager_v1_create);+ pub fn create(wl_server: *wl.Server) !*ForeignToplevelManagerV1 {+ return wlr_foreign_toplevel_manager_v1_create(wl_server) orelse error.OutOfMemory;+ }+};++pub const ForeignToplevelHandleV1 = extern struct {+ pub const State = packed struct(u32) {+ maximized: bool = false,+ minimized: bool = false,+ activated: bool = false,+ fullscreen: bool = false,+ _: u28 = 0,+ };++ pub const Output = extern struct {+ link: wl.list.Link,+ output: *wlr.Output,+ toplevel: *ForeignToplevelHandleV1,+ };++ pub const event = struct {+ pub const Maximized = extern struct {+ toplevel: *ForeignToplevelHandleV1,+ maximized: bool,+ };++ pub const Minimized = extern struct {+ toplevel: *ForeignToplevelHandleV1,+ minimized: bool,+ };++ pub const Activated = extern struct {+ toplevel: *ForeignToplevelHandleV1,+ seat: *wlr.Seat,+ };++ pub const Fullscreen = extern struct {+ toplevel: *ForeignToplevelHandleV1,+ fullscreen: bool,+ output: ?*wlr.Output,+ };++ pub const SetRectangle = extern struct {+ toplevel: *ForeignToplevelHandleV1,+ surface: *wlr.Surface,+ x: i32,+ y: i32,+ width: i32,+ height: i32,+ };+ };++ manager: *ForeignToplevelManagerV1,+ resources: wl.list.Head(wl.Resource, null),+ link: wl.list.Link,+ idle_source: ?*wl.EventSource,++ title: ?[*:0]u8,+ app_id: ?[*:0]u8,+ parent: ?*ForeignToplevelHandleV1,+ outputs: wl.list.Head(ForeignToplevelHandleV1.Output, .link),+ state: State,++ events: extern struct {+ request_maximize: wl.Signal(*event.Maximized),+ request_minimize: wl.Signal(*event.Minimized),+ request_activate: wl.Signal(*event.Activated),+ request_fullscreen: wl.Signal(*event.Fullscreen),+ request_close: wl.Signal(*ForeignToplevelHandleV1),+ set_rectangle: wl.Signal(*event.SetRectangle),+ destroy: wl.Signal(*ForeignToplevelHandleV1),+ },++ data: ?*anyopaque,++ const wlr_foreign_toplevel_handle_v1_create = abi.bind(fn (manager: *ForeignToplevelManagerV1) callconv(.c) ?*ForeignToplevelHandleV1, c.wlr_foreign_toplevel_handle_v1_create);+ pub fn create(manager: *ForeignToplevelManagerV1) !*ForeignToplevelHandleV1 {+ return wlr_foreign_toplevel_handle_v1_create(manager) orelse error.OutOfMemory;+ }++ const wlr_foreign_toplevel_handle_v1_destroy = abi.bind(fn (toplevel: *ForeignToplevelHandleV1) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_destroy);+ pub const destroy = wlr_foreign_toplevel_handle_v1_destroy;++ const wlr_foreign_toplevel_handle_v1_set_title = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, title: [*:0]const u8) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_set_title);+ pub const setTitle = wlr_foreign_toplevel_handle_v1_set_title;++ const wlr_foreign_toplevel_handle_v1_set_app_id = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, app_id: [*:0]const u8) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_set_app_id);+ pub const setAppId = wlr_foreign_toplevel_handle_v1_set_app_id;++ const wlr_foreign_toplevel_handle_v1_output_enter = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, output: *wlr.Output) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_output_enter);+ pub const outputEnter = wlr_foreign_toplevel_handle_v1_output_enter;++ const wlr_foreign_toplevel_handle_v1_output_leave = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, output: *wlr.Output) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_output_leave);+ pub const outputLeave = wlr_foreign_toplevel_handle_v1_output_leave;++ const wlr_foreign_toplevel_handle_v1_set_maximized = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, maximized: bool) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_set_maximized);+ pub const setMaximized = wlr_foreign_toplevel_handle_v1_set_maximized;++ const wlr_foreign_toplevel_handle_v1_set_minimized = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, minimized: bool) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_set_minimized);+ pub const setMinimized = wlr_foreign_toplevel_handle_v1_set_minimized;++ const wlr_foreign_toplevel_handle_v1_set_activated = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, activated: bool) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_set_activated);+ pub const setActivated = wlr_foreign_toplevel_handle_v1_set_activated;++ const wlr_foreign_toplevel_handle_v1_set_fullscreen = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, fullscreen: bool) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_set_fullscreen);+ pub const setFullscreen = wlr_foreign_toplevel_handle_v1_set_fullscreen;++ const wlr_foreign_toplevel_handle_v1_set_parent = abi.bind(fn (toplevel: *ForeignToplevelHandleV1, parent: ?*ForeignToplevelHandleV1) callconv(.c) void, c.wlr_foreign_toplevel_handle_v1_set_parent);+ pub const setParent = wlr_foreign_toplevel_handle_v1_set_parent;+};++comptime {+ std.debug.assert(@as(u32, @bitCast(ForeignToplevelHandleV1.State{ .maximized = true })) == c.WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED);+ std.debug.assert(@as(u32, @bitCast(ForeignToplevelHandleV1.State{ .minimized = true })) == c.WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED);+ std.debug.assert(@as(u32, @bitCast(ForeignToplevelHandleV1.State{ .activated = true })) == c.WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED);+ std.debug.assert(@as(u32, @bitCast(ForeignToplevelHandleV1.State{ .fullscreen = true })) == c.WLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN);+ abi.assertFields(ForeignToplevelManagerV1, c.wlr_foreign_toplevel_manager_v1);+ abi.assertFields(ForeignToplevelHandleV1, c.wlr_foreign_toplevel_handle_v1);+ abi.assertFields(ForeignToplevelHandleV1.Output, c.wlr_foreign_toplevel_handle_v1_output);+ abi.assertFields(ForeignToplevelHandleV1.event.Maximized, c.wlr_foreign_toplevel_handle_v1_maximized_event);+ abi.assertFields(ForeignToplevelHandleV1.event.Minimized, c.wlr_foreign_toplevel_handle_v1_minimized_event);+ abi.assertFields(ForeignToplevelHandleV1.event.Activated, c.wlr_foreign_toplevel_handle_v1_activated_event);+ abi.assertFields(ForeignToplevelHandleV1.event.Fullscreen, c.wlr_foreign_toplevel_handle_v1_fullscreen_event);+ abi.assertFields(ForeignToplevelHandleV1.event.SetRectangle, c.wlr_foreign_toplevel_handle_v1_set_rectangle_event);+}diff --git a/src/wlr/input_device.zig b/src/wlr/input_device.zignew file mode 100644index 0000000..009252f--- /dev/null+++ b/src/wlr/input_device.zig@@ -0,0 +1,70 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const InputDevice = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_device);+ }++ pub const Type = enum(c_int) {+ keyboard = c.WLR_INPUT_DEVICE_KEYBOARD,+ pointer = c.WLR_INPUT_DEVICE_POINTER,+ touch = c.WLR_INPUT_DEVICE_TOUCH,+ tablet = c.WLR_INPUT_DEVICE_TABLET,+ tablet_pad = c.WLR_INPUT_DEVICE_TABLET_PAD,+ @"switch" = c.WLR_INPUT_DEVICE_SWITCH,+ };++ type: Type,+ name: ?[*:0]u8,++ events: extern struct {+ destroy: wl.Signal(*InputDevice),+ },++ data: ?*anyopaque,++ const wlr_keyboard_from_input_device = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) *wlr.Keyboard, c.wlr_keyboard_from_input_device);+ pub const toKeyboard = wlr_keyboard_from_input_device;++ const wlr_pointer_from_input_device = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) *wlr.Pointer, c.wlr_pointer_from_input_device);+ pub const toPointer = wlr_pointer_from_input_device;++ const wlr_touch_from_input_device = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) *wlr.Touch, c.wlr_touch_from_input_device);+ pub const toTouch = wlr_touch_from_input_device;++ const wlr_switch_from_input_device = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) *wlr.Switch, c.wlr_switch_from_input_device);+ pub const toSwitch = wlr_switch_from_input_device;++ const wlr_tablet_from_input_device = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) *wlr.Tablet, c.wlr_tablet_from_input_device);+ pub const toTablet = wlr_tablet_from_input_device;++ const wlr_tablet_pad_from_input_device = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) *wlr.TabletPad, c.wlr_tablet_pad_from_input_device);+ pub const toTabletPad = wlr_tablet_pad_from_input_device;++ const wlr_input_device_get_virtual_keyboard = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) ?*wlr.VirtualKeyboardV1, c.wlr_input_device_get_virtual_keyboard);+ pub const getVirtualKeyboard = wlr_input_device_get_virtual_keyboard;++ const wlr_input_device_is_libinput = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) bool, c.wlr_input_device_is_libinput);+ pub const isLibinput = wlr_input_device_is_libinput;++ const wlr_libinput_get_device_handle = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) *LibinputDevice, c.wlr_libinput_get_device_handle);+ pub fn getLibinputDevice(wlr_dev: *InputDevice) ?*LibinputDevice {+ if (!wlr_input_device_is_libinput(wlr_dev)) return null;+ return wlr_libinput_get_device_handle(wlr_dev);+ }++ const wlr_input_device_is_wl = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) bool, c.wlr_input_device_is_wl);+ pub const isWl = wlr_input_device_is_wl;++ const wlr_input_device_is_x11 = abi.bind(fn (wlr_dev: *InputDevice) callconv(.c) bool, c.wlr_input_device_is_x11);+ pub const isX11 = wlr_input_device_is_x11;+};++const LibinputDevice = opaque {};diff --git a/src/wlr/input_method_v2.zig b/src/wlr/input_method_v2.zignew file mode 100644index 0000000..59a00d0--- /dev/null+++ b/src/wlr/input_method_v2.zig@@ -0,0 +1,163 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const InputMethodManagerV2 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_method_manager_v2);+ }++ global: *wl.Global,+ input_methods: wl.list.Head(InputMethodV2, .link),++ events: extern struct {+ new_input_method: wl.Signal(*wlr.InputMethodV2),+ destroy: wl.Signal(void),+ },++ WLR_PRIVATE: @FieldType(c.wlr_input_method_manager_v2, "WLR_PRIVATE"),++ const wlr_input_method_manager_v2_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*wlr.InputMethodManagerV2, c.wlr_input_method_manager_v2_create);+ pub fn create(server: *wl.Server) !*wlr.InputMethodManagerV2 {+ return wlr_input_method_manager_v2_create(server) orelse error.OutOfMemory;+ }+};++pub const InputMethodV2 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_method_v2);+ }++ pub const PreeditString = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_method_v2_preedit_string);+ }++ text: ?[*:0]u8,+ cursor_begin: i32,+ cursor_end: i32,+ };++ pub const DeleteSurroundingText = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_method_v2_delete_surrounding_text);+ }++ before_length: u32,+ after_length: u32,+ };++ pub const State = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_method_v2_state);+ }++ preedit: wlr.InputMethodV2.PreeditString,+ commit_text: ?[*:0]u8,+ delete: wlr.InputMethodV2.DeleteSurroundingText,+ };++ pub const KeyboardGrab = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_method_keyboard_grab_v2);+ }++ resource: *wl.Resource,+ input_method: *wlr.InputMethodV2,+ keyboard: ?*wlr.Keyboard,++ events: extern struct {+ destroy: wl.Signal(void),+ },++ WLR_PRIVATE: @FieldType(c.wlr_input_method_keyboard_grab_v2, "WLR_PRIVATE"),++ const wlr_input_method_keyboard_grab_v2_send_key = abi.bind(fn (keyboard_grab: *wlr.InputMethodV2.KeyboardGrab, time: u32, key: u32, state: u32) callconv(.c) void, c.wlr_input_method_keyboard_grab_v2_send_key);+ pub fn sendKey(keyboard_grab: *wlr.InputMethodV2.KeyboardGrab, time: u32, key: u32, state: wl.Keyboard.KeyState) void {+ wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab, time, key, @as(u32, @intCast(@intFromEnum(state))));+ }++ const wlr_input_method_keyboard_grab_v2_send_modifiers = abi.bind(fn (keyboard_grab: *wlr.InputMethodV2.KeyboardGrab, modifiers: *const wlr.Keyboard.Modifiers) callconv(.c) void, c.wlr_input_method_keyboard_grab_v2_send_modifiers);+ pub const sendModifiers = wlr_input_method_keyboard_grab_v2_send_modifiers;++ const wlr_input_method_keyboard_grab_v2_set_keyboard = abi.bind(fn (keyboard_grab: *wlr.InputMethodV2.KeyboardGrab, keyboard: ?*wlr.Keyboard) callconv(.c) void, c.wlr_input_method_keyboard_grab_v2_set_keyboard);+ pub const setKeyboard = wlr_input_method_keyboard_grab_v2_set_keyboard;++ const wlr_input_method_keyboard_grab_v2_destroy = abi.bind(fn (keyboard_grab: *wlr.InputMethodV2.KeyboardGrab) callconv(.c) void, c.wlr_input_method_keyboard_grab_v2_destroy);+ pub const destroy = wlr_input_method_keyboard_grab_v2_destroy;+ };++ resource: *wl.Resource,+ seat: *wlr.Seat,+ seat_client: *wlr.Seat.Client,++ pending: wlr.InputMethodV2.State,+ current: wlr.InputMethodV2.State,+ active: bool,+ client_active: bool,+ current_serial: u32,++ popup_surfaces: wl.list.Head(InputPopupSurfaceV2, .link),+ keyboard_grab: ?*KeyboardGrab,++ link: wl.list.Link,++ events: extern struct {+ commit: wl.Signal(void),+ new_popup_surface: wl.Signal(*wlr.InputPopupSurfaceV2),+ grab_keyboard: wl.Signal(*wlr.InputMethodV2.KeyboardGrab),+ destroy: wl.Signal(void),+ },++ WLR_PRIVATE: @FieldType(c.wlr_input_method_v2, "WLR_PRIVATE"),++ const wlr_input_method_v2_send_activate = abi.bind(fn (input_method: *wlr.InputMethodV2) callconv(.c) void, c.wlr_input_method_v2_send_activate);+ pub const sendActivate = wlr_input_method_v2_send_activate;++ const wlr_input_method_v2_send_deactivate = abi.bind(fn (input_method: *wlr.InputMethodV2) callconv(.c) void, c.wlr_input_method_v2_send_deactivate);+ pub const sendDeactivate = wlr_input_method_v2_send_deactivate;++ const wlr_input_method_v2_send_surrounding_text = abi.bind(fn (input_method: *wlr.InputMethodV2, text: [*:0]const u8, cursor: u32, anchor: u32) callconv(.c) void, c.wlr_input_method_v2_send_surrounding_text);+ pub const sendSurroundingText = wlr_input_method_v2_send_surrounding_text;++ const wlr_input_method_v2_send_content_type = abi.bind(fn (input_method: *wlr.InputMethodV2, hint: u32, purpose: u32) callconv(.c) void, c.wlr_input_method_v2_send_content_type);+ pub const sendContentType = wlr_input_method_v2_send_content_type;++ const wlr_input_method_v2_send_text_change_cause = abi.bind(fn (input_method: *wlr.InputMethodV2, cause: u32) callconv(.c) void, c.wlr_input_method_v2_send_text_change_cause);+ pub const sendTextChangeCause = wlr_input_method_v2_send_text_change_cause;++ const wlr_input_method_v2_send_done = abi.bind(fn (input_method: *wlr.InputMethodV2) callconv(.c) void, c.wlr_input_method_v2_send_done);+ pub const sendDone = wlr_input_method_v2_send_done;++ const wlr_input_method_v2_send_unavailable = abi.bind(fn (input_method: *wlr.InputMethodV2) callconv(.c) void, c.wlr_input_method_v2_send_unavailable);+ pub const sendUnavailable = wlr_input_method_v2_send_unavailable;+};++pub const InputPopupSurfaceV2 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_input_popup_surface_v2);+ }++ resource: *wl.Resource,+ input_method: *InputMethodV2,+ link: wl.list.Link,++ surface: *wlr.Surface,++ events: extern struct {+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ const wlr_input_popup_surface_v2_try_from_wlr_surface = abi.bind(fn (surface: *wlr.Surface) callconv(.c) ?*wlr.InputPopupSurfaceV2, c.wlr_input_popup_surface_v2_try_from_wlr_surface);+ pub const tryFromWlrSurface = wlr_input_popup_surface_v2_try_from_wlr_surface;++ const wlr_input_popup_surface_v2_send_text_input_rectangle = abi.bind(fn (popup_surface: *wlr.InputPopupSurfaceV2, box: *wlr.Box) callconv(.c) void, c.wlr_input_popup_surface_v2_send_text_input_rectangle);+ pub const sendTextInputRectangle = wlr_input_popup_surface_v2_send_text_input_rectangle;+};diff --git a/src/wlr/input_tests.zig b/src/wlr/input_tests.zignew file mode 100644index 0000000..2438c41--- /dev/null+++ b/src/wlr/input_tests.zig@@ -0,0 +1,31 @@+const std = @import("std");+const wlr = @import("wlr.zig");++test "initializing and finishing embedded input devices preserves adjacent storage" {+ const Guarded = extern struct {+ before: u64,+ pointer: wlr.Pointer,+ between: u64,+ keyboard: wlr.Keyboard,+ after: u64,+ };+ const sentinel: u64 = 0x8192_a3b4_c5d6_e7f8;+ var guarded: Guarded = .{+ .before = sentinel,+ .pointer = undefined,+ .between = sentinel,+ .keyboard = undefined,+ .after = sentinel,+ };+ const pointer_impl: wlr.Pointer.Impl = .{ .name = "binding-test-pointer" };+ const keyboard_impl: wlr.Keyboard.Impl = .{ .name = "binding-test-keyboard" };+ wlr.Pointer.init(&guarded.pointer, &pointer_impl, "binding-test-pointer");+ wlr.Keyboard.init(&guarded.keyboard, &keyboard_impl, "binding-test-keyboard");+ const initialized = guarded.before == sentinel and guarded.between == sentinel and guarded.after == sentinel;+ wlr.Pointer.finish(&guarded.pointer);+ wlr.Keyboard.finish(&guarded.keyboard);+ try std.testing.expect(initialized);+ try std.testing.expectEqual(sentinel, guarded.before);+ try std.testing.expectEqual(sentinel, guarded.between);+ try std.testing.expectEqual(sentinel, guarded.after);+}diff --git a/src/wlr/keyboard.zig b/src/wlr/keyboard.zignew file mode 100644index 0000000..9989966--- /dev/null+++ b/src/wlr/keyboard.zig@@ -0,0 +1,148 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const std = @import("std");++const wayland = @import("wayland");+const wl = wayland.server.wl;++const xkb = @import("xkbcommon");++pub const Keyboard = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_keyboard);+ }++ pub const led_count = c.WLR_LED_COUNT;+ pub const led = struct {+ pub const num_lock = c.WLR_LED_NUM_LOCK;+ pub const caps_lock = c.WLR_LED_CAPS_LOCK;+ pub const scroll_lock = c.WLR_LED_SCROLL_LOCK;+ pub const compose = c.WLR_LED_COMPOSE;+ pub const kana = c.WLR_LED_KANA;+ };++ pub const modifier_count = c.WLR_MODIFIER_COUNT;+ pub const ModifierMask = packed struct(u32) {+ shift: bool = false,+ caps: bool = false,+ ctrl: bool = false,+ alt: bool = false,+ mod2: bool = false,+ mod3: bool = false,+ logo: bool = false,+ mod5: bool = false,+ _: u24 = 0,+ };++ pub const Modifiers = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_keyboard_modifiers);+ }++ depressed: xkb.ModMask,+ latched: xkb.ModMask,+ locked: xkb.ModMask,+ group: xkb.LayoutIndex,+ };++ pub const event = struct {+ pub const Key = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_keyboard_key_event);+ }++ time_msec: u32,+ keycode: u32,+ update_state: bool,+ state: wl.Keyboard.KeyState,+ };+ };++ pub const Impl = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_keyboard_impl);+ }++ name: [*:0]const u8,+ led_update: ?*const fn (keyboard: *Keyboard, leds: u32) callconv(.c) void = null,+ };++ base: wlr.InputDevice,++ impl: *const Impl,+ group: ?*wlr.KeyboardGroup,++ keymap_string: [*:0]u8,+ keymap_size: usize,+ keymap_fd: c_int,+ keymap: ?*xkb.Keymap,+ xkb_state: ?*xkb.State,+ led_indexes: [led_count]xkb.LED_Index,+ mod_indexes: [modifier_count]xkb.ModIndex,++ leds: u32,+ keycodes: [c.WLR_KEYBOARD_KEYS_CAP]u32,+ num_keycodes: usize,+ modifiers: Modifiers,++ repeat_info: extern struct {+ rate: i32,+ delay: i32,+ },++ events: extern struct {+ key: wl.Signal(*event.Key),+ modifiers: wl.Signal(*Keyboard),+ keymap: wl.Signal(*Keyboard),+ repeat_info: wl.Signal(*Keyboard),+ },++ data: ?*anyopaque,++ const wlr_keyboard_init = abi.bind(fn (keyboard: *Keyboard, impl: *const Impl, name: [*:0]const u8) callconv(.c) void, c.wlr_keyboard_init);+ pub const init = wlr_keyboard_init;++ const wlr_keyboard_finish = abi.bind(fn (keyboard: *Keyboard) callconv(.c) void, c.wlr_keyboard_finish);+ pub const finish = wlr_keyboard_finish;++ const wlr_keyboard_set_keymap = abi.bind(fn (keyboard: *Keyboard, keymap: ?*xkb.Keymap) callconv(.c) bool, c.wlr_keyboard_set_keymap);+ pub const setKeymap = wlr_keyboard_set_keymap;++ const wlr_keyboard_keymaps_match = abi.bind(fn (km1: ?*xkb.Keymap, km2: ?*xkb.Keymap) callconv(.c) bool, c.wlr_keyboard_keymaps_match);+ pub const keymapsMatch = wlr_keyboard_keymaps_match;++ const wlr_keyboard_set_repeat_info = abi.bind(fn (keyboard: *Keyboard, rate: i32, delay: i32) callconv(.c) void, c.wlr_keyboard_set_repeat_info);+ pub const setRepeatInfo = wlr_keyboard_set_repeat_info;++ const wlr_keyboard_led_update = abi.bind(fn (keyboard: *Keyboard, leds: u32) callconv(.c) void, c.wlr_keyboard_led_update);+ pub const ledUpdate = wlr_keyboard_led_update;++ const wlr_keyboard_get_modifiers = abi.bind(fn (keyboard: *Keyboard) callconv(.c) u32, c.wlr_keyboard_get_modifiers);+ pub fn getModifiers(keyboard: *Keyboard) ModifierMask {+ return @as(ModifierMask, @bitCast(wlr_keyboard_get_modifiers(keyboard)));+ }++ const wlr_keyboard_notify_key = abi.bind(fn (keyboard: *Keyboard, event: *event.Key) callconv(.c) void, c.wlr_keyboard_notify_key);+ pub const notifyKey = wlr_keyboard_notify_key;++ const wlr_keyboard_notify_modifiers = abi.bind(fn (+ keyboard: *Keyboard,+ mods_depressed: u32,+ mods_latched: u32,+ mods_locked: u32,+ group: u32,+ ) callconv(.c) void, c.wlr_keyboard_notify_modifiers);+ pub fn notifyModifiers(keyboard: *Keyboard, modifiers: Modifiers) void {+ wlr_keyboard_notify_modifiers(+ keyboard,+ modifiers.depressed,+ modifiers.latched,+ modifiers.locked,+ modifiers.group,+ );+ }+};diff --git a/src/wlr/keyboard_group.zig b/src/wlr/keyboard_group.zignew file mode 100644index 0000000..cf94f2e--- /dev/null+++ b/src/wlr/keyboard_group.zig@@ -0,0 +1,45 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wl = @import("wayland").server.wl;++pub const KeyboardGroup = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_keyboard_group);+ }++ keyboard: wlr.Keyboard,++ // these are technically list heads, but their usage is internal to wlroots+ devices: wl.list.Link,+ keys: wl.list.Link,++ events: extern struct {+ /// wl.Array of u32 keycodes+ enter: wl.Signal(*wl.Array),+ /// wl.Array of u32 keycodes+ leave: wl.Signal(*wl.Array),+ },++ data: ?*anyopaque,++ const wlr_keyboard_group_create = abi.bind(fn () callconv(.c) ?*KeyboardGroup, c.wlr_keyboard_group_create);+ pub fn create() !*KeyboardGroup {+ return wlr_keyboard_group_create() orelse error.OutOfMemory;+ }++ const wlr_keyboard_group_from_wlr_keyboard = abi.bind(fn (keyboard: *wlr.Keyboard) callconv(.c) ?*KeyboardGroup, c.wlr_keyboard_group_from_wlr_keyboard);+ pub const fromKeyboard = wlr_keyboard_group_from_wlr_keyboard;++ const wlr_keyboard_group_add_keyboard = abi.bind(fn (group: *KeyboardGroup, keyboard: *wlr.Keyboard) callconv(.c) bool, c.wlr_keyboard_group_add_keyboard);+ pub const addKeyboard = wlr_keyboard_group_add_keyboard;++ const wlr_keyboard_group_remove_keyboard = abi.bind(fn (group: *KeyboardGroup, keyboard: *wlr.Keyboard) callconv(.c) void, c.wlr_keyboard_group_remove_keyboard);+ pub const removeKeyboard = wlr_keyboard_group_remove_keyboard;++ const wlr_keyboard_group_destroy = abi.bind(fn (group: *KeyboardGroup) callconv(.c) void, c.wlr_keyboard_group_destroy);+ pub const destroy = wlr_keyboard_group_destroy;+};diff --git a/src/wlr/layer_shell.zig b/src/wlr/layer_shell.zignew file mode 100644index 0000000..df54c36--- /dev/null+++ b/src/wlr/layer_shell.zig@@ -0,0 +1,165 @@+//! Typed wlroots header adapter. API shapes adapted from zig-wlroots;+//! see LICENSE.zig-wlroots for its MIT license.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const zwlr = wayland.server.zwlr;++pub const LayerShellV1 = extern struct {+ global: *wl.Global,++ events: extern struct {+ new_surface: wl.Signal(*LayerSurfaceV1),+ destroy: wl.Signal(*LayerShellV1),+ },++ data: ?*anyopaque,++ const wlr_layer_shell_v1_create = abi.bind(fn (server: *wl.Server, version: u32) callconv(.c) ?*LayerShellV1, c.wlr_layer_shell_v1_create);+ pub fn create(server: *wl.Server, version: u32) !*LayerShellV1 {+ return wlr_layer_shell_v1_create(server, version) orelse error.OutOfMemory;+ }+};++pub const LayerSurfaceV1 = extern struct {+ pub const State = extern struct {+ pub const Fields = packed struct(u32) {+ desired_size: bool = false,+ anchor: bool = false,+ exclusive_zone: bool = false,+ margin: bool = false,+ keyboard_interactivity: bool = false,+ layer: bool = false,+ exclusive_edge: bool = false,+ _: u25 = 0,+ };++ committed: Fields,+ anchor: zwlr.LayerSurfaceV1.Anchor,+ exclusive_zone: i32,+ margin: extern struct {+ top: i32,+ right: i32,+ bottom: i32,+ left: i32,+ },+ keyboard_interactive: zwlr.LayerSurfaceV1.KeyboardInteractivity,+ desired_width: u32,+ desired_height: u32,+ layer: zwlr.LayerShellV1.Layer,+ exclusive_edge: u32,++ configure_serial: u32,+ actual_width: u32,+ actual_height: u32,+ };++ pub const Configure = extern struct {+ /// LayerSurfaceV1.configure_list+ link: wl.list.Link,+ serial: u32,++ width: u32,+ height: u32,+ };++ surface: *wlr.Surface,+ output: ?*wlr.Output,+ resource: *wl.Resource,+ shell: *LayerShellV1,+ /// wlr.XdgPopup.link+ popups: wl.list.Head(wlr.XdgPopup, .link),++ namespace: [*:0]u8,++ configured: bool,++ configure_list: wl.list.Head(LayerSurfaceV1.Configure, .link),++ current: State,+ pending: State,++ initialized: bool,+ initial_commit: bool,++ events: extern struct {+ destroy: wl.Signal(*LayerSurfaceV1),+ new_popup: wl.Signal(*wlr.XdgPopup),+ },++ data: ?*anyopaque,++ const wlr_layer_surface_v1_configure = abi.bind(fn (surface: *LayerSurfaceV1, width: u32, height: u32) callconv(.c) u32, c.wlr_layer_surface_v1_configure);+ pub const configure = wlr_layer_surface_v1_configure;++ pub const getExclusiveEdge = abi.bind(fn (surface: *LayerSurfaceV1) callconv(.c) wlr.Edges, c.wlr_layer_surface_v1_get_exclusive_edge);++ const wlr_layer_surface_v1_destroy = abi.bind(fn (surface: *LayerSurfaceV1) callconv(.c) void, c.wlr_layer_surface_v1_destroy);+ pub const destroy = wlr_layer_surface_v1_destroy;++ const wlr_layer_surface_v1_try_from_wlr_surface = abi.bind(fn (surface: *wlr.Surface) callconv(.c) ?*LayerSurfaceV1, c.wlr_layer_surface_v1_try_from_wlr_surface);+ pub const tryFromWlrSurface = wlr_layer_surface_v1_try_from_wlr_surface;++ const wlr_layer_surface_v1_for_each_surface = abi.bind(fn (+ surface: *LayerSurfaceV1,+ iterator: *const fn (*wlr.Surface, c_int, c_int, ?*anyopaque) callconv(.c) void,+ user_data: ?*anyopaque,+ ) callconv(.c) void, c.wlr_layer_surface_v1_for_each_surface);+ pub inline fn forEachSurface(+ surface: *LayerSurfaceV1,+ comptime T: type,+ comptime iterator: fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: T) void,+ data: T,+ ) void {+ wlr_layer_surface_v1_for_each_surface(+ surface,+ struct {+ fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void {+ iterator(s, sx, sy, @ptrCast(@alignCast(d)));+ }+ }.wrapper,+ data,+ );+ }++ const wlr_layer_surface_v1_for_each_popup_surface = abi.bind(fn (+ surface: *LayerSurfaceV1,+ iterator: *const fn (*wlr.Surface, c_int, c_int, ?*anyopaque) callconv(.c) void,+ user_data: ?*anyopaque,+ ) callconv(.c) void, c.wlr_layer_surface_v1_for_each_popup_surface);+ pub inline fn forEachPopupSurface(+ surface: *LayerSurfaceV1,+ comptime T: type,+ comptime iterator: fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: T) void,+ data: T,+ ) void {+ wlr_layer_surface_v1_for_each_popup_surface(+ surface,+ struct {+ fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void {+ iterator(s, sx, sy, @ptrCast(@alignCast(d)));+ }+ }.wrapper,+ data,+ );+ }++ const wlr_layer_surface_v1_surface_at = abi.bind(fn (surface: *LayerSurfaceV1, sx: f64, sy: f64, sub_x: *f64, sub_y: *f64) callconv(.c) ?*wlr.Surface, c.wlr_layer_surface_v1_surface_at);+ pub const surfaceAt = wlr_layer_surface_v1_surface_at;++ const wlr_layer_surface_v1_popup_surface_at = abi.bind(fn (surface: *LayerSurfaceV1, sx: f64, sy: f64, sub_x: *f64, sub_y: *f64) callconv(.c) ?*wlr.Surface, c.wlr_layer_surface_v1_popup_surface_at);+ pub const popupSurfaceAt = wlr_layer_surface_v1_popup_surface_at;++ const wlr_layer_surface_v1_from_resource = abi.bind(fn (resource: *wl.Resource) callconv(.c) ?*LayerSurfaceV1, c.wlr_layer_surface_v1_from_resource);+ pub const fromResource = wlr_layer_surface_v1_from_resource;+};++comptime {+ abi.assertFields(LayerShellV1, c.wlr_layer_shell_v1);+ abi.assertFields(LayerSurfaceV1, c.wlr_layer_surface_v1);+ abi.assertLayout(LayerSurfaceV1.State, c.wlr_layer_surface_v1_state);+ abi.assertLayout(LayerSurfaceV1.Configure, c.struct_wlr_layer_surface_v1_configure);+}diff --git a/src/wlr/linux_dmabuf_v1.zig b/src/wlr/linux_dmabuf_v1.zignew file mode 100644index 0000000..df217a7--- /dev/null+++ b/src/wlr/linux_dmabuf_v1.zig@@ -0,0 +1,83 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const std = @import("std");+const posix = std.posix;++const wayland = @import("wayland");+const wl = wayland.server.wl;+const zwp = wayland.server.zwp;++pub const DmabufBufferV1 = extern struct {+ base: wlr.Buffer,++ resource: ?*wl.Resource,+ attributes: wlr.DmabufAttributes,++ const wlr_dmabuf_v1_buffer_try_from_buffer_resource = abi.bind(fn (buffer_resource: *wl.Resource) callconv(.c) ?*DmabufBufferV1, c.wlr_dmabuf_v1_buffer_try_from_buffer_resource);+ pub const tryFromBufferResource = wlr_dmabuf_v1_buffer_try_from_buffer_resource;+};++pub const LinuxDmabufFeedbackV1 = extern struct {+ pub const Tranche = extern struct {+ target_device: posix.dev_t,+ flags: zwp.LinuxDmabufFeedbackV1.TrancheFlags,+ formats: wlr.DrmFormatSet,+ };++ main_device: posix.dev_t,+ tranches: wl.Array,++ const wlr_linux_dmabuf_feedback_add_tranche = abi.bind(fn (feedback: *LinuxDmabufFeedbackV1) callconv(.c) ?*Tranche, c.wlr_linux_dmabuf_feedback_add_tranche);+ pub fn addTranche(feedback: *LinuxDmabufFeedbackV1) !*Tranche {+ return wlr_linux_dmabuf_feedback_add_tranche(feedback) orelse error.OutOfMemory;+ }++ const wlr_linux_dmabuf_feedback_v1_finish = abi.bind(fn (feedback: *LinuxDmabufFeedbackV1) callconv(.c) void, c.wlr_linux_dmabuf_feedback_v1_finish);+ pub const finish = wlr_linux_dmabuf_feedback_v1_finish;++ pub const InitOptions = extern struct {+ main_renderer: *wlr.Renderer,+ scanout_primary_output: ?*wlr.Output,+ // TODO: Bind wlr_output_layer and related structs+ output_layer_feedback_event: ?*const anyopaque,+ };+ const wlr_linux_dmabuf_feedback_v1_init_with_options = abi.bind(fn (feedback: *LinuxDmabufFeedbackV1, options: *const InitOptions) callconv(.c) bool, c.wlr_linux_dmabuf_feedback_v1_init_with_options);+ pub const initWithOptions = wlr_linux_dmabuf_feedback_v1_init_with_options;+};++pub const LinuxDmabufFeedbackV1Compiled = opaque {};++pub const LinuxDmabufV1 = extern struct {+ global: *wl.Global,++ events: extern struct {+ destroy: wl.Signal(*LinuxDmabufV1),+ },++ const wlr_linux_dmabuf_v1_create = abi.bind(fn (server: *wl.Server, version: u32, default_feedback: *const LinuxDmabufFeedbackV1) callconv(.c) ?*LinuxDmabufV1, c.wlr_linux_dmabuf_v1_create);+ pub fn create(server: *wl.Server, version: u32, default_feedback: *const LinuxDmabufFeedbackV1) !*LinuxDmabufV1 {+ return wlr_linux_dmabuf_v1_create(server, version, default_feedback) orelse error.OutOfMemory;+ }++ const wlr_linux_dmabuf_v1_create_with_renderer = abi.bind(fn (server: *wl.Server, version: u32, renderer: *wlr.Renderer) callconv(.c) ?*LinuxDmabufV1, c.wlr_linux_dmabuf_v1_create_with_renderer);+ pub fn createWithRenderer(server: *wl.Server, version: u32, renderer: *wlr.Renderer) !*LinuxDmabufV1 {+ return wlr_linux_dmabuf_v1_create_with_renderer(server, version, renderer) orelse error.OutOfMemory;+ }++ const wlr_linux_dmabuf_v1_set_surface_feedback = abi.bind(fn (linux_dmabuf: *LinuxDmabufV1, surface: *wlr.Surface, feedback: ?*const LinuxDmabufFeedbackV1) callconv(.c) bool, c.wlr_linux_dmabuf_v1_set_surface_feedback);+ pub const setSurfaceFeedback = wlr_linux_dmabuf_v1_set_surface_feedback;+};++comptime {+ abi.assertFields(DmabufBufferV1, c.wlr_dmabuf_v1_buffer);+ abi.assertFields(LinuxDmabufFeedbackV1, c.wlr_linux_dmabuf_feedback_v1);+ @import("signal.zig").assertSameLayout(LinuxDmabufFeedbackV1, c.wlr_linux_dmabuf_feedback_v1);+ abi.assertFields(LinuxDmabufFeedbackV1.Tranche, c.wlr_linux_dmabuf_feedback_v1_tranche);+ @import("signal.zig").assertSameLayout(LinuxDmabufFeedbackV1.Tranche, c.wlr_linux_dmabuf_feedback_v1_tranche);+ abi.assertFields(LinuxDmabufFeedbackV1.InitOptions, c.wlr_linux_dmabuf_feedback_v1_init_options);+ @import("signal.zig").assertSameLayout(LinuxDmabufFeedbackV1.InitOptions, c.wlr_linux_dmabuf_feedback_v1_init_options);+ abi.assertFields(LinuxDmabufV1, c.wlr_linux_dmabuf_v1);+}diff --git a/src/wlr/linux_drm_syncobj_v1.zig b/src/wlr/linux_drm_syncobj_v1.zignew file mode 100644index 0000000..6e5d1e3--- /dev/null+++ b/src/wlr/linux_drm_syncobj_v1.zig@@ -0,0 +1,18 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const LinuxDrmSyncobjManagerV1 = extern struct {+ global: *wl.Global,++ const wlr_linux_drm_syncobj_manager_v1_create = abi.bind(fn (server: *wl.Server, version: u32, drm_fd: c_int) callconv(.c) ?*LinuxDrmSyncobjManagerV1, c.wlr_linux_drm_syncobj_manager_v1_create);+ pub const create = wlr_linux_drm_syncobj_manager_v1_create;+};++comptime {+ abi.assertFields(LinuxDrmSyncobjManagerV1, c.wlr_linux_drm_syncobj_manager_v1);+}diff --git a/src/wlr/log.zig b/src/wlr/log.zignew file mode 100644index 0000000..3b3b324--- /dev/null+++ b/src/wlr/log.zig@@ -0,0 +1,22 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++const std = @import("std");++pub const Importance = enum(c_int) {+ silent = c.WLR_SILENT,+ err = c.WLR_ERROR,+ info = c.WLR_INFO,+ debug = c.WLR_DEBUG,+ last = c.WLR_LOG_IMPORTANCE_LAST,+};++const wlr_log_init = abi.bind(fn (+ verbosity: Importance,+ callback: ?*const fn (importance: Importance, fmt: [*:0]const u8, args: *std.builtin.VaList) callconv(.c) void,+) callconv(.c) void, c.wlr_log_init);+pub const init = wlr_log_init;++const wlr_log_get_verbosity = abi.bind(fn () callconv(.c) Importance, c.wlr_log_get_verbosity);+pub const getVerbosity = wlr_log_get_verbosity;diff --git a/src/wlr/output.zig b/src/wlr/output.zigindex c11d301..8b09e1e 100644--- a/src/wlr/output.zig+++ b/src/wlr/output.zig@@ -31,9 +31,7 @@//! `commit_seq`/`presented` are read); `Damage`/`Precommit`/`Bind`//! aren't defined at all since nothing connects those signals.//!-//! `Backend`, `Renderer`, `Allocator`, `Buffer`, `ColorTransform` are-//! still on the old zig-wlroots dependency, so this file takes them as-//! parameters the same way output_power.zig took `Output`.+//! Dependencies are supplied by wlr.zig from the same header-backed module.const std = @import("std");const wl = @import("wayland").server.wl;const pixman = @import("pixman");@@ -220,6 +218,10 @@ pub fn Types(c.wlr_output_state_set_buffer(@ptrCast(state), @ptrCast(buffer));}+ pub fn setColorTransform(state: *State, transform: ?*ColorTransform) void {+ c.wlr_output_state_set_color_transform(@ptrCast(state), @ptrCast(transform));+ }+pub fn setDamage(state: *State, damage: *const pixman.Region32) void {c.wlr_output_state_set_damage(@ptrCast(state), @ptrCast(damage));}diff --git a/src/wlr/output_management.zig b/src/wlr/output_management.zignew file mode 100644index 0000000..6911f99--- /dev/null+++ b/src/wlr/output_management.zig@@ -0,0 +1,154 @@+//! Output management uses the facade's Output and Output.State throughout,+//! including client configurations received through the apply/test signals.+//! Only wlroots allocates the manager and heads, so their private tails are+//! omitted; the embedded head state and complete configuration retain their+//! full C layouts.+const wl = @import("wayland").server.wl;+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub fn Types(comptime Output: type) type {+ return struct {+ pub const OutputManagerV1 = extern struct {+ server: *wl.Server,+ global: *wl.Global,+ resources: wl.list.Head(wl.Resource, null),+ heads: wl.list.Head(OutputHeadV1, .link),+ serial: u32,+ current_configuration_dirty: bool,++ events: extern struct {+ apply: wl.Signal(*OutputConfigurationV1),+ @"test": wl.Signal(*OutputConfigurationV1),+ destroy: wl.Signal(*OutputManagerV1),+ },++ data: ?*anyopaque,++ pub fn create(server: *wl.Server) !*OutputManagerV1 {+ const raw = c.wlr_output_manager_v1_create(@ptrCast(server));+ return @as(?*OutputManagerV1, @ptrCast(raw)) orelse error.OutOfMemory;+ }++ /// Transfers ownership of the configuration to wlroots.+ pub fn setConfiguration(manager: *OutputManagerV1, config: *OutputConfigurationV1) void {+ c.wlr_output_manager_v1_set_configuration(@ptrCast(manager), @ptrCast(config));+ }++ comptime {+ const Real = c.wlr_output_manager_v1;+ if (@offsetOf(OutputManagerV1, "server") != @offsetOf(Real, "display"))+ @compileError("OutputManagerV1.server offset drifted from wlr_output_manager_v1.display");+ assertSameLayout(@FieldType(OutputManagerV1, "server"), @FieldType(Real, "display"));+ for (.{ "global", "resources", "heads", "serial", "current_configuration_dirty", "events", "data" }) |field| {+ assertFieldOffset(OutputManagerV1, Real, field);+ assertSameLayout(@FieldType(OutputManagerV1, field), @FieldType(Real, field));+ }++ const Events = @FieldType(OutputManagerV1, "events");+ const RealEvents = @FieldType(Real, "events");+ for (.{ "apply", "test", "destroy" }) |field| {+ assertFieldOffset(Events, RealEvents, field);+ assertSameLayout(@FieldType(Events, field), c.wl_signal);+ }+ }+ };++ pub const OutputHeadV1 = extern struct {+ pub const State = extern struct {+ output: *Output,+ enabled: bool,+ mode: ?*Output.Mode,+ custom_mode: @FieldType(c.wlr_output_head_v1_state, "custom_mode"),+ x: i32,+ y: i32,+ transform: wl.Output.Transform,+ scale: f32,+ adaptive_sync_enabled: bool,++ pub fn apply(state: *const State, output_state: *Output.State) void {+ c.wlr_output_head_v1_state_apply(@ptrCast(state), @ptrCast(output_state));+ }++ comptime {+ const Real = c.wlr_output_head_v1_state;+ assertSameLayout(State, Real);+ for (@typeInfo(State).@"struct".fields) |field| {+ assertFieldOffset(State, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };++ state: State,+ manager: *OutputManagerV1,+ link: wl.list.Link,+ resources: wl.list.Head(wl.Resource, null),+ mode_resources: wl.list.Head(wl.Resource, null),++ comptime {+ const Real = c.wlr_output_head_v1;+ for (@typeInfo(OutputHeadV1).@"struct".fields) |field| {+ assertFieldOffset(OutputHeadV1, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };++ pub const OutputConfigurationV1 = extern struct {+ pub const Head = extern struct {+ state: OutputHeadV1.State,+ config: *OutputConfigurationV1,+ link: wl.list.Link,+ resource: ?*wl.Resource,++ pub fn create(config: *OutputConfigurationV1, output: *Output) !*Head {+ const raw = c.wlr_output_configuration_head_v1_create(@ptrCast(config), @ptrCast(output));+ return @as(?*Head, @ptrCast(raw)) orelse error.OutOfMemory;+ }++ comptime {+ const Real = c.wlr_output_configuration_head_v1;+ for (@typeInfo(Head).@"struct".fields) |field| {+ assertFieldOffset(Head, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };++ heads: wl.list.Head(Head, .link),+ manager: ?*OutputManagerV1,+ serial: u32,+ finalized: bool,+ finished: bool,+ resource: ?*wl.Resource,++ pub fn create() !*OutputConfigurationV1 {+ const raw = c.wlr_output_configuration_v1_create();+ return @as(?*OutputConfigurationV1, @ptrCast(raw)) orelse error.OutOfMemory;+ }++ pub fn destroy(config: *OutputConfigurationV1) void {+ c.wlr_output_configuration_v1_destroy(@ptrCast(config));+ }++ pub fn sendSucceeded(config: *OutputConfigurationV1) void {+ c.wlr_output_configuration_v1_send_succeeded(@ptrCast(config));+ }++ pub fn sendFailed(config: *OutputConfigurationV1) void {+ c.wlr_output_configuration_v1_send_failed(@ptrCast(config));+ }++ comptime {+ const Real = c.wlr_output_configuration_v1;+ assertSameLayout(OutputConfigurationV1, Real);+ for (@typeInfo(OutputConfigurationV1).@"struct".fields) |field| {+ assertFieldOffset(OutputConfigurationV1, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };+ };+}diff --git a/src/wlr/output_power.zig b/src/wlr/output_power.zigindex 8323937..e93bfea 100644--- a/src/wlr/output_power.zig+++ b/src/wlr/output_power.zig@@ -11,9 +11,7 @@//! future wlroots release that reorders or inserts a field fails the//! build instead of silently corrupting memory.//!-//! `Output` still comes from the old zig-wlroots dependency: it hasn't-//! migrated yet, so this file takes it as a parameter from wlr.zig-//! rather than hardcoding which `Output` type is current.+//! `Output` is supplied by wlr.zig and comes from the header-backed facade.const wl = @import("wayland").server.wl;const zwlr = @import("wayland").server.zwlr;const c = @import("c.zig").c;diff --git a/src/wlr/pointer.zig b/src/wlr/pointer.zignew file mode 100644index 0000000..9bd94f4--- /dev/null+++ b/src/wlr/pointer.zig@@ -0,0 +1,190 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const Pointer = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer);+ }++ pub const event = struct {+ pub const Motion = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_motion_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ delta_x: f64,+ delta_y: f64,+ unaccel_dx: f64,+ unaccel_dy: f64,+ };++ pub const MotionAbsolute = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_motion_absolute_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ x: f64,+ y: f64,+ };++ pub const Button = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_button_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ button: u32,+ state: wl.Pointer.ButtonState,+ };++ pub const Axis = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_axis_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ source: wl.Pointer.AxisSource,+ orientation: wl.Pointer.Axis,+ relative_direction: wl.Pointer.AxisRelativeDirection,+ delta: f64,+ delta_discrete: i32,+ };++ pub const SwipeBegin = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_swipe_begin_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ fingers: u32,+ };++ pub const SwipeUpdate = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_swipe_update_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ fingers: u32,+ dx: f64,+ dy: f64,+ };++ pub const SwipeEnd = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_swipe_end_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ cancelled: bool,+ };++ pub const PinchBegin = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_pinch_begin_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ fingers: u32,+ };++ pub const PinchUpdate = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_pinch_update_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ fingers: u32,+ dx: f64,+ dy: f64,+ scale: f64,+ rotation: f64,+ };++ pub const PinchEnd = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_pinch_end_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ cancelled: bool,+ };++ pub const HoldBegin = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_hold_begin_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ fingers: u32,+ };++ pub const HoldEnd = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_hold_end_event);+ }++ pointer: *wlr.Pointer,+ time_msec: u32,+ cancelled: bool,+ };+ };++ pub const Impl = extern struct {+ name: [*:0]const u8,+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_impl);+ }+ };++ base: wlr.InputDevice,++ impl: *const Impl,++ output_name: ?[*:0]u8,++ buttons: [c.WLR_POINTER_BUTTONS_CAP]u32,+ button_count: usize,++ events: extern struct {+ motion: wl.Signal(*event.Motion),+ motion_absolute: wl.Signal(*event.MotionAbsolute),+ button: wl.Signal(*event.Button),+ axis: wl.Signal(*event.Axis),+ frame: wl.Signal(*Pointer),++ swipe_begin: wl.Signal(*event.SwipeBegin),+ swipe_update: wl.Signal(*event.SwipeUpdate),+ swipe_end: wl.Signal(*event.SwipeEnd),++ pinch_begin: wl.Signal(*event.PinchBegin),+ pinch_update: wl.Signal(*event.PinchUpdate),+ pinch_end: wl.Signal(*event.PinchEnd),++ hold_begin: wl.Signal(*event.HoldBegin),+ hold_end: wl.Signal(*event.HoldEnd),+ },+ data: ?*anyopaque,++ pub const init = abi.bind(fn (*Pointer, *const Impl, [*:0]const u8) callconv(.c) void, c.wlr_pointer_init);+ pub const finish = abi.bind(fn (*Pointer) callconv(.c) void, c.wlr_pointer_finish);+};diff --git a/src/wlr/pointer_gestures_v1.zig b/src/wlr/pointer_gestures_v1.zignew file mode 100644index 0000000..3c2d234--- /dev/null+++ b/src/wlr/pointer_gestures_v1.zig@@ -0,0 +1,102 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const std = @import("std");+const wayland = @import("wayland");+const wl = wayland.server.wl;+const zwp = wayland.server.zwp;++pub const PointerGesturesV1 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_gestures_v1);+ }++ global: *wl.Global,+ swipes: wl.list.Head(zwp.PointerGestureSwipeV1, null),+ pinches: wl.list.Head(zwp.PointerGesturePinchV1, null),+ holds: wl.list.Head(zwp.PointerGestureHoldV1, null),++ events: extern struct {+ destroy: wl.Signal(*PointerGesturesV1),+ },++ data: ?*anyopaque,++ WLR_PRIVATE: @FieldType(c.wlr_pointer_gestures_v1, "WLR_PRIVATE"),++ const wlr_pointer_gestures_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*PointerGesturesV1, c.wlr_pointer_gestures_v1_create);+ pub fn create(server: *wl.Server) !*PointerGesturesV1 {+ return wlr_pointer_gestures_v1_create(server) orelse error.OutOfMemory;+ }++ const wlr_pointer_gestures_v1_send_swipe_begin = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ fingers: u32,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_swipe_begin);+ pub const sendSwipeBegin = wlr_pointer_gestures_v1_send_swipe_begin;++ const wlr_pointer_gestures_v1_send_swipe_update = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ dx: f64,+ dy: f64,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_swipe_update);+ pub const sendSwipeUpdate = wlr_pointer_gestures_v1_send_swipe_update;++ const wlr_pointer_gestures_v1_send_swipe_end = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ cancelled: bool,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_swipe_end);+ pub const sendSwipeEnd = wlr_pointer_gestures_v1_send_swipe_end;++ const wlr_pointer_gestures_v1_send_pinch_begin = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ fingers: u32,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_pinch_begin);+ pub const sendPinchBegin = wlr_pointer_gestures_v1_send_pinch_begin;++ const wlr_pointer_gestures_v1_send_pinch_update = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ dx: f64,+ dy: f64,+ scale: f64,+ rotation: f64,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_pinch_update);+ pub const sendPinchUpdate = wlr_pointer_gestures_v1_send_pinch_update;++ const wlr_pointer_gestures_v1_send_pinch_end = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ cancelled: bool,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_pinch_end);+ pub const sendPinchEnd = wlr_pointer_gestures_v1_send_pinch_end;++ const wlr_pointer_gestures_v1_send_hold_begin = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ fingers: u32,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_hold_begin);+ pub const sendHoldBegin = wlr_pointer_gestures_v1_send_hold_begin;++ const wlr_pointer_gestures_v1_send_hold_end = abi.bind(fn (+ pointer_gestures: *PointerGesturesV1,+ seat: *wlr.Seat,+ time_msec: u32,+ cancelled: bool,+ ) callconv(.c) void, c.wlr_pointer_gestures_v1_send_hold_end);+ pub const sendHoldEnd = wlr_pointer_gestures_v1_send_hold_end;+};diff --git a/src/wlr/presentation.zig b/src/wlr/presentation.zignew file mode 100644index 0000000..030cf67--- /dev/null+++ b/src/wlr/presentation.zig@@ -0,0 +1,31 @@+//! Presentation protocol registration. Feedback sampling remains in the C+//! output pass; this facade only creates the display-owned manager.+const wl = @import("wayland").server.wl;+const wlr = @import("wlr.zig");+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub const Presentation = extern struct {+ global: *wl.Global,+ events: extern struct {+ destroy: wl.Signal(*Presentation),+ },++ pub fn create(server: *wl.Server, backend: *wlr.Backend, version: u32) !*Presentation {+ const raw = c.wlr_presentation_create(@ptrCast(server), @ptrCast(backend), version);+ return @as(?*Presentation, @ptrCast(raw)) orelse error.OutOfMemory;+ }++ comptime {+ const Real = c.wlr_presentation;+ for (.{ "global", "events" }) |field| {+ assertFieldOffset(Presentation, Real, field);+ assertSameLayout(@FieldType(Presentation, field), @FieldType(Real, field));+ }+ const Events = @FieldType(Presentation, "events");+ const RealEvents = @FieldType(Real, "events");+ assertFieldOffset(Events, RealEvents, "destroy");+ assertSameLayout(@FieldType(Events, "destroy"), c.wl_signal);+ }+};diff --git a/src/wlr/primary_selection.zig b/src/wlr/primary_selection.zignew file mode 100644index 0000000..b2c187e--- /dev/null+++ b/src/wlr/primary_selection.zig@@ -0,0 +1,36 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++const wl = @import("wayland").server.wl;++pub const PrimarySelectionSource = extern struct {+ pub const Impl = extern struct {+ send: *const fn (source: *PrimarySelectionSource, mime_type: [*:0]const u8, fd: c_int) callconv(.c) void,+ destroy: ?*const fn (source: *PrimarySelectionSource) callconv(.c) void,+ };++ impl: *const Impl,++ mime_types: wl.Array,++ events: extern struct {+ destroy: wl.Signal(*PrimarySelectionSource),+ },++ data: ?*anyopaque,++ const wlr_primary_selection_source_init = abi.bind(fn (source: *PrimarySelectionSource, impl: *const PrimarySelectionSource.Impl) callconv(.c) void, c.wlr_primary_selection_source_init);+ pub const init = wlr_primary_selection_source_init;++ const wlr_primary_selection_source_destroy = abi.bind(fn (source: *PrimarySelectionSource) callconv(.c) void, c.wlr_primary_selection_source_destroy);+ pub const destroy = wlr_primary_selection_source_destroy;++ const wlr_primary_selection_source_send = abi.bind(fn (source: *PrimarySelectionSource, mime_type: [*:0]const u8, fd: c_int) callconv(.c) void, c.wlr_primary_selection_source_send);+ pub const send = wlr_primary_selection_source_send;+};++comptime {+ abi.assertLayout(PrimarySelectionSource, c.wlr_primary_selection_source);+ abi.assertLayout(PrimarySelectionSource.Impl, c.wlr_primary_selection_source_impl);+}diff --git a/src/wlr/primary_selection_v1.zig b/src/wlr/primary_selection_v1.zignew file mode 100644index 0000000..42b4224--- /dev/null+++ b/src/wlr/primary_selection_v1.zig@@ -0,0 +1,41 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const PrimarySelectionDeviceManagerV1 = extern struct {+ global: *wl.Global,+ /// PrimarySelectionV1Device.link+ devices: wl.list.Head(PrimarySelectionDeviceV1, .link),++ events: extern struct {+ destroy: wl.Signal(*PrimarySelectionDeviceManagerV1),+ },++ data: ?*anyopaque,++ const wlr_primary_selection_v1_device_manager_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*PrimarySelectionDeviceManagerV1, c.wlr_primary_selection_v1_device_manager_create);+ pub fn create(server: *wl.Server) !*PrimarySelectionDeviceManagerV1 {+ return wlr_primary_selection_v1_device_manager_create(server) orelse error.OutOfMemory;+ }+};++pub const PrimarySelectionDeviceV1 = extern struct {+ manager: *PrimarySelectionDeviceManagerV1,+ seat: *wlr.Seat,+ /// PrimarySelectionDeviceManagerV1.devices+ link: wl.list.Link,+ resources: wl.list.Head(wl.Resource, null),++ offers: wl.list.Head(wl.Resource, null),++ data: ?*anyopaque,+};++comptime {+ abi.assertFields(PrimarySelectionDeviceManagerV1, c.wlr_primary_selection_v1_device_manager);+ abi.assertFields(PrimarySelectionDeviceV1, c.wlr_primary_selection_v1_device);+}diff --git a/src/wlr/region.zig b/src/wlr/region.zignew file mode 100644index 0000000..28cebb1--- /dev/null+++ b/src/wlr/region.zig@@ -0,0 +1,26 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++const pixman = @import("pixman");++const wayland = @import("wayland");+const wl = wayland.server.wl;++const wlr_region_scale = abi.bind(fn (dst: *pixman.Region32, src: *const pixman.Region32, scale: f32) callconv(.c) void, c.wlr_region_scale);+pub const scale = wlr_region_scale;++const wlr_region_scale_xy = abi.bind(fn (dst: *pixman.Region32, src: *const pixman.Region32, scale_x: f32, scale_y: f32) callconv(.c) void, c.wlr_region_scale_xy);+pub const scaleXY = wlr_region_scale_xy;++const wlr_region_transform = abi.bind(fn (dst: *pixman.Region32, src: *const pixman.Region32, transform: wl.Output.Transform, width: c_int, height: c_int) callconv(.c) void, c.wlr_region_transform);+pub const transform = wlr_region_transform;++const wlr_region_expand = abi.bind(fn (dst: *pixman.Region32, src: *const pixman.Region32, distance: c_int) callconv(.c) void, c.wlr_region_expand);+pub const expand = wlr_region_expand;++const wlr_region_rotated_bounds = abi.bind(fn (dst: *pixman.Region32, src: *const pixman.Region32, rotation: f32, ox: c_int, oy: c_int) callconv(.c) void, c.wlr_region_rotated_bounds);+pub const rotatedBounds = wlr_region_rotated_bounds;++const wlr_region_confine = abi.bind(fn (region: *const pixman.Region32, x1: f64, y1: f64, x2: f64, y2: f64, x2_out: *f64, y2_out: *f64) callconv(.c) bool, c.wlr_region_confine);+pub const confine = wlr_region_confine;diff --git a/src/wlr/render_pass.zig b/src/wlr/render_pass.zignew file mode 100644index 0000000..3c10e24--- /dev/null+++ b/src/wlr/render_pass.zig@@ -0,0 +1,77 @@+//! Drawing options are caller-owned values: check every field and the full+//! layout against wlroots before passing them to the output/capture passes.+const wl = @import("wayland").server.wl;+const pixman = @import("pixman");+const wlr = @import("wlr.zig");+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub const RenderPass = opaque {+ pub const BlendMode = enum(c_int) {+ premultiplied = c.WLR_RENDER_BLEND_MODE_PREMULTIPLIED,+ none = c.WLR_RENDER_BLEND_MODE_NONE,+ };++ pub const ScaleFilterMode = enum(c_int) {+ bilinear = c.WLR_SCALE_FILTER_BILINEAR,+ nearest = c.WLR_SCALE_FILTER_NEAREST,+ };++ pub const Color = c.wlr_render_color;++ pub const TextureOptions = extern struct {+ texture: *wlr.Texture,+ src_box: wlr.FBox,+ dst_box: wlr.Box,+ alpha: ?*const f32,+ clip: ?*const pixman.Region32,+ transform: wl.Output.Transform,+ filter_mode: ScaleFilterMode,+ blend_mode: BlendMode,+ transfer_function: wlr.color.TransferFunction,+ primaries: *const wlr.color.Primaries,+ color_encoding: wlr.color.Encoding,+ color_range: wlr.color.Range,+ luminance_multiplier: ?*const f32,+ wait_timeline: ?*wlr.DrmSyncobjTimeline = null,+ wait_point: u64,++ comptime {+ const Real = c.wlr_render_texture_options;+ assertSameLayout(TextureOptions, Real);+ for (@typeInfo(TextureOptions).@"struct".fields) |field| {+ assertFieldOffset(TextureOptions, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };++ pub const RectOptions = extern struct {+ box: wlr.Box,+ color: Color,+ clip: ?*const pixman.Region32,+ blend_mode: BlendMode,++ comptime {+ const Real = c.wlr_render_rect_options;+ assertSameLayout(RectOptions, Real);+ for (@typeInfo(RectOptions).@"struct".fields) |field| {+ assertFieldOffset(RectOptions, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };++ pub fn submit(pass: *RenderPass) bool {+ return c.wlr_render_pass_submit(@ptrCast(pass));+ }++ pub fn addTexture(pass: *RenderPass, options: *const TextureOptions) void {+ c.wlr_render_pass_add_texture(@ptrCast(pass), @ptrCast(options));+ }++ pub fn addRect(pass: *RenderPass, options: *const RectOptions) void {+ c.wlr_render_pass_add_rect(@ptrCast(pass), @ptrCast(options));+ }+};diff --git a/src/wlr/renderer.zig b/src/wlr/renderer.zignew file mode 100644index 0000000..6385649--- /dev/null+++ b/src/wlr/renderer.zig@@ -0,0 +1,90 @@+//! Renderer lifecycle and capabilities from the installed wlroots headers.+//! wlroots owns the renderer allocation, so its private tail is omitted.+const wl = @import("wayland").server.wl;+const wlr = @import("wlr.zig");+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub const Renderer = extern struct {+ pub const BufferPassOptions = extern struct {+ timer: ?*c.wlr_render_timer = null,+ color_transform: ?*wlr.ColorTransform = null,+ signal_timeline: ?*wlr.DrmSyncobjTimeline = null,+ signal_point: u64 = 0,++ comptime {+ const Real = c.wlr_buffer_pass_options;+ assertSameLayout(BufferPassOptions, Real);+ for (@typeInfo(BufferPassOptions).@"struct".fields) |field| {+ assertFieldOffset(BufferPassOptions, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };++ render_buffer_caps: u32,+ color_encodings: u32,+ events: extern struct {+ destroy: wl.Signal(*Renderer),+ lost: wl.Signal(void),+ },+ features: extern struct {+ input_color_transform: bool,+ output_color_transform: bool,+ timeline: bool,+ },++ pub fn autocreate(backend: *wlr.Backend) !*Renderer {+ const raw = c.wlr_renderer_autocreate(@ptrCast(backend));+ return @as(?*Renderer, @ptrCast(raw)) orelse error.RendererCreateFailed;+ }++ pub fn destroy(renderer: *Renderer) void {+ c.wlr_renderer_destroy(@ptrCast(renderer));+ }++ pub fn initServer(renderer: *Renderer, server: *wl.Server) !void {+ if (!c.wlr_renderer_init_wl_display(@ptrCast(renderer), @ptrCast(server)))+ return error.RenderInitFailed;+ }++ pub fn getDrmFd(renderer: *Renderer) c_int {+ return c.wlr_renderer_get_drm_fd(@ptrCast(renderer));+ }++ // Format sets and their elements share the header-backed facade.+ pub fn getTextureFormats(renderer: *Renderer, buffer_caps: u32) ?*const wlr.DrmFormatSet {+ return @ptrCast(c.wlr_renderer_get_texture_formats(@ptrCast(renderer), buffer_caps));+ }++ pub fn isGles2(renderer: *Renderer) bool {+ return c.wlr_renderer_is_gles2(@ptrCast(renderer));+ }++ pub fn isPixman(renderer: *Renderer) bool {+ return c.wlr_renderer_is_pixman(@ptrCast(renderer));+ }++ comptime {+ const Real = c.wlr_renderer;+ for (@typeInfo(Renderer).@"struct".fields) |field| {+ assertFieldOffset(Renderer, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }++ const Events = @FieldType(Renderer, "events");+ const RealEvents = @FieldType(Real, "events");+ for (@typeInfo(Events).@"struct".fields) |field| {+ assertFieldOffset(Events, RealEvents, field.name);+ assertSameLayout(field.type, c.wl_signal);+ }++ const Features = @FieldType(Renderer, "features");+ const RealFeatures = @FieldType(Real, "features");+ for (@typeInfo(Features).@"struct".fields) |field| {+ assertFieldOffset(Features, RealFeatures, field.name);+ assertSameLayout(field.type, @FieldType(RealFeatures, field.name));+ }+ }+};diff --git a/src/wlr/scene.zig b/src/wlr/scene.zignew file mode 100644index 0000000..67a3b41--- /dev/null+++ b/src/wlr/scene.zig@@ -0,0 +1,5 @@+//! The compositor owns its scene tree; the remaining carrier pointers+//! need the C layout only, with no Zig methods or copied fields.+const c = @import("c.zig").c;+pub const Scene = c.wlr_scene;+pub const SceneNode = c.wlr_scene_node;diff --git a/src/wlr/screencopy_v1.zig b/src/wlr/screencopy_v1.zignew file mode 100644index 0000000..92cea57--- /dev/null+++ b/src/wlr/screencopy_v1.zig@@ -0,0 +1,60 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const ScreencopyManagerV1 = extern struct {+ global: *wl.Global,+ frames: wl.list.Head(ScreencopyFrameV1, .link),++ events: extern struct {+ destroy: wl.Signal(*ScreencopyManagerV1),+ },++ data: ?*anyopaque,++ const wlr_screencopy_manager_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*ScreencopyManagerV1, c.wlr_screencopy_manager_v1_create);+ pub fn create(server: *wl.Server) !*ScreencopyManagerV1 {+ return wlr_screencopy_manager_v1_create(server) orelse error.OutOfMemory;+ }+};++pub const ScreencopyClientV1 = extern struct {+ ref: c_int,+ manager: *ScreencopyManagerV1,+ // A list head, but usage is internal to wlroots+ damages: wl.list.Link,+};++pub const ScreencopyFrameV1 = extern struct {+ resource: *wl.Resource,+ client: *ScreencopyClientV1,+ /// ScreencopyManagerV1.frames+ link: wl.list.Link,++ shm_format: u32,+ dmabuf_format: u32,+ box: wlr.Box,+ shm_stride: c_int,++ overlay_cursor: bool,+ cursor_locked: bool,++ with_damage: bool,++ buffer_cap: wlr.BufferCap,+ buffer: ?*wlr.Buffer,++ output: *wlr.Output,++ data: ?*anyopaque,+};++comptime {+ abi.assertFields(ScreencopyManagerV1, c.wlr_screencopy_manager_v1);+ abi.assertFields(ScreencopyClientV1, c.wlr_screencopy_v1_client);+ abi.assertFields(ScreencopyFrameV1, c.wlr_screencopy_frame_v1);+}diff --git a/src/wlr/seat.zig b/src/wlr/seat.zignew file mode 100644index 0000000..e138ffd--- /dev/null+++ b/src/wlr/seat.zig@@ -0,0 +1,605 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const posix = @import("std").posix;++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const SerialRange = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_serial_range);+ }++ min_incl: u32,+ max_incl: u32,+};++pub const SerialRingset = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_serial_ringset);+ }++ data: [c.WLR_SERIAL_RINGSET_SIZE]SerialRange,+ end: c_int,+ count: c_int,+};++pub const TouchPoint = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_touch_point);+ }++ touch_id: i32,+ surface: ?*wlr.Surface,+ client: *wlr.Seat.Client,++ focus_surface: ?*wlr.Surface,+ focus_client: ?*wlr.Seat.Client,+ sx: f64,+ sy: f64,++ events: extern struct {+ destroy: wl.Signal(*TouchPoint),+ },++ /// Seat.TouchState.touch_points+ link: wl.list.Link,++ WLR_PRIVATE: @FieldType(c.wlr_touch_point, "WLR_PRIVATE"),+};++pub const Seat = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat);+ }++ pub const Client = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_client);+ }++ client: *wl.Client,+ seat: *Seat,+ /// Seat.clients+ link: wl.list.Link,++ resources: wl.list.Head(wl.Seat, null),+ pointers: wl.list.Head(wl.Pointer, null),+ keyboards: wl.list.Head(wl.Keyboard, null),+ touches: wl.list.Head(wl.Touch, null),+ data_devices: wl.list.Head(wl.DataDevice, null),++ events: extern struct {+ destroy: wl.Signal(*Seat.Client),+ },++ serials: SerialRingset,+ needs_touch_frame: bool,++ value120: extern struct {+ acc_discrete: [2]i32,+ last_discrete: [2]i32,+ acc_axis: [2]f64,+ },++ const wlr_seat_client_next_serial = abi.bind(fn (client: *Client) callconv(.c) u32, c.wlr_seat_client_next_serial);+ pub const nextSerial = wlr_seat_client_next_serial;++ const wlr_seat_client_validate_event_serial = abi.bind(fn (client: *Client, serial: u32) callconv(.c) bool, c.wlr_seat_client_validate_event_serial);+ pub const validateEventSerial = wlr_seat_client_validate_event_serial;++ const wlr_seat_client_from_resource = abi.bind(fn (seat: *wl.Seat) callconv(.c) ?*Client, c.wlr_seat_client_from_resource);+ pub const fromWlSeat = wlr_seat_client_from_resource;++ const wlr_seat_client_from_pointer_resource = abi.bind(fn (pointer: *wl.Pointer) callconv(.c) ?*Client, c.wlr_seat_client_from_pointer_resource);+ pub const fromWlPointer = wlr_seat_client_from_pointer_resource;+ };++ pub const PointerGrab = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_pointer_grab);+ }++ pub const Interface = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_pointer_grab_interface);+ }++ enter: *const fn (+ grab: *PointerGrab,+ surface: *wlr.Surface,+ sx: f64,+ sy: f64,+ ) callconv(.c) void,+ clear_focus: *const fn (grab: *PointerGrab) callconv(.c) void,+ motion: *const fn (grab: *PointerGrab, time_msec: u32, sx: f64, sy: f64) callconv(.c) void,+ button: *const fn (+ grab: *PointerGrab,+ time_msec: u32,+ button: u32,+ state: wl.Pointer.ButtonState,+ ) callconv(.c) u32,+ axis: *const fn (+ grab: *PointerGrab,+ time_msec: u32,+ orientation: wl.Pointer.Axis,+ value: f64,+ value_discrete: i32,+ source: wl.Pointer.AxisSource,+ relative_direction: wl.Pointer.AxisRelativeDirection,+ ) callconv(.c) void,+ frame: ?*const fn (grab: *PointerGrab) callconv(.c) void,+ cancel: ?*const fn (grab: *PointerGrab) callconv(.c) void,+ };++ interface: *const Interface,+ seat: *Seat,+ data: ?*anyopaque,+ };++ pub const KeyboardGrab = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_keyboard_grab);+ }++ pub const Interface = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_keyboard_grab_interface);+ }++ enter: *const fn (+ grab: *KeyboardGrab,+ surface: *wlr.Surface,+ keycodes: ?[*]const u32,+ num_keycodes: usize,+ modifiers: ?*const wlr.Keyboard.Modifiers,+ ) callconv(.c) void,+ clear_focus: *const fn (grab: *KeyboardGrab) callconv(.c) void,+ key: *const fn (grab: *KeyboardGrab, time_msec: u32, key: u32, state: u32) callconv(.c) void,+ modifiers: *const fn (grab: *KeyboardGrab, modifiers: ?*const wlr.Keyboard.Modifiers) callconv(.c) void,+ cancel: ?*const fn (grab: *KeyboardGrab) callconv(.c) void,+ };++ interface: *const Interface,+ seat: *Seat,+ data: ?*anyopaque,+ };++ pub const TouchGrab = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_touch_grab);+ }++ pub const Interface = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_touch_grab_interface);+ }++ down: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) u32,+ up: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) u32,+ motion: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) void,+ enter: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) void,+ frame: ?*const fn (grab: *TouchGrab) callconv(.c) void,+ cancel: ?*const fn (grab: *TouchGrab) callconv(.c) void,+ wl_cancel: ?*const fn (grab: *TouchGrab, seat_client: *wlr.Seat.Client) callconv(.c) void,+ clear_focus: ?*const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) void,+ };++ interface: *const Interface,+ seat: *Seat,+ data: ?*anyopaque,+ };++ pub const PointerState = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_pointer_state);+ }++ pub const Button = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_pointer_button);+ }++ button: u32,+ n_pressed: usize,+ };++ seat: *Seat,+ focused_client: ?*Seat.Client,+ focused_surface: ?*wlr.Surface,+ sx: f64,+ sy: f64,++ grab: *PointerGrab,+ default_grab: *PointerGrab,++ sent_axis_source: bool,+ cached_axis_source: wl.Pointer.AxisSource,++ buttons: [16]Button,+ button_count: usize,+ grab_button: u32,+ grab_serial: u32,+ grab_time: u32,++ events: extern struct {+ focus_change: wl.Signal(*event.PointerFocusChange),+ },++ WLR_PRIVATE: @FieldType(c.wlr_seat_pointer_state, "WLR_PRIVATE"),+ };++ pub const KeyboardState = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_keyboard_state);+ }++ seat: *Seat,+ keyboard: ?*wlr.Keyboard,++ focused_client: ?*Seat.Client,+ focused_surface: ?*wlr.Surface,++ grab: *KeyboardGrab,+ default_grab: *KeyboardGrab,++ events: extern struct {+ focus_change: wl.Signal(*event.KeyboardFocusChange),+ },++ WLR_PRIVATE: @FieldType(c.wlr_seat_keyboard_state, "WLR_PRIVATE"),+ };++ pub const TouchState = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_touch_state);+ }++ seat: *Seat,+ touch_points: wl.list.Head(TouchPoint, .link),++ grab_serial: u32,+ grab_id: u32,++ grab: *TouchGrab,+ default_grab: *TouchGrab,+ };++ pub const event = struct {+ pub const PointerFocusChange = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_pointer_focus_change_event);+ }++ seat: *Seat,+ old_surface: ?*wlr.Surface,+ new_surface: ?*wlr.Surface,+ sx: f64,+ sy: f64,+ };++ pub const KeyboardFocusChange = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_keyboard_focus_change_event);+ }++ seat: *Seat,+ old_surface: ?*wlr.Surface,+ new_surface: ?*wlr.Surface,+ };++ pub const RequestSetCursor = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_pointer_request_set_cursor_event);+ }++ seat_client: *Seat.Client,+ surface: ?*wlr.Surface,+ serial: u32,+ hotspot_x: i32,+ hotspot_y: i32,+ };++ pub const RequestSetSelection = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_request_set_selection_event);+ }++ source: ?*wlr.DataSource,+ serial: u32,+ };++ pub const RequestSetPrimarySelection = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_request_set_primary_selection_event);+ }++ source: ?*wlr.PrimarySelectionSource,+ serial: u32,+ };++ pub const RequestStartDrag = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_seat_request_start_drag_event);+ }++ drag: *wlr.Drag,+ origin: *wlr.Surface,+ serial: u32,+ };+ };++ global: *wl.Global,+ display: *wl.Server,+ clients: wl.list.Head(Seat.Client, .link),++ name: [*:0]u8,++ capabilities: u32,+ accumulated_capabilities: u32,++ selection_source: ?*wlr.DataSource,+ selection_serial: u32,+ /// wlr.DataOffer.link+ selection_offers: wl.list.Head(wlr.DataOffer, .link),++ primary_selection_source: ?*wlr.PrimarySelectionSource,+ primary_selection_serial: u32,++ drag: ?*wlr.Drag,+ drag_source: ?*wlr.DataSource,+ drag_serial: u32,+ /// wlr.DataOffer.link+ drag_offers: wl.list.Head(wlr.DataOffer, .link),++ pointer_state: PointerState,+ keyboard_state: KeyboardState,+ touch_state: TouchState,++ events: extern struct {+ pointer_grab_begin: wl.Signal(*PointerGrab),+ pointer_grab_end: wl.Signal(*PointerGrab),++ keyboard_grab_begin: wl.Signal(*KeyboardGrab),+ keyboard_grab_end: wl.Signal(*KeyboardGrab),++ touch_grab_begin: wl.Signal(*TouchGrab),+ touch_grab_end: wl.Signal(*TouchGrab),++ request_set_cursor: wl.Signal(*event.RequestSetCursor),++ request_set_selection: wl.Signal(*event.RequestSetSelection),+ set_selection: wl.Signal(*wlr.Seat),++ request_set_primary_selection: wl.Signal(*event.RequestSetPrimarySelection),+ set_primary_selection: wl.Signal(*wlr.Seat),++ request_start_drag: wl.Signal(*event.RequestStartDrag),+ start_drag: wl.Signal(*wlr.Drag),++ destroy: wl.Signal(*wlr.Seat),+ },++ data: ?*anyopaque,++ WLR_PRIVATE: @FieldType(c.wlr_seat, "WLR_PRIVATE"),++ const wlr_seat_create = abi.bind(fn (server: *wl.Server, name: [*:0]const u8) callconv(.c) ?*Seat, c.wlr_seat_create);+ pub fn create(server: *wl.Server, name: [*:0]const u8) !*Seat {+ return wlr_seat_create(server, name) orelse error.OutOfMemory;+ }++ const wlr_seat_destroy = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_destroy);+ pub const destroy = wlr_seat_destroy;++ const wlr_seat_client_for_wl_client = abi.bind(fn (seat: *Seat, wl_client: *wl.Client) callconv(.c) ?*Seat.Client, c.wlr_seat_client_for_wl_client);+ pub const clientForWlClient = wlr_seat_client_for_wl_client;++ const wlr_seat_set_capabilities = abi.bind(fn (seat: *Seat, capabilities: u32) callconv(.c) void, c.wlr_seat_set_capabilities);+ pub inline fn setCapabilities(seat: *Seat, capabilities: wl.Seat.Capability) void {+ wlr_seat_set_capabilities(seat, @as(u32, @bitCast(capabilities)));+ }++ const wlr_seat_set_name = abi.bind(fn (seat: *Seat, name: [*:0]const u8) callconv(.c) void, c.wlr_seat_set_name);+ pub const setName = wlr_seat_set_name;++ const wlr_seat_pointer_surface_has_focus = abi.bind(fn (seat: *Seat, surface: *wlr.Surface) callconv(.c) bool, c.wlr_seat_pointer_surface_has_focus);+ pub const pointerSurfaceHasFocus = wlr_seat_pointer_surface_has_focus;++ const wlr_seat_pointer_enter = abi.bind(fn (seat: *Seat, surface: ?*wlr.Surface, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_pointer_enter);+ pub const pointerEnter = wlr_seat_pointer_enter;++ const wlr_seat_pointer_clear_focus = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_pointer_clear_focus);+ pub const pointerClearFocus = wlr_seat_pointer_clear_focus;++ const wlr_seat_pointer_send_motion = abi.bind(fn (seat: *Seat, time_msec: u32, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_pointer_send_motion);+ pub const pointerSendMotion = wlr_seat_pointer_send_motion;++ const wlr_seat_pointer_send_button = abi.bind(fn (seat: *Seat, time_msec: u32, button: u32, state: wl.Pointer.ButtonState) callconv(.c) u32, c.wlr_seat_pointer_send_button);+ pub const pointerSendButton = wlr_seat_pointer_send_button;++ const wlr_seat_pointer_send_axis = abi.bind(fn (+ seat: *Seat,+ time_msec: u32,+ orientation: wl.Pointer.Axis,+ value: f64,+ value_discrete: i32,+ source: wl.Pointer.AxisSource,+ relative_direction: wl.Pointer.AxisRelativeDirection,+ ) callconv(.c) void, c.wlr_seat_pointer_send_axis);+ pub const pointerSendAxis = wlr_seat_pointer_send_axis;++ const wlr_seat_pointer_send_frame = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_pointer_send_frame);+ pub const pointerSendFrame = wlr_seat_pointer_send_frame;++ const wlr_seat_pointer_notify_enter = abi.bind(fn (seat: *Seat, surface: *wlr.Surface, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_pointer_notify_enter);+ pub const pointerNotifyEnter = wlr_seat_pointer_notify_enter;++ const wlr_seat_pointer_notify_clear_focus = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_pointer_notify_clear_focus);+ pub const pointerNotifyClearFocus = wlr_seat_pointer_notify_clear_focus;++ const wlr_seat_pointer_warp = abi.bind(fn (seat: *Seat, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_pointer_warp);+ pub const pointerWarp = wlr_seat_pointer_warp;++ const wlr_seat_pointer_notify_motion = abi.bind(fn (seat: *Seat, time_msec: u32, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_pointer_notify_motion);+ pub const pointerNotifyMotion = wlr_seat_pointer_notify_motion;++ const wlr_seat_pointer_notify_button = abi.bind(fn (seat: *Seat, time_msec: u32, button: u32, state: wl.Pointer.ButtonState) callconv(.c) u32, c.wlr_seat_pointer_notify_button);+ pub const pointerNotifyButton = wlr_seat_pointer_notify_button;++ const wlr_seat_pointer_notify_axis = abi.bind(fn (+ seat: *Seat,+ time_msec: u32,+ orientation: wl.Pointer.Axis,+ value: f64,+ value_discrete: i32,+ source: wl.Pointer.AxisSource,+ relative_direction: wl.Pointer.AxisRelativeDirection,+ ) callconv(.c) void, c.wlr_seat_pointer_notify_axis);+ pub const pointerNotifyAxis = wlr_seat_pointer_notify_axis;++ const wlr_seat_pointer_notify_frame = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_pointer_notify_frame);+ pub const pointerNotifyFrame = wlr_seat_pointer_notify_frame;++ const wlr_seat_pointer_start_grab = abi.bind(fn (seat: *Seat, grab: ?*PointerGrab) callconv(.c) void, c.wlr_seat_pointer_start_grab);+ pub const pointerStartGrab = wlr_seat_pointer_start_grab;++ const wlr_seat_pointer_end_grab = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_pointer_end_grab);+ pub const pointerEndGrab = wlr_seat_pointer_end_grab;++ const wlr_seat_pointer_has_grab = abi.bind(fn (seat: *Seat) callconv(.c) bool, c.wlr_seat_pointer_has_grab);+ pub const pointerHasGrab = wlr_seat_pointer_has_grab;++ const wlr_seat_set_keyboard = abi.bind(fn (seat: *Seat, keyboard: ?*wlr.Keyboard) callconv(.c) void, c.wlr_seat_set_keyboard);+ pub const setKeyboard = wlr_seat_set_keyboard;++ const wlr_seat_get_keyboard = abi.bind(fn (seat: *Seat) callconv(.c) ?*wlr.Keyboard, c.wlr_seat_get_keyboard);+ pub const getKeyboard = wlr_seat_get_keyboard;++ const wlr_seat_keyboard_send_key = abi.bind(fn (seat: *Seat, time_msec: u32, key: u32, state: u32) callconv(.c) void, c.wlr_seat_keyboard_send_key);+ pub const keyboardSendKey = wlr_seat_keyboard_send_key;++ const wlr_seat_keyboard_send_modifiers = abi.bind(fn (seat: *Seat, modifiers: ?*const wlr.Keyboard.Modifiers) callconv(.c) void, c.wlr_seat_keyboard_send_modifiers);+ pub const keyboardSendModifiers = wlr_seat_keyboard_send_modifiers;++ const wlr_seat_keyboard_enter = abi.bind(fn (seat: *Seat, surface: ?*wlr.Surface, keycodes: ?[*]const u32, num_keycodes: usize, modifiers: ?*const wlr.Keyboard.Modifiers) callconv(.c) void, c.wlr_seat_keyboard_enter);+ pub fn keyboardEnter(seat: *Seat, surface: ?*wlr.Surface, keycodes: []const u32, modifiers: ?*const wlr.Keyboard.Modifiers) void {+ wlr_seat_keyboard_enter(seat, surface, keycodes.ptr, keycodes.len, modifiers);+ }++ const wlr_seat_keyboard_clear_focus = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_keyboard_clear_focus);+ pub const keyboardClearFocus = wlr_seat_keyboard_clear_focus;++ const wlr_seat_keyboard_notify_key = abi.bind(fn (seat: *Seat, time_msec: u32, key: u32, state: u32) callconv(.c) void, c.wlr_seat_keyboard_notify_key);+ pub fn keyboardNotifyKey(seat: *Seat, time_msec: u32, key: u32, state: wl.Keyboard.KeyState) void {+ wlr_seat_keyboard_notify_key(seat, time_msec, key, @as(u32, @intCast(@intFromEnum(state))));+ }++ const wlr_seat_keyboard_notify_modifiers = abi.bind(fn (seat: *Seat, modifiers: ?*const wlr.Keyboard.Modifiers) callconv(.c) void, c.wlr_seat_keyboard_notify_modifiers);+ pub const keyboardNotifyModifiers = wlr_seat_keyboard_notify_modifiers;++ const wlr_seat_keyboard_notify_enter = abi.bind(fn (seat: *Seat, surface: *wlr.Surface, keycodes: ?[*]const u32, num_keycodes: usize, modifiers: ?*const wlr.Keyboard.Modifiers) callconv(.c) void, c.wlr_seat_keyboard_notify_enter);+ pub fn keyboardNotifyEnter(seat: *Seat, surface: *wlr.Surface, keycodes: []const u32, modifiers: ?*const wlr.Keyboard.Modifiers) void {+ wlr_seat_keyboard_notify_enter(seat, surface, keycodes.ptr, keycodes.len, modifiers);+ }++ const wlr_seat_keyboard_notify_clear_focus = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_keyboard_notify_clear_focus);+ pub const keyboardNotifyClearFocus = wlr_seat_keyboard_notify_clear_focus;++ const wlr_seat_keyboard_start_grab = abi.bind(fn (seat: *Seat, grab: *KeyboardGrab) callconv(.c) void, c.wlr_seat_keyboard_start_grab);+ pub const keyboardStartGrab = wlr_seat_keyboard_start_grab;++ const wlr_seat_keyboard_end_grab = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_keyboard_end_grab);+ pub const keyboardEndGrab = wlr_seat_keyboard_end_grab;++ const wlr_seat_keyboard_has_grab = abi.bind(fn (seat: *Seat) callconv(.c) bool, c.wlr_seat_keyboard_has_grab);+ pub const keyboardHasGrab = wlr_seat_keyboard_has_grab;++ const wlr_seat_touch_get_point = abi.bind(fn (seat: *Seat, touch_id: i32) callconv(.c) ?*TouchPoint, c.wlr_seat_touch_get_point);+ pub const touchGetPoint = wlr_seat_touch_get_point;++ const wlr_seat_touch_point_focus = abi.bind(fn (seat: *Seat, surface: *wlr.Surface, time_msec: u32, touch_id: i32, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_touch_point_focus);+ pub const touchPointFocus = wlr_seat_touch_point_focus;++ const wlr_seat_touch_point_clear_focus = abi.bind(fn (seat: *Seat, time_msec: u32, touch_id: i32) callconv(.c) void, c.wlr_seat_touch_point_clear_focus);+ pub const touchPointClearFocus = wlr_seat_touch_point_clear_focus;++ const wlr_seat_touch_send_down = abi.bind(fn (seat: *Seat, surface: *wlr.Surface, time_msec: u32, touch_id: i32, sx: f64, sy: f64) callconv(.c) u32, c.wlr_seat_touch_send_down);+ pub const touchSendDown = wlr_seat_touch_send_down;++ const wlr_seat_touch_send_up = abi.bind(fn (seat: *Seat, time_msec: u32, touch_id: i32) callconv(.c) u32, c.wlr_seat_touch_send_up);+ pub const touchSendUp = wlr_seat_touch_send_up;++ const wlr_seat_touch_send_motion = abi.bind(fn (seat: *Seat, time_msec: u32, touch_id: i32, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_touch_send_motion);+ pub const touchSendMotion = wlr_seat_touch_send_motion;++ const wlr_seat_touch_send_frame = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_touch_send_frame);+ pub const touchSendFrame = wlr_seat_touch_send_frame;++ const wlr_seat_touch_send_cancel = abi.bind(fn (seat: *Seat, seat_client: *wlr.Seat.Client) callconv(.c) void, c.wlr_seat_touch_send_cancel);+ pub const touchSendCancel = wlr_seat_touch_send_cancel;++ const wlr_seat_touch_notify_down = abi.bind(fn (seat: *Seat, surface: *wlr.Surface, time_msec: u32, touch_id: i32, sx: f64, sy: f64) callconv(.c) u32, c.wlr_seat_touch_notify_down);+ pub const touchNotifyDown = wlr_seat_touch_notify_down;++ const wlr_seat_touch_notify_up = abi.bind(fn (seat: *Seat, time_msec: u32, touch_id: i32) callconv(.c) u32, c.wlr_seat_touch_notify_up);+ pub const touchNotifyUp = wlr_seat_touch_notify_up;++ const wlr_seat_touch_notify_motion = abi.bind(fn (seat: *Seat, time_msec: u32, touch_id: i32, sx: f64, sy: f64) callconv(.c) void, c.wlr_seat_touch_notify_motion);+ pub const touchNotifyMotion = wlr_seat_touch_notify_motion;++ const wlr_seat_touch_notify_frame = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_touch_notify_frame);+ pub const touchNotifyFrame = wlr_seat_touch_notify_frame;++ const wlr_seat_touch_notify_cancel = abi.bind(fn (seat: *Seat, seat_client: *wlr.Seat.Client) callconv(.c) void, c.wlr_seat_touch_notify_cancel);+ pub const touchNotifyCancel = wlr_seat_touch_notify_cancel;++ const wlr_seat_touch_notify_clear_focus = abi.bind(fn (seat: *Seat, time_msec: u32, touch_id: i32) callconv(.c) void, c.wlr_seat_touch_notify_clear_focus);+ pub const touchNotifyClearFocus = wlr_seat_touch_notify_clear_focus;++ const wlr_seat_touch_num_points = abi.bind(fn (seat: *Seat) callconv(.c) c_int, c.wlr_seat_touch_num_points);+ pub const touchNumPoints = wlr_seat_touch_num_points;++ const wlr_seat_touch_start_grab = abi.bind(fn (seat: *Seat, grab: *TouchGrab) callconv(.c) void, c.wlr_seat_touch_start_grab);+ pub const touchStartGrab = wlr_seat_touch_start_grab;++ const wlr_seat_touch_end_grab = abi.bind(fn (seat: *Seat) callconv(.c) void, c.wlr_seat_touch_end_grab);+ pub const touchEndGrab = wlr_seat_touch_end_grab;++ const wlr_seat_touch_has_grab = abi.bind(fn (seat: *Seat) callconv(.c) bool, c.wlr_seat_touch_has_grab);+ pub const touchHasGrab = wlr_seat_touch_has_grab;++ const wlr_seat_validate_pointer_grab_serial = abi.bind(fn (seat: *Seat, origin: ?*wlr.Surface, serial: u32) callconv(.c) bool, c.wlr_seat_validate_pointer_grab_serial);+ pub const validatePointerGrabSerial = wlr_seat_validate_pointer_grab_serial;++ const wlr_seat_validate_touch_grab_serial = abi.bind(fn (seat: *Seat, origin: ?*wlr.Surface, serial: u32, point_ptr: ?**wlr.TouchPoint) callconv(.c) bool, c.wlr_seat_validate_touch_grab_serial);+ pub const validateTouchGrabSerial = wlr_seat_validate_touch_grab_serial;++ const wlr_seat_request_set_selection = abi.bind(fn (seat: *Seat, client: ?*Seat.Client, source: ?*wlr.DataSource, serial: u32) callconv(.c) void, c.wlr_seat_request_set_selection);+ pub const requestSetSelection = wlr_seat_request_set_selection;++ const wlr_seat_set_selection = abi.bind(fn (seat: *Seat, source: ?*wlr.DataSource, serial: u32) callconv(.c) void, c.wlr_seat_set_selection);+ pub const setSelection = wlr_seat_set_selection;++ const wlr_seat_request_set_primary_selection = abi.bind(fn (seat: *Seat, client: ?*Seat.Client, source: ?*wlr.PrimarySelectionSource, serial: u32) callconv(.c) void, c.wlr_seat_request_set_primary_selection);+ pub const requestSetPrimarySelection = wlr_seat_request_set_primary_selection;++ const wlr_seat_set_primary_selection = abi.bind(fn (seat: *Seat, source: ?*wlr.PrimarySelectionSource, serial: u32) callconv(.c) void, c.wlr_seat_set_primary_selection);+ pub const setPrimarySelection = wlr_seat_set_primary_selection;++ const wlr_seat_request_start_drag = abi.bind(fn (seat: *Seat, drag: *wlr.Drag, origin: *wlr.Surface, serial: u32) callconv(.c) void, c.wlr_seat_request_start_drag);+ pub const requestStartDrag = wlr_seat_request_start_drag;++ const wlr_seat_start_drag = abi.bind(fn (seat: *Seat, drag: *wlr.Drag, serial: u32) callconv(.c) void, c.wlr_seat_start_drag);+ pub const startDrag = wlr_seat_start_drag;++ const wlr_seat_start_pointer_drag = abi.bind(fn (seat: *Seat, drag: *wlr.Drag, serial: u32) callconv(.c) void, c.wlr_seat_start_pointer_drag);+ pub const startPointerDrag = wlr_seat_start_pointer_drag;++ const wlr_seat_start_touch_drag = abi.bind(fn (seat: *Seat, drag: *wlr.Drag, serial: u32, point: *TouchPoint) callconv(.c) void, c.wlr_seat_start_touch_drag);+ pub const startTouchDrag = wlr_seat_start_touch_drag;+};diff --git a/src/wlr/session.zig b/src/wlr/session.zignew file mode 100644index 0000000..ea2dbef--- /dev/null+++ b/src/wlr/session.zig@@ -0,0 +1,84 @@+//! Native session state and VT switching. Backend.autocreate owns session+//! creation and teardown; the compositor only observes active changes and+//! requests VT switches. Never allocate this prefix: wlroots owns its private+//! event-loop listener after the public fields.+const wl = @import("wayland").server.wl;+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++// The session's intrusive list needs the link's real offset even though+// compositor code does not currently enumerate devices.+const Device = extern struct {+ fd: c_int,+ device_id: c_int,+ dev: c.dev_t,+ link: wl.list.Link,+ events: extern struct {+ change: wl.Signal(*c.wlr_device_change_event),+ remove: wl.Signal(void),+ },++ comptime {+ const Real = c.wlr_device;+ assertSameLayout(Device, Real);+ for (.{ "fd", "device_id", "dev", "link", "events" }) |field| {+ assertFieldOffset(Device, Real, field);+ assertSameLayout(@FieldType(Device, field), @FieldType(Real, field));+ }+ const Events = @FieldType(Device, "events");+ const RealEvents = @FieldType(Real, "events");+ for (.{ "change", "remove" }) |field| {+ assertSameLayout(@FieldType(Events, field), c.wl_signal);+ assertFieldOffset(Events, RealEvents, field);+ }+ }+};++pub const Session = extern struct {+ pub const event = struct {+ pub const Add = extern struct {+ path: [*:0]const u8,++ comptime {+ assertSameLayout(Add, c.wlr_session_add_event);+ assertFieldOffset(Add, c.wlr_session_add_event, "path");+ }+ };+ };++ active: bool,+ seat: [256]u8,+ udev: ?*c.udev,+ mon: ?*c.udev_monitor,+ udev_event: ?*wl.EventSource,+ seat_handle: ?*c.libseat,+ libseat_event: ?*wl.EventSource,+ devices: wl.list.Head(Device, .link),+ event_loop: *wl.EventLoop,+ events: extern struct {+ // Server.handleSessionActive reads Session.active and does not+ // consume a payload from this signal.+ active: wl.Signal(void),+ add_drm_card: wl.Signal(*event.Add),+ destroy: wl.Signal(*Session),+ },++ pub fn changeVt(session: *Session, vt: c_uint) !void {+ if (!c.wlr_session_change_vt(@ptrCast(session), vt)) return error.ChangeVtFailed;+ }++ comptime {+ const Real = c.wlr_session;+ for (.{ "active", "seat", "udev", "mon", "udev_event", "seat_handle", "libseat_event", "devices", "event_loop", "events" }) |field| {+ assertFieldOffset(Session, Real, field);+ assertSameLayout(@FieldType(Session, field), @FieldType(Real, field));+ }+ const Events = @FieldType(Session, "events");+ const RealEvents = @FieldType(Real, "events");+ for (.{ "active", "add_drm_card", "destroy" }) |field| {+ assertSameLayout(@FieldType(Events, field), c.wl_signal);+ assertFieldOffset(Events, RealEvents, field);+ }+ }+};diff --git a/src/wlr/session_lock_v1.zig b/src/wlr/session_lock_v1.zignew file mode 100644index 0000000..3070458--- /dev/null+++ b/src/wlr/session_lock_v1.zig@@ -0,0 +1,96 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const ext = wayland.server.ext;++pub const SessionLockManagerV1 = extern struct {+ global: *wl.Global,++ events: extern struct {+ new_lock: wl.Signal(*SessionLockV1),+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ const wlr_session_lock_manager_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*SessionLockManagerV1, c.wlr_session_lock_manager_v1_create);+ pub fn create(server: *wl.Server) !*SessionLockManagerV1 {+ return wlr_session_lock_manager_v1_create(server) orelse error.OutOfMemory;+ }+};++pub const SessionLockV1 = extern struct {+ resource: *ext.SessionLockV1,++ surfaces: wl.list.Head(SessionLockSurfaceV1, .link),++ events: extern struct {+ new_surface: wl.Signal(*SessionLockSurfaceV1),+ unlock: wl.Signal(void),+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ const wlr_session_lock_v1_send_locked = abi.bind(fn (lock: *SessionLockV1) callconv(.c) void, c.wlr_session_lock_v1_send_locked);+ pub const sendLocked = wlr_session_lock_v1_send_locked;++ const wlr_session_lock_v1_destroy = abi.bind(fn (lock: *SessionLockV1) callconv(.c) void, c.wlr_session_lock_v1_destroy);+ pub const destroy = wlr_session_lock_v1_destroy;+};++pub const SessionLockSurfaceV1 = extern struct {+ pub const State = extern struct {+ width: u32,+ height: u32,+ configure_serial: u32,+ };++ pub const Configure = extern struct {+ /// SessionLockSurfaceV1.configure_list+ link: wl.list.Link,+ serial: u32,+ width: u32,+ height: u32,+ };++ resource: *ext.SessionLockSurfaceV1,+ /// SessionLockV1.surfaces+ link: wl.list.Link,++ output: *wlr.Output,+ surface: *wlr.Surface,++ configured: bool,++ configure_list: wl.list.Head(Configure, .link),++ current: State,+ pending: State,++ events: extern struct {+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ const wlr_session_lock_surface_v1_configure = abi.bind(fn (lock_surface: *SessionLockSurfaceV1, width: u32, height: u32) callconv(.c) u32, c.wlr_session_lock_surface_v1_configure);+ pub const configure = wlr_session_lock_surface_v1_configure;++ const wlr_session_lock_surface_v1_try_from_wlr_surface = abi.bind(fn (surface: *wlr.Surface) callconv(.c) ?*SessionLockSurfaceV1, c.wlr_session_lock_surface_v1_try_from_wlr_surface);+ pub const tryFromWlrSurface = wlr_session_lock_surface_v1_try_from_wlr_surface;+};++comptime {+ abi.assertFields(SessionLockManagerV1, c.wlr_session_lock_manager_v1);+ abi.assertFields(SessionLockV1, c.wlr_session_lock_v1);+ abi.assertFields(SessionLockSurfaceV1, c.wlr_session_lock_surface_v1);+ abi.assertFields(SessionLockSurfaceV1.State, c.wlr_session_lock_surface_v1_state);+ @import("signal.zig").assertSameLayout(SessionLockSurfaceV1.State, c.wlr_session_lock_surface_v1_state);+ abi.assertFields(SessionLockSurfaceV1.Configure, c.struct_wlr_session_lock_surface_v1_configure);+ @import("signal.zig").assertSameLayout(SessionLockSurfaceV1.Configure, c.struct_wlr_session_lock_surface_v1_configure);+}diff --git a/src/wlr/single_pixel_buffer_v1.zig b/src/wlr/single_pixel_buffer_v1.zignew file mode 100644index 0000000..686bbe3--- /dev/null+++ b/src/wlr/single_pixel_buffer_v1.zig@@ -0,0 +1,17 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wl = @import("wayland").server.wl;++pub const SinglePixelBufferManagerV1 = extern struct {+ global: *wl.Global,++ const wlr_single_pixel_buffer_manager_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*SinglePixelBufferManagerV1, c.wlr_single_pixel_buffer_manager_v1_create);+ pub fn create(server: *wl.Server) !*SinglePixelBufferManagerV1 {+ return wlr_single_pixel_buffer_manager_v1_create(server) orelse error.OutOfMemory;+ }+};++comptime {+ abi.assertFields(SinglePixelBufferManagerV1, c.wlr_single_pixel_buffer_manager_v1);+}diff --git a/src/wlr/subcompositor.zig b/src/wlr/subcompositor.zignew file mode 100644index 0000000..8c61429--- /dev/null+++ b/src/wlr/subcompositor.zig@@ -0,0 +1,62 @@+//! Typed wlroots header adapter. API shapes adapted from zig-wlroots;+//! see LICENSE.zig-wlroots for its MIT license.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const Subcompositor = extern struct {+ global: *wl.Global,++ events: extern struct {+ destroy: wl.Signal(*Subcompositor),+ },++ const wlr_subcompositor_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*Subcompositor, c.wlr_subcompositor_create);+ pub fn create(server: *wl.Server) !*Subcompositor {+ return wlr_subcompositor_create(server) orelse error.OutOfMemory;+ }+};++pub const Subsurface = extern struct {+ pub const ParentState = extern struct {+ x: i32,+ y: i32,+ /// wlr.Surface.State.subsurfaces_above/subsurfaces_below+ link: wl.list.Link,++ WLR_PRIVATE: @FieldType(c.wlr_subsurface_parent_state, "WLR_PRIVATE"),+ };++ resource: *wl.Subsurface,+ surface: *wlr.Surface,+ parent: *wlr.Surface,++ current: ParentState,+ pending: ParentState,++ cached_seq: u32,+ has_cache: bool,++ synchronized: bool,+ added: bool,++ events: extern struct {+ destroy: wl.Signal(*Subsurface),+ },++ data: ?*anyopaque,++ const wlr_subsurface_try_from_wlr_surface = abi.bind(fn (surface: *wlr.Surface) callconv(.c) ?*wlr.Subsurface, c.wlr_subsurface_try_from_wlr_surface);+ pub const tryFromWlrSurface = wlr_subsurface_try_from_wlr_surface;+};++comptime {+ abi.assertFields(Subcompositor, c.wlr_subcompositor);+ abi.assertFields(Subsurface, c.wlr_subsurface);+ // ParentState is embedded twice in Subsurface and must retain its full+ // header-derived private tail so pending and following fields line up.+ abi.assertLayout(Subsurface.ParentState, c.wlr_subsurface_parent_state);+}diff --git a/src/wlr/swapchain.zig b/src/wlr/swapchain.zignew file mode 100644index 0000000..731abb3--- /dev/null+++ b/src/wlr/swapchain.zig@@ -0,0 +1,55 @@+// Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");++const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const Swapchain = extern struct {+ pub const Slot = extern struct {+ buffer: ?*wlr.Buffer,+ /// Waiting for release+ acquired: bool,++ WLR_PRIVATE: @FieldType(c.wlr_swapchain_slot, "WLR_PRIVATE"),+ };++ /// `null` if destroyed+ allocator: ?*wlr.Allocator,++ width: c_int,+ height: c_int,+ format: wlr.DrmFormat,++ slots: [4]Slot,++ WLR_PRIVATE: @FieldType(c.wlr_swapchain, "WLR_PRIVATE"),++ const wlr_swapchain_create = abi.bind(fn (alloc: *wlr.Allocator, width: c_int, height: c_int, format: *const wlr.DrmFormat) callconv(.c) ?*Swapchain, c.wlr_swapchain_create);+ pub fn create(alloc: *wlr.Allocator, width: c_int, height: c_int, format: *const wlr.DrmFormat) !*Swapchain {+ return wlr_swapchain_create(alloc, width, height, format) orelse error.SwapchainCreateFailed;+ }++ const wlr_swapchain_destroy = abi.bind(fn (swapchain: *Swapchain) callconv(.c) void, c.wlr_swapchain_destroy);+ pub const destroy = wlr_swapchain_destroy;++ /// Acquire a buffer from the swap chain.+ ///+ /// The returned buffer is locked. When the caller is done with it, they must+ /// unlock it by calling `wlr.Buffer.unlock`.+ const wlr_swapchain_acquire = abi.bind(fn (swapchain: *Swapchain) callconv(.c) ?*wlr.Buffer, c.wlr_swapchain_acquire);+ pub fn acquire(swapchain: *Swapchain) !*wlr.Buffer {+ return wlr_swapchain_acquire(swapchain) orelse error.SwapchainAquireBufferFailed;+ }++ /// Returns `true` if this buffer has been created by this swapchain, and false otherwise+ const wlr_swapchain_has_buffer = abi.bind(fn (swapchain: *Swapchain, buffer: *wlr.Buffer) callconv(.c) bool, c.wlr_swapchain_has_buffer);+ pub const hasBuffer = wlr_swapchain_has_buffer;+};++comptime {+ abi.assertLayout(Swapchain, c.wlr_swapchain);+ abi.assertLayout(Swapchain.Slot, c.wlr_swapchain_slot);+}diff --git a/src/wlr/switch.zig b/src/wlr/switch.zignew file mode 100644index 0000000..11f44f3--- /dev/null+++ b/src/wlr/switch.zig@@ -0,0 +1,49 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const SwitchType = enum(c_int) {+ lid = c.WLR_SWITCH_TYPE_LID,+ tablet_mode = c.WLR_SWITCH_TYPE_TABLET_MODE,+ keypad_slide = c.WLR_SWITCH_TYPE_KEYPAD_SLIDE,+};++pub const SwitchState = enum(c_int) {+ off = c.WLR_SWITCH_STATE_OFF,+ on = c.WLR_SWITCH_STATE_ON,+};++pub const Switch = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_switch);+ }++ pub const event = struct {+ pub const Toggle = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_switch_toggle_event);+ }++ time_msec: u32,+ switch_type: SwitchType,+ switch_state: SwitchState,+ };+ };++ const Impl = opaque {};++ base: wlr.InputDevice,++ impl: *const Impl,++ events: extern struct {+ toggle: wl.Signal(*event.Toggle),+ },++ data: ?*anyopaque,+};diff --git a/src/wlr/tablet_pad.zig b/src/wlr/tablet_pad.zignew file mode 100644index 0000000..6598027--- /dev/null+++ b/src/wlr/tablet_pad.zig@@ -0,0 +1,100 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const zwp = wayland.server.zwp;++pub const TabletPad = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_pad);+ }++ pub const event = extern struct {+ pub const Button = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_pad_button_event);+ }++ time_msec: u32,+ button: u32,+ state: zwp.TabletPadV2.ButtonState,+ mode: c_uint,+ group: c_uint,+ };++ pub const Ring = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_pad_ring_event);+ }++ pub const Source = enum(c_int) {+ unknown = c.WLR_TABLET_PAD_RING_SOURCE_UNKNOWN,+ finger = c.WLR_TABLET_PAD_RING_SOURCE_FINGER,+ };++ time_msec: u32,+ source: Source,+ ring: u32,+ position: f64,+ mode: c_uint,+ };++ pub const Strip = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_pad_strip_event);+ }++ pub const Source = enum(c_int) {+ unknown = c.WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN,+ finger = c.WLR_TABLET_PAD_STRIP_SOURCE_FINGER,+ };++ time_msec: u32,+ source: Source,+ strip: u32,+ position: f64,+ mode: c_uint,+ };+ };++ pub const Group = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_pad_group);+ }++ link: wl.list.Link, // TabletPad.groups++ button_count: usize,+ buttons: [*]c_uint,++ strip_count: usize,+ strips: [*]c_uint,++ ring_count: usize,+ rings: [*]c_uint,++ mode_count: c_uint,+ };++ base: wlr.InputDevice,+ impl: *const opaque {},++ events: extern struct {+ button: wl.Signal(*event.Button),+ ring: wl.Signal(*event.Ring),+ strip: wl.Signal(*event.Strip),+ attach_tablet: wl.Signal(*wlr.TabletTool),+ },++ button_count: usize,+ ring_count: usize,+ strip_count: usize,+ groups: wl.list.Head(Group, .link),+ paths: wl.Array, // char *++ data: ?*anyopaque,+};diff --git a/src/wlr/tablet_tool.zig b/src/wlr/tablet_tool.zignew file mode 100644index 0000000..52b214d--- /dev/null+++ b/src/wlr/tablet_tool.zig@@ -0,0 +1,164 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const zwp = wayland.server.zwp;++pub const TabletTool = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_tool);+ }++ pub const Type = enum(c_int) {+ pen = c.WLR_TABLET_TOOL_TYPE_PEN,+ eraser = c.WLR_TABLET_TOOL_TYPE_ERASER,+ brush = c.WLR_TABLET_TOOL_TYPE_BRUSH,+ pencil = c.WLR_TABLET_TOOL_TYPE_PENCIL,+ airbrush = c.WLR_TABLET_TOOL_TYPE_AIRBRUSH,+ mouse = c.WLR_TABLET_TOOL_TYPE_MOUSE,+ lens = c.WLR_TABLET_TOOL_TYPE_LENS,+ totem = c.WLR_TABLET_TOOL_TYPE_TOTEM,+ };++ pub const Axes = packed struct(u32) {+ x: bool = false,+ y: bool = false,+ distance: bool = false,+ pressure: bool = false,+ tilt_x: bool = false,+ tilt_y: bool = false,+ rotation: bool = false,+ slider: bool = false,+ wheel: bool = false,+ _: u23 = 0,+ };++ type: Type,+ hardware_serial: u64,+ hardware_wacom: u64,++ tilt: bool,+ pressure: bool,+ distance: bool,+ rotation: bool,+ slider: bool,+ wheel: bool,++ events: extern struct {+ destroy: wl.Signal(*TabletTool),+ },++ data: ?*anyopaque,+};++pub const Tablet = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet);+ }++ pub const event = struct {+ pub const Axis = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_tool_axis_event);+ }++ tablet: *wlr.Tablet,+ tool: *TabletTool,++ time_msec: u32,+ updated_axes: wlr.TabletTool.Axes,+ /// From 0..1+ x: f64,+ /// From 0..1+ y: f64,+ /// Relative to last event+ dx: f64,+ /// Relative to last event+ dy: f64,+ pressure: f64,+ distance: f64,+ tilt_x: f64,+ tilt_y: f64,+ rotation: f64,+ slider: f64,+ wheel_delta: f64,+ };++ pub const Proximity = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_tool_proximity_event);+ }++ pub const State = enum(c_int) {+ out = c.WLR_TABLET_TOOL_PROXIMITY_OUT,+ in = c.WLR_TABLET_TOOL_PROXIMITY_IN,+ };++ tablet: *wlr.Tablet,+ tool: *TabletTool,++ time_msec: u32,+ x: f64,+ y: f64,+ state: Proximity.State,+ };++ pub const Tip = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_tool_tip_event);+ }++ pub const State = enum(c_int) {+ up = c.WLR_TABLET_TOOL_TIP_UP,+ down = c.WLR_TABLET_TOOL_TIP_DOWN,+ };++ tablet: *wlr.Tablet,+ tool: *TabletTool,++ time_msec: u32,+ x: f64,+ y: f64,+ state: Tip.State,+ };++ pub const Button = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_tool_button_event);+ }++ tablet: *wlr.Tablet,+ tool: *TabletTool,++ time_msec: u32,+ button: u32,+ state: zwp.TabletToolV2.ButtonState,+ };+ };++ const Impl = opaque {};++ base: wlr.InputDevice,++ impl: *const Impl,++ usb_vendor_id: u16,+ usb_product_id: u16,+ width_mm: f64,+ height_mm: f64,++ events: extern struct {+ axis: wl.Signal(*event.Axis),+ proximity: wl.Signal(*event.Proximity),+ tip: wl.Signal(*event.Tip),+ button: wl.Signal(*event.Button),+ },++ paths: wl.Array,++ data: ?*anyopaque,+};diff --git a/src/wlr/tablet_v2.zig b/src/wlr/tablet_v2.zignew file mode 100644index 0000000..900a30a--- /dev/null+++ b/src/wlr/tablet_v2.zig@@ -0,0 +1,323 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const zwp = wayland.server.zwp;++pub const TabletManagerV2 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_manager_v2);+ }++ wl_global: *wl.Global,+ clients: wl.list.Link, // private to wlroots+ seats: wl.list.Link, // private to wlroots++ events: extern struct {+ destroy: wl.Signal(void),+ },++ data: ?*anyopaque,++ WLR_PRIVATE: @FieldType(c.wlr_tablet_manager_v2, "WLR_PRIVATE"),++ const wlr_tablet_v2_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*TabletManagerV2, c.wlr_tablet_v2_create);+ pub fn create(server: *wl.Server) !*TabletManagerV2 {+ return wlr_tablet_v2_create(server) orelse error.OutOfMemory;+ }++ const wlr_tablet_create = abi.bind(fn (manager: *TabletManagerV2, wlr_seat: *wlr.Seat, wlr_device: *wlr.InputDevice) callconv(.c) ?*TabletV2Tablet, c.wlr_tablet_create);+ pub fn createTabletV2Tablet(manager: *TabletManagerV2, wlr_seat: *wlr.Seat, wlr_device: *wlr.InputDevice) !*TabletV2Tablet {+ return wlr_tablet_create(manager, wlr_seat, wlr_device) orelse error.OutOfMemory;+ }++ const wlr_tablet_pad_create = abi.bind(fn (manager: *TabletManagerV2, wlr_seat: *wlr.Seat, wlr_device: *wlr.InputDevice) callconv(.c) ?*TabletV2TabletPad, c.wlr_tablet_pad_create);+ pub fn createTabletV2TabletPad(manager: *TabletManagerV2, wlr_seat: *wlr.Seat, wlr_device: *wlr.InputDevice) !*TabletV2TabletPad {+ return wlr_tablet_pad_create(manager, wlr_seat, wlr_device) orelse error.OutOfMemory;+ }++ const wlr_tablet_tool_create = abi.bind(fn (manager: *TabletManagerV2, wlr_seat: *wlr.Seat, wlr_tool: *wlr.TabletTool) callconv(.c) ?*TabletV2TabletTool, c.wlr_tablet_tool_create);+ pub fn createTabletV2TabletTool(manager: *TabletManagerV2, wlr_seat: *wlr.Seat, wlr_tool: *wlr.TabletTool) !*TabletV2TabletTool {+ return wlr_tablet_tool_create(manager, wlr_seat, wlr_tool) orelse error.OutOfMemory;+ }+};++pub const TabletV2Tablet = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_v2_tablet);+ }++ link: wl.list.Link, // private to wlroots+ wlr_tablet: *wlr.Tablet,+ wlr_device: *wlr.InputDevice,+ clients: wl.list.Link, // private to wlroots++ current_client: ?*opaque {},++ WLR_PRIVATE: @FieldType(c.wlr_tablet_v2_tablet, "WLR_PRIVATE"),+};++pub const TabletV2TabletTool = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_v2_tablet_tool);+ }++ pub const event = struct {+ pub const SetCursor = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_v2_event_cursor);+ }++ surface: ?*wlr.Surface,+ serial: u32,+ hotspot_x: i32,+ hotspot_y: i32,+ seat_client: *wlr.Seat.Client,+ };+ };++ pub const Grab = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_tool_v2_grab);+ }++ pub const Interface = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_tool_v2_grab_interface);+ }++ proximity_in: ?*const fn (*Grab, *TabletV2Tablet, *wlr.Surface) callconv(.c) void,+ down: ?*const fn (*Grab) callconv(.c) void,+ up: ?*const fn (*Grab) callconv(.c) void,+ motion: ?*const fn (*Grab, f64, f64) callconv(.c) void,+ pressure: ?*const fn (*Grab, f64) callconv(.c) void,+ distance: ?*const fn (*Grab, f64) callconv(.c) void,+ tilt: ?*const fn (*Grab, f64, f64) callconv(.c) void,+ rotation: ?*const fn (*Grab, f64) callconv(.c) void,+ slider: ?*const fn (*Grab, f64) callconv(.c) void,+ wheel: ?*const fn (*Grab, f64, i32) callconv(.c) void,+ proximity_out: ?*const fn (*Grab) callconv(.c) void,+ button: ?*const fn (*Grab, u32, zwp.TabletToolV2.ButtonState) callconv(.c) void,+ cancel: ?*const fn (*Grab) callconv(.c) void,+ };+ interface: *const Interface,+ tool: *TabletV2TabletTool,+ data: ?*anyopaque,+ };++ link: wl.list.Link, // private to wlroots+ wlr_tool: *wlr.TabletTool,+ clients: wl.list.Link, // private to wlroots++ current_client: ?*opaque {},+ focused_surface: ?*wlr.Surface,++ grab: *Grab,+ default_grab: Grab,++ proximity_serial: u32,+ is_down: bool,+ down_serial: u32,+ num_buttons: usize,+ pressed_buttons: [c.WLR_TABLET_V2_TOOL_BUTTONS_CAP]u32,+ pressed_serials: [c.WLR_TABLET_V2_TOOL_BUTTONS_CAP]u32,++ events: extern struct {+ set_cursor: wl.Signal(*event.SetCursor),+ },++ WLR_PRIVATE: @FieldType(c.wlr_tablet_v2_tablet_tool, "WLR_PRIVATE"),++ const wlr_send_tablet_v2_tablet_tool_proximity_in = abi.bind(fn (tool: *TabletV2TabletTool, tablet: *TabletV2Tablet, surface: *wlr.Surface) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_proximity_in);+ pub const sendProximityIn = wlr_send_tablet_v2_tablet_tool_proximity_in;++ const wlr_send_tablet_v2_tablet_tool_down = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_down);+ pub const sendDown = wlr_send_tablet_v2_tablet_tool_down;++ const wlr_send_tablet_v2_tablet_tool_up = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_up);+ pub const sendUp = wlr_send_tablet_v2_tablet_tool_up;++ const wlr_send_tablet_v2_tablet_tool_motion = abi.bind(fn (tool: *TabletV2TabletTool, x: f64, y: f64) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_motion);+ pub const sendMotion = wlr_send_tablet_v2_tablet_tool_motion;++ const wlr_send_tablet_v2_tablet_tool_pressure = abi.bind(fn (tool: *TabletV2TabletTool, pressure: f64) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_pressure);+ pub const sendPressure = wlr_send_tablet_v2_tablet_tool_pressure;++ const wlr_send_tablet_v2_tablet_tool_distance = abi.bind(fn (tool: *TabletV2TabletTool, distance: f64) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_distance);+ pub const sendDistance = wlr_send_tablet_v2_tablet_tool_distance;++ const wlr_send_tablet_v2_tablet_tool_tilt = abi.bind(fn (tool: *TabletV2TabletTool, x: f64, y: f64) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_tilt);+ pub const sendTilt = wlr_send_tablet_v2_tablet_tool_tilt;++ const wlr_send_tablet_v2_tablet_tool_rotation = abi.bind(fn (tool: *TabletV2TabletTool, degrees: f64) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_rotation);+ pub const sendRotation = wlr_send_tablet_v2_tablet_tool_rotation;++ const wlr_send_tablet_v2_tablet_tool_slider = abi.bind(fn (tool: *TabletV2TabletTool, position: f64) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_slider);+ pub const sendSlider = wlr_send_tablet_v2_tablet_tool_slider;++ const wlr_send_tablet_v2_tablet_tool_wheel = abi.bind(fn (tool: *TabletV2TabletTool, degrees: f64, clicks: i32) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_wheel);+ pub const sendWheel = wlr_send_tablet_v2_tablet_tool_wheel;++ const wlr_send_tablet_v2_tablet_tool_proximity_out = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_proximity_out);+ pub const sendProximityOut = wlr_send_tablet_v2_tablet_tool_proximity_out;++ const wlr_send_tablet_v2_tablet_tool_button = abi.bind(fn (tool: *TabletV2TabletTool, button: u32, state: zwp.TabletToolV2.ButtonState) callconv(.c) void, c.wlr_send_tablet_v2_tablet_tool_button);+ pub const sendButton = wlr_send_tablet_v2_tablet_tool_button;++ const wlr_tablet_v2_tablet_tool_notify_proximity_in = abi.bind(fn (tool: *TabletV2TabletTool, tablet: *TabletV2Tablet, surface: *wlr.Surface) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_proximity_in);+ pub const notifyProximityIn = wlr_tablet_v2_tablet_tool_notify_proximity_in;++ const wlr_tablet_v2_tablet_tool_notify_down = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_down);+ pub const notifyDown = wlr_tablet_v2_tablet_tool_notify_down;++ const wlr_tablet_v2_tablet_tool_notify_up = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_up);+ pub const notifyUp = wlr_tablet_v2_tablet_tool_notify_up;++ const wlr_tablet_v2_tablet_tool_notify_motion = abi.bind(fn (tool: *TabletV2TabletTool, x: f64, y: f64) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_motion);+ pub const notifyMotion = wlr_tablet_v2_tablet_tool_notify_motion;++ const wlr_tablet_v2_tablet_tool_notify_pressure = abi.bind(fn (tool: *TabletV2TabletTool, pressure: f64) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_pressure);+ pub const notifyPressure = wlr_tablet_v2_tablet_tool_notify_pressure;++ const wlr_tablet_v2_tablet_tool_notify_distance = abi.bind(fn (tool: *TabletV2TabletTool, distance: f64) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_distance);+ pub const notifyDistance = wlr_tablet_v2_tablet_tool_notify_distance;++ const wlr_tablet_v2_tablet_tool_notify_tilt = abi.bind(fn (tool: *TabletV2TabletTool, x: f64, y: f64) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_tilt);+ pub const notifyTilt = wlr_tablet_v2_tablet_tool_notify_tilt;++ const wlr_tablet_v2_tablet_tool_notify_rotation = abi.bind(fn (tool: *TabletV2TabletTool, degrees: f64) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_rotation);+ pub const notifyRotation = wlr_tablet_v2_tablet_tool_notify_rotation;++ const wlr_tablet_v2_tablet_tool_notify_slider = abi.bind(fn (tool: *TabletV2TabletTool, position: f64) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_slider);+ pub const notifySlider = wlr_tablet_v2_tablet_tool_notify_slider;++ const wlr_tablet_v2_tablet_tool_notify_wheel = abi.bind(fn (tool: *TabletV2TabletTool, degrees: f64, clicks: i32) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_wheel);+ pub const notifyWheel = wlr_tablet_v2_tablet_tool_notify_wheel;++ const wlr_tablet_v2_tablet_tool_notify_proximity_out = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_proximity_out);+ pub const notifyProximityOut = wlr_tablet_v2_tablet_tool_notify_proximity_out;++ const wlr_tablet_v2_tablet_tool_notify_button = abi.bind(fn (tool: *TabletV2TabletTool, button: u32, state: zwp.TabletToolV2.ButtonState) callconv(.c) void, c.wlr_tablet_v2_tablet_tool_notify_button);+ pub const notifyButton = wlr_tablet_v2_tablet_tool_notify_button;++ const wlr_tablet_tool_v2_start_grab = abi.bind(fn (tool: *TabletV2TabletTool, grab: *Grab) callconv(.c) void, c.wlr_tablet_tool_v2_start_grab);+ pub const startGrab = wlr_tablet_tool_v2_start_grab;++ const wlr_tablet_tool_v2_end_grab = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_tablet_tool_v2_end_grab);+ pub const endGrab = wlr_tablet_tool_v2_end_grab;++ const wlr_tablet_tool_v2_start_implicit_grab = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) void, c.wlr_tablet_tool_v2_start_implicit_grab);+ pub const startImplicitGrab = wlr_tablet_tool_v2_start_implicit_grab;++ const wlr_tablet_tool_v2_has_implicit_grab = abi.bind(fn (tool: *TabletV2TabletTool) callconv(.c) bool, c.wlr_tablet_tool_v2_has_implicit_grab);+ pub const hasImplicitGrab = wlr_tablet_tool_v2_has_implicit_grab;+};++pub const TabletV2TabletPad = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_v2_tablet_pad);+ }++ pub const event = struct {+ pub const Feedback = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_v2_event_feedback);+ }++ description: [*:0]const u8,+ index: usize,+ serial: u32,+ };+ };++ pub const Grab = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_pad_v2_grab);+ }++ pub const Interface = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_tablet_pad_v2_grab_interface);+ }++ enter: ?*const fn (*Grab, *TabletV2Tablet, *wlr.Surface) callconv(.c) u32,+ button: ?*const fn (*Grab, usize, u32, zwp.TabletPadV2.ButtonState) callconv(.c) void,+ strip: ?*const fn (*Grab, u32, f64, bool, u32) callconv(.c) void,+ ring: ?*const fn (*Grab, u32, f64, bool, u32) callconv(.c) void,+ leave: ?*const fn (*Grab, *wlr.Surface) callconv(.c) u32,+ mode: ?*const fn (*Grab, usize, u32, u32) callconv(.c) u32,+ cancel: ?*const fn (*Grab) callconv(.c) void,+ };++ interface: *const Interface,+ pad: *TabletV2TabletPad,+ data: ?*anyopaque,+ };++ link: wl.list.Link, // private to wlroots+ wlr_pad: *wlr.TabletPad,+ wlr_device: *wlr.InputDevice,+ clients: wl.list.Link, // private to wlroots++ group_count: usize,+ groups: [*]u32,++ current_client: ?*opaque {},++ grab: *Grab,+ default_grab: Grab,++ events: extern struct {+ button_feedback: wl.Signal(*event.Feedback),+ strip_feedback: wl.Signal(*event.Feedback),+ ring_feedback: wl.Signal(*event.Feedback),+ },++ WLR_PRIVATE: @FieldType(c.wlr_tablet_v2_tablet_pad, "WLR_PRIVATE"),++ const wlr_send_tablet_v2_tablet_pad_enter = abi.bind(fn (pad: *TabletV2TabletPad, tablet: *TabletV2Tablet, surface: *wlr.Surface) callconv(.c) u32, c.wlr_send_tablet_v2_tablet_pad_enter);+ pub const sendEnter = wlr_send_tablet_v2_tablet_pad_enter;++ const wlr_send_tablet_v2_tablet_pad_button = abi.bind(fn (pad: *TabletV2TabletPad, button: usize, time: u32, state: zwp.TabletPadV2.ButtonState) callconv(.c) void, c.wlr_send_tablet_v2_tablet_pad_button);+ pub const sendButton = wlr_send_tablet_v2_tablet_pad_button;++ const wlr_send_tablet_v2_tablet_pad_strip = abi.bind(fn (pad: *TabletV2TabletPad, strip: u32, position: f64, finger: bool, time: u32) callconv(.c) void, c.wlr_send_tablet_v2_tablet_pad_strip);+ pub const sendStrip = wlr_send_tablet_v2_tablet_pad_strip;++ const wlr_send_tablet_v2_tablet_pad_ring = abi.bind(fn (pad: *TabletV2TabletPad, ring: u32, position: f64, finger: bool, time: u32) callconv(.c) void, c.wlr_send_tablet_v2_tablet_pad_ring);+ pub const sendRing = wlr_send_tablet_v2_tablet_pad_ring;++ const wlr_send_tablet_v2_tablet_pad_leave = abi.bind(fn (pad: *TabletV2TabletPad, surface: *wlr.Surface) callconv(.c) u32, c.wlr_send_tablet_v2_tablet_pad_leave);+ pub const sendLeave = wlr_send_tablet_v2_tablet_pad_leave;++ const wlr_send_tablet_v2_tablet_pad_mode = abi.bind(fn (pad: *TabletV2TabletPad, group: usize, mode: u32, time: u32) callconv(.c) u32, c.wlr_send_tablet_v2_tablet_pad_mode);+ pub const sendMode = wlr_send_tablet_v2_tablet_pad_mode;++ const wlr_tablet_v2_tablet_pad_notify_enter = abi.bind(fn (pad: *TabletV2TabletPad, tablet: *TabletV2Tablet, surface: *wlr.Surface) callconv(.c) u32, c.wlr_tablet_v2_tablet_pad_notify_enter);+ pub const notifyEnter = wlr_tablet_v2_tablet_pad_notify_enter;++ const wlr_tablet_v2_tablet_pad_notify_button = abi.bind(fn (pad: *TabletV2TabletPad, button: usize, time: u32, state: zwp.TabletPadV2.ButtonState) callconv(.c) void, c.wlr_tablet_v2_tablet_pad_notify_button);+ pub const notifyButton = wlr_tablet_v2_tablet_pad_notify_button;++ const wlr_tablet_v2_tablet_pad_notify_strip = abi.bind(fn (pad: *TabletV2TabletPad, strip: u32, position: f64, finger: bool, time: u32) callconv(.c) void, c.wlr_tablet_v2_tablet_pad_notify_strip);+ pub const notifyStrip = wlr_tablet_v2_tablet_pad_notify_strip;++ const wlr_tablet_v2_tablet_pad_notify_ring = abi.bind(fn (pad: *TabletV2TabletPad, ring: u32, position: f64, finger: bool, time: u32) callconv(.c) void, c.wlr_tablet_v2_tablet_pad_notify_ring);+ pub const notifyRing = wlr_tablet_v2_tablet_pad_notify_ring;++ const wlr_tablet_v2_tablet_pad_notify_leave = abi.bind(fn (pad: *TabletV2TabletPad, surface: *wlr.Surface) callconv(.c) u32, c.wlr_tablet_v2_tablet_pad_notify_leave);+ pub const notifyLeave = wlr_tablet_v2_tablet_pad_notify_leave;++ const wlr_tablet_v2_tablet_pad_notify_mode = abi.bind(fn (pad: *TabletV2TabletPad, group: usize, mode: u32, time: u32) callconv(.c) u32, c.wlr_tablet_v2_tablet_pad_notify_mode);+ pub const notifyMode = wlr_tablet_v2_tablet_pad_notify_mode;++ const wlr_tablet_v2_end_grab = abi.bind(fn (pad: *TabletV2TabletPad) callconv(.c) void, c.wlr_tablet_v2_end_grab);+ pub const endGrab = wlr_tablet_v2_end_grab;++ const wlr_tablet_v2_start_grab = abi.bind(fn (pad: *TabletV2TabletPad, grab: *Grab) callconv(.c) void, c.wlr_tablet_v2_start_grab);+ pub const startGrab = wlr_tablet_v2_start_grab;+};diff --git a/src/wlr/text_input_v3.zig b/src/wlr/text_input_v3.zignew file mode 100644index 0000000..cfedbf6--- /dev/null+++ b/src/wlr/text_input_v3.zig@@ -0,0 +1,104 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const TextInputManagerV3 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_text_input_manager_v3);+ }++ global: *wl.Global,+ text_inputs: wl.list.Head(TextInputV3, .link),++ events: extern struct {+ new_text_input: wl.Signal(*wlr.TextInputV3),+ destroy: wl.Signal(void),+ },++ WLR_PRIVATE: @FieldType(c.wlr_text_input_manager_v3, "WLR_PRIVATE"),++ const wlr_text_input_manager_v3_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*wlr.TextInputManagerV3, c.wlr_text_input_manager_v3_create);+ pub fn create(server: *wl.Server) !*wlr.TextInputManagerV3 {+ return wlr_text_input_manager_v3_create(server) orelse error.OutOfMemory;+ }+};++pub const TextInputV3 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_text_input_v3);+ }++ pub const Features = packed struct(u32) {+ surrounding_text: bool = false,+ content_type: bool = false,+ cursor_rectangle: bool = false,+ _: u29 = 0,+ };++ pub const State = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_text_input_v3_state);+ }++ surrounding: extern struct {+ text: ?[*:0]u8,+ cursor: u32,+ anchor: u32,+ },++ text_change_cause: u32,++ content_type: extern struct {+ hint: u32,+ purpose: u32,+ },++ cursor_rectangle: wlr.Box,++ features: Features,+ };++ seat: ?*wlr.Seat,+ resource: *wl.Resource,+ focused_surface: ?*wlr.Surface,+ pending: wlr.TextInputV3.State,+ current: wlr.TextInputV3.State,+ current_serial: u32,+ pending_enabled: bool,+ current_enabled: bool,+ active_features: Features,++ link: wl.list.Link,++ events: extern struct {+ enable: wl.Signal(void),+ commit: wl.Signal(void),+ disable: wl.Signal(void),+ destroy: wl.Signal(void),+ },++ WLR_PRIVATE: @FieldType(c.wlr_text_input_v3, "WLR_PRIVATE"),++ const wlr_text_input_v3_send_enter = abi.bind(fn (text_input: *wlr.TextInputV3, surface: *wlr.Surface) callconv(.c) void, c.wlr_text_input_v3_send_enter);+ pub const sendEnter = wlr_text_input_v3_send_enter;++ const wlr_text_input_v3_send_leave = abi.bind(fn (text_input: *wlr.TextInputV3) callconv(.c) void, c.wlr_text_input_v3_send_leave);+ pub const sendLeave = wlr_text_input_v3_send_leave;++ const wlr_text_input_v3_send_preedit_string = abi.bind(fn (text_input: *wlr.TextInputV3, text: [*:0]const u8, cursor_begin: i32, cursor_end: i32) callconv(.c) void, c.wlr_text_input_v3_send_preedit_string);+ pub const sendPreeditString = wlr_text_input_v3_send_preedit_string;++ const wlr_text_input_v3_send_commit_string = abi.bind(fn (text_input: *wlr.TextInputV3, text: [*:0]const u8) callconv(.c) void, c.wlr_text_input_v3_send_commit_string);+ pub const sendCommitString = wlr_text_input_v3_send_commit_string;++ const wlr_text_input_v3_send_delete_surrounding_text = abi.bind(fn (text_input: *wlr.TextInputV3, before_length: u32, after_length: u32) callconv(.c) void, c.wlr_text_input_v3_send_delete_surrounding_text);+ pub const sendDeleteSurroundingText = wlr_text_input_v3_send_delete_surrounding_text;++ const wlr_text_input_v3_send_done = abi.bind(fn (text_input: *wlr.TextInputV3) callconv(.c) void, c.wlr_text_input_v3_send_done);+ pub const sendDone = wlr_text_input_v3_send_done;+};diff --git a/src/wlr/texture.zig b/src/wlr/texture.zignew file mode 100644index 0000000..d93171f--- /dev/null+++ b/src/wlr/texture.zig@@ -0,0 +1,56 @@+//! Textures remain owned by wlroots. Readback options use the facade's Box+//! and retain their complete C layout because callers allocate them in Zig.+const wlr = @import("wlr.zig");+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub const Texture = extern struct {+ pub const ReadPixelsOptions = extern struct {+ data: *anyopaque,+ format: u32,+ stride: u32,+ dst_x: u32,+ dst_y: u32,+ src_box: wlr.Box,++ comptime {+ const Real = c.wlr_texture_read_pixels_options;+ assertSameLayout(ReadPixelsOptions, Real);+ for (@typeInfo(ReadPixelsOptions).@"struct".fields) |field| {+ assertFieldOffset(ReadPixelsOptions, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+ };++ impl: *const c.wlr_texture_impl,+ width: u32,+ height: u32,+ renderer: *wlr.Renderer,++ pub fn fromBuffer(renderer: *wlr.Renderer, buffer: *wlr.Buffer) ?*Texture {+ return @ptrCast(c.wlr_texture_from_buffer(@ptrCast(renderer), @ptrCast(buffer)));+ }++ pub fn destroy(texture: *Texture) void {+ c.wlr_texture_destroy(@ptrCast(texture));+ }++ pub fn readPixels(texture: *Texture, options: *const ReadPixelsOptions) bool {+ return c.wlr_texture_read_pixels(@ptrCast(texture), @ptrCast(options));+ }++ pub fn preferredReadFormat(texture: *Texture) u32 {+ return c.wlr_texture_preferred_read_format(@ptrCast(texture));+ }++ comptime {+ const Real = c.wlr_texture;+ assertSameLayout(Texture, Real);+ for (@typeInfo(Texture).@"struct".fields) |field| {+ assertFieldOffset(Texture, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ }+};diff --git a/src/wlr/touch.zig b/src/wlr/touch.zignew file mode 100644index 0000000..34f251c--- /dev/null+++ b/src/wlr/touch.zig@@ -0,0 +1,83 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wl = @import("wayland").server.wl;++pub const Touch = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_touch);+ }++ pub const event = struct {+ pub const Down = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_touch_down_event);+ }++ touch: *wlr.Touch,+ time_msec: u32,+ touch_id: i32,+ /// From 0..1+ x: f64,+ /// From 0..1+ y: f64,+ };++ pub const Up = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_touch_up_event);+ }++ touch: *wlr.Touch,+ time_msec: u32,+ touch_id: i32,+ };++ pub const Motion = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_touch_motion_event);+ }++ touch: *wlr.Touch,+ time_msec: u32,+ touch_id: i32,+ /// From 0..1+ x: f64,+ /// From 0..1+ y: f64,+ };++ pub const Cancel = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_touch_cancel_event);+ }++ touch: *wlr.Touch,+ time_msec: u32,+ touch_id: i32,+ };+ };++ const Impl = opaque {};++ base: wlr.InputDevice,++ impl: *const Impl,++ output_name: ?[*:0]u8,+ width_mm: f64,+ height_mm: f64,++ events: extern struct {+ down: wl.Signal(*event.Down),+ up: wl.Signal(*event.Up),+ motion: wl.Signal(*event.Motion),+ cancel: wl.Signal(*event.Cancel),+ frame: wl.Signal(void),+ },++ data: ?*anyopaque,+};diff --git a/src/wlr/viewporter.zig b/src/wlr/viewporter.zignew file mode 100644index 0000000..7c39533--- /dev/null+++ b/src/wlr/viewporter.zig@@ -0,0 +1,24 @@+//! Header-checked wlroots protocol API. Adapted from zig-wlroots; see LICENSE.zig-wlroots.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const Viewporter = extern struct {+ global: *wl.Global,++ events: extern struct {+ destroy: wl.Signal(void),+ },++ const wlr_viewporter_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*Viewporter, c.wlr_viewporter_create);+ pub fn create(server: *wl.Server) !*Viewporter {+ return wlr_viewporter_create(server) orelse error.OutOfMemory;+ }+};++comptime {+ abi.assertFields(Viewporter, c.wlr_viewporter);+}diff --git a/src/wlr/virtual_keyboard_v1.zig b/src/wlr/virtual_keyboard_v1.zignew file mode 100644index 0000000..e3147a5--- /dev/null+++ b/src/wlr/virtual_keyboard_v1.zig@@ -0,0 +1,49 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const zwp = wayland.server.zwp;++pub const VirtualKeyboardManagerV1 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_virtual_keyboard_manager_v1);+ }++ global: *wl.Global,+ virtual_keyboards: wl.list.Head(VirtualKeyboardV1, .link),++ events: extern struct {+ new_virtual_keyboard: wl.Signal(*VirtualKeyboardV1),+ destroy: wl.Signal(*VirtualKeyboardManagerV1),+ },++ WLR_PRIVATE: @FieldType(c.wlr_virtual_keyboard_manager_v1, "WLR_PRIVATE"),++ const wlr_virtual_keyboard_manager_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*VirtualKeyboardManagerV1, c.wlr_virtual_keyboard_manager_v1_create);+ pub fn create(server: *wl.Server) !*VirtualKeyboardManagerV1 {+ return wlr_virtual_keyboard_manager_v1_create(server) orelse error.OutOfMemory;+ }+};++pub const VirtualKeyboardV1 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_virtual_keyboard_v1);+ }++ keyboard: wlr.Keyboard,+ resource: *zwp.VirtualKeyboardV1,+ seat: *wlr.Seat,+ has_keymap: bool,++ /// VirtualKeyboardManagerV1.virtual_keyboards+ link: wl.list.Link,++ WLR_PRIVATE: @FieldType(c.wlr_virtual_keyboard_v1, "WLR_PRIVATE"),++ const wlr_virtual_keyboard_v1_from_resource = abi.bind(fn (resource: *zwp.VirtualKeyboardV1) callconv(.c) ?*VirtualKeyboardV1, c.wlr_virtual_keyboard_v1_from_resource);+ pub const fromResource = wlr_virtual_keyboard_v1_from_resource;+};diff --git a/src/wlr/virtual_pointer_v1.zig b/src/wlr/virtual_pointer_v1.zignew file mode 100644index 0000000..526047a--- /dev/null+++ b/src/wlr/virtual_pointer_v1.zig@@ -0,0 +1,57 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const VirtualPointerManagerV1 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_virtual_pointer_manager_v1);+ }++ pub const event = struct {+ pub const NewPointer = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_virtual_pointer_v1_new_pointer_event);+ }++ new_pointer: *VirtualPointerV1,+ suggested_seat: ?*wlr.Seat,+ suggested_output: ?*wlr.Output,+ };+ };++ global: *wl.Global,+ virtual_pointers: wl.list.Head(VirtualPointerV1, .link),++ events: extern struct {+ new_virtual_pointer: wl.Signal(*event.NewPointer),+ destroy: wl.Signal(*VirtualPointerManagerV1),+ },++ WLR_PRIVATE: @FieldType(c.wlr_virtual_pointer_manager_v1, "WLR_PRIVATE"),++ const wlr_virtual_pointer_manager_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*VirtualPointerManagerV1, c.wlr_virtual_pointer_manager_v1_create);+ pub fn create(server: *wl.Server) !*VirtualPointerManagerV1 {+ return wlr_virtual_pointer_manager_v1_create(server) orelse error.OutOfMemory;+ }+};++pub const VirtualPointerV1 = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_virtual_pointer_v1);+ }++ pointer: wlr.Pointer,+ resource: *wl.Resource,++ axis_event: [2]wlr.Pointer.event.Axis,+ axis: wl.Pointer.Axis,+ axis_valid: [2]bool,++ /// VirtualPointerManagerV1.virtual_pointers+ link: wl.list.Link,+};diff --git a/src/wlr/wlr.zig b/src/wlr/wlr.zigindex 4109dbc..b8b722d 100644--- a/src/wlr/wlr.zig+++ b/src/wlr/wlr.zig@@ -1,163 +1,171 @@-//! Facade over wlroots: the same `wlr.*` names callers already use,-//! migrated off zig-wlroots one subsystem at a time onto a module backed-//! directly by @cImport against the real wlroots headers (see the-//! "zig-wlroots" note in the top-level AGENTS.md for why, and-//! docs/agent-notes for the migration order). Everything below that-//! hasn't migrated yet forwards straight to the real zig-wlroots-//! dependency, imported here as `old`, so callers never see a difference-//! until a type actually moves off it.-const old = @import("old");-+//! Header-backed wlroots API for RediWM. See AGENTS.md in this directory.const output_power = @import("output_power.zig").Types(Output);pub const OutputPowerManagerV1 = output_power.OutputPowerManagerV1;pub const OutputPowerV1 = output_power.OutputPowerV1;-const idle_notify = @import("idle_notify.zig").Types(old.Seat);+const idle_notify = @import("idle_notify.zig").Types(Seat);pub const IdleNotifierV1 = idle_notify.IdleNotifierV1;-const idle_inhibit = @import("idle_inhibit.zig").Types(old.Surface);+const idle_inhibit = @import("idle_inhibit.zig").Types(Surface);pub const IdleInhibitManagerV1 = idle_inhibit.IdleInhibitManagerV1;pub const IdleInhibitorV1 = idle_inhibit.IdleInhibitorV1;-const kb_shortcuts_inhibit = @import("keyboard_shortcuts_inhibit.zig").Types(old.Surface, old.Seat);+const kb_shortcuts_inhibit = @import("keyboard_shortcuts_inhibit.zig").Types(Surface, Seat);pub const KeyboardShortcutsInhibitManagerV1 = kb_shortcuts_inhibit.KeyboardShortcutsInhibitManagerV1;pub const KeyboardShortcutsInhibitorV1 = kb_shortcuts_inhibit.KeyboardShortcutsInhibitorV1;+pub const SecurityContextManagerV1 = @import("security_context.zig").SecurityContextManagerV1;+pub const SecurityContextV1State = @import("security_context.zig").SecurityContextV1State;-const security_context = @import("security_context.zig");-pub const SecurityContextManagerV1 = security_context.SecurityContextManagerV1;-pub const SecurityContextV1State = security_context.SecurityContextV1State;--const fractional_scale = @import("fractional_scale.zig").Types(old.Surface);+const fractional_scale = @import("fractional_scale.zig").Types(Surface);pub const FractionalScaleManagerV1 = fractional_scale.FractionalScaleManagerV1;-const relative_pointer = @import("relative_pointer.zig").Types(old.Seat);+const relative_pointer = @import("relative_pointer.zig").Types(Seat);pub const RelativePointerManagerV1 = relative_pointer.RelativePointerManagerV1;pub const RelativePointerV1 = relative_pointer.RelativePointerV1;-const pointer_constraints = @import("pointer_constraints.zig").Types(old.Surface, old.Seat);+const pointer_constraints = @import("pointer_constraints.zig").Types(Surface, Seat);pub const PointerConstraintsV1 = pointer_constraints.PointerConstraintsV1;pub const PointerConstraintV1 = pointer_constraints.PointerConstraintV1;+pub const Backend = @import("backend.zig").Backend;+pub const Session = @import("session.zig").Session;+pub const Presentation = @import("presentation.zig").Presentation;+pub const Renderer = @import("renderer.zig").Renderer;+pub const Allocator = @import("allocator.zig").Allocator;+pub const RenderPass = @import("render_pass.zig").RenderPass;+pub const Texture = @import("texture.zig").Texture;-const output_mod = @import("output.zig").Types(old.Backend, old.Renderer, old.Allocator, old.Buffer, old.ColorTransform);+const output_mod = @import("output.zig").Types(Backend, Renderer, Allocator, Buffer, ColorTransform);pub const Output = output_mod.Output;pub const OutputCursor = output_mod.OutputCursor;const output_layout_mod = @import("output_layout.zig").Types(Output);pub const OutputLayout = output_layout_mod.OutputLayout;-// Box/FBox/Edges: OutputLayout.getBox was their main blocker (45 call-// sites) and just migrated above. The remaining crossings-// (Surface.getBufferSourceBox, XdgPopup.unconstrainFromBox,-// InputPopupSurfaceV2.sendTextInputRectangle, XdgToplevel.setTiled) are-// single-digit call counts against types that haven't migrated, each-// handled with a `@ptrCast` at that one call site instead of waiting for-// those types too -- see assertSameLayout(Box, old.Box) below, which is-// exactly what makes that cast provably safe.+const output_management = @import("output_management.zig").Types(Output);+pub const OutputManagerV1 = output_management.OutputManagerV1;+pub const OutputHeadV1 = output_management.OutputHeadV1;+pub const OutputConfigurationV1 = output_management.OutputConfigurationV1;+pub const XdgOutputManagerV1 = @import("xdg_output.zig").Types(OutputLayout).XdgOutputManagerV1;pub const Box = @import("box.zig").Box;pub const FBox = @import("box.zig").FBox;pub const Edges = @import("edges.zig").Edges;+pub const AddonSet = @import("addon.zig").AddonSet;+pub const Buffer = @import("buffer.zig").Buffer;+pub const ColorTransform = @import("c.zig").c.wlr_color_transform;+pub const Compositor = @import("compositor.zig").Compositor;+pub const Cursor = @import("cursor.zig").Cursor;+pub const CursorShapeManagerV1 = @import("cursor_shape_v1.zig").CursorShapeManagerV1;+pub const DataControlManagerV1 = @import("data_control_v1.zig").DataControlManagerV1;+pub const DataDeviceManager = @import("data_device.zig").DataDeviceManager;+pub const DataSource = @import("data_device.zig").DataSource;+pub const Drag = @import("data_device.zig").Drag;+pub const DrmFormat = @import("drm_format_set.zig").DrmFormat;+pub const DrmSyncobjTimeline = @import("c.zig").c.wlr_drm_syncobj_timeline;+pub const ExtDataControlManagerV1 = @import("ext_data_control_v1.zig").ExtDataControlManagerV1;+pub const ExtForeignToplevelHandleV1 = @import("foreign_toplevel_list_v1.zig").ExtForeignToplevelHandleV1;+pub const ExtForeignToplevelImageCaptureSourceManagerV1 = @import("ext_image_capture_source_v1.zig").ExtForeignToplevelImageCaptureSourceManagerV1;+pub const ExtForeignToplevelListV1 = @import("foreign_toplevel_list_v1.zig").ExtForeignToplevelListV1;+pub const ExtImageCaptureSourceV1 = @import("ext_image_capture_source_v1.zig").ExtImageCaptureSourceV1;+pub const ExtImageCopyCaptureFrameV1 = @import("ext_image_copy_capture_v1.zig").ExtImageCopyCaptureFrameV1;+pub const ExtImageCopyCaptureManagerV1 = @import("ext_image_copy_capture_v1.zig").ExtImageCopyCaptureManagerV1;+pub const ExtImageCopyCaptureSessionV1 = @import("ext_image_copy_capture_v1.zig").ExtImageCopyCaptureSessionV1;+pub const ExtOutputImageCaptureSourceManagerV1 = @import("ext_image_capture_source_v1.zig").ExtOutputImageCaptureSourceManagerV1;+pub const ForeignToplevelHandleV1 = @import("foreign_toplevel_management_v1.zig").ForeignToplevelHandleV1;+pub const ForeignToplevelManagerV1 = @import("foreign_toplevel_management_v1.zig").ForeignToplevelManagerV1;+pub const InputDevice = @import("input_device.zig").InputDevice;+pub const InputMethodManagerV2 = @import("input_method_v2.zig").InputMethodManagerV2;+pub const InputMethodV2 = @import("input_method_v2.zig").InputMethodV2;+pub const InputPopupSurfaceV2 = @import("input_method_v2.zig").InputPopupSurfaceV2;+pub const Keyboard = @import("keyboard.zig").Keyboard;+pub const LayerShellV1 = @import("layer_shell.zig").LayerShellV1;+pub const LayerSurfaceV1 = @import("layer_shell.zig").LayerSurfaceV1;+pub const LinuxDmabufV1 = @import("linux_dmabuf_v1.zig").LinuxDmabufV1;+pub const LinuxDrmSyncobjManagerV1 = @import("linux_drm_syncobj_v1.zig").LinuxDrmSyncobjManagerV1;+pub const Pointer = @import("pointer.zig").Pointer;+pub const PointerGesturesV1 = @import("pointer_gestures_v1.zig").PointerGesturesV1;+pub const PrimarySelectionDeviceManagerV1 = @import("primary_selection_v1.zig").PrimarySelectionDeviceManagerV1;+pub const Scene = @import("scene.zig").Scene;+pub const ScreencopyFrameV1 = @import("screencopy_v1.zig").ScreencopyFrameV1;+pub const ScreencopyManagerV1 = @import("screencopy_v1.zig").ScreencopyManagerV1;+pub const Seat = @import("seat.zig").Seat;+pub const SessionLockManagerV1 = @import("session_lock_v1.zig").SessionLockManagerV1;+pub const SessionLockSurfaceV1 = @import("session_lock_v1.zig").SessionLockSurfaceV1;+pub const SessionLockV1 = @import("session_lock_v1.zig").SessionLockV1;+pub const SinglePixelBufferManagerV1 = @import("single_pixel_buffer_v1.zig").SinglePixelBufferManagerV1;+pub const Subcompositor = @import("subcompositor.zig").Subcompositor;+pub const Surface = @import("compositor.zig").Surface;+pub const Swapchain = @import("swapchain.zig").Swapchain;+pub const Switch = @import("switch.zig").Switch;+pub const Tablet = @import("tablet_tool.zig").Tablet;+pub const TabletManagerV2 = @import("tablet_v2.zig").TabletManagerV2;+pub const TabletPad = @import("tablet_pad.zig").TabletPad;+pub const TabletTool = @import("tablet_tool.zig").TabletTool;+pub const TabletV2Tablet = @import("tablet_v2.zig").TabletV2Tablet;+pub const TabletV2TabletPad = @import("tablet_v2.zig").TabletV2TabletPad;+pub const TabletV2TabletTool = @import("tablet_v2.zig").TabletV2TabletTool;+pub const TextInputManagerV3 = @import("text_input_v3.zig").TextInputManagerV3;+pub const TextInputV3 = @import("text_input_v3.zig").TextInputV3;+pub const Touch = @import("touch.zig").Touch;+pub const Viewporter = @import("viewporter.zig").Viewporter;+pub const VirtualKeyboardManagerV1 = @import("virtual_keyboard_v1.zig").VirtualKeyboardManagerV1;+pub const VirtualKeyboardV1 = @import("virtual_keyboard_v1.zig").VirtualKeyboardV1;+pub const VirtualPointerManagerV1 = @import("virtual_pointer_v1.zig").VirtualPointerManagerV1;+pub const XcursorManager = @import("xcursor_manager.zig").XcursorManager;+pub const XdgActivationTokenV1 = @import("xdg_activation.zig").XdgActivationTokenV1;+pub const XdgActivationV1 = @import("xdg_activation.zig").XdgActivationV1;+pub const XdgDecorationManagerV1 = @import("xdg_decoration.zig").XdgDecorationManagerV1;+pub const XdgPopup = @import("xdg_shell.zig").XdgPopup;+pub const XdgShell = @import("xdg_shell.zig").XdgShell;+pub const XdgSurface = @import("xdg_shell.zig").XdgSurface;+pub const XdgToplevel = @import("xdg_shell.zig").XdgToplevel;+pub const XdgToplevelDecorationV1 = @import("xdg_decoration.zig").XdgToplevelDecorationV1;+pub const Xwayland = @import("xwayland.zig").Xwayland;+pub const XwaylandSurface = @import("xwayland.zig").XwaylandSurface;+pub const color = @import("color.zig");+pub const config = @import("config.zig");+pub const log = @import("log.zig");+pub const region = @import("region.zig");+pub const Addon = @import("addon.zig").Addon;+pub const ShmAttributes = @import("buffer.zig").ShmAttributes;+pub const BufferCap = @import("buffer.zig").BufferCap;+pub const ClientBuffer = @import("buffer.zig").ClientBuffer;+pub const DataControlDeviceV1 = @import("data_control_v1.zig").DataControlDeviceV1;+pub const DataOffer = @import("data_device.zig").DataOffer;+pub const DmabufAttributes = @import("dmabuf.zig").DmabufAttributes;+pub const DrmFormatSet = @import("drm_format_set.zig").DrmFormatSet;+pub const ExtDataControlDeviceV1 = @import("ext_data_control_v1.zig").ExtDataControlDeviceV1;+pub const DmabufBufferV1 = @import("linux_dmabuf_v1.zig").DmabufBufferV1;+pub const LinuxDmabufFeedbackV1 = @import("linux_dmabuf_v1.zig").LinuxDmabufFeedbackV1;+pub const LinuxDmabufFeedbackV1Compiled = @import("linux_dmabuf_v1.zig").LinuxDmabufFeedbackV1Compiled;+pub const PrimarySelectionDeviceV1 = @import("primary_selection_v1.zig").PrimarySelectionDeviceV1;+pub const SceneNode = @import("scene.zig").SceneNode;+pub const ScreencopyClientV1 = @import("screencopy_v1.zig").ScreencopyClientV1;+pub const Subsurface = @import("subcompositor.zig").Subsurface;+pub const XdgClient = @import("xdg_shell.zig").XdgClient;+pub const XdgPositioner = @import("xdg_shell.zig").XdgPositioner;+pub const XdgPopupGrab = @import("xdg_shell.zig").XdgPopupGrab;+pub const Xwm = @import("xwayland.zig").Xwm;+pub const KeyboardGroup = @import("keyboard_group.zig").KeyboardGroup;+pub const PrimarySelectionSource = @import("primary_selection.zig").PrimarySelectionSource;+pub const SerialRange = @import("seat.zig").SerialRange;+pub const SerialRingset = @import("seat.zig").SerialRingset;+pub const TouchPoint = @import("seat.zig").TouchPoint;+pub const SwitchType = @import("switch.zig").SwitchType;+pub const SwitchState = @import("switch.zig").SwitchState;+pub const VirtualPointerV1 = @import("virtual_pointer_v1.zig").VirtualPointerV1;+pub const XcursorImage = @import("xcursor.zig").XcursorImage;+pub const Xcursor = @import("xcursor.zig").Xcursor;+pub const XcursorTheme = @import("xcursor.zig").XcursorTheme;+pub const XcursorManagerTheme = @import("xcursor_manager.zig").XcursorManagerTheme;+comptime {- const assertSameLayout = @import("signal.zig").assertSameLayout;- assertSameLayout(Box, old.Box);- assertSameLayout(FBox, old.FBox);- assertSameLayout(Edges, old.Edges);+ const c = @import("c.zig").c;+ if (c.WLR_VERSION_MAJOR != 0 or c.WLR_VERSION_MINOR != 20)+ @compileError("RediWM requires wlroots 0.20 headers");}-/// Backend, ForeignToplevelHandleV1 and anything else still on `old`-/// that embeds `*wlr.Output` in its own signature (a signal payload, a-/// method parameter) is pinned to zig-wlroots's own Output type, not-/// ours, for exactly that crossing -- see Server.zig's `new_output`-/// listener and foreign_toplevel.zig's `outputEnter`/`outputLeave` for-/// the two places that needs a `@ptrCast`. Exposed here rather than-/// scattered `@import("old")`s so every such crossing reads the same way.-pub const zig_wlroots = old;--pub const AddonSet = old.AddonSet;-pub const Allocator = old.Allocator;-pub const Backend = old.Backend;-pub const Buffer = old.Buffer;-pub const ColorTransform = old.ColorTransform;-pub const Compositor = old.Compositor;-pub const Cursor = old.Cursor;-pub const CursorShapeManagerV1 = old.CursorShapeManagerV1;-pub const DataControlManagerV1 = old.DataControlManagerV1;-pub const DataDeviceManager = old.DataDeviceManager;-pub const DataSource = old.DataSource;-pub const Drag = old.Drag;-pub const DrmFormat = old.DrmFormat;-pub const DrmSyncobjTimeline = old.DrmSyncobjTimeline;-pub const ExtDataControlManagerV1 = old.ExtDataControlManagerV1;-pub const ExtForeignToplevelHandleV1 = old.ExtForeignToplevelHandleV1;-pub const ExtForeignToplevelImageCaptureSourceManagerV1 = old.ExtForeignToplevelImageCaptureSourceManagerV1;-pub const ExtForeignToplevelListV1 = old.ExtForeignToplevelListV1;-pub const ExtImageCaptureSourceV1 = old.ExtImageCaptureSourceV1;-pub const ExtImageCopyCaptureFrameV1 = old.ExtImageCopyCaptureFrameV1;-pub const ExtImageCopyCaptureManagerV1 = old.ExtImageCopyCaptureManagerV1;-pub const ExtImageCopyCaptureSessionV1 = old.ExtImageCopyCaptureSessionV1;-pub const ExtOutputImageCaptureSourceManagerV1 = old.ExtOutputImageCaptureSourceManagerV1;-pub const ForeignToplevelHandleV1 = old.ForeignToplevelHandleV1;-pub const ForeignToplevelManagerV1 = old.ForeignToplevelManagerV1;-pub const InputDevice = old.InputDevice;-pub const InputMethodManagerV2 = old.InputMethodManagerV2;-pub const InputMethodV2 = old.InputMethodV2;-pub const InputPopupSurfaceV2 = old.InputPopupSurfaceV2;-pub const Keyboard = old.Keyboard;-pub const LayerShellV1 = old.LayerShellV1;-pub const LayerSurfaceV1 = old.LayerSurfaceV1;-pub const LinuxDmabufV1 = old.LinuxDmabufV1;-pub const LinuxDrmSyncobjManagerV1 = old.LinuxDrmSyncobjManagerV1;-pub const OutputConfigurationV1 = old.OutputConfigurationV1;-pub const OutputHeadV1 = old.OutputHeadV1;-pub const OutputManagerV1 = old.OutputManagerV1;-pub const Pointer = old.Pointer;-pub const PointerGesturesV1 = old.PointerGesturesV1;-pub const Presentation = old.Presentation;-pub const PrimarySelectionDeviceManagerV1 = old.PrimarySelectionDeviceManagerV1;-pub const RenderPass = old.RenderPass;-pub const Renderer = old.Renderer;-pub const Scene = old.Scene;-pub const ScreencopyFrameV1 = old.ScreencopyFrameV1;-pub const ScreencopyManagerV1 = old.ScreencopyManagerV1;-pub const Seat = old.Seat;-pub const Session = old.Session;-pub const SessionLockManagerV1 = old.SessionLockManagerV1;-pub const SessionLockSurfaceV1 = old.SessionLockSurfaceV1;-pub const SessionLockV1 = old.SessionLockV1;-pub const SinglePixelBufferManagerV1 = old.SinglePixelBufferManagerV1;-pub const Subcompositor = old.Subcompositor;-pub const Surface = old.Surface;-pub const Swapchain = old.Swapchain;-pub const Switch = old.Switch;-pub const Tablet = old.Tablet;-pub const TabletManagerV2 = old.TabletManagerV2;-pub const TabletPad = old.TabletPad;-pub const TabletTool = old.TabletTool;-pub const TabletV2Tablet = old.TabletV2Tablet;-pub const TabletV2TabletPad = old.TabletV2TabletPad;-pub const TabletV2TabletTool = old.TabletV2TabletTool;-pub const TextInputManagerV3 = old.TextInputManagerV3;-pub const TextInputV3 = old.TextInputV3;-pub const Texture = old.Texture;-pub const Touch = old.Touch;-pub const Viewporter = old.Viewporter;-pub const VirtualKeyboardManagerV1 = old.VirtualKeyboardManagerV1;-pub const VirtualKeyboardV1 = old.VirtualKeyboardV1;-pub const VirtualPointerManagerV1 = old.VirtualPointerManagerV1;-pub const XcursorManager = old.XcursorManager;-pub const XdgActivationTokenV1 = old.XdgActivationTokenV1;-pub const XdgActivationV1 = old.XdgActivationV1;-pub const XdgDecorationManagerV1 = old.XdgDecorationManagerV1;-pub const XdgOutputManagerV1 = old.XdgOutputManagerV1;-pub const XdgPopup = old.XdgPopup;-pub const XdgShell = old.XdgShell;-pub const XdgSurface = old.XdgSurface;-pub const XdgToplevel = old.XdgToplevel;-pub const XdgToplevelDecorationV1 = old.XdgToplevelDecorationV1;-pub const Xwayland = old.Xwayland;-pub const XwaylandSurface = old.XwaylandSurface;--pub const color = old.color;-pub const config = old.config;-pub const log = old.log;-pub const region = old.region;+test {+ _ = @import("bindings_tests.zig");+ _ = @import("input_tests.zig");+}diff --git a/src/wlr/xcursor.zig b/src/wlr/xcursor.zignew file mode 100644index 0000000..2b493f6--- /dev/null+++ b/src/wlr/xcursor.zig@@ -0,0 +1,64 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++pub const XcursorImage = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_xcursor_image);+ }++ width: u32,+ height: u32,+ hotspot_x: u32,+ hotspot_y: u32,+ delay: u32,+ buffer: [*]u8,++ WLR_PRIVATE: @FieldType(c.wlr_xcursor_image, "WLR_PRIVATE"),++ const wlr_xcursor_image_get_buffer = abi.bind(fn (image: *XcursorImage) callconv(.c) *wlr.Buffer, c.wlr_xcursor_image_get_buffer);+ pub const getBuffer = wlr_xcursor_image_get_buffer;+};++pub const Xcursor = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_xcursor);+ }++ image_count: c_uint,+ images: [*]*XcursorImage,+ name: [*:0]u8,+ total_delay: u32,++ const wlr_xcursor_frame = abi.bind(fn (cursor: *Xcursor, time: u32) callconv(.c) c_int, c.wlr_xcursor_frame);+ pub const frame = wlr_xcursor_frame;++ // kinda ugly, wlroots decided to use the enum directly here instead of+ // a uint32_t which has the ABI of an int+ const wlr_xcursor_get_resize_name = abi.bind(fn (edges: c_int) callconv(.c) [*:0]const u8, c.wlr_xcursor_get_resize_name);+ pub fn getResizeName(edges: wlr.Edges) [*:0]const u8 {+ return wlr_xcursor_get_resize_name(@as(c_int, @bitCast(edges)));+ }+};++pub const XcursorTheme = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_xcursor_theme);+ }++ cursor_count: c_uint,+ cursors: [*]*Xcursor,+ name: [*:0]u8,+ size: c_int,++ const wlr_xcursor_theme_load = abi.bind(fn (name: [*:0]const u8, size: c_int) callconv(.c) ?*XcursorTheme, c.wlr_xcursor_theme_load);+ pub const load = wlr_xcursor_theme_load;++ const wlr_xcursor_theme_destroy = abi.bind(fn (theme: *XcursorTheme) callconv(.c) void, c.wlr_xcursor_theme_destroy);+ pub const destroy = wlr_xcursor_theme_destroy;++ const wlr_xcursor_theme_get_cursor = abi.bind(fn (theme: *XcursorTheme, name: [*:0]const u8) callconv(.c) ?*Xcursor, c.wlr_xcursor_theme_get_cursor);+ pub const getCursor = wlr_xcursor_theme_get_cursor;+};diff --git a/src/wlr/xcursor_manager.zig b/src/wlr/xcursor_manager.zignew file mode 100644index 0000000..536f105--- /dev/null+++ b/src/wlr/xcursor_manager.zig@@ -0,0 +1,46 @@+//! Adapted from zig-wlroots (MIT); see LICENSE.zig-wlroots.+//! Layout and function signatures are checked against the installed headers.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wl = @import("wayland").server.wl;++pub const XcursorManagerTheme = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_xcursor_manager_theme);+ }++ scale: f32,+ theme: *wlr.XcursorTheme,+ /// XcursorManager.scaled_themes+ link: wl.list.Link,+};++pub const XcursorManager = extern struct {+ comptime {+ abi.assertLayout(@This(), c.wlr_xcursor_manager);+ }++ name: ?[*:0]u8,+ size: u32,+ scaled_themes: wl.list.Head(XcursorManagerTheme, .link),++ const wlr_xcursor_manager_create = abi.bind(fn (name: ?[*:0]const u8, size: u32) callconv(.c) ?*XcursorManager, c.wlr_xcursor_manager_create);+ pub fn create(name: ?[*:0]const u8, size: u32) !*XcursorManager {+ return wlr_xcursor_manager_create(name, size) orelse return error.OutOfMemory;+ }++ const wlr_xcursor_manager_destroy = abi.bind(fn (manager: *XcursorManager) callconv(.c) void, c.wlr_xcursor_manager_destroy);+ pub const destroy = wlr_xcursor_manager_destroy;++ const wlr_xcursor_manager_load = abi.bind(fn (manager: *XcursorManager, scale: f32) callconv(.c) bool, c.wlr_xcursor_manager_load);+ pub fn load(manager: *XcursorManager, scale: f32) !void {+ if (!wlr_xcursor_manager_load(manager, scale)) {+ return error.OutOfMemory;+ }+ }++ const wlr_xcursor_manager_get_xcursor = abi.bind(fn (manager: *XcursorManager, name: [*:0]const u8, scale: f32) callconv(.c) ?*wlr.Xcursor, c.wlr_xcursor_manager_get_xcursor);+ pub const getXcursor = wlr_xcursor_manager_get_xcursor;+};diff --git a/src/wlr/xdg_activation.zig b/src/wlr/xdg_activation.zignew file mode 100644index 0000000..7fb752b--- /dev/null+++ b/src/wlr/xdg_activation.zig@@ -0,0 +1,75 @@+//! Typed wlroots header adapter. API shapes adapted from zig-wlroots;+//! see LICENSE.zig-wlroots for its MIT license.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;++pub const XdgActivationV1 = extern struct {+ pub const event = struct {+ pub const RequestActivate = extern struct {+ activation: *wlr.XdgActivationV1,+ token: *wlr.XdgActivationTokenV1,+ surface: *wlr.Surface,+ };+ };++ global: *wl.Global,++ /// token timeout in milliseconds (0 to disable)+ token_timeout_msec: u32,++ tokens: wl.list.Head(XdgActivationTokenV1, .link),++ events: extern struct {+ destroy: wl.Signal(*XdgActivationV1),+ request_activate: wl.Signal(*XdgActivationV1.event.RequestActivate),+ new_token: wl.Signal(*XdgActivationTokenV1),+ },++ const wlr_xdg_activation_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*XdgActivationV1, c.wlr_xdg_activation_v1_create);+ pub fn create(server: *wl.Server) !*XdgActivationV1 {+ return wlr_xdg_activation_v1_create(server) orelse error.OutOfMemory;+ }++ const wlr_xdg_activation_token_v1_create = abi.bind(fn (activation: *XdgActivationV1) callconv(.c) ?*XdgActivationTokenV1, c.wlr_xdg_activation_token_v1_create);+ pub const createToken = wlr_xdg_activation_token_v1_create;++ const wlr_xdg_activation_v1_find_token = abi.bind(fn (activation: *XdgActivationV1, token_str: [*:0]const u8) callconv(.c) ?*XdgActivationTokenV1, c.wlr_xdg_activation_v1_find_token);+ pub const findToken = wlr_xdg_activation_v1_find_token;++ const wlr_xdg_activation_v1_add_token = abi.bind(fn (activation: *XdgActivationV1, token_str: [*:0]const u8) callconv(.c) ?*XdgActivationTokenV1, c.wlr_xdg_activation_v1_add_token);+ pub const addToken = wlr_xdg_activation_v1_add_token;+};++pub const XdgActivationTokenV1 = extern struct {+ activation: *wlr.XdgActivationV1,+ surface: ?*wlr.Surface,+ seat: ?*wlr.Seat,++ /// Invalid if seat is null+ serial: u32,+ app_id: ?[*:0]u8,++ link: wl.list.Link,++ data: ?*anyopaque,++ events: extern struct {+ destroy: wl.Signal(void),+ },++ const wlr_xdg_activation_token_v1_destroy = abi.bind(fn (token: *XdgActivationTokenV1) callconv(.c) void, c.wlr_xdg_activation_token_v1_destroy);+ pub const destroy = wlr_xdg_activation_token_v1_destroy;++ const wlr_xdg_activation_token_v1_get_name = abi.bind(fn (token: *XdgActivationTokenV1) callconv(.c) [*:0]const u8, c.wlr_xdg_activation_token_v1_get_name);+ pub const name = wlr_xdg_activation_token_v1_get_name;+};++comptime {+ abi.assertFields(XdgActivationV1, c.wlr_xdg_activation_v1);+ abi.assertFields(XdgActivationTokenV1, c.wlr_xdg_activation_token_v1);+ abi.assertLayout(XdgActivationV1.event.RequestActivate, c.wlr_xdg_activation_v1_request_activate_event);+}diff --git a/src/wlr/xdg_decoration.zig b/src/wlr/xdg_decoration.zignew file mode 100644index 0000000..d2b745b--- /dev/null+++ b/src/wlr/xdg_decoration.zig@@ -0,0 +1,76 @@+//! Typed wlroots header adapter. API shapes adapted from zig-wlroots;+//! see LICENSE.zig-wlroots for its MIT license.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const zxdg = wayland.server.zxdg;++pub const XdgDecorationManagerV1 = extern struct {+ global: *wl.Global,+ decorations: wl.list.Head(XdgToplevelDecorationV1, .link),++ events: extern struct {+ new_toplevel_decoration: wl.Signal(*XdgToplevelDecorationV1),+ destroy: wl.Signal(*XdgDecorationManagerV1),+ },++ data: ?*anyopaque,++ const wlr_xdg_decoration_manager_v1_create = abi.bind(fn (server: *wl.Server) callconv(.c) ?*XdgDecorationManagerV1, c.wlr_xdg_decoration_manager_v1_create);+ pub fn create(server: *wl.Server) !*XdgDecorationManagerV1 {+ return wlr_xdg_decoration_manager_v1_create(server) orelse error.OutOfMemory;+ }+};++pub const XdgToplevelDecorationV1 = extern struct {+ pub const Mode = enum(c_int) {+ none = c.WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE,+ client_side = c.WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE,+ server_side = c.WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE,+ };++ pub const State = extern struct {+ mode: Mode,+ };++ pub const Configure = extern struct {+ /// XdgToplevelDecorationV1.configure_list+ link: wl.list.Link,+ surface_configure: *wlr.XdgSurface.Configure,+ mode: Mode,+ };++ resource: *zxdg.ToplevelDecorationV1,+ toplevel: *wlr.XdgToplevel,+ manager: *XdgDecorationManagerV1,+ /// XdgDecorationManagerV1.decorations+ link: wl.list.Link,++ current: State,+ pending: State,++ scheduled_mode: Mode,+ requested_mode: Mode,++ configure_list: wl.list.Head(XdgToplevelDecorationV1.Configure, .link),++ events: extern struct {+ destroy: wl.Signal(*XdgToplevelDecorationV1),+ request_mode: wl.Signal(*XdgToplevelDecorationV1),+ },++ data: ?*anyopaque,++ const wlr_xdg_toplevel_decoration_v1_set_mode = abi.bind(fn (decoration: *XdgToplevelDecorationV1, mode: Mode) callconv(.c) u32, c.wlr_xdg_toplevel_decoration_v1_set_mode);+ pub const setMode = wlr_xdg_toplevel_decoration_v1_set_mode;+};++comptime {+ abi.assertFields(XdgDecorationManagerV1, c.wlr_xdg_decoration_manager_v1);+ abi.assertFields(XdgToplevelDecorationV1, c.wlr_xdg_toplevel_decoration_v1);+ abi.assertLayout(XdgToplevelDecorationV1.State, c.wlr_xdg_toplevel_decoration_v1_state);+ abi.assertLayout(XdgToplevelDecorationV1.Configure, c.wlr_xdg_toplevel_decoration_v1_configure);+}diff --git a/src/wlr/xdg_output.zig b/src/wlr/xdg_output.zignew file mode 100644index 0000000..b5fc466--- /dev/null+++ b/src/wlr/xdg_output.zig@@ -0,0 +1,53 @@+//! xdg-output metadata uses the same header-backed OutputLayout as the+//! compositor. wlroots owns these structs; omit their private listeners.+const wl = @import("wayland").server.wl;+const c = @import("c.zig").c;+const assertSameLayout = @import("signal.zig").assertSameLayout;+const assertFieldOffset = @import("signal.zig").assertFieldOffset;++pub fn Types(comptime OutputLayout: type) type {+ return struct {+ pub const XdgOutputV1 = extern struct {+ manager: *XdgOutputManagerV1,+ resources: wl.list.Head(wl.Resource, null),+ link: wl.list.Link,+ layout_output: *OutputLayout.Output,+ x: i32,+ y: i32,+ width: i32,+ height: i32,++ comptime {+ for (@typeInfo(XdgOutputV1).@"struct".fields) |field| {+ assertFieldOffset(XdgOutputV1, c.wlr_xdg_output_v1, field.name);+ assertSameLayout(field.type, @FieldType(c.wlr_xdg_output_v1, field.name));+ }+ }+ };++ pub const XdgOutputManagerV1 = extern struct {+ global: *wl.Global,+ layout: *OutputLayout,+ outputs: wl.list.Head(XdgOutputV1, .link),+ events: extern struct {+ destroy: wl.Signal(*XdgOutputManagerV1),+ },++ pub fn create(server: *wl.Server, layout: *OutputLayout) !*XdgOutputManagerV1 {+ const raw = c.wlr_xdg_output_manager_v1_create(@ptrCast(server), @ptrCast(layout));+ return @as(?*XdgOutputManagerV1, @ptrCast(raw)) orelse error.OutOfMemory;+ }++ comptime {+ const Real = c.wlr_xdg_output_manager_v1;+ for (@typeInfo(XdgOutputManagerV1).@"struct".fields) |field| {+ assertFieldOffset(XdgOutputManagerV1, Real, field.name);+ assertSameLayout(field.type, @FieldType(Real, field.name));+ }+ const Events = @FieldType(XdgOutputManagerV1, "events");+ assertFieldOffset(Events, @FieldType(Real, "events"), "destroy");+ assertSameLayout(@FieldType(Events, "destroy"), c.wl_signal);+ }+ };+ };+}diff --git a/src/wlr/xdg_shell.zig b/src/wlr/xdg_shell.zignew file mode 100644index 0000000..fc772e7--- /dev/null+++ b/src/wlr/xdg_shell.zig@@ -0,0 +1,473 @@+//! Typed wlroots header adapter. API shapes adapted from zig-wlroots;+//! see LICENSE.zig-wlroots for its MIT license.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const wayland = @import("wayland");+const wl = wayland.server.wl;+const xdg = wayland.server.xdg;++pub const XdgShell = extern struct {+ global: *wl.Global,+ version: u32,+ clients: wl.list.Head(XdgClient, .link),+ popup_grabs: wl.list.Head(XdgPopupGrab, .link),+ ping_timeout: u32,++ events: extern struct {+ new_surface: wl.Signal(*wlr.XdgSurface),+ new_toplevel: wl.Signal(*wlr.XdgToplevel),+ new_popup: wl.Signal(*wlr.XdgPopup),+ destroy: wl.Signal(*wlr.XdgShell),+ },++ data: ?*anyopaque,++ const wlr_xdg_shell_create = abi.bind(fn (server: *wl.Server, version: u32) callconv(.c) ?*wlr.XdgShell, c.wlr_xdg_shell_create);+ pub fn create(server: *wl.Server, version: u32) !*wlr.XdgShell {+ return wlr_xdg_shell_create(server, version) orelse error.OutOfMemory;+ }+};++pub const XdgClient = extern struct {+ shell: *wlr.XdgShell,+ resource: *xdg.WmBase,+ client: *wl.Client,+ surfaces: wl.list.Head(XdgSurface, .link),+ /// XdgShell.clients+ link: wl.list.Link,++ ping_serial: u32,+ ping_timer: *wl.EventSource,+};++pub const XdgPositioner = extern struct {+ pub const Rules = extern struct {+ anchor_rect: wlr.Box,+ anchor: xdg.Positioner.Anchor,+ gravity: xdg.Positioner.Gravity,+ constraint_adjustment: xdg.Positioner.ConstraintAdjustment,++ reactive: bool,++ has_parent_configure_serial: bool,+ parent_configure_serial: u32,++ size: extern struct {+ width: i32,+ height: i32,+ },+ parent_size: extern struct {+ width: i32,+ height: i32,+ },++ offset: extern struct {+ x: i32,+ y: i32,+ },++ const wlr_xdg_positioner_rules_get_geometry = abi.bind(fn (rules: *const Rules, box: *wlr.Box) callconv(.c) void, c.wlr_xdg_positioner_rules_get_geometry);+ pub const getGeometry = wlr_xdg_positioner_rules_get_geometry;++ const wlr_xdg_positioner_rules_unconstrain_box = abi.bind(fn (rules: *const Rules, constraint: *const wlr.Box, box: *wlr.Box) callconv(.c) void, c.wlr_xdg_positioner_rules_unconstrain_box);+ pub const unconstrainBox = wlr_xdg_positioner_rules_unconstrain_box;+ };++ resource: *xdg.Positioner,+ rules: Rules,++ const wlr_xdg_positioner_from_resource = abi.bind(fn (resource: *xdg.Positioner) callconv(.c) *XdgPositioner, c.wlr_xdg_positioner_from_resource);+ pub const fromResource = wlr_xdg_positioner_from_resource;+};++pub const XdgPopupGrab = extern struct {+ client: *wl.Client,++ pointer_grab: wlr.Seat.PointerGrab,+ keyboard_grab: wlr.Seat.KeyboardGrab,+ touch_grab: wlr.Seat.TouchGrab,+ seat: *wlr.Seat,++ popups: wl.list.Head(XdgPopup, .grab_link),+ /// XdgShell.popup_grabs+ link: wl.list.Link,+};++pub const XdgPopup = extern struct {+ pub const State = extern struct {+ geometry: wlr.Box,+ reactive: bool,+ };++ pub const Configure = extern struct {+ fields: u32,+ geometry: wlr.Box,+ rules: XdgPositioner.Rules,++ reposition_token: u32,+ };++ base: *wlr.XdgSurface,+ link: wl.list.Link,++ resource: *xdg.Popup,+ parent: ?*wlr.Surface,+ seat: ?*wlr.Seat,++ scheduled: Configure,++ current: State,+ pending: State,++ events: extern struct {+ destroy: wl.Signal(void),+ reposition: wl.Signal(void),+ },++ /// Grab.popups+ grab_link: wl.list.Link,++ const wlr_xdg_popup_from_resource = abi.bind(fn (resource: *xdg.Popup) callconv(.c) ?*wlr.XdgPopup, c.wlr_xdg_popup_from_resource);+ pub const fromResource = wlr_xdg_popup_from_resource;++ const wlr_xdg_popup_destroy = abi.bind(fn (popup: *wlr.XdgPopup) callconv(.c) void, c.wlr_xdg_popup_destroy);+ pub const destroy = wlr_xdg_popup_destroy;++ const wlr_xdg_popup_get_position = abi.bind(fn (popup: *XdgPopup, popup_sx: *f64, popup_sy: *f64) callconv(.c) void, c.wlr_xdg_popup_get_position);+ pub const getPosition = wlr_xdg_popup_get_position;++ const wlr_xdg_popup_get_toplevel_coords = abi.bind(fn (popup: *XdgPopup, popup_sx: c_int, popup_sy: c_int, toplevel_sx: *c_int, toplevel_sy: *c_int) callconv(.c) void, c.wlr_xdg_popup_get_toplevel_coords);+ pub const getToplevelCoords = wlr_xdg_popup_get_toplevel_coords;++ const wlr_xdg_popup_unconstrain_from_box = abi.bind(fn (popup: *XdgPopup, toplevel_space_box: *const wlr.Box) callconv(.c) void, c.wlr_xdg_popup_unconstrain_from_box);+ pub const unconstrainFromBox = wlr_xdg_popup_unconstrain_from_box;+};++pub const XdgToplevel = extern struct {+ pub const State = extern struct {+ maximized: bool,+ fullscreen: bool,+ resizing: bool,+ activated: bool,+ suspended: bool,+ tiled: wlr.Edges,+ constrained: wlr.Edges,+ width: i32,+ height: i32,+ max_width: i32,+ max_height: i32,+ min_width: i32,+ min_height: i32,+ };++ pub const WmCapabilities = packed struct(u32) {+ window_menu: bool = false,+ maximize: bool = false,+ fullscreen: bool = false,+ minimize: bool = false,+ _: u28 = 0,+ };++ pub const Configure = extern struct {+ pub const Fields = packed struct(u32) {+ bounds: bool = false,+ wm_capabilities: bool = false,+ _: u30 = 0,+ };++ fields: Fields,+ maximized: bool,+ fullscreen: bool,+ resizing: bool,+ activated: bool,+ suspended: bool,+ tiled: wlr.Edges,+ constrained: wlr.Edges,+ width: i32,+ height: i32,+ bounds: extern struct {+ width: i32,+ height: i32,+ },+ wm_capabilities: WmCapabilities,+ };++ pub const Requested = extern struct {+ maximized: bool,+ minimized: bool,+ fullscreen: bool,++ fullscreen_output: ?*wlr.Output,++ WLR_PRIVATE: @FieldType(c.wlr_xdg_toplevel_requested, "WLR_PRIVATE"),+ };++ pub const event = struct {+ pub const Move = extern struct {+ toplevel: *wlr.XdgToplevel,+ seat: *wlr.Seat.Client,+ serial: u32,+ };++ pub const Resize = extern struct {+ toplevel: *wlr.XdgToplevel,+ seat: *wlr.Seat.Client,+ serial: u32,+ edges: wlr.Edges,+ };++ pub const ShowWindowMenu = extern struct {+ toplevel: *wlr.XdgToplevel,+ seat: *wlr.Seat.Client,+ serial: u32,+ x: i32,+ y: i32,+ };+ };++ resource: *xdg.Toplevel,+ base: *wlr.XdgSurface,+ parent: ?*wlr.XdgToplevel,++ current: State,+ pending: State,+ scheduled: Configure,+ requested: Requested,++ title: ?[*:0]u8,+ app_id: ?[*:0]u8,+ events: extern struct {+ destroy: wl.Signal(void),+ request_maximize: wl.Signal(void),+ request_fullscreen: wl.Signal(void),+ request_minimize: wl.Signal(void),+ request_move: wl.Signal(*event.Move),+ request_resize: wl.Signal(*event.Resize),+ request_show_window_menu: wl.Signal(*event.ShowWindowMenu),+ set_parent: wl.Signal(void),+ set_title: wl.Signal(void),+ set_app_id: wl.Signal(void),+ },++ const wlr_xdg_toplevel_from_resource = abi.bind(fn (resource: *xdg.Toplevel) callconv(.c) ?*wlr.XdgToplevel, c.wlr_xdg_toplevel_from_resource);+ pub const fromResource = wlr_xdg_toplevel_from_resource;++ const wlr_xdg_toplevel_configure = abi.bind(fn (toplevel: *wlr.XdgToplevel, configure: *const Configure) callconv(.c) u32, c.wlr_xdg_toplevel_configure);+ pub const configure = wlr_xdg_toplevel_configure;++ const wlr_xdg_toplevel_set_size = abi.bind(fn (toplevel: *wlr.XdgToplevel, width: i32, height: i32) callconv(.c) u32, c.wlr_xdg_toplevel_set_size);+ pub const setSize = wlr_xdg_toplevel_set_size;++ const wlr_xdg_toplevel_set_activated = abi.bind(fn (toplevel: *wlr.XdgToplevel, activated: bool) callconv(.c) u32, c.wlr_xdg_toplevel_set_activated);+ pub const setActivated = wlr_xdg_toplevel_set_activated;++ const wlr_xdg_toplevel_set_maximized = abi.bind(fn (toplevel: *wlr.XdgToplevel, maximized: bool) callconv(.c) u32, c.wlr_xdg_toplevel_set_maximized);+ pub const setMaximized = wlr_xdg_toplevel_set_maximized;++ const wlr_xdg_toplevel_set_fullscreen = abi.bind(fn (toplevel: *wlr.XdgToplevel, fullscreen: bool) callconv(.c) u32, c.wlr_xdg_toplevel_set_fullscreen);+ pub const setFullscreen = wlr_xdg_toplevel_set_fullscreen;++ const wlr_xdg_toplevel_set_resizing = abi.bind(fn (toplevel: *wlr.XdgToplevel, resizing: bool) callconv(.c) u32, c.wlr_xdg_toplevel_set_resizing);+ pub const setResizing = wlr_xdg_toplevel_set_resizing;++ const wlr_xdg_toplevel_set_tiled = abi.bind(fn (toplevel: *wlr.XdgToplevel, tiled_edges: u32) callconv(.c) u32, c.wlr_xdg_toplevel_set_tiled);+ pub fn setTiled(toplevel: *wlr.XdgToplevel, tiled_edges: wlr.Edges) u32 {+ return wlr_xdg_toplevel_set_tiled(toplevel, @bitCast(tiled_edges));+ }++ const wlr_xdg_toplevel_set_constrained = abi.bind(fn (toplevel: *wlr.XdgToplevel, constrained_edges: u32) callconv(.c) u32, c.wlr_xdg_toplevel_set_constrained);+ pub fn setConstrained(toplevel: *wlr.XdgToplevel, constrained_edges: wlr.Edges) u32 {+ return wlr_xdg_toplevel_set_constrained(toplevel, @bitCast(constrained_edges));+ }++ const wlr_xdg_toplevel_set_bounds = abi.bind(fn (toplevel: *wlr.XdgToplevel, width: i32, height: i32) callconv(.c) u32, c.wlr_xdg_toplevel_set_bounds);+ pub const setBounds = wlr_xdg_toplevel_set_bounds;++ const wlr_xdg_toplevel_set_wm_capabilities = abi.bind(fn (toplevel: *wlr.XdgToplevel, caps: WmCapabilities) callconv(.c) u32, c.wlr_xdg_toplevel_set_wm_capabilities);+ pub const setWmCapabilities = wlr_xdg_toplevel_set_wm_capabilities;++ const wlr_xdg_toplevel_set_suspended = abi.bind(fn (toplevel: *wlr.XdgToplevel, suspended: bool) callconv(.c) u32, c.wlr_xdg_toplevel_set_suspended);+ pub const setSuspended = wlr_xdg_toplevel_set_suspended;++ const wlr_xdg_toplevel_send_close = abi.bind(fn (toplevel: *wlr.XdgToplevel) callconv(.c) void, c.wlr_xdg_toplevel_send_close);+ pub const sendClose = wlr_xdg_toplevel_send_close;++ const wlr_xdg_toplevel_set_parent = abi.bind(fn (toplevel: *wlr.XdgToplevel, parent: ?*wlr.XdgToplevel) callconv(.c) bool, c.wlr_xdg_toplevel_set_parent);+ pub const setParent = wlr_xdg_toplevel_set_parent;+};++pub const XdgSurface = extern struct {+ pub const Role = enum(c_int) {+ none = c.WLR_XDG_SURFACE_ROLE_NONE,+ toplevel = c.WLR_XDG_SURFACE_ROLE_TOPLEVEL,+ popup = c.WLR_XDG_SURFACE_ROLE_POPUP,+ };++ pub const State = extern struct {+ committed: packed struct(u32) {+ geometry: bool = false,+ _: u31 = 0,+ },++ geometry: wlr.Box,++ configure_serial: u32,+ };++ pub const Configure = extern struct {+ surface: *wlr.XdgSurface,+ /// XdgSurface.configure_list+ link: wl.list.Link,+ serial: u32,++ role: extern union {+ toplevel: *wlr.XdgToplevel.Configure,+ popup: *wlr.XdgPopup.Configure,+ },+ };++ client: *wlr.XdgClient,+ resource: *xdg.Surface,+ surface: *wlr.Surface,+ /// XdgClient.surfaces+ link: wl.list.Link,++ role: Role,+ role_resource: ?*wl.Resource,+ role_data: extern union {+ toplevel: ?*wlr.XdgToplevel,+ popup: ?*wlr.XdgPopup,+ },++ popups: wl.list.Head(XdgPopup, .link),++ configured: bool,+ configure_idle: ?*wl.EventSource,+ scheduled_serial: u32,+ configure_list: wl.list.Head(XdgSurface.Configure, .link),++ current: State,+ pending: State,++ initialized: bool,+ initial_commit: bool,++ geometry: wlr.Box,++ events: extern struct {+ destroy: wl.Signal(void),+ ping_timeout: wl.Signal(void),+ new_popup: wl.Signal(*wlr.XdgPopup),+ configure: wl.Signal(*wlr.XdgSurface.Configure),+ ack_configure: wl.Signal(*wlr.XdgSurface.Configure),+ },++ data: ?*anyopaque,++ const wlr_xdg_surface_from_resource = abi.bind(fn (resource: *xdg.Surface) callconv(.c) ?*wlr.XdgSurface, c.wlr_xdg_surface_from_resource);+ pub const fromResource = wlr_xdg_surface_from_resource;++ const wlr_xdg_surface_ping = abi.bind(fn (surface: *wlr.XdgSurface) callconv(.c) void, c.wlr_xdg_surface_ping);+ pub const ping = wlr_xdg_surface_ping;++ const wlr_xdg_surface_surface_at = abi.bind(fn (surface: *wlr.XdgSurface, sx: f64, sy: f64, sub_x: *f64, sub_y: *f64) callconv(.c) ?*wlr.Surface, c.wlr_xdg_surface_surface_at);+ pub const surfaceAt = wlr_xdg_surface_surface_at;++ const wlr_xdg_surface_popup_surface_at = abi.bind(fn (surface: *wlr.XdgSurface, sx: f64, sy: f64, sub_x: *f64, sub_y: *f64) callconv(.c) ?*wlr.Surface, c.wlr_xdg_surface_popup_surface_at);+ pub const popupSurfaceAt = wlr_xdg_surface_popup_surface_at;++ const wlr_xdg_surface_try_from_wlr_surface = abi.bind(fn (surface: *wlr.Surface) callconv(.c) ?*wlr.XdgSurface, c.wlr_xdg_surface_try_from_wlr_surface);+ pub const tryFromWlrSurface = wlr_xdg_surface_try_from_wlr_surface;++ const wlr_xdg_surface_for_each_surface = abi.bind(fn (+ surface: *wlr.XdgSurface,+ iterator: *const fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void,+ user_data: ?*anyopaque,+ ) callconv(.c) void, c.wlr_xdg_surface_for_each_surface);+ pub inline fn forEachSurface(+ surface: *wlr.XdgSurface,+ comptime T: type,+ comptime iterator: fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: T) void,+ data: T,+ ) void {+ wlr_xdg_surface_for_each_surface(+ surface,+ struct {+ fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void {+ iterator(s, sx, sy, @ptrCast(@alignCast(d)));+ }+ }.wrapper,+ data,+ );+ }++ const wlr_xdg_surface_for_each_popup_surface = abi.bind(fn (+ surface: *wlr.XdgSurface,+ iterator: *const fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void,+ user_data: ?*anyopaque,+ ) callconv(.c) void, c.wlr_xdg_surface_for_each_popup_surface);+ pub inline fn forEachPopupSurface(+ surface: *wlr.XdgSurface,+ comptime T: type,+ comptime iterator: fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: T) void,+ data: T,+ ) void {+ wlr_xdg_surface_for_each_popup_surface(+ surface,+ struct {+ fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void {+ iterator(s, sx, sy, @ptrCast(@alignCast(d)));+ }+ }.wrapper,+ data,+ );+ }++ const wlr_xdg_surface_schedule_configure = abi.bind(fn (surface: *wlr.XdgSurface) callconv(.c) u32, c.wlr_xdg_surface_schedule_configure);+ pub const scheduleConfigure = wlr_xdg_surface_schedule_configure;+};++/// translate-c gives anonymous unions generated field names. Match these by+/// position and validate each alternative instead of baking that name in.+fn assertWithAnonymousUnion(comptime T: type, comptime C: type) void {+ const real = @typeInfo(C).@"struct".fields;+ for (@typeInfo(T).@"struct".fields, 0..) |field, index| {+ const actual = real[index];+ if (@offsetOf(T, field.name) != @offsetOf(C, actual.name))+ @compileError("XDG field offset changed: " ++ @typeName(T) ++ "." ++ field.name);+ abi.assertValue(field.type, actual.type);+ if (@typeInfo(field.type) == .@"union") {+ const fields = @typeInfo(field.type).@"union".fields;+ const alternatives = @typeInfo(actual.type).@"union".fields;+ if (fields.len != alternatives.len) @compileError("XDG union alternatives changed");+ for (fields, alternatives) |ours, theirs| abi.assertValue(ours.type, theirs.type);+ } else if (!@import("std").mem.eql(u8, field.name, actual.name)) {+ @compileError("XDG field changed: " ++ field.name);+ }+ }+}++comptime {+ @setEvalBranchQuota(10000);+ abi.assertFields(XdgShell, c.wlr_xdg_shell);+ abi.assertLayout(XdgClient, c.wlr_xdg_client);+ abi.assertLayout(XdgPositioner, c.wlr_xdg_positioner);+ abi.assertLayout(XdgPositioner.Rules, c.wlr_xdg_positioner_rules);+ abi.assertFields(XdgPopupGrab, c.wlr_xdg_popup_grab);+ abi.assertFields(XdgPopup, c.wlr_xdg_popup);+ abi.assertLayout(XdgPopup.State, c.wlr_xdg_popup_state);+ abi.assertLayout(XdgPopup.Configure, c.wlr_xdg_popup_configure);+ abi.assertFields(XdgToplevel, c.wlr_xdg_toplevel);+ abi.assertLayout(XdgToplevel.State, c.wlr_xdg_toplevel_state);+ abi.assertLayout(XdgToplevel.Configure, c.struct_wlr_xdg_toplevel_configure);+ abi.assertLayout(XdgToplevel.Requested, c.wlr_xdg_toplevel_requested);+ abi.assertLayout(XdgToplevel.event.Move, c.wlr_xdg_toplevel_move_event);+ abi.assertLayout(XdgToplevel.event.Resize, c.wlr_xdg_toplevel_resize_event);+ abi.assertLayout(XdgToplevel.event.ShowWindowMenu, c.wlr_xdg_toplevel_show_window_menu_event);+ assertWithAnonymousUnion(XdgSurface, c.wlr_xdg_surface);+ assertWithAnonymousUnion(XdgSurface.Configure, c.wlr_xdg_surface_configure);+ @import("signal.zig").assertSameLayout(XdgSurface.Configure, c.wlr_xdg_surface_configure);+ abi.assertLayout(XdgSurface.State, c.wlr_xdg_surface_state);+}diff --git a/src/wlr/xwayland.zig b/src/wlr/xwayland.zignew file mode 100644index 0000000..554f24c--- /dev/null+++ b/src/wlr/xwayland.zig@@ -0,0 +1,291 @@+//! Typed wlroots header adapter. API shapes adapted from zig-wlroots;+//! see LICENSE.zig-wlroots for its MIT license.+const c = @import("c.zig").c;+const abi = @import("abi.zig");+const wlr = @import("wlr.zig");++const std = @import("std");+const posix = std.posix;++const wayland = @import("wayland");+const wl = wayland.server.wl;++// Only bind enough to make binding wlr/xwayland.h possible+// Consider full xcb bindings in the future if needed+const xcb = struct {+ const GenericEvent = opaque {};+ const Pixmap = u32;+ const Window = u32;+ const Atom = u32;++ const StackMode = enum(c_int) {+ above = c.XCB_STACK_MODE_ABOVE,+ below = c.XCB_STACK_MODE_BELOW,+ top_if = c.XCB_STACK_MODE_TOP_IF,+ bottom_if = c.XCB_STACK_MODE_BOTTOM_IF,+ opposite = c.XCB_STACK_MODE_OPPOSITE,+ };++ pub const IcccmWmHints = c.xcb_icccm_wm_hints_t;++ pub const SizeHints = c.xcb_size_hints_t;++ pub const EwmhWmStrutPartial = c.xcb_ewmh_wm_strut_partial_t;+};++pub const Xwm = opaque {};++// Only the ownership fields are read by the global filter. wlroots owns both+// objects, so their unrelated public fields and private tails are omitted.+const XwaylandServer = extern struct {+ pid: posix.pid_t,+ client: ?*wl.Client,+};+const XwaylandShellV1 = extern struct {+ global: *wl.Global,+};++pub const Xwayland = extern struct {+ pub const event = struct {+ pub const RemoveStartupInfo = extern struct {+ id: [*:0]const u8,+ window: xcb.Window,+ };+ };++ /// This can be null during destruction+ server: ?*XwaylandServer,+ own_server: bool,+ xwm: ?*Xwm,+ shell_v1: *XwaylandShellV1,++ display_name: [*:0]const u8,++ wl_display: *wl.Server,+ compositor: *wlr.Compositor,+ seat: ?*wlr.Seat,++ events: extern struct {+ destroy: wl.Signal(void),+ ready: wl.Signal(void),+ new_surface: wl.Signal(*XwaylandSurface),+ remove_startup_info: wl.Signal(*event.RemoveStartupInfo),+ },++ user_event_handler: ?*const fn (*Xwayland, *xcb.GenericEvent) callconv(.c) bool,++ data: ?*anyopaque,++ const wlr_xwayland_create = abi.bind(fn (server: *wl.Server, compositor: *wlr.Compositor, lazy: bool) callconv(.c) ?*Xwayland, c.wlr_xwayland_create);+ pub fn create(server: *wl.Server, compositor: *wlr.Compositor, lazy: bool) !*Xwayland {+ return wlr_xwayland_create(server, compositor, lazy) orelse error.XwaylandCreateFailed;+ }++ const wlr_xwayland_create_with_server = abi.bind(fn (server: *wl.Server, compositor: *wlr.Compositor, xwayland_server: *XwaylandServer) callconv(.c) ?*Xwayland, c.wlr_xwayland_create_with_server);+ pub fn createWithServer(server: *wl.Server, compositor: *wlr.Compositor, xwayland_server: *XwaylandServer) !*Xwayland {+ return wlr_xwayland_create_with_server(server, compositor, xwayland_server) orelse error.XwaylandCreateWithServerFailed;+ }++ const wlr_xwayland_destroy = abi.bind(fn (wlr_xwayland: *Xwayland) callconv(.c) void, c.wlr_xwayland_destroy);+ pub const destroy = wlr_xwayland_destroy;++ const wlr_xwayland_set_cursor = abi.bind(fn (wlr_xwayland: *Xwayland, buffer: *wlr.Buffer, hotspot_x: i32, hotspot_y: i32) callconv(.c) void, c.wlr_xwayland_set_cursor);+ pub const setCursor = wlr_xwayland_set_cursor;++ const wlr_xwayland_set_seat = abi.bind(fn (xwayland: *Xwayland, seat: *wlr.Seat) callconv(.c) void, c.wlr_xwayland_set_seat);+ pub const setSeat = wlr_xwayland_set_seat;+};++pub const XwaylandSurface = extern struct {+ pub const IcccmInputModel = enum(c_int) {+ none = c.WLR_ICCCM_INPUT_MODEL_NONE,+ passive = c.WLR_ICCCM_INPUT_MODEL_PASSIVE,+ local = c.WLR_ICCCM_INPUT_MODEL_LOCAL,+ global = c.WLR_ICCCM_INPUT_MODEL_GLOBAL,+ };++ /// Bitfield with the size/alignment of a u32+ pub const Decorations = packed struct(u32) {+ no_border: bool = false,+ no_title: bool = false,+ _: u30 = 0,+ };++ pub const event = struct {+ pub const Configure = extern struct {+ surface: *XwaylandSurface,+ x: i16,+ y: i16,+ width: u16,+ height: u16,+ mask: u16,+ };++ pub const Resize = extern struct {+ surface: *XwaylandSurface,+ edges: u32,+ };++ pub const Minimize = extern struct {+ surface: *XwaylandSurface,+ minimize: bool,+ };+ };++ window_id: xcb.Window,+ xwm: *Xwm,+ surface_id: u32,+ serial: u64,++ link: wl.list.Link,+ stack_link: wl.list.Link,+ unpaired_link: wl.list.Link,++ surface: ?*wlr.Surface,+ surface_addon: c.wlr_addon,++ x: i16,+ y: i16,+ width: u16,+ height: u16,+ override_redirect: bool,+ opacity: f32,++ title: ?[*:0]u8,+ class: ?[*:0]u8,+ instance: ?[*:0]u8,+ role: ?[*:0]u8,+ startup_id: ?[*:0]u8,+ pid: posix.pid_t,++ children: wl.list.Head(XwaylandSurface, .parent_link),+ parent: ?*XwaylandSurface,+ /// XwaylandSurface.children+ parent_link: wl.list.Link,++ window_type: ?[*]xcb.Atom,+ window_type_len: usize,++ protocols: ?[*]xcb.Atom,+ protocols_len: usize,++ decorations: Decorations,+ hints: ?*xcb.IcccmWmHints,+ size_hints: ?*xcb.SizeHints,+ strut_partial: ?*xcb.EwmhWmStrutPartial,++ pinging: bool,+ ping_timer: *wl.EventSource,++ modal: bool,+ fullscreen: bool,+ maximized_vert: bool,+ maximized_horz: bool,+ minimized: bool,+ withdrawn: bool,+ sticky: bool,+ shaded: bool,+ skip_taskbar: bool,+ skip_pager: bool,+ above: bool,+ below: bool,+ demands_attention: bool,++ has_alpha: bool,++ events: extern struct {+ destroy: wl.Signal(void),+ request_configure: wl.Signal(*event.Configure),+ request_move: wl.Signal(void),+ request_resize: wl.Signal(*event.Resize),+ request_minimize: wl.Signal(*event.Minimize),+ request_maximize: wl.Signal(void),+ request_fullscreen: wl.Signal(void),+ request_activate: wl.Signal(void),+ request_close: wl.Signal(void),+ request_sticky: wl.Signal(void),+ request_shaded: wl.Signal(void),+ request_skip_taskbar: wl.Signal(void),+ request_skip_pager: wl.Signal(void),+ request_above: wl.Signal(void),+ request_below: wl.Signal(void),+ request_demands_attention: wl.Signal(void),++ associate: wl.Signal(void),+ dissociate: wl.Signal(void),++ set_title: wl.Signal(void),+ set_class: wl.Signal(void),+ set_role: wl.Signal(void),+ set_parent: wl.Signal(void),+ set_startup_id: wl.Signal(void),+ set_window_type: wl.Signal(void),+ set_hints: wl.Signal(void),+ set_size_hints: wl.Signal(void),+ set_decorations: wl.Signal(void),+ set_strut_partial: wl.Signal(void),+ set_override_redirect: wl.Signal(void),+ set_geometry: wl.Signal(void),+ set_opacity: wl.Signal(void),+ set_icon: wl.Signal(void),+ focus_in: wl.Signal(void),+ grab_focus: wl.Signal(void),++ map_request: wl.Signal(void),++ ping_timeout: wl.Signal(void),+ },++ data: ?*anyopaque,++ const wlr_xwayland_surface_activate = abi.bind(fn (surface: *XwaylandSurface, activated: bool) callconv(.c) void, c.wlr_xwayland_surface_activate);+ pub const activate = wlr_xwayland_surface_activate;++ const wlr_xwayland_surface_restack = abi.bind(fn (surface: *XwaylandSurface, sibling: ?*XwaylandSurface, mode: xcb.StackMode) callconv(.c) void, c.wlr_xwayland_surface_restack);+ pub const restack = wlr_xwayland_surface_restack;++ const wlr_xwayland_surface_configure = abi.bind(fn (surface: *XwaylandSurface, x: i16, y: i16, width: u16, height: u16) callconv(.c) void, c.wlr_xwayland_surface_configure);+ pub const configure = wlr_xwayland_surface_configure;++ const wlr_xwayland_surface_close = abi.bind(fn (surface: *XwaylandSurface) callconv(.c) void, c.wlr_xwayland_surface_close);+ pub const close = wlr_xwayland_surface_close;++ const wlr_xwayland_surface_set_withdrawn = abi.bind(fn (surface: *XwaylandSurface, withdrawn: bool) callconv(.c) void, c.wlr_xwayland_surface_set_withdrawn);+ pub const setWithdrawn = wlr_xwayland_surface_set_withdrawn;++ const wlr_xwayland_surface_set_minimized = abi.bind(fn (surface: *XwaylandSurface, minimized: bool) callconv(.c) void, c.wlr_xwayland_surface_set_minimized);+ pub const setMinimized = wlr_xwayland_surface_set_minimized;++ const wlr_xwayland_surface_set_maximized = abi.bind(fn (surface: *XwaylandSurface, maximized_horz: bool, maximized_vert: bool) callconv(.c) void, c.wlr_xwayland_surface_set_maximized);+ pub const setMaximized = wlr_xwayland_surface_set_maximized;++ const wlr_xwayland_surface_set_fullscreen = abi.bind(fn (surface: *XwaylandSurface, fullscreen: bool) callconv(.c) void, c.wlr_xwayland_surface_set_fullscreen);+ pub const setFullscreen = wlr_xwayland_surface_set_fullscreen;++ const wlr_xwayland_surface_try_from_wlr_surface = abi.bind(fn (surface: *wlr.Surface) callconv(.c) ?*XwaylandSurface, c.wlr_xwayland_surface_try_from_wlr_surface);+ pub const tryFromWlrSurface = wlr_xwayland_surface_try_from_wlr_surface;++ const wlr_xwayland_surface_ping = abi.bind(fn (surface: *XwaylandSurface) callconv(.c) void, c.wlr_xwayland_surface_ping);+ pub const ping = wlr_xwayland_surface_ping;++ pub const offerFocus = abi.bind(fn (surface: *XwaylandSurface) callconv(.c) void, c.wlr_xwayland_surface_offer_focus);+ pub const setDemandsAttention = abi.bind(fn (surface: *XwaylandSurface, urgent: bool) callconv(.c) void, c.wlr_xwayland_surface_set_demands_attention);++ const wlr_xwayland_surface_override_redirect_wants_focus = abi.bind(fn (surface: *const XwaylandSurface) callconv(.c) bool, c.wlr_xwayland_surface_override_redirect_wants_focus);+ pub const overrideRedirectWantsFocus = wlr_xwayland_surface_override_redirect_wants_focus;++ const wlr_xwayland_surface_icccm_input_model = abi.bind(fn (surface: *const XwaylandSurface) callconv(.c) IcccmInputModel, c.wlr_xwayland_surface_icccm_input_model);+ pub const icccmInputModel = wlr_xwayland_surface_icccm_input_model;+};++comptime {+ @setEvalBranchQuota(10000);+ abi.assertFields(XwaylandServer, c.wlr_xwayland_server);+ abi.assertFields(XwaylandShellV1, c.wlr_xwayland_shell_v1);+ abi.assertFields(Xwayland, c.wlr_xwayland);+ abi.assertFields(XwaylandSurface, c.wlr_xwayland_surface);+ abi.assertLayout(Xwayland.event.RemoveStartupInfo, c.wlr_xwayland_remove_startup_info_event);+ abi.assertLayout(XwaylandSurface.event.Configure, c.wlr_xwayland_surface_configure_event);+ abi.assertLayout(XwaylandSurface.event.Resize, c.wlr_xwayland_resize_event);+ abi.assertLayout(XwaylandSurface.event.Minimize, c.wlr_xwayland_minimize_event);+}diff --git a/src/xdg.zig b/src/xdg.zigindex 57fef94..95c6498 100644--- a/src/xdg.zig+++ b/src/xdg.zig@@ -110,9 +110,7 @@ fn handleRequestResize(const toplevel = adapter.window;const surface = adapter.xdg_toplevel.base.surface;if (!toplevel.server.input.seat.validatePointerGrabSerial(surface, event.serial)) return;- // XdgToplevel hasn't migrated off zig-wlroots; see wlr.zig's- // assertSameLayout(Edges, old.Edges) for why this cast is safe.- toplevel.server.input.startResize(toplevel, @bitCast(event.edges), null, 0x110);+ toplevel.server.input.startResize(toplevel, event.edges, null, 0x110);}fn handleRequestMaximize(listener: *wl.Listener(void)) void {diff --git a/src/xwayland_surface.zig b/src/xwayland_surface.zigindex fa4bb4b..d2c8343 100644--- a/src/xwayland_surface.zig+++ b/src/xwayland_surface.zig@@ -12,8 +12,7 @@ const resize = @import("resize.zig");const Adapter = @This();const log = std.log.scoped(.xwayland);-extern fn wlr_xwayland_surface_offer_focus(surface: *wlr.XwaylandSurface) void;-pub const offerFocus = wlr_xwayland_surface_offer_focus;+pub const offerFocus = wlr.XwaylandSurface.offerFocus;const config_x: u16 = 1;const config_y: u16 = 2;@@ -435,13 +434,11 @@ fn handleSetHints(listener: *wl.Listener(void)) void {adapter.window.setUrgent(urgent);}-extern fn wlr_xwayland_surface_set_demands_attention(surface: *wlr.XwaylandSurface, demands_attention: bool) void;-pub fn setDemandsAttention(adapter: *Adapter, urgent: bool) void {// Requests update wlroots' cached flag before emitting the signal. Also// compare compositor state so accepting a request publishes the X property.if (adapter.xsurface.demands_attention != urgent or adapter.window.needs_attention != urgent)- wlr_xwayland_surface_set_demands_attention(adapter.xsurface, urgent);+ adapter.xsurface.setDemandsAttention(urgent);}fn handleRequestDemandsAttention(listener: *wl.Listener(void)) void {