apprt/glfw: update to new reload config action

This commit is contained in:
Mitchell Hashimoto
2024-11-22 11:27:40 -08:00
parent a191f3c396
commit 0a794addf1

View File

@ -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.