Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions sources/NSAppearance+iTerm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
20 changes: 20 additions & 0 deletions sources/NSAppearance+iTerm.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#import "NSAppearance+iTerm.h"
#import "DebugLogging.h"
#import "NSColor+iTerm.h"
#import "iTermPreferences.h"

@implementation NSAppearance (iTerm)
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions sources/PTYSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -18098,6 +18098,10 @@ - (BOOL)popupWindowShouldAvoidChangingWindowOrderOnClose {
return [iTermPreferences boolForKey:kPreferenceKeyFocusFollowsMouse] && ![self.delegate sessionBelongsToHotkeyWindow:self];
}

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

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

#import "ToastWindowController.h"
#import <QuartzCore/QuartzCore.h>
#import "NSAppearance+iTerm.h"
#import "NSScreen+iTerm.h"
#import "PTYSession.h"
#import "PseudoTerminal.h"
#import "RoundedRectView.h"
#import "iTermController.h"
Expand Down Expand Up @@ -58,15 +60,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;
NSAppearance *sessionAppearance = [NSAppearance it_appearanceForCurrentSessionWithBackgroundColor:session.effectiveUnprocessedBackgroundColor];
BOOL isDark = sessionAppearance.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 +144,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
3 changes: 3 additions & 0 deletions sources/iTermGlobalSearchWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "FindContext.h"
#import "iTerm2SharedARC-Swift.h"
#import "iTermController.h"
#import "NSAppearance+iTerm.h"
#import "iTermFocusReportingTextField.h"
#import "iTermGlobalSearchEngine.h"
#import "iTermGlobalSearchOutlineView.h"
Expand Down Expand Up @@ -58,6 +59,8 @@ - (instancetype)init {
- (void)windowDidLoad {
self.window.delegate = self;
self.window.level = NSFloatingWindowLevel;
PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession;
self.window.appearance = [NSAppearance it_appearanceForCurrentSessionWithBackgroundColor:session.effectiveUnprocessedBackgroundColor];
[_outlineView expandItem:nil expandChildren:YES];
_panel.becomesKeyOnlyIfNeeded = YES;
[_findType selectItemWithTag:[iTermUserDefaults globalSearchMode]];
Expand Down
6 changes: 6 additions & 0 deletions sources/iTermInstantReplayWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#import "iTermInstantReplayWindowController.h"

#import "DebugLogging.h"
#import "iTermController.h"
#import "NSAppearance+iTerm.h"
#import "PTYSession.h"
#import "PseudoTerminal.h"

static const float kAlphaValue = 0.9;

Expand Down Expand Up @@ -138,6 +142,8 @@ - (void)windowDidLoad

self.window.level = NSFloatingWindowLevel;
self.window.alphaValue = kAlphaValue;
PTYSession *session = [[iTermController sharedInstance] currentTerminal].currentSession;
self.window.appearance = [NSAppearance it_appearanceForCurrentSessionWithBackgroundColor:session.effectiveUnprocessedBackgroundColor];
}

- (void)windowWillClose:(NSNotification *)notification {
Expand Down
1 change: 0 additions & 1 deletion sources/iTermOpenQuicklyWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions sources/iTermPopupWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
// 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;

@optional
- (NSColor *)popupWindowBackgroundColor;
@end

@protocol iTermPopupWindowHosting
Expand Down
5 changes: 5 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,9 @@ - (void)popWithDelegate:(id<PopupDelegate>)delegate

[self.popupWindow setOwningWindow:owningWindow];

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;
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