10
78
Fork
You've already forked zig-wayland
32
Zig wayland scanner and libwayland bindings
  • Zig 100%
Isaac Freund a8e10e87e5
Some checks reported errors
builds.sr.ht/archlinux Job failed
builds.sr.ht/alpine Job completed
builds.sr.ht/freebsd Job completed
test: add presentation-time.xml to snapshot
This protocol has XML comments in descriptions
2026年05月21日 08:41:39 +02:00
.builds build: update to Zig 0.16 2026年04月16日 14:08:37 +02:00
example build: update to Zig 0.16 2026年04月16日 14:08:37 +02:00
src scanner: allow comments in descriptions 2026年05月20日 18:57:11 +03:00
test test: add presentation-time.xml to snapshot 2026年05月21日 08:41:39 +02:00
.gitignore build: upgrade to Zig 0.13.0 2024年06月07日 13:17:57 +02:00
build.zig test: add presentation-time.xml to snapshot 2026年05月21日 08:41:39 +02:00
build.zig.zon build: bump version to 0.7.0-dev 2026年04月25日 12:49:05 +02:00
LICENSE Add MIT (expat) license 2020年09月23日 20:47:32 +02:00
README.md doc: update code snippet in readme for Zig 0.16 2026年04月25日 12:48:31 +02:00

zig-wayland

Zig 0.16 bindings and protocol scanner for libwayland.

The main repository is on codeberg, which is where the issue tracker may be found and where contributions are accepted.

Read-only mirrors exist on sourcehut and github.

Usage

A Scanner interface is provided which you may integrate with your build.zig:

conststd=@import("std");constBuild=std.Build;constScanner=@import("wayland").Scanner;pubfnbuild(b:*Build)!void{consttarget=b.standardTargetOptions(.{});constoptimize=b.standardOptimizeOption(.{});constscanner=Scanner.create(b,.{});constwayland=b.createModule(.{.root_source_file=scanner.result});scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");scanner.addSystemProtocol("staging/ext-session-lock/ext-session-lock-v1.xml");scanner.addCustomProtocol(b.path("protocol/private_foobar.xml"));// Pass the maximum version implemented by your wayland server or client.// Requests, events, enums, etc. from newer versions will not be generated,// ensuring forwards compatibility with newer protocol xml.// This will also generate code for interfaces created using the provided// global interface, in this example wl_keyboard, wl_pointer, xdg_surface,// xdg_toplevel, etc. would be generated as well.scanner.generate("wl_seat",4);scanner.generate("xdg_wm_base",3);scanner.generate("ext_session_lock_manager_v1",1);scanner.generate("private_foobar_manager",1);constexe=b.addExecutable(.{.name="foobar",.root_module=b.createModule(.{.root_source_file=b.path("foobar.zig"),.target=target,.optimize=optimize,.link_libc=true,}),});exe.root_module.addImport("wayland",wayland);exe.root_module.linkSystemLibrary("wayland-client",.{});b.installArtifact(exe);}

Then, you may import the provided module in your project:

constwayland=@import("wayland");constwl=wayland.client.wl;

There is an example project using zig-wayland here in the example/hello directory of this repository.

Note that zig-wayland does not currently do extensive verification of Wayland protocol xml or provide good error messages if protocol xml is invalid. It is recommend to use wayland-scanner --strict to debug protocol xml instead.

Versioning

For now, zig-wayland versions are of the form 0.major.patch. A major version bump indicates a zig-wayland release that breaks API or requires a newer Zig version to build. A patch version bump indicates a zig-wayland release that is fully backwards compatible.

For unreleased versions, the -dev suffix is used (e.g. 0.1.0-dev).

The version of zig-wayland currently has no direct relation to the upstream libwayland version supported.

Breaking changes in zig-wayland's API will be necessary until a stable Zig 1.0 version is released, at which point I plan to switch to a new versioning scheme and start the version numbers with 1 instead of 0.

License

zig-wayland is released under the MIT (expat) license.

The contents of the hello-zig-wayland directory are not part of zig-wayland and are released under the Zero Clause BSD license.