diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2024-01-09 09:21:15 -0800 |
|---|---|---|
| committer | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2024-01-09 09:21:15 -0800 |
| commit | 96d33fef20dbe2742ae718beccd6cc42719016ba (patch) | |
| tree | 53a91778fb3f92502658a67512704ccac3c1cad2 /src/renderer/message.zig | |
| parent | 92697bad1240ac647b2bc7f471f87fb7f65f7305 (diff) | |
custom shader animation can be set to "always" to always remain active
Fixes #1225
The `custom-shader-animation` configuration can now be set to "always"
which keeps animation active even if the terminal is unfocused.
Diffstat (limited to 'src/renderer/message.zig')
| -rw-r--r-- | src/renderer/message.zig | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/renderer/message.zig b/src/renderer/message.zig index 3278a2c1c..73faa0ad7 100644 --- a/src/renderer/message.zig +++ b/src/renderer/message.zig @@ -1,6 +1,7 @@ const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; +const configpkg = @import("../config.zig"); const font = @import("../font/main.zig"); const renderer = @import("../renderer.zig"); const terminal = @import("../terminal/main.zig"); @@ -45,9 +46,42 @@ pub const Message = union(enum) { /// The derived configuration to update the renderer with. change_config: struct { alloc: Allocator, - ptr: *renderer.Renderer.DerivedConfig, + thread: *renderer.Thread.DerivedConfig, + impl: *renderer.Renderer.DerivedConfig, }, /// Activate or deactivate the inspector. inspector: bool, + + /// Initialize a change_config message. + pub fn initChangeConfig(alloc: Allocator, config: *const configpkg.Config) !Message { + const thread_ptr = try alloc.create(renderer.Thread.DerivedConfig); + errdefer alloc.destroy(thread_ptr); + const config_ptr = try alloc.create(renderer.Renderer.DerivedConfig); + errdefer alloc.destroy(config_ptr); + + thread_ptr.* = renderer.Thread.DerivedConfig.init(config); + config_ptr.* = try renderer.Renderer.DerivedConfig.init(alloc, config); + errdefer config_ptr.deinit(); + + return .{ + .change_config = .{ + .alloc = alloc, + .thread = thread_ptr, + .impl = config_ptr, + }, + }; + } + + pub fn deinit(self: *const Message) void { + switch (self.*) { + .change_config => |v| { + v.impl.deinit(); + v.alloc.destroy(v.impl); + v.alloc.destroy(v.thread); + }, + + else => {}, + } + } }; |
