Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions sources/PTYSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -18069,6 +18069,10 @@ - (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose {
return [iTermPreferences boolForKey:kPreferenceKeyFocusFollowsMouse] && ![self.delegate sessionBelongsToHotkeyWindow:self];
}

- (NSColor *)popupWindowBackgroundColor {
return self.effectiveUnprocessedBackgroundColor;
}

- (VT100Screen *)popupVT100Screen {
return _screen;
}
Expand Down
15 changes: 11 additions & 4 deletions sources/ToastWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

#import "ToastWindowController.h"
#import <QuartzCore/QuartzCore.h>
#import "NSAppearance+iTerm.h"
#import "NSColor+iTerm.h"
#import "NSScreen+iTerm.h"
#import "PTYSession.h"
#import "PseudoTerminal.h"
#import "RoundedRectView.h"
#import "iTermController.h"
Expand Down Expand Up @@ -58,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];
Expand Down Expand Up @@ -138,8 +145,8 @@ + (void)showToastWithMessage:(NSString *)message duration:(NSInteger)duration sc
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];
Expand Down
24 changes: 24 additions & 0 deletions sources/iTermApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -238,6 +239,7 @@ @implementation iTermApplicationDelegate {
id<NSObject> _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?

Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions sources/iTermGlobalSearchWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]];
Expand Down
9 changes: 9 additions & 0 deletions sources/iTermInstantReplayWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion sources/iTermOpenQuicklyWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions sources/iTermPopupWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// If the cursor is preceded by whitespace the last word will be empty. Words go in reverse order.
- (NSArray<NSString *> *)popupWordsBeforeInsertionPoint:(int)count;
- (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose;
- (NSColor *)popupWindowBackgroundColor;
@end

@protocol iTermPopupWindowHosting
Expand Down
6 changes: 6 additions & 0 deletions sources/iTermPopupWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#import "DebugLogging.h"
#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"
Expand Down Expand Up @@ -161,6 +163,10 @@ - (void)popWithDelegate:(id<PopupDelegate>)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];

static const NSTimeInterval kAnimationDuration = 0.15;
self.window.alphaValue = 0;
if (delegate.popupWindowIsInFloatingHotkeyWindow) {
Expand Down
4 changes: 4 additions & 0 deletions sources/iTermStatusBarLargeComposerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ - (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose {
return NO;
}

- (NSColor *)popupWindowBackgroundColor {
return nil;
}

- (NSRect)popupScreenVisibleFrame {
return self.view.window.screen.visibleFrame;
}
Expand Down
Loading