| 1 | Authentication-Results: mail-a.sr.ht; dkim=pass header.d=disroot.org [email protected]
|
| 2 | Received: from layka.disroot.org (layka.disroot.org [178.21.23.139])
|
| 3 | by mail-a.sr.ht (Postfix) with ESMTPS id 1F6E720910
|
| 4 | for <~novakane/[email protected]>; Sun, 19 Apr 2026 21:26:19 +0000 (UTC)
|
| 5 | Received: from mail01.disroot.lan (localhost [127.0.0.1])
|
| 6 | by disroot.org (Postfix) with ESMTP id ECAEC2706B
|
| 7 | for <~novakane/[email protected]>; Sun, 19 Apr 2026 23:26:18 +0200 (CEST)
|
| 8 | X-Virus-Scanned: SPAM Filter at disroot.org
|
| 9 | Received: from layka.disroot.org ([127.0.0.1])
|
| 10 | by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP
|
| 11 | id OmryCbhHRPfO for <~novakane/[email protected]>;
|
| 12 | Sun, 19 Apr 2026 23:26:18 +0200 (CEST)
|
| 13 | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail;
|
| 14 | t=1776633978; bh=LyYzJ+gKbYCkCluDYEkuv7dj4+LSYNh9AMBCmdFysxo=;
|
| 15 | h=To:From:Date:Subject;
|
| 16 | b=FOdkgSUSh7hqYx13NUZgtzuVb9qKmQux/oUumKbcKJCS25uOIN7aeRBnMUeV0LoPh
|
| 17 | 6eAhvnGjUJDkM5+7225nIWpgRY7CZjPiOBpjDZaW8I7CMbav0FASEUcZbu42vP8pQt
|
| 18 | mw52d0gVgBW2J4NYChfWUIGge62MMdQEb1rztq5Y2gE6KJPh//RqxR/w+abpmpGTDs
|
| 19 | 7KG5BXIRSsb//XrltUSshBtz3LxpYThywyFNy2WIhLKdEG1DcChwRNyEQ8r5+EGso1
|
| 20 | vhYDA4gl3/Ef1x5VgSXbEKjqmxvc1Yxvs/eyIlZaKA8fLueNAsDb8Uwo6NGxw+74XH
|
| 21 | v1S7aAZHAX3dw==
|
| 22 | Message-Id: <[email protected]>
|
| 23 | To: <~novakane/[email protected]>
|
| 24 | From: "tranzystorekk" <[email protected]>
|
| 25 | Date: Sun, 19 Apr 2026 17:37:03 +0200
|
| 26 | Subject: [PATCH zelbar] Update to zig 0.16
|
| 27 |
|
| 28 | ---
|
| 29 | .gitignore | 1 +
|
| 30 | build.zig | 16 +++++++--------
|
| 31 | build.zig.zon | 4 ++--
|
| 32 | common/flags.zig | 49 ++++++++++++++++++++++++---------------------
|
| 33 | src/Backend.zig | 26 ++++++++++++++----------
|
| 34 | src/Bar.zig | 3 +--
|
| 35 | src/decorations.zig | 2 +-
|
| 36 | src/event_loop.zig | 2 +-
|
| 37 | src/main.zig | 38 ++++++++++++++++++++---------------
|
| 38 | 9 files changed, 76 insertions(+), 65 deletions(-)
|
| 39 |
|
| 40 | diff --git a/.gitignore b/.gitignore
|
| 41 | index 3b25ac4..09b8add 100644
|
| 42 | |
| 43 | |
| 44 | @@ -1,3 +1,4 @@
|
| 45 | .zig-cache/
|
| 46 | zig-out/
|
| 47 | +zig-pkg/
|
| 48 | .valgrindrc
|
| 49 | diff --git a/build.zig b/build.zig
|
| 50 | index f7f81b2..797809c 100644
|
| 51 | |
| 52 | |
| 53 | @@ -25,7 +25,7 @@ pub fn build(b: *std.Build) !void {
|
| 54 | const git_describe_long = b.runAllowFail(
|
| 55 | &[_][]const u8{ "git", "-C", b.build_root.path orelse ".", "describe", "--long" },
|
| 56 | &ret,
|
| 57 | - .Inherit,
|
| 58 | + .inherit,
|
| 59 | ) catch break :blk version;
|
| 60 |
|
| 61 | var it = mem.splitSequence(u8, mem.trim(
|
| 62 | @@ -79,19 +79,17 @@ pub fn build(b: *std.Build) !void {
|
| 63 |
|
| 64 | zelbar.root_module.addOptions("build_options", options);
|
| 65 |
|
| 66 | - zelbar.linkLibC();
|
| 67 | -
|
| 68 | zelbar.root_module.addImport("wayland", wayland);
|
| 69 | - zelbar.linkSystemLibrary("wayland-client");
|
| 70 | - zelbar.linkSystemLibrary("wayland-cursor");
|
| 71 | + zelbar.root_module.linkSystemLibrary("wayland-client", .{});
|
| 72 | + zelbar.root_module.linkSystemLibrary("wayland-cursor", .{});
|
| 73 |
|
| 74 | zelbar.root_module.addImport("flags", flags);
|
| 75 |
|
| 76 | zelbar.root_module.addImport("pixman", pixman);
|
| 77 | - zelbar.linkSystemLibrary("pixman-1");
|
| 78 | + zelbar.root_module.linkSystemLibrary("pixman-1", .{});
|
| 79 |
|
| 80 | zelbar.root_module.addImport("fcft", fcft);
|
| 81 | - zelbar.linkSystemLibrary("fcft");
|
| 82 | + zelbar.root_module.linkSystemLibrary("fcft", .{});
|
| 83 |
|
| 84 | zelbar.pie = pie;
|
| 85 |
|
| 86 | @@ -107,8 +105,8 @@ pub fn build(b: *std.Build) !void {
|
| 87 | tests.root_module.addImport("wayland", wayland);
|
| 88 | tests.root_module.addImport("pixman", pixman);
|
| 89 | tests.root_module.addImport("fcft", fcft);
|
| 90 | - tests.linkSystemLibrary("pixman-1");
|
| 91 | - tests.linkSystemLibrary("fcft");
|
| 92 | + tests.root_module.linkSystemLibrary("pixman-1", .{});
|
| 93 | + tests.root_module.linkSystemLibrary("fcft", .{});
|
| 94 | const test_step = b.step("test", "Run all tests");
|
| 95 | test_step.dependOn(&b.addRunArtifact(tests).step);
|
| 96 | }
|
| 97 | diff --git a/build.zig.zon b/build.zig.zon
|
| 98 | index 9b18d95..7f84a04 100644
|
| 99 | |
| 100 | |
| 101 | @@ -9,8 +9,8 @@
|
| 102 | .hash = "pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX",
|
| 103 | },
|
| 104 | .@"zig-wayland" = .{
|
| 105 | - .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.4.0.tar.gz",
|
| 106 | - .hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27",
|
| 107 | + .url = "https://codeberg.org/ifreund/zig-wayland/archive/4a150a04f76f7329e80280661355c04328369d1f.tar.gz",
|
| 108 | + .hash = "wayland-0.6.0-dev-lQa1krD8AQBlMqwuhAMJjPQKXvpRByZBxxqMVAZ7yzbG",
|
| 109 | },
|
| 110 | .@"zig-fcft" = .{
|
| 111 | .url = "https://git.sr.ht/~novakane/zig-fcft/archive/v3.0.0.tar.gz",
|
| 112 | diff --git a/common/flags.zig b/common/flags.zig
|
| 113 | index 79adde9..a1e5be8 100644
|
| 114 | |
| 115 | |
| 116 | @@ -36,32 +36,35 @@ pub fn parser(comptime Arg: type, comptime flags: []const Flag) type {
|
| 117 | flags: Flags,
|
| 118 |
|
| 119 | pub const Flags = flags_type: {
|
| 120 | - var fields: []const std.builtin.Type.StructField = &.{};
|
| 121 | - for (flags) |flag| {
|
| 122 | - const field: std.builtin.Type.StructField = switch (flag.kind) {
|
| 123 | - .boolean => .{
|
| 124 | - .name = flag.name,
|
| 125 | - .type = bool,
|
| 126 | - .default_value_ptr = &false,
|
| 127 | - .is_comptime = false,
|
| 128 | - .alignment = @alignOf(bool),
|
| 129 | + var field_names: [flags.len][]const u8 = undefined;
|
| 130 | + var field_types: [flags.len]type = undefined;
|
| 131 | + var field_attrs: [flags.len]std.builtin.Type.StructField.Attributes = undefined;
|
| 132 | + for (flags, 0..) |flag, i| {
|
| 133 | + field_names[i] = flag.name;
|
| 134 | + switch (flag.kind) {
|
| 135 | + .boolean => {
|
| 136 | + field_types[i] = bool;
|
| 137 | + field_attrs[i] = .{
|
| 138 | + .@"align" = @alignOf(bool),
|
| 139 | + .default_value_ptr = &false,
|
| 140 | + };
|
| 141 | },
|
| 142 | - .arg => .{
|
| 143 | - .name = flag.name,
|
| 144 | - .type = ?[:0]const u8,
|
| 145 | - .default_value_ptr = &@as(?[:0]const u8, null),
|
| 146 | - .is_comptime = false,
|
| 147 | - .alignment = @alignOf(?[:0]const u8),
|
| 148 | + .arg => {
|
| 149 | + field_types[i] = ?[:0]const u8;
|
| 150 | + field_attrs[i] = .{
|
| 151 | + .@"align" = @alignOf(?[:0]const u8),
|
| 152 | + .default_value_ptr = &@as(?[:0]const u8, null),
|
| 153 | + };
|
| 154 | },
|
| 155 | - };
|
| 156 | - fields = fields ++ [_]std.builtin.Type.StructField{field};
|
| 157 | + }
|
| 158 | }
|
| 159 | - break :flags_type @Type(.{ .@"struct" = .{
|
| 160 | - .layout = .auto,
|
| 161 | - .fields = fields,
|
| 162 | - .decls = &.{},
|
| 163 | - .is_tuple = false,
|
| 164 | - } });
|
| 165 | + break :flags_type @Struct(
|
| 166 | + .auto,
|
| 167 | + null,
|
| 168 | + &field_names,
|
| 169 | + &field_types,
|
| 170 | + &field_attrs,
|
| 171 | + );
|
| 172 | };
|
| 173 | };
|
| 174 |
|
| 175 | diff --git a/src/Backend.zig b/src/Backend.zig
|
| 176 | index fd1936a..3401458 100644
|
| 177 | |
| 178 | |
| 179 | @@ -17,7 +17,7 @@
|
| 180 | const std = @import("std");
|
| 181 | const assert = std.debug.assert;
|
| 182 | const builtin = @import("builtin");
|
| 183 | -const io = std.io;
|
| 184 | +const linux = std.os.linux;
|
| 185 | const mem = std.mem;
|
| 186 | const posix = std.posix;
|
| 187 | const fs = std.fs;
|
| 188 | @@ -98,9 +98,9 @@ const HotSpot = struct {
|
| 189 | }
|
| 190 |
|
| 191 | /// Write action in STDOUT.
|
| 192 | - fn act(hotspot: HotSpot) !void {
|
| 193 | + fn act(hotspot: HotSpot, io: std.Io) !void {
|
| 194 | var stdout_buffer: [stdout_buffer_size]u8 = undefined;
|
| 195 | - var bw = fs.File.stdout().writer(&stdout_buffer);
|
| 196 | + var bw = std.Io.File.stdout().writer(io, &stdout_buffer);
|
| 197 | var writer = &bw.interface;
|
| 198 | try writer.writeAll(hotspot.action);
|
| 199 | try writer.writeByte('\n');
|
| 200 | @@ -111,6 +111,7 @@ const HotSpot = struct {
|
| 201 | // Pointers event code have been taken and adapted from
|
| 202 | // https://git.sr.ht/~leon_plickat/wayprompt, same license.
|
| 203 | const Seat = struct {
|
| 204 | + io: std.Io,
|
| 205 | wl_seat: *wl.Seat,
|
| 206 | id: u32,
|
| 207 |
|
| 208 | @@ -127,8 +128,9 @@ const Seat = struct {
|
| 209 |
|
| 210 | node: std.SinglyLinkedList.Node = .{},
|
| 211 |
|
| 212 | - fn init(seat: *Seat, wl_seat: *wl.Seat, id: u32) !void {
|
| 213 | + fn init(seat: *Seat, io: std.Io, wl_seat: *wl.Seat, id: u32) !void {
|
| 214 | seat.* = .{
|
| 215 | + .io = io,
|
| 216 | .wl_seat = wl_seat,
|
| 217 | .id = id,
|
| 218 | };
|
| 219 | @@ -203,7 +205,7 @@ const Seat = struct {
|
| 220 | .released => {
|
| 221 | if (seat.press_hotspot == null) return;
|
| 222 | if (ctx.backend.surface.?.hotspot_from_point(seat.pointer_x, seat.pointer_y)) |hs| {
|
| 223 | - if (hs == seat.press_hotspot.?) hs.act() catch {};
|
| 224 | + if (hs == seat.press_hotspot.?) hs.act(seat.io) catch {};
|
| 225 | }
|
| 226 | seat.press_hotspot = null;
|
| 227 | },
|
| 228 | @@ -294,7 +296,7 @@ const Surface = struct {
|
| 229 | wl_surface: *wl.Surface = undefined,
|
| 230 | layer_surface: *zwlr.LayerSurfaceV1 = undefined,
|
| 231 |
|
| 232 | - hotspots: std.ArrayListUnmanaged(HotSpot) = .{},
|
| 233 | + hotspots: std.ArrayList(HotSpot) = .empty,
|
| 234 |
|
| 235 | frame_callback: ?*wl.Callback = null,
|
| 236 | /// True if we requested a frame callback.
|
| 237 | @@ -565,13 +567,13 @@ pub const Buffer = struct {
|
| 238 | .linux, .freebsd => try posix.memfd_createZ("zelbar-shm-buffer-pool", std.os.linux.MFD.CLOEXEC),
|
| 239 | else => @compileError("target OS not supported"),
|
| 240 | };
|
| 241 | - defer posix.close(fd);
|
| 242 | - try posix.ftruncate(fd, size);
|
| 243 | + defer _ = linux.close(fd);
|
| 244 | + _ = linux.ftruncate(fd, size);
|
| 245 |
|
| 246 | // mmap the memory file, to be used by the pximan image.
|
| 247 | const data = mem.bytesAsSlice(
|
| 248 | u8,
|
| 249 | - try posix.mmap(null, size, posix.PROT.READ | posix.PROT.WRITE, .{ .TYPE = .SHARED }, fd, 0),
|
| 250 | + try posix.mmap(null, size, .{ .READ = true, .WRITE = true }, .{ .TYPE = .SHARED }, fd, 0),
|
| 251 | );
|
| 252 | errdefer posix.munmap(data);
|
| 253 |
|
| 254 | @@ -620,6 +622,7 @@ pub const Buffer = struct {
|
| 255 | }
|
| 256 | };
|
| 257 |
|
| 258 | +io: std.Io = undefined,
|
| 259 | display: *wl.Display = undefined,
|
| 260 | registry: *wl.Registry = undefined,
|
| 261 |
|
| 262 | @@ -637,8 +640,9 @@ req_output: *Output = undefined,
|
| 263 | surface: ?Surface = null,
|
| 264 | pool: BufferPool = .{},
|
| 265 |
|
| 266 | -pub fn init(backend: *Backend) !bool {
|
| 267 | +pub fn init(backend: *Backend, io: std.Io) !bool {
|
| 268 | backend.* = .{
|
| 269 | + .io = io,
|
| 270 | .display = wl.Display.connect(null) catch {
|
| 271 | ctx.fatal(.backend, "failed to connect to Wayland compositor", .{});
|
| 272 | },
|
| 273 | @@ -802,7 +806,7 @@ fn registry_event(backend: *Backend, registry: *wl.Registry, event: wl.Registry.
|
| 274 | const seat = try ctx.gpa.create(Seat);
|
| 275 | errdefer ctx.gpa.destroy(seat);
|
| 276 |
|
| 277 | - try seat.init(wl_seat, ev.name);
|
| 278 | + try seat.init(backend.io, wl_seat, ev.name);
|
| 279 | backend.seats.prepend(&seat.node);
|
| 280 | } else if (mem.orderZ(u8, ev.interface, zwlr.LayerShellV1.interface.name) == .eq) {
|
| 281 | // Version 3 required for layer_shell.destroy();
|
| 282 | diff --git a/src/Bar.zig b/src/Bar.zig
|
| 283 | index 9180842..883db9d 100644
|
| 284 | |
| 285 | |
| 286 | @@ -64,7 +64,7 @@ font: *fcft.Font = undefined,
|
| 287 | req_width: bool = false,
|
| 288 |
|
| 289 | /// Raw input received from STDIN.
|
| 290 | -input: std.ArrayListUnmanaged(u8) = .{},
|
| 291 | +input: std.ArrayList(u8) = .empty,
|
| 292 |
|
| 293 | pub fn new(config: Config) !Bar {
|
| 294 | return Bar{
|
| 295 | @@ -89,7 +89,6 @@ pub fn render(bar: *Bar, buffer: *Buffer, surface_w: u16, h: u16) !void {
|
| 296 | bar.config.border.check_size(w, h) catch |err| switch (err) {
|
| 297 | error.BordersGreaterHeight => ctx.fatal(.bar, "borders greater than bar height({d})", .{h}),
|
| 298 | error.BordersGreaterWidth => ctx.fatal(.bar, "borders greater than bar width({d})", .{w}),
|
| 299 | - else => return err,
|
| 300 | };
|
| 301 |
|
| 302 | // Starting position of the bar in the output.
|
| 303 | diff --git a/src/decorations.zig b/src/decorations.zig
|
| 304 | index a4f753d..8a24765 100644
|
| 305 | |
| 306 | |
| 307 | @@ -142,7 +142,7 @@ pub fn parse_rgba(s: []const u8) !pixman.Color {
|
| 308 | }
|
| 309 |
|
| 310 | /// Check if the color use the right format: "0xRRGGBB" or "0xRRGGBBAA".
|
| 311 | -pub fn check_rgba(comptime scope: @Type(.enum_literal), s: []const u8) void {
|
| 312 | +pub fn check_rgba(comptime scope: @EnumLiteral(), s: []const u8) void {
|
| 313 | if (s.len != 8 and s.len != 10) {
|
| 314 | ctx.fatal(scope, "color must be '0xRRGGBB' or '0xRRGGBBAA': {s}", .{s});
|
| 315 | }
|
| 316 | diff --git a/src/event_loop.zig b/src/event_loop.zig
|
| 317 | index 2a70b8e..a97d195 100644
|
| 318 | |
| 319 | |
| 320 | @@ -91,6 +91,6 @@ pub fn run() !void {
|
| 321 | ctx.backend.flush_wayland_and_prepare_read();
|
| 322 | }
|
| 323 |
|
| 324 | -fn handle_sig(_: c_int) callconv(.c) void {
|
| 325 | +fn handle_sig(_: posix.SIG) callconv(.c) void {
|
| 326 | ctx.initialized = false;
|
| 327 | }
|
| 328 | diff --git a/src/main.zig b/src/main.zig
|
| 329 | index 592ebbf..50b966e 100644
|
| 330 | |
| 331 | |
| 332 | @@ -16,10 +16,9 @@
|
| 333 |
|
| 334 | const std = @import("std");
|
| 335 | const fmt = std.fmt;
|
| 336 | -const io = std.io;
|
| 337 | +const linux = std.os.linux;
|
| 338 | const mem = std.mem;
|
| 339 | const posix = std.posix;
|
| 340 | -const fs = std.fs;
|
| 341 |
|
| 342 | const build_options = @import("build_options");
|
| 343 | const fcft = @import("fcft");
|
| 344 | @@ -71,12 +70,12 @@ const Context = struct {
|
| 345 |
|
| 346 | pub fn fatal(
|
| 347 | _: Context,
|
| 348 | - comptime scope: @Type(.enum_literal),
|
| 349 | + comptime scope: @EnumLiteral(),
|
| 350 | comptime format: []const u8,
|
| 351 | args: anytype,
|
| 352 | ) noreturn {
|
| 353 | std.log.scoped(scope).err(format, args);
|
| 354 | - posix.exit(1);
|
| 355 | + linux.exit(1);
|
| 356 | }
|
| 357 | };
|
| 358 |
|
| 359 | @@ -87,7 +86,14 @@ const background: []const u8 = "0xf9f9fa";
|
| 360 | const foreground: []const u8 = "0x202325";
|
| 361 | const line: []const u8 = "0x9e2f59";
|
| 362 |
|
| 363 | -pub fn main() anyerror!void {
|
| 364 | +pub fn main(init: std.process.Init) anyerror!void {
|
| 365 | + const io = init.io;
|
| 366 | + const argv = try init.minimal.args.toSlice(init.arena.allocator());
|
| 367 | +
|
| 368 | + var stderr_buffer: [1024]u8 = undefined;
|
| 369 | + var stderr_writer = std.Io.File.stderr().writer(io, &stderr_buffer);
|
| 370 | + const stderr = &stderr_writer.interface;
|
| 371 | +
|
| 372 | // Default configuration changed by cli options.
|
| 373 | var default_cfg: Bar.Config = .{};
|
| 374 | try default_cfg.colors.putNoClobber(context.gpa, .bg, background);
|
| 375 | @@ -95,7 +101,7 @@ pub fn main() anyerror!void {
|
| 376 | try default_cfg.colors.putNoClobber(context.gpa, .line, line);
|
| 377 |
|
| 378 | // Parse cli options.
|
| 379 | - const result = flags.parser([*:0]const u8, &.{
|
| 380 | + const result = flags.parser([:0]const u8, &.{
|
| 381 | .{ .name = "h", .kind = .boolean },
|
| 382 | .{ .name = "version", .kind = .boolean },
|
| 383 | .{ .name = "o", .kind = .arg },
|
| 384 | @@ -111,23 +117,23 @@ pub fn main() anyerror!void {
|
| 385 | .{ .name = "bc", .kind = .arg },
|
| 386 | .{ .name = "lh", .kind = .arg },
|
| 387 | .{ .name = "lc", .kind = .arg },
|
| 388 | - }).parse(std.os.argv[1..]) catch {
|
| 389 | - try fs.File.stderr().writeAll(usage);
|
| 390 | - posix.exit(1);
|
| 391 | + }).parse(argv[1..]) catch {
|
| 392 | + try stderr.writeAll(usage);
|
| 393 | + linux.exit(1);
|
| 394 | };
|
| 395 | if (result.args.len != 0) {
|
| 396 | log.err("unknown option '{s}'", .{result.args[0]});
|
| 397 | - fs.File.stderr().writeAll(usage) catch {};
|
| 398 | - posix.exit(1);
|
| 399 | + stderr.writeAll(usage) catch {};
|
| 400 | + linux.exit(1);
|
| 401 | }
|
| 402 |
|
| 403 | if (result.flags.h) {
|
| 404 | - try fs.File.stderr().writeAll(usage);
|
| 405 | - posix.exit(0);
|
| 406 | + try stderr.writeAll(usage);
|
| 407 | + linux.exit(0);
|
| 408 | }
|
| 409 | if (result.flags.version) {
|
| 410 | - try fs.File.stderr().writeAll(build_options.version ++ "\n");
|
| 411 | - posix.exit(0);
|
| 412 | + try stderr.writeAll(build_options.version ++ "\n");
|
| 413 | + linux.exit(0);
|
| 414 | }
|
| 415 | if (result.flags.o) |raw| default_cfg.output_name = raw;
|
| 416 | if (result.flags.btm) default_cfg.location = .bottom;
|
| 417 | @@ -205,7 +211,7 @@ pub fn main() anyerror!void {
|
| 418 | defer fcft.fini();
|
| 419 |
|
| 420 | context.bar = try Bar.new(default_cfg);
|
| 421 | - context.initialized = try context.backend.init();
|
| 422 | + context.initialized = try context.backend.init(io);
|
| 423 | defer context.deinit();
|
| 424 |
|
| 425 | try event_loop.run();
|
| 426 |
|
| 427 | base-commit: b1f1fe4a7f30332fbe6bffeaea77ef292c0f1932
|
| 428 | --
|
| 429 | 2.53.0
|