surface propagates new config to renderer

This commit is contained in:
Mitchell Hashimoto
2023-03-16 17:03:57 -07:00
parent f34da17a11
commit 7eda21d544
5 changed files with 24 additions and 1 deletions

View File

@ -570,7 +570,13 @@ fn changeConfig(self: *Surface, config: *const configpkg.Config) !void {
// Update our derived configurations for the renderer and termio,
// then send them a message to update.
// TODO
var renderer_config = try Renderer.DerivedConfig.init(self.alloc, config);
errdefer renderer_config.deinit();
// TODO: termio config
_ = self.renderer_thread.mailbox.push(.{
.change_config = renderer_config,
}, .{ .forever = {} });
}
/// Returns the x/y coordinate of where the IME (Input Method Editor)

View File

@ -724,6 +724,11 @@ fn drawCells(
}
}
/// Update the configuration.
pub fn changeConfig(self: *Metal, config: DerivedConfig) !void {
self.config = config;
}
/// Resize the screen.
pub fn setScreenSize(self: *Metal, dim: renderer.ScreenSize) !void {
// Store our screen size

View File

@ -1232,6 +1232,11 @@ 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;
}
/// Set the screen size for rendering. This will update the projection
/// used for the shader so that the scaling of the grid is correct.
pub fn setScreenSize(self: *OpenGL, dim: renderer.ScreenSize) !void {

View File

@ -255,6 +255,10 @@ fn drainMailbox(self: *Thread) !void {
.screen_size => |size| {
try self.renderer.setScreenSize(size);
},
.change_config => |config| {
try self.renderer.changeConfig(config);
},
}
}
}

View File

@ -22,4 +22,7 @@ pub const Message = union(enum) {
/// Change the screen size.
screen_size: renderer.ScreenSize,
/// The derived configuration to update the renderer with.
change_config: renderer.Renderer.DerivedConfig,
};