From f4611e141422d0abfbb66975223f15a8144e66a2 Mon Sep 17 00:00:00 2001 From: LeRoyce Pearson Date: Sat, 6 Aug 2022 20:38:04 -0600 Subject: [PATCH] mach: add headless option (#450) Co-authored-by: Stephen Gutekanst --- src/platform/native.zig | 1 + src/structs.zig | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/platform/native.zig b/src/platform/native.zig index f8a301b7..9f8b1225 100644 --- a/src/platform/native.zig +++ b/src/platform/native.zig @@ -406,6 +406,7 @@ pub const Platform = struct { const position = platform.last_position; try platform.window.setMonitor(null, @intCast(i32, position.x), @intCast(i32, position.y), options.width, options.height, null); } + if (options.headless) platform.window.hide() catch {}; } pub fn setShouldClose(platform: *Platform, value: bool) void { diff --git a/src/structs.zig b/src/structs.zig index 2cb11fbd..68b73ab0 100644 --- a/src/structs.zig +++ b/src/structs.zig @@ -34,6 +34,10 @@ pub const Options = struct { /// Fullscreen window. fullscreen: bool = false, + /// Headless mode. Once set, this cannot be unset (because e.g. Wayland does not support showing + /// a window after it was hidden.) + headless: bool = false, + /// Monitor synchronization modes. vsync: enums.VSyncMode = .double,