From 1c0434a948787429d2676db9c8a4f5106b3acc1e Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 25 Aug 2024 18:17:42 -0700 Subject: [PATCH] core: remove verbose comments Signed-off-by: Stephen Gutekanst --- src/Core.zig | 11 ++++++++++- src/core/Darwin.zig | 16 ---------------- src/core/Null.zig | 16 ---------------- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/Core.zig b/src/Core.zig index 21c5e2a3..3e6bed3a 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -5,6 +5,8 @@ const build_options = @import("build-options"); const mach = @import("main.zig"); const gpu = mach.gpu; const log = std.log.scoped(.mach); + +// TODO: move to Linux.zig const gamemode_log = std.log.scoped(.gamemode); const Platform = switch (build_options.core_platform) { @@ -134,9 +136,11 @@ state: enum { deinitializing, exited, } = .running, -linux_gamemode: ?bool = null, frame: mach.time.Frequency, +// TODO: move to Linux.zig +linux_gamemode: ?bool = null, + // Might be accessed by Platform backend input: mach.time.Frequency, swap_chain_update: std.Thread.ResetEvent = .{}, @@ -291,6 +295,7 @@ fn init(core: *Mod, entities: *mach.Entities.Mod) !void { try core.set(state.main_window, .width, state.platform.size.width); try core.set(state.main_window, .height, state.platform.size.height); + // TODO: move to Linux.zig if (builtin.os.tag == .linux and !options.is_app and state.linux_gamemode == null and try wantGamemode(options.allocator)) state.linux_gamemode = initLinuxGamemode(); @@ -374,6 +379,7 @@ pub fn deinit(entities: *mach.Entities.Mod, core: *Mod) !void { } } + // TODO: move to Linux.zig if (builtin.os.tag == .linux and state.linux_gamemode != null and state.linux_gamemode.?) @@ -1009,6 +1015,7 @@ pub inline fn printUnhandledErrorCallback(_: void, ty: gpu.ErrorType, message: [ std.process.exit(1); } +// TODO: move to Linux.zig /// Check if gamemode should be activated pub fn wantGamemode(allocator: std.mem.Allocator) error{ OutOfMemory, InvalidWtf8 }!bool { const use_gamemode = std.process.getEnvVarOwned( @@ -1023,6 +1030,7 @@ pub fn wantGamemode(allocator: std.mem.Allocator) error{ OutOfMemory, InvalidWtf return !(std.ascii.eqlIgnoreCase(use_gamemode, "off") or std.ascii.eqlIgnoreCase(use_gamemode, "false")); } +// TODO: move to Linux.zig pub fn initLinuxGamemode() bool { mach.gamemode.start(); if (!mach.gamemode.isActive()) return false; @@ -1030,6 +1038,7 @@ pub fn initLinuxGamemode() bool { return true; } +// TODO: move to Linux.zig pub fn deinitLinuxGamemode() void { mach.gamemode.stop(); gamemode_log.info("gamemode: deactivated", .{}); diff --git a/src/core/Darwin.zig b/src/core/Darwin.zig index 70894597..3b9496ff 100644 --- a/src/core/Darwin.zig +++ b/src/core/Darwin.zig @@ -67,7 +67,6 @@ pub fn run(comptime on_each_update_fn: anytype, args_tuple: std.meta.ArgsTuple(@ // TODO: support UIKit. } -// Called on the main thread pub fn init( darwin: *Darwin, core: *Core.Mod, @@ -130,77 +129,62 @@ pub fn deinit(darwin: *Darwin) void { return; } -// Called on the main thread pub fn update(_: *Darwin) !void { return; } -// May be called from any thread. pub fn setTitle(_: *Darwin, _: [:0]const u8) void { return; } -// May be called from any thread. pub fn setDisplayMode(_: *Darwin, _: DisplayMode) void { return; } -// May be called from any thread. pub fn setBorder(_: *Darwin, _: bool) void { return; } -// May be called from any thread. pub fn setHeadless(_: *Darwin, _: bool) void { return; } -// May be called from any thread. pub fn setVSync(_: *Darwin, _: VSyncMode) void { return; } -// May be called from any thread. pub fn setSize(_: *Darwin, _: Size) void { return; } -// May be called from any thread. pub fn size(_: *Darwin) Size { return Size{ .width = 100, .height = 100 }; } -// May be called from any thread. pub fn setCursorMode(_: *Darwin, _: CursorMode) void { return; } -// May be called from any thread. pub fn setCursorShape(_: *Darwin, _: CursorShape) void { return; } -// May be called from any thread. pub fn keyPressed(_: *Darwin, _: Key) bool { return false; } -// May be called from any thread. pub fn keyReleased(_: *Darwin, _: Key) bool { return true; } -// May be called from any thread. pub fn mousePressed(_: *Darwin, _: MouseButton) bool { return false; } -// May be called from any thread. pub fn mouseReleased(_: *Darwin, _: MouseButton) bool { return true; } -// May be called from any thread. pub fn mousePosition(_: *Darwin) Position { return Position{ .x = 0, .y = 0 }; } diff --git a/src/core/Null.zig b/src/core/Null.zig index 0f67dd4f..81a644f1 100644 --- a/src/core/Null.zig +++ b/src/core/Null.zig @@ -38,7 +38,6 @@ refresh_rate: u32, size: Size, surface_descriptor: gpu.Surface.Descriptor, -// Called on the main thread pub fn init( nul: *Null, core: *Core.Mod, @@ -54,77 +53,62 @@ pub fn deinit(_: *Null) void { return; } -// Called on the main thread pub fn update(_: *Null) !void { return; } -// May be called from any thread. pub fn setTitle(_: *Null, _: [:0]const u8) void { return; } -// May be called from any thread. pub fn setDisplayMode(_: *Null, _: DisplayMode) void { return; } -// May be called from any thread. pub fn setBorder(_: *Null, _: bool) void { return; } -// May be called from any thread. pub fn setHeadless(_: *Null, _: bool) void { return; } -// May be called from any thread. pub fn setVSync(_: *Null, _: VSyncMode) void { return; } -// May be called from any thread. pub fn setSize(_: *Null, _: Size) void { return; } -// May be called from any thread. pub fn size(_: *Null) Size { return Size{ .width = 100, .height = 100 }; } -// May be called from any thread. pub fn setCursorMode(_: *Null, _: CursorMode) void { return; } -// May be called from any thread. pub fn setCursorShape(_: *Null, _: CursorShape) void { return; } -// May be called from any thread. pub fn keyPressed(_: *Null, _: Key) bool { return false; } -// May be called from any thread. pub fn keyReleased(_: *Null, _: Key) bool { return true; } -// May be called from any thread. pub fn mousePressed(_: *Null, _: MouseButton) bool { return false; } -// May be called from any thread. pub fn mouseReleased(_: *Null, _: MouseButton) bool { return true; } -// May be called from any thread. pub fn mousePosition(_: *Null) Position { return Position{ .x = 0, .y = 0 }; }