feat(gui): add cli option to set window class / app_id
This commit is contained in:
parent
8e4f5f4e17
commit
6ea26a800a
2 changed files with 14 additions and 1 deletions
|
|
@ -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 = .{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue