mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 11:16:08 +03:00
update config messages use pointers now to make messages small again
This commit is contained in:
@ -569,17 +569,30 @@ fn changeConfig(self: *Surface, config: *const configpkg.Config) !void {
|
||||
self.config.deinit();
|
||||
self.config = derived;
|
||||
|
||||
// We need to store our configs in a heap-allocated pointer so that
|
||||
// our messages aren't huge.
|
||||
var renderer_config_ptr = try self.alloc.create(Renderer.DerivedConfig);
|
||||
errdefer self.alloc.destroy(renderer_config_ptr);
|
||||
var termio_config_ptr = try self.alloc.create(termio.Impl.DerivedConfig);
|
||||
errdefer self.alloc.destroy(termio_config_ptr);
|
||||
|
||||
// Update our derived configurations for the renderer and termio,
|
||||
// then send them a message to update.
|
||||
var renderer_config = try Renderer.DerivedConfig.init(self.alloc, config);
|
||||
errdefer renderer_config.deinit();
|
||||
var termio_config = try termio.Impl.DerivedConfig.init(self.alloc, config);
|
||||
errdefer termio_config.deinit();
|
||||
renderer_config_ptr.* = try Renderer.DerivedConfig.init(self.alloc, config);
|
||||
errdefer renderer_config_ptr.deinit();
|
||||
termio_config_ptr.* = try termio.Impl.DerivedConfig.init(self.alloc, config);
|
||||
errdefer termio_config_ptr.deinit();
|
||||
_ = self.renderer_thread.mailbox.push(.{
|
||||
.change_config = renderer_config,
|
||||
.change_config = .{
|
||||
.alloc = self.alloc,
|
||||
.ptr = renderer_config_ptr,
|
||||
},
|
||||
}, .{ .forever = {} });
|
||||
_ = self.io_thread.mailbox.push(.{
|
||||
.change_config = termio_config,
|
||||
.change_config = .{
|
||||
.alloc = self.alloc,
|
||||
.ptr = termio_config_ptr,
|
||||
},
|
||||
}, .{ .forever = {} });
|
||||
|
||||
// With mailbox messages sent, we have to wake them up so they process it.
|
||||
|
@ -725,8 +725,8 @@ fn drawCells(
|
||||
}
|
||||
|
||||
/// Update the configuration.
|
||||
pub fn changeConfig(self: *Metal, config: DerivedConfig) !void {
|
||||
self.config = config;
|
||||
pub fn changeConfig(self: *Metal, config: *DerivedConfig) !void {
|
||||
self.config = config.*;
|
||||
}
|
||||
|
||||
/// Resize the screen.
|
||||
|
@ -1233,8 +1233,8 @@ fn gridSize(self: *const OpenGL, screen_size: renderer.ScreenSize) renderer.Grid
|
||||
}
|
||||
|
||||
/// Update the configuration.
|
||||
pub fn changeConfig(self: *OpenGL, config: DerivedConfig) !void {
|
||||
self.config = config;
|
||||
pub fn changeConfig(self: *OpenGL, config: *DerivedConfig) !void {
|
||||
self.config = config.*;
|
||||
}
|
||||
|
||||
/// Set the screen size for rendering. This will update the projection
|
||||
|
@ -257,7 +257,8 @@ fn drainMailbox(self: *Thread) !void {
|
||||
},
|
||||
|
||||
.change_config => |config| {
|
||||
try self.renderer.changeConfig(config);
|
||||
defer config.alloc.destroy(config.ptr);
|
||||
try self.renderer.changeConfig(config.ptr);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,8 @@ pub const Message = union(enum) {
|
||||
screen_size: renderer.ScreenSize,
|
||||
|
||||
/// The derived configuration to update the renderer with.
|
||||
change_config: renderer.Renderer.DerivedConfig,
|
||||
change_config: struct {
|
||||
alloc: Allocator,
|
||||
ptr: *renderer.Renderer.DerivedConfig,
|
||||
},
|
||||
};
|
||||
|
@ -218,9 +218,8 @@ pub fn threadExit(self: *Exec, data: ThreadData) void {
|
||||
}
|
||||
|
||||
/// Update the configuration.
|
||||
pub fn changeConfig(self: *Exec, config: DerivedConfig) !void {
|
||||
var copy = config;
|
||||
defer copy.deinit();
|
||||
pub fn changeConfig(self: *Exec, config: *DerivedConfig) !void {
|
||||
defer config.deinit();
|
||||
|
||||
// Update the configuration that we know about.
|
||||
//
|
||||
|
@ -150,7 +150,10 @@ fn drainMailbox(self: *Thread) !void {
|
||||
|
||||
log.debug("mailbox message={}", .{message});
|
||||
switch (message) {
|
||||
.change_config => |config| try self.impl.changeConfig(config),
|
||||
.change_config => |config| {
|
||||
defer config.alloc.destroy(config.ptr);
|
||||
try self.impl.changeConfig(config.ptr);
|
||||
},
|
||||
.resize => |v| self.handleResize(v),
|
||||
.clear_screen => |v| try self.impl.clearScreen(v.history),
|
||||
.write_small => |v| try self.impl.queueWrite(v.data[0..v.len]),
|
||||
|
@ -29,8 +29,12 @@ pub const Message = union(enum) {
|
||||
padding: renderer.Padding,
|
||||
};
|
||||
|
||||
/// The derived configuration to update the implementation with.
|
||||
change_config: termio.Impl.DerivedConfig,
|
||||
/// The derived configuration to update the implementation with. This
|
||||
/// is allocated via the allocator and is expected to be freed when done.
|
||||
change_config: struct {
|
||||
alloc: Allocator,
|
||||
ptr: *termio.Impl.DerivedConfig,
|
||||
},
|
||||
|
||||
/// Resize the window.
|
||||
resize: Resize,
|
||||
|
Reference in New Issue
Block a user