mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
gtk: forward config updates to GTK apprt surfaces
This commit is contained in:
@ -892,6 +892,9 @@ fn configChange(
|
|||||||
) void {
|
) void {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
.surface => |surface| surface: {
|
.surface => |surface| surface: {
|
||||||
|
surface.rt_surface.updateConfig(new_config) catch |err| {
|
||||||
|
log.err("unable to update surface config: {}", .{err});
|
||||||
|
};
|
||||||
const window = surface.rt_surface.container.window() orelse break :surface;
|
const window = surface.rt_surface.container.window() orelse break :surface;
|
||||||
window.updateConfig(new_config) catch |err| {
|
window.updateConfig(new_config) catch |err| {
|
||||||
log.warn("error updating config for window err={}", .{err});
|
log.warn("error updating config for window err={}", .{err});
|
||||||
|
@ -682,6 +682,12 @@ pub fn deinit(self: *Surface) void {
|
|||||||
self.resize_overlay.deinit();
|
self.resize_overlay.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update our local copy of any configuration that we use.
|
||||||
|
pub fn updateConfig(self: *Surface, config: *const configpkg.Config) !void {
|
||||||
|
_ = self;
|
||||||
|
_ = config;
|
||||||
|
}
|
||||||
|
|
||||||
// unref removes the long-held reference to the gl_area and kicks off the
|
// unref removes the long-held reference to the gl_area and kicks off the
|
||||||
// deinit/destroy process for this surface.
|
// deinit/destroy process for this surface.
|
||||||
pub fn unref(self: *Surface) void {
|
pub fn unref(self: *Surface) void {
|
||||||
|
@ -31,6 +31,10 @@ const log = std.log.scoped(.gtk);
|
|||||||
|
|
||||||
app: *App,
|
app: *App,
|
||||||
|
|
||||||
|
/// Used to deduplicate updateConfig invocations
|
||||||
|
last_config: usize,
|
||||||
|
|
||||||
|
/// Local copy of any configuration
|
||||||
config: DerivedConfig,
|
config: DerivedConfig,
|
||||||
|
|
||||||
/// Our window
|
/// Our window
|
||||||
@ -107,6 +111,7 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
// Set up our own state
|
// Set up our own state
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.app = app,
|
.app = app,
|
||||||
|
.last_config = @intFromPtr(&app.config),
|
||||||
.config = DerivedConfig.init(&app.config),
|
.config = DerivedConfig.init(&app.config),
|
||||||
.window = undefined,
|
.window = undefined,
|
||||||
.headerbar = undefined,
|
.headerbar = undefined,
|
||||||
@ -355,6 +360,13 @@ pub fn updateConfig(
|
|||||||
self: *Window,
|
self: *Window,
|
||||||
config: *const configpkg.Config,
|
config: *const configpkg.Config,
|
||||||
) !void {
|
) !void {
|
||||||
|
// avoid multiple reconfigs when we have many surfaces contained in this
|
||||||
|
// surface using the integer value of config as a simple marker to know if
|
||||||
|
// we've "seen" this particular config before
|
||||||
|
const this_config = @intFromPtr(config);
|
||||||
|
if (self.last_config == this_config) return;
|
||||||
|
self.last_config = this_config;
|
||||||
|
|
||||||
self.config = DerivedConfig.init(config);
|
self.config = DerivedConfig.init(config);
|
||||||
|
|
||||||
// We always resync our appearance whenever the config changes.
|
// We always resync our appearance whenever the config changes.
|
||||||
|
Reference in New Issue
Block a user