mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
apprt/gtk: support light/dark mode change on the fly
This commit is contained in:
@ -462,6 +462,7 @@ pub fn performAction(
|
|||||||
.equalize_splits => self.equalizeSplits(target),
|
.equalize_splits => self.equalizeSplits(target),
|
||||||
.goto_split => self.gotoSplit(target, value),
|
.goto_split => self.gotoSplit(target, value),
|
||||||
.open_config => try configpkg.edit.open(self.core_app.alloc),
|
.open_config => try configpkg.edit.open(self.core_app.alloc),
|
||||||
|
.config_change_conditional_state => self.configChangeConditionalState(target),
|
||||||
.inspector => self.controlInspector(target, value),
|
.inspector => self.controlInspector(target, value),
|
||||||
.desktop_notification => self.showDesktopNotification(target, value),
|
.desktop_notification => self.showDesktopNotification(target, value),
|
||||||
.set_title => try self.setTitle(target, value),
|
.set_title => try self.setTitle(target, value),
|
||||||
@ -487,7 +488,6 @@ pub fn performAction(
|
|||||||
.render_inspector,
|
.render_inspector,
|
||||||
.renderer_health,
|
.renderer_health,
|
||||||
.color_change,
|
.color_change,
|
||||||
.config_change_conditional_state,
|
|
||||||
=> log.warn("unimplemented action={}", .{action}),
|
=> log.warn("unimplemented action={}", .{action}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -817,6 +817,35 @@ fn showDesktopNotification(
|
|||||||
c.g_application_send_notification(g_app, n.body.ptr, notification);
|
c.g_application_send_notification(g_app, n.body.ptr, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn configChangeConditionalState(
|
||||||
|
self: *App,
|
||||||
|
target: apprt.Target,
|
||||||
|
) void {
|
||||||
|
const surface: *CoreSurface = switch (target) {
|
||||||
|
.app => return,
|
||||||
|
.surface => |v| v,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Build our new configuration. We can free the memory
|
||||||
|
// immediately after because the surface will derive any
|
||||||
|
// values it needs to.
|
||||||
|
var new_config = self.config.changeConditionalState(
|
||||||
|
surface.config_conditional_state,
|
||||||
|
) catch |err| {
|
||||||
|
// Not a big deal if we error... we just don't update
|
||||||
|
// the config. We log the error and move on.
|
||||||
|
log.warn("error changing config conditional state err={}", .{err});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
defer new_config.deinit();
|
||||||
|
|
||||||
|
// Update our surface.
|
||||||
|
surface.updateConfig(&new_config) catch |err| {
|
||||||
|
log.warn("error updating surface config for state change err={}", .{err});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Reload the configuration. This should return the new configuration.
|
/// Reload the configuration. This should return the new configuration.
|
||||||
/// The old value can be freed immediately at this point assuming a
|
/// The old value can be freed immediately at this point assuming a
|
||||||
/// successful return.
|
/// successful return.
|
||||||
|
Reference in New Issue
Block a user