From 6ea26a800a2917844fbff57ceb20bac4b40e22db Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 8 Apr 2026 16:26:22 +0200 Subject: [PATCH] feat(gui): add cli option to set window class / app_id --- src/gui/wio/app.zig | 10 ++++++++++ src/main.zig | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/wio/app.zig b/src/gui/wio/app.zig index db02d154..e38f4b73 100644 --- a/src/gui/wio/app.zig +++ b/src/gui/wio/app.zig @@ -68,6 +68,10 @@ var title_buf: [512]u8 = undefined; var title_len: usize = 0; var title_dirty: std.atomic.Value(bool) = .init(false); +// Window class / app_id - read on wio thread during window creation +var window_class_buf: [256]u8 = undefined; +var window_class_len: usize = 0; + // Clipboard write (heap-allocated, transferred to wio thread) var clipboard_mutex: std.Thread.Mutex = .{}; var clipboard_write: ?[]u8 = null; @@ -90,8 +94,13 @@ var wio_font: gpu.Font = .{ .cell_size = .{ .x = 8, .y = 16 }, .backend = .{ .fr pub fn start() !std.Thread { tui_pid = thespian.self_pid().clone(); font_name_len = 0; + window_class_len = 0; stop_requested.store(false, .release); loadConfig(); + const class = thespian.env.get().str("window-class"); + const copy_len = @min(class.len, window_class_buf.len); + @memcpy(window_class_buf[0..copy_len], class[0..copy_len]); + window_class_len = copy_len; return std.Thread.spawn(.{}, wioLoop, .{}); } @@ -380,6 +389,7 @@ fn wioLoop() void { var window = wio.createWindow(.{ .title = "flow", + .app_id = if (window_class_len > 0) window_class_buf[0..window_class_len] else "flow", .size = .{ .width = 1280, .height = 720 }, .scale = 1.0, .opengl = .{ diff --git a/src/main.zig b/src/main.zig index 054340ca..41cd98e6 100644 --- a/src/main.zig +++ b/src/main.zig @@ -83,9 +83,10 @@ pub fn main() anyerror!void { .dark = "Use dark color scheme", .light = "Use light color scheme", .version = "Show build version and exit", + .class = "Set window class", }; - pub const formats = .{ .frame_rate = "num", .trace_level = "num", .exec = "cmds" }; + pub const formats = .{ .frame_rate = "num", .trace_level = "num", .exec = "cmds", .class = "name" }; pub const switches = .{ .project = 'p', @@ -123,6 +124,7 @@ pub fn main() anyerror!void { dark: bool, light: bool, version: bool, + class: ?[]const u8, positional: struct { trailing: []const []const u8, @@ -247,6 +249,7 @@ pub fn main() anyerror!void { if (args.frame_rate) |s| env.num_set("frame-rate", @intCast(s)); env.proc_set("log", log_proc.ref()); if (args.language) |s| env.str_set("language", s); + if (args.class) |s| env.str_set("window-class", s); var eh = thespian.make_exit_handler({}, print_exit_status); const tui_proc = try tui.spawn(a, &ctx, &eh, &env);