Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/apprt/gtk/class/application.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,9 @@ pub const Application = extern struct {
// Sync our accelerators for menu items.
self.syncActionAccelerators();

// Sync the application color scheme with the updated configuration.
self.updateStyleManager();

// Load our runtime and custom CSS. If this fails then our window is
// just stuck with the old CSS but we don't want to fail the entire
// config change operation.
Expand Down Expand Up @@ -1421,15 +1424,10 @@ pub const Application = extern struct {
}
}

/// Setup the style manager on startup. The primary task here is to
/// setup our initial light/dark mode based on the configuration and
/// setup listeners for changes to the style manager.
fn startupStyleManager(self: *Self) void {
const priv = self.private();
const config = priv.config.get();

// Setup our initial light/dark
fn updateStyleManager(self: *Self) void {
const config = self.private().config.get();
const style = self.as(adw.Application).getStyleManager();

style.setColorScheme(switch (config.@"window-theme") {
.auto, .ghostty => auto: {
const lum = config.background.toTerminalRGB().perceivedLuminance();
Expand All @@ -1442,6 +1440,15 @@ pub const Application = extern struct {
.dark => .force_dark,
.light => .force_light,
});
}

/// Setup the style manager on startup. The primary task here is to
/// setup our initial light/dark mode based on the configuration and
/// setup listeners for changes to the style manager.
fn startupStyleManager(self: *Self) void {
// Setup our initial light/dark
const style = self.as(adw.Application).getStyleManager();
self.updateStyleManager();

// Setup color change notifications
_ = gobject.Object.signals.notify.connect(
Expand Down
Loading