From e769edb66b3dc42c585061d155442e7587724817 Mon Sep 17 00:00:00 2001 From: Erwann Mest Date: Sun, 5 Apr 2026 15:16:25 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20feat(open-quickly):=20refine=20?= =?UTF-8?q?quick=20open=20window=20theming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Adjust glass effect tintColor values for better theme contrast in iTermOpenQuicklyView. • Apply current theme appearance to Quick Open window in iTermOpenQuicklyWindowController via it_appearanceForCurrentTheme. These improvements produce more consistent and visually pleasing Quick Open window theming across light and dark modes. --- sources/iTermOpenQuicklyView.m | 4 ++-- sources/iTermOpenQuicklyWindowController.m | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sources/iTermOpenQuicklyView.m b/sources/iTermOpenQuicklyView.m index a60f133698..c34781edfc 100644 --- a/sources/iTermOpenQuicklyView.m +++ b/sources/iTermOpenQuicklyView.m @@ -36,8 +36,8 @@ - (void)awakeFromNib { if (@available(macOS 26, *)) { NSGlassEffectView *glassView = [[NSGlassEffectView alloc] initWithFrame:self.bounds]; _backgroundEffectView = glassView; - glassView.tintColor = [NSColor it_dynamicColorForLightMode:[NSColor colorWithWhite:0.8 alpha:0.7] - darkMode:[NSColor colorWithWhite:0.2 alpha:0.7]]; + glassView.tintColor = [NSColor it_dynamicColorForLightMode:[NSColor colorWithWhite:0.95 alpha:0.55] + darkMode:[NSColor colorWithWhite:0.08 alpha:0.88]]; _glassContentView = [[NSView alloc] initWithFrame:_backgroundEffectView.bounds]; glassView.contentView = _glassContentView; [_container addSubview:_backgroundEffectView]; diff --git a/sources/iTermOpenQuicklyWindowController.m b/sources/iTermOpenQuicklyWindowController.m index 49c9944317..d6407dc206 100644 --- a/sources/iTermOpenQuicklyWindowController.m +++ b/sources/iTermOpenQuicklyWindowController.m @@ -17,6 +17,7 @@ #import "iTermSessionLauncher.h" #import "iTermSnippetsMenuController.h" #import "DebugLogging.h" +#import "NSAppearance+iTerm.h" #import "NSColor+iTerm.h" #import "NSObject+iTerm.h" #import "NSTextField+iTerm.h" @@ -141,6 +142,7 @@ - (void)awakeFromNib { - (void)presentWindow { [_model removeAllItems]; [_table reloadData]; + self.window.appearance = [NSAppearance it_appearanceForCurrentTheme]; // Set the window's frame to be table-less initially. [self.window setFrame:[self frame] display:YES animate:NO]; [_textField selectText:nil]; From 122828e03b878de62d5df781d5938815f5b2a234 Mon Sep 17 00:00:00 2001 From: Erwann Mest Date: Sun, 5 Apr 2026 15:34:31 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=A8=20feat(window):=20adapt=20popups?= =?UTF-8?q?=20to=20session=20theme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adapt toast, global search, instant replay, and popup windows to inherit their dark/light appearance from the active session/theme, using background perceived brightness and improved theme helpers. - Added background/theme brightness detection for popups (ToastWindowController, iTermGlobalSearchWindowController, iTermInstantReplayWindowController, iTermPopupWindowController). - Imported NSAppearance+iTerm and NSColor+iTerm for centralised theme checks. - Ensured window material/appearance matches session, responding dynamically to dark/light modes. Reasons: - Improves visual consistency across secondary windows - Introduces session-aware theme logic via PTYSession and NSColor+iTerm - Refactors appearance logic to avoid hardcoded dark mode - files: sources/ToastWindowController.m, sources/iTermGlobalSearchWindowController.m, sources/iTermInstantReplayWindowController.m, sources/iTermPopupWindowController.m --- sources/ToastWindowController.m | 11 +++++++++-- sources/iTermGlobalSearchWindowController.m | 6 ++++++ sources/iTermInstantReplayWindowController.m | 9 +++++++++ sources/iTermPopupWindowController.m | 4 ++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/sources/ToastWindowController.m b/sources/ToastWindowController.m index 74e2320b17..1e2f7a022b 100644 --- a/sources/ToastWindowController.m +++ b/sources/ToastWindowController.m @@ -8,7 +8,10 @@ #import "ToastWindowController.h" #import +#import "NSAppearance+iTerm.h" +#import "NSColor+iTerm.h" #import "NSScreen+iTerm.h" +#import "PTYSession.h" #import "PseudoTerminal.h" #import "RoundedRectView.h" #import "iTermController.h" @@ -134,12 +137,16 @@ + (void)showToastWithMessage:(NSString *)message duration:(NSInteger)duration sc }]; maskImage.capInsets = NSEdgeInsetsMake(cornerRadius, cornerRadius, cornerRadius, cornerRadius); + PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; + NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; + BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : YES; + NSVisualEffectView *vev = [[NSVisualEffectView alloc] initWithFrame:container.bounds]; vev.wantsLayer = YES; vev.blendingMode = NSVisualEffectBlendingModeBehindWindow; vev.state = NSVisualEffectStateActive; - vev.material = NSVisualEffectMaterialHUDWindow; - vev.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; + vev.material = isDark ? NSVisualEffectMaterialHUDWindow : NSVisualEffectMaterialSheet; + vev.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameVibrantDark : NSAppearanceNameVibrantLight]; vev.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; vev.maskImage = maskImage; [container addSubview:vev]; diff --git a/sources/iTermGlobalSearchWindowController.m b/sources/iTermGlobalSearchWindowController.m index 100e155038..ab8634c37c 100644 --- a/sources/iTermGlobalSearchWindowController.m +++ b/sources/iTermGlobalSearchWindowController.m @@ -10,6 +10,8 @@ #import "FindContext.h" #import "iTerm2SharedARC-Swift.h" #import "iTermController.h" +#import "NSAppearance+iTerm.h" +#import "NSColor+iTerm.h" #import "iTermFocusReportingTextField.h" #import "iTermGlobalSearchEngine.h" #import "iTermGlobalSearchOutlineView.h" @@ -58,6 +60,10 @@ - (instancetype)init { - (void)windowDidLoad { self.window.delegate = self; self.window.level = NSFloatingWindowLevel; + PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; + NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; + BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; + self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; [_outlineView expandItem:nil expandChildren:YES]; _panel.becomesKeyOnlyIfNeeded = YES; [_findType selectItemWithTag:[iTermUserDefaults globalSearchMode]]; diff --git a/sources/iTermInstantReplayWindowController.m b/sources/iTermInstantReplayWindowController.m index 7f1c56ba6e..c0e26670a9 100644 --- a/sources/iTermInstantReplayWindowController.m +++ b/sources/iTermInstantReplayWindowController.m @@ -9,6 +9,11 @@ #import "iTermInstantReplayWindowController.h" #import "DebugLogging.h" +#import "iTermController.h" +#import "NSAppearance+iTerm.h" +#import "NSColor+iTerm.h" +#import "PTYSession.h" +#import "PseudoTerminal.h" static const float kAlphaValue = 0.9; @@ -138,6 +143,10 @@ - (void)windowDidLoad self.window.level = NSFloatingWindowLevel; self.window.alphaValue = kAlphaValue; + PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; + NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; + BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; + self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; } - (void)windowWillClose:(NSNotification *)notification { diff --git a/sources/iTermPopupWindowController.m b/sources/iTermPopupWindowController.m index adbdc81e74..2d962f5ae0 100644 --- a/sources/iTermPopupWindowController.m +++ b/sources/iTermPopupWindowController.m @@ -4,6 +4,7 @@ #import "DebugLogging.h" #import "iTermAdvancedSettingsModel.h" #import "iTermPreferences.h" +#import "NSAppearance+iTerm.h" #import "NSObject+iTerm.h" #import "NSTextField+iTerm.h" #import "NSView+iTerm.h" @@ -161,6 +162,9 @@ - (void)popWithDelegate:(id)delegate [self.popupWindow setOwningWindow:owningWindow]; + BOOL isDark = owningWindow.effectiveAppearance.it_isDark; + self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; + static const NSTimeInterval kAnimationDuration = 0.15; self.window.alphaValue = 0; if (delegate.popupWindowIsInFloatingHotkeyWindow) { From 913e9fd1c25adfc74bf5590abf93fb87bb292b46 Mon Sep 17 00:00:00 2001 From: Erwann Mest Date: Fri, 10 Apr 2026 21:47:59 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20fix(ui-theme):=20ensure=20po?= =?UTF-8?q?pup=20and=20toast=20windows=20match=20session=20appearance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure popup and toast windows inherit the correct dark/light appearance based on the session's effective background color, improving theme consistency during modal interactions and Sparkle update alerts. Refactor window appearance assignment to use session background color and perceived brightness. Add popupWindowBackgroundColor API to better coordinate colour queries between controllers and delegate objects. Update related logic in iTermPopupWindowController, ToastWindowController, iTermOpenQuicklyWindowController, and iTermApplicationDelegate. Addresses inconsistent UI theming when system theme and session differ. --- sources/PTYSession.m | 4 ++++ sources/ToastWindowController.m | 12 +++++----- sources/iTermApplicationDelegate.m | 24 +++++++++++++++++++ sources/iTermOpenQuicklyWindowController.m | 5 +++- sources/iTermPopupWindowController.h | 1 + sources/iTermPopupWindowController.m | 4 +++- ...TermStatusBarLargeComposerViewController.m | 4 ++++ 7 files changed, 46 insertions(+), 8 deletions(-) diff --git a/sources/PTYSession.m b/sources/PTYSession.m index bfc307e7ab..e4d542a58a 100644 --- a/sources/PTYSession.m +++ b/sources/PTYSession.m @@ -18069,6 +18069,10 @@ - (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose { return [iTermPreferences boolForKey:kPreferenceKeyFocusFollowsMouse] && ![self.delegate sessionBelongsToHotkeyWindow:self]; } +- (NSColor *)popupWindowBackgroundColor { + return self.effectiveUnprocessedBackgroundColor; +} + - (VT100Screen *)popupVT100Screen { return _screen; } diff --git a/sources/ToastWindowController.m b/sources/ToastWindowController.m index 1e2f7a022b..c98e8b3739 100644 --- a/sources/ToastWindowController.m +++ b/sources/ToastWindowController.m @@ -61,15 +61,19 @@ + (void)showToastWithMessage:(NSString *)message duration:(NSInteger)duration to + (void)showToastWithMessage:(NSString *)message duration:(NSInteger)duration screenCoordinate:(NSPoint)screenCoordinate pointSize:(CGFloat)pointSize center:(BOOL)center { ToastWindowController *toast = [[ToastWindowController alloc] init]; + PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; + NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; + BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; + NSTextField *textField = [[NSTextField alloc] init]; - [textField setTextColor:[NSColor whiteColor]]; + [textField setTextColor:isDark ? [NSColor whiteColor] : [NSColor blackColor]]; [textField setBackgroundColor:[NSColor clearColor]]; [textField setFont:[NSFont systemFontOfSize:pointSize weight:NSFontWeightMedium]]; [textField setBordered:NO]; [textField setStringValue:message]; [textField setEditable:NO]; NSShadow *textShadow = [[NSShadow alloc] init]; - textShadow.shadowColor = [[NSColor blackColor] colorWithAlphaComponent:0.3]; + textShadow.shadowColor = [isDark ? [NSColor blackColor] : [NSColor whiteColor] colorWithAlphaComponent:0.3]; textShadow.shadowOffset = NSMakeSize(0, -1); textShadow.shadowBlurRadius = 2.0; [textField setShadow:textShadow]; @@ -137,10 +141,6 @@ + (void)showToastWithMessage:(NSString *)message duration:(NSInteger)duration sc }]; maskImage.capInsets = NSEdgeInsetsMake(cornerRadius, cornerRadius, cornerRadius, cornerRadius); - PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; - NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; - BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : YES; - NSVisualEffectView *vev = [[NSVisualEffectView alloc] initWithFrame:container.bounds]; vev.wantsLayer = YES; vev.blendingMode = NSVisualEffectBlendingModeBehindWindow; diff --git a/sources/iTermApplicationDelegate.m b/sources/iTermApplicationDelegate.m index b2ac87a7a9..b0381318e1 100644 --- a/sources/iTermApplicationDelegate.m +++ b/sources/iTermApplicationDelegate.m @@ -36,6 +36,7 @@ #import "NSApplication+iTerm.h" #import "NSArray+iTerm.h" #import "NSBundle+iTerm.h" +#import "NSColor+iTerm.h" #import "NSData+GZIP.h" #import "NSFileManager+iTerm.h" #import "NSFont+iTerm.h" @@ -238,6 +239,7 @@ @implementation iTermApplicationDelegate { id _appNapStoppingActivity; BOOL _sparkleRestarting; // Is Sparkle about to restart the app? + BOOL _waitingForSparkleWindow; // Sparkle is about to show a window; apply theme appearance when it does. BOOL _orphansAdopted; // Have orphan servers been adopted? @@ -2267,6 +2269,20 @@ - (IBAction)checkForUpdatesFromMenu:(id)sender { [suUpdater checkForUpdates:(sender)]; } +#pragma mark - SUUpdaterDelegate + +- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item { + _waitingForSparkleWindow = YES; +} + +- (void)updaterWillShowModalAlert:(SUUpdater *)updater { + _waitingForSparkleWindow = YES; +} + +- (void)updaterDidShowModalAlert:(SUUpdater *)updater { + _waitingForSparkleWindow = NO; +} + - (IBAction)installClaudeCodeIntegration:(id)sender { [iTermClaudeCodeOnboarding show]; } @@ -3309,6 +3325,14 @@ - (void)currentSessionDidChange { - (void)windowDidChangeKeyStatus:(NSNotification *)notification { DLog(@"%@:\n%@", notification.name, [NSThread callStackSymbols]); + if (_waitingForSparkleWindow && [notification.name isEqualToString:NSWindowDidBecomeKeyNotification]) { + _waitingForSparkleWindow = NO; + NSWindow *window = notification.object; + PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; + NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; + BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; + window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; + } } #pragma mark - iTermOrphanServerAdopterDelegate diff --git a/sources/iTermOpenQuicklyWindowController.m b/sources/iTermOpenQuicklyWindowController.m index d6407dc206..e82aea95f0 100644 --- a/sources/iTermOpenQuicklyWindowController.m +++ b/sources/iTermOpenQuicklyWindowController.m @@ -142,7 +142,10 @@ - (void)awakeFromNib { - (void)presentWindow { [_model removeAllItems]; [_table reloadData]; - self.window.appearance = [NSAppearance it_appearanceForCurrentTheme]; + PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; + NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; + BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; + self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; // Set the window's frame to be table-less initially. [self.window setFrame:[self frame] display:YES animate:NO]; [_textField selectText:nil]; diff --git a/sources/iTermPopupWindowController.h b/sources/iTermPopupWindowController.h index 51c9f04575..c820e1246c 100644 --- a/sources/iTermPopupWindowController.h +++ b/sources/iTermPopupWindowController.h @@ -35,6 +35,7 @@ // If the cursor is preceded by whitespace the last word will be empty. Words go in reverse order. - (NSArray *)popupWordsBeforeInsertionPoint:(int)count; - (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose; +- (NSColor *)popupWindowBackgroundColor; @end @protocol iTermPopupWindowHosting diff --git a/sources/iTermPopupWindowController.m b/sources/iTermPopupWindowController.m index 2d962f5ae0..b5146d3384 100644 --- a/sources/iTermPopupWindowController.m +++ b/sources/iTermPopupWindowController.m @@ -5,6 +5,7 @@ #import "iTermAdvancedSettingsModel.h" #import "iTermPreferences.h" #import "NSAppearance+iTerm.h" +#import "NSColor+iTerm.h" #import "NSObject+iTerm.h" #import "NSTextField+iTerm.h" #import "NSView+iTerm.h" @@ -162,7 +163,8 @@ - (void)popWithDelegate:(id)delegate [self.popupWindow setOwningWindow:owningWindow]; - BOOL isDark = owningWindow.effectiveAppearance.it_isDark; + NSColor *bgColor = [delegate popupWindowBackgroundColor]; + BOOL isDark = bgColor ? bgColor.isDark : owningWindow.effectiveAppearance.it_isDark; self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; static const NSTimeInterval kAnimationDuration = 0.15; diff --git a/sources/iTermStatusBarLargeComposerViewController.m b/sources/iTermStatusBarLargeComposerViewController.m index 4e7c299d0c..5a895adde3 100644 --- a/sources/iTermStatusBarLargeComposerViewController.m +++ b/sources/iTermStatusBarLargeComposerViewController.m @@ -365,6 +365,10 @@ - (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose { return NO; } +- (NSColor *)popupWindowBackgroundColor { + return nil; +} + - (NSRect)popupScreenVisibleFrame { return self.view.window.screen.visibleFrame; } From 72a4b26d446e881c288ccc488086b070451a4ecd Mon Sep 17 00:00:00 2001 From: Erwann Mest Date: Sun, 12 Apr 2026 12:43:21 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(ui-theme):=20?= =?UTF-8?q?consolidate=20dark=20mode=20detection=20in=20NSAppearance=20hel?= =?UTF-8?q?per?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract repeated isDark detection into +it_appearanceForCurrentSessionWithBackgroundColor: on NSAppearance+iTerm. Minimal/Compact themes use session background brightness; Regular/Automatic use it_appearanceForCurrentTheme. Make popupWindowBackgroundColor optional in PopupDelegate with respondsToSelector guard. Replace 4-line copy-pasted pattern in iTermPopupWindowController, iTermInstantReplayWindowController, iTermGlobalSearchWindowController, ToastWindowController with the new helper. Revert iTermOpenQuicklyWindowController to it_appearanceForCurrentTheme (global panel, not session-tied). Revert Sparkle theming in iTermApplicationDelegate (fragile, arbitrary)—keep tab style observer. --- sources/NSAppearance+iTerm.h | 1 + sources/NSAppearance+iTerm.m | 20 ++++++++++++++++ sources/ToastWindowController.m | 5 ++-- sources/iTermApplicationDelegate.m | 24 -------------------- sources/iTermGlobalSearchWindowController.m | 5 +--- sources/iTermInstantReplayWindowController.m | 5 +--- sources/iTermOpenQuicklyWindowController.m | 6 +---- sources/iTermPopupWindowController.h | 2 ++ sources/iTermPopupWindowController.m | 5 ++-- 9 files changed, 30 insertions(+), 43 deletions(-) diff --git a/sources/NSAppearance+iTerm.h b/sources/NSAppearance+iTerm.h index 8f9942bb58..3ee21eaef5 100644 --- a/sources/NSAppearance+iTerm.h +++ b/sources/NSAppearance+iTerm.h @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN // Converts a tab style if automatic. - (iTermPreferencesTabStyle)it_tabStyle:(iTermPreferencesTabStyle)tabStyle; + (instancetype)it_appearanceForCurrentTheme; ++ (instancetype)it_appearanceForCurrentSessionWithBackgroundColor:(nullable NSColor *)backgroundColor; + (void)it_performBlockWithCurrentAppearanceSetToAppearanceForCurrentTheme:(void (^)(void))block; - (void)it_performAsCurrentDrawingAppearance:(void (^NS_NOESCAPE)(void))block; diff --git a/sources/NSAppearance+iTerm.m b/sources/NSAppearance+iTerm.m index d1f78c6f59..a57460c2ba 100644 --- a/sources/NSAppearance+iTerm.m +++ b/sources/NSAppearance+iTerm.m @@ -7,6 +7,7 @@ #import "NSAppearance+iTerm.h" #import "DebugLogging.h" +#import "NSColor+iTerm.h" #import "iTermPreferences.h" @implementation NSAppearance (iTerm) @@ -41,6 +42,25 @@ + (instancetype)it_appearanceForCurrentTheme { } } ++ (instancetype)it_appearanceForCurrentSessionWithBackgroundColor:(nullable NSColor *)backgroundColor { + iTermPreferencesTabStyle preferredStyle = [iTermPreferences intForKey:kPreferenceKeyTabStyle]; + switch (preferredStyle) { + case TAB_STYLE_MINIMAL: + case TAB_STYLE_COMPACT: + if (backgroundColor) { + BOOL isDark = backgroundColor.perceivedBrightness < 0.5; + return [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; + } + return NSApp.effectiveAppearance; + case TAB_STYLE_AUTOMATIC: + case TAB_STYLE_LIGHT: + case TAB_STYLE_LIGHT_HIGH_CONTRAST: + case TAB_STYLE_DARK: + case TAB_STYLE_DARK_HIGH_CONTRAST: + return [self it_appearanceForCurrentTheme]; + } +} + + (void)it_performBlockWithCurrentAppearanceSetToAppearanceForCurrentTheme:(void (^)(void))block { NSAppearance *appearance = [self it_appearanceForCurrentTheme]; [appearance performAsCurrentDrawingAppearance:block]; diff --git a/sources/ToastWindowController.m b/sources/ToastWindowController.m index c98e8b3739..e5a73d6f23 100644 --- a/sources/ToastWindowController.m +++ b/sources/ToastWindowController.m @@ -9,7 +9,6 @@ #import "ToastWindowController.h" #import #import "NSAppearance+iTerm.h" -#import "NSColor+iTerm.h" #import "NSScreen+iTerm.h" #import "PTYSession.h" #import "PseudoTerminal.h" @@ -62,8 +61,8 @@ + (void)showToastWithMessage:(NSString *)message duration:(NSInteger)duration sc ToastWindowController *toast = [[ToastWindowController alloc] init]; PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; - NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; - BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; + NSAppearance *sessionAppearance = [NSAppearance it_appearanceForCurrentSessionWithBackgroundColor:session.effectiveUnprocessedBackgroundColor]; + BOOL isDark = sessionAppearance.it_isDark; NSTextField *textField = [[NSTextField alloc] init]; [textField setTextColor:isDark ? [NSColor whiteColor] : [NSColor blackColor]]; diff --git a/sources/iTermApplicationDelegate.m b/sources/iTermApplicationDelegate.m index 96eea77d45..eb9f4787a0 100644 --- a/sources/iTermApplicationDelegate.m +++ b/sources/iTermApplicationDelegate.m @@ -36,7 +36,6 @@ #import "NSApplication+iTerm.h" #import "NSArray+iTerm.h" #import "NSBundle+iTerm.h" -#import "NSColor+iTerm.h" #import "NSData+GZIP.h" #import "NSFileManager+iTerm.h" #import "NSFont+iTerm.h" @@ -239,7 +238,6 @@ @implementation iTermApplicationDelegate { id _appNapStoppingActivity; BOOL _sparkleRestarting; // Is Sparkle about to restart the app? - BOOL _waitingForSparkleWindow; // Sparkle is about to show a window; apply theme appearance when it does. BOOL _orphansAdopted; // Have orphan servers been adopted? @@ -2276,20 +2274,6 @@ - (IBAction)checkForUpdatesFromMenu:(id)sender { [suUpdater checkForUpdates:(sender)]; } -#pragma mark - SUUpdaterDelegate - -- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item { - _waitingForSparkleWindow = YES; -} - -- (void)updaterWillShowModalAlert:(SUUpdater *)updater { - _waitingForSparkleWindow = YES; -} - -- (void)updaterDidShowModalAlert:(SUUpdater *)updater { - _waitingForSparkleWindow = NO; -} - - (IBAction)installClaudeCodeIntegration:(id)sender { [iTermClaudeCodeOnboarding show]; } @@ -3332,14 +3316,6 @@ - (void)currentSessionDidChange { - (void)windowDidChangeKeyStatus:(NSNotification *)notification { DLog(@"%@:\n%@", notification.name, [NSThread callStackSymbols]); - if (_waitingForSparkleWindow && [notification.name isEqualToString:NSWindowDidBecomeKeyNotification]) { - _waitingForSparkleWindow = NO; - NSWindow *window = notification.object; - PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; - NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; - BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; - window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; - } } #pragma mark - iTermOrphanServerAdopterDelegate diff --git a/sources/iTermGlobalSearchWindowController.m b/sources/iTermGlobalSearchWindowController.m index ab8634c37c..806a9b15fc 100644 --- a/sources/iTermGlobalSearchWindowController.m +++ b/sources/iTermGlobalSearchWindowController.m @@ -11,7 +11,6 @@ #import "iTerm2SharedARC-Swift.h" #import "iTermController.h" #import "NSAppearance+iTerm.h" -#import "NSColor+iTerm.h" #import "iTermFocusReportingTextField.h" #import "iTermGlobalSearchEngine.h" #import "iTermGlobalSearchOutlineView.h" @@ -61,9 +60,7 @@ - (void)windowDidLoad { self.window.delegate = self; self.window.level = NSFloatingWindowLevel; PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; - NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; - BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; - self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; + self.window.appearance = [NSAppearance it_appearanceForCurrentSessionWithBackgroundColor:session.effectiveUnprocessedBackgroundColor]; [_outlineView expandItem:nil expandChildren:YES]; _panel.becomesKeyOnlyIfNeeded = YES; [_findType selectItemWithTag:[iTermUserDefaults globalSearchMode]]; diff --git a/sources/iTermInstantReplayWindowController.m b/sources/iTermInstantReplayWindowController.m index c0e26670a9..727e35e11f 100644 --- a/sources/iTermInstantReplayWindowController.m +++ b/sources/iTermInstantReplayWindowController.m @@ -11,7 +11,6 @@ #import "DebugLogging.h" #import "iTermController.h" #import "NSAppearance+iTerm.h" -#import "NSColor+iTerm.h" #import "PTYSession.h" #import "PseudoTerminal.h" @@ -144,9 +143,7 @@ - (void)windowDidLoad self.window.level = NSFloatingWindowLevel; self.window.alphaValue = kAlphaValue; PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; - NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; - BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; - self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; + self.window.appearance = [NSAppearance it_appearanceForCurrentSessionWithBackgroundColor:session.effectiveUnprocessedBackgroundColor]; } - (void)windowWillClose:(NSNotification *)notification { diff --git a/sources/iTermOpenQuicklyWindowController.m b/sources/iTermOpenQuicklyWindowController.m index e82aea95f0..cf77c56990 100644 --- a/sources/iTermOpenQuicklyWindowController.m +++ b/sources/iTermOpenQuicklyWindowController.m @@ -18,7 +18,6 @@ #import "iTermSnippetsMenuController.h" #import "DebugLogging.h" #import "NSAppearance+iTerm.h" -#import "NSColor+iTerm.h" #import "NSObject+iTerm.h" #import "NSTextField+iTerm.h" #import "NSWindow+iTerm.h" @@ -142,10 +141,7 @@ - (void)awakeFromNib { - (void)presentWindow { [_model removeAllItems]; [_table reloadData]; - PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession; - NSColor *bgColor = session.effectiveUnprocessedBackgroundColor; - BOOL isDark = bgColor ? bgColor.perceivedBrightness < 0.5 : [NSAppearance it_appearanceForCurrentTheme].it_isDark; - self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; + self.window.appearance = [NSAppearance it_appearanceForCurrentTheme]; // Set the window's frame to be table-less initially. [self.window setFrame:[self frame] display:YES animate:NO]; [_textField selectText:nil]; diff --git a/sources/iTermPopupWindowController.h b/sources/iTermPopupWindowController.h index c820e1246c..58381c98a5 100644 --- a/sources/iTermPopupWindowController.h +++ b/sources/iTermPopupWindowController.h @@ -35,6 +35,8 @@ // If the cursor is preceded by whitespace the last word will be empty. Words go in reverse order. - (NSArray *)popupWordsBeforeInsertionPoint:(int)count; - (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose; + +@optional - (NSColor *)popupWindowBackgroundColor; @end diff --git a/sources/iTermPopupWindowController.m b/sources/iTermPopupWindowController.m index b5146d3384..030288eeb8 100644 --- a/sources/iTermPopupWindowController.m +++ b/sources/iTermPopupWindowController.m @@ -163,9 +163,8 @@ - (void)popWithDelegate:(id)delegate [self.popupWindow setOwningWindow:owningWindow]; - NSColor *bgColor = [delegate popupWindowBackgroundColor]; - BOOL isDark = bgColor ? bgColor.isDark : owningWindow.effectiveAppearance.it_isDark; - self.window.appearance = [NSAppearance appearanceNamed:isDark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]; + NSColor *bgColor = [delegate respondsToSelector:@selector(popupWindowBackgroundColor)] ? [delegate popupWindowBackgroundColor] : nil; + self.window.appearance = [NSAppearance it_appearanceForCurrentSessionWithBackgroundColor:bgColor]; static const NSTimeInterval kAnimationDuration = 0.15; self.window.alphaValue = 0;