From 0a794addf1523a9dd333ae025d386beea8cc7918 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 22 Nov 2024 11:27:40 -0800 Subject: [PATCH] apprt/glfw: update to new reload config action --- src/apprt/glfw.zig | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig index 19be46778..51d82ca7a 100644 --- a/src/apprt/glfw.zig +++ b/src/apprt/glfw.zig @@ -200,6 +200,8 @@ pub const App = struct { }), }, + .reload_config => try self.reloadConfig(target, value), + // Unimplemented .new_split, .goto_split, @@ -236,16 +238,34 @@ pub const App = struct { /// successful return. /// /// The returned pointer value is only valid for a stable self pointer. - pub fn reloadConfig(self: *App) !?*const Config { + fn reloadConfig( + self: *App, + target: apprt.action.Target, + opts: apprt.action.ReloadConfig, + ) !void { + if (opts.soft) { + switch (target) { + .app => try self.app.updateConfig(self, &self.config), + .surface => |core_surface| try core_surface.updateConfig( + &self.config, + ), + } + return; + } + // Load our configuration var config = try Config.load(self.app.alloc); errdefer config.deinit(); + // Call into our app to update + switch (target) { + .app => try self.app.updateConfig(self, &config), + .surface => |core_surface| try core_surface.updateConfig(&config), + } + // Update the existing config, be sure to clean up the old one. self.config.deinit(); self.config = config; - - return &self.config; } /// Toggle the window to fullscreen mode.