Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ Intermediates/
NMSSH.framework.dSYM/
NMSSH/
iTerm2.xcodeproj/xcuserdata/

.idea/*
182 changes: 147 additions & 35 deletions Interfaces/PreferencePanel.xib

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion iTerm2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4658,7 +4658,7 @@
0464AB0C006CD2EC7F000001 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
LastUpgradeCheck = 0620;
};
buildConfigurationList = BB024D39096EE4080021E793 /* Build configuration list for PBXProject "iTerm2" */;
compatibilityVersion = "Xcode 3.2";
Expand Down
4 changes: 4 additions & 0 deletions sources/ITAddressBookMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
#define KEY_BLEND @"Blend"
#define KEY_BLUR @"Blur"
#define KEY_BLUR_RADIUS @"Blur Radius"
#define KEY_USE_INACTIVE_TRANSPARENCY @"Use Inactive Transparency Values"
#define KEY_INACTIVE_TRANSPARENCY @"Inactive Transparency"
#define KEY_INACTIVE_BLUR @"Use Inactive Blur"
#define KEY_INACTIVE_BLUR_RADIUS @"Inactive Blur Radius"
#define KEY_ANTI_ALIASING @"Anti Aliasing" // DEPRECATED
#define KEY_ASCII_ANTI_ALIASED @"ASCII Anti Aliased"
#define KEY_USE_NONASCII_FONT @"Use Non-ASCII Font"
Expand Down
4 changes: 4 additions & 0 deletions sources/KeysPreferencesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ - (void)generateHotkeyWindowProfile {
[dict setObject:[NSNumber numberWithFloat:0.3] forKey:KEY_TRANSPARENCY];
[dict setObject:[NSNumber numberWithFloat:0.5] forKey:KEY_BLEND];
[dict setObject:[NSNumber numberWithFloat:2.0] forKey:KEY_BLUR_RADIUS];
[dict setObject:[NSNumber numberWithFloat:0.3] forKey:KEY_INACTIVE_TRANSPARENCY];
[dict setObject:[NSNumber numberWithFloat:2.0] forKey:KEY_INACTIVE_BLUR_RADIUS];
[dict setObject:[NSNumber numberWithBool:YES] forKey:KEY_BLUR];
[dict setObject:[NSNumber numberWithBool:YES] forKey:KEY_INACTIVE_BLUR];
[dict setObject:[NSNumber numberWithBool:YES] forKey:KEY_USE_INACTIVE_TRANSPARENCY];
[dict setObject:[NSNumber numberWithInt:-1] forKey:KEY_SCREEN];
[dict setObject:[NSNumber numberWithInt:-1] forKey:KEY_SPACE];
[dict setObject:@"" forKey:KEY_SHORTCUT];
Expand Down
11 changes: 9 additions & 2 deletions sources/PTYSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,18 @@ typedef enum {
@property(nonatomic, retain) NSImage *backgroundImage;

@property(nonatomic, retain) iTermColorMap *colorMap;
@property(nonatomic, assign) float transparency;
@property(nonatomic, assign) float blend;
@property(nonatomic, assign) double transparency;
@property(nonatomic, assign) BOOL useInactiveTransparency;
@property(nonatomic, assign) double inactiveTransparency;
@property(nonatomic, assign) double blend;
@property(nonatomic, assign) BOOL useBoldFont;
@property(nonatomic, assign) BOOL useItalicFont;

@property(nonatomic, readonly) BOOL inactiveBlur;
@property(nonatomic, readonly) BOOL blur;
@property(nonatomic, readonly) double inactiveBlurRadius;
@property(nonatomic, readonly) double blurRadius;

@property(nonatomic, readonly) BOOL logging;
@property(nonatomic, readonly) BOOL exited;

Expand Down
49 changes: 44 additions & 5 deletions sources/PTYSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,8 @@ - (BOOL)setScreenSize:(NSRect)aRect parent:(id<WindowControllerInterface>)parent
horizontalSpacing:[[_profile objectForKey:KEY_HORIZONTAL_SPACING] floatValue]
verticalSpacing:[[_profile objectForKey:KEY_VERTICAL_SPACING] floatValue]];
[self setTransparency:[[_profile objectForKey:KEY_TRANSPARENCY] floatValue]];
[self setInactiveTransparency:[iTermProfilePreferences floatForKey:KEY_INACTIVE_TRANSPARENCY inProfile:_profile]];
[self setUseInactiveTransparency:[iTermProfilePreferences boolForKey:KEY_USE_INACTIVE_TRANSPARENCY inProfile:_profile]];
const float theBlend =
[_profile objectForKey:KEY_BLEND] ? [[_profile objectForKey:KEY_BLEND] floatValue] : 0.5;
[self setBlend:theBlend];
Expand Down Expand Up @@ -2281,6 +2283,8 @@ - (void)setPreferencesFromAddressBookEntry:(NSDictionary *)aePrefs

// transparency
[self setTransparency:[iTermProfilePreferences floatForKey:KEY_TRANSPARENCY inProfile:aDict]];
[self setUseInactiveTransparency:[iTermProfilePreferences boolForKey:KEY_USE_INACTIVE_TRANSPARENCY inProfile:aDict]];
[self setInactiveTransparency:[iTermProfilePreferences floatForKey:KEY_INACTIVE_TRANSPARENCY inProfile:aDict]];
[self setBlend:[iTermProfilePreferences floatForKey:KEY_BLEND inProfile:aDict]];

// bold
Expand Down Expand Up @@ -2655,7 +2659,7 @@ - (void)setMinimumContrast:(float)value

// Changes transparency

- (float)transparency
- (double)transparency
{
return [_textview transparency];
}
Expand All @@ -2669,13 +2673,48 @@ - (void)setTransparency:(float)transparency
[_textview setTransparency:transparency];
}

- (float)blend
- (double)inactiveTransparency {
return [_textview inactiveTransparency];
}

- (void)setInactiveTransparency:(float)inactiveTransparency {
// Limit transparency because fully transparent windows can't be clicked on.
if (inactiveTransparency > 0.9) {
inactiveTransparency = 0.9;
}
[_textview setInactiveTransparency:inactiveTransparency];
}

- (BOOL)useInactiveTransparency {
return [_textview useInactiveTransparency];
}

- (void)setUseInactiveTransparency:(BOOL)useInactiveTransparency {
[_textview setUseInactiveTransparency:useInactiveTransparency];
}

- (BOOL)inactiveBlur {
return [iTermProfilePreferences boolForKey:KEY_INACTIVE_BLUR inProfile:_profile];
}

- (BOOL)blur {
return [iTermProfilePreferences boolForKey:KEY_BLUR inProfile:_profile];
}

- (double)inactiveBlurRadius {
return [iTermProfilePreferences floatForKey:KEY_INACTIVE_BLUR_RADIUS inProfile:_profile];
}

- (double)blurRadius {
return [iTermProfilePreferences floatForKey:KEY_BLUR_RADIUS inProfile:_profile];
}

- (double)blend
{
return [_textview blend];
}

- (void)setBlend:(float)blendVal
{
- (void)setBlend:(double)blendVal {
[_textview setBlend:blendVal];
}

Expand Down Expand Up @@ -4648,7 +4687,7 @@ - (NSImage *)patternedImage {
- (void)textViewDrawBackgroundImageInView:(NSView *)view
viewRect:(NSRect)rect
blendDefaultBackground:(BOOL)blendDefaultBackground {
const float alpha = _textview.useTransparency ? (1.0 - _textview.transparency) : 1.0;
float alpha = [_textview transparencyAlpha];
if (_backgroundImage) {
NSRect localRect = [_view convertRect:rect fromView:view];
NSImage *image;
Expand Down
2 changes: 1 addition & 1 deletion sources/PTYTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
- (PTYSession*)sessionBelow:(PTYSession*)session;
- (BOOL)canSplitVertically:(BOOL)isVertical withSize:(NSSize)newSessionSize;
- (NSImage*)image:(BOOL)withSpaceForFrame;
- (bool)blur;
- (BOOL)blur;
- (double)blurRadius;
- (void)recheckBlur;

Expand Down
78 changes: 57 additions & 21 deletions sources/PTYTab.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ - (id)initWithSession:(PTYSession*)session
activeSession_ = session;
[session setActivityCounter:@(_activityCounter++)];
[[session view] setDimmed:NO];
[[session tab] recheckBlur];
[self setRoot:[[[PTYSplitView alloc] init] autorelease]];
PTYTab *oldTab = [session tab];
if (oldTab && [oldTab tmuxWindow] >= 0) {
Expand Down Expand Up @@ -360,7 +361,7 @@ - (void)setActiveSession:(PTYSession*)session updateActivityCounter:(BOOL)update
// a invisible textview the first responder.
[[realParentWindow_ window] makeFirstResponder:[session textview]];
}
[realParentWindow_ setDimmingForSessions];
[realParentWindow_ updateDimAndBlurForSessions];
}
for (PTYSession* aSession in [self sessions]) {
[[aSession textview] refresh];
Expand Down Expand Up @@ -1855,51 +1856,86 @@ - (NSSize)_minSizeOfView:(NSView*)view
}

// Blur the window if any session is blurred.
- (bool)blur
{
int n = 0;
int y = 0;
- (BOOL)blur {
NSArray* sessions = [self sessions];
for (PTYSession* session in sessions) {
if ([session transparency] > 0 &&
[[session textview] useTransparency] &&
[[[session profile] objectForKey:KEY_BLUR] boolValue]) {
++y;
} else {
++n;
return YES;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

}
}
return y > 0;
return NO;
}

- (double)blurRadius
{
- (double)averageBlurRadiusForInactive:(BOOL)inactive {
double sum = 0;
double count = 0;
NSArray* sessions = [self sessions];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before *, also on next line

for (PTYSession* session in sessions) {
if ([[[session profile] objectForKey:KEY_BLUR] boolValue]) {
sum += [[session profile] objectForKey:KEY_BLUR_RADIUS] ? [[[session profile] objectForKey:KEY_BLUR_RADIUS] floatValue] : 2.0;
BOOL useBlur = inactive ? [session inactiveBlur] : [session blur];
if (useBlur) {
double blurRadius = inactive ? [session inactiveBlurRadius] : [session blurRadius];
sum += blurRadius;
++count;
}
}
if (count > 0) {
return sum / count;
} else {
// This shouldn't actually happen, but better save than divide by zero.
// This shouldn't actually happen, but better safe than divide by zero.
return 2.0;
}
}

- (void)recheckBlur
{
- (double)blurRadius {
return [self averageBlurRadiusForInactive:NO];
}

- (BOOL)useInactiveTransparency {
NSArray *sessions = [self sessions];
for (PTYSession *session in sessions) {
if ([[session textview] useInactiveTransparency]) {
return YES;
}
}
return NO;
}

- (BOOL)inactiveBlur {
NSArray* sessions = [self sessions];
for (PTYSession* session in sessions) {
if ([session inactiveTransparency] > 0 &&
[session useInactiveTransparency] &&
[session inactiveBlur]) {
return YES;
}
}
return NO;
}

- (double)inactiveBlurRadius {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of duplicated code with -blurRadius. Please refactor into a common method like
- (double)averageBlurRadiusForInactive:(BOOL)inactive

return [self averageBlurRadiusForInactive:YES];
}

- (void)recheckBlur {
PtyLog(@"PTYTab recheckBlur");
if ([realParentWindow_ currentTab] == self &&
![[realParentWindow_ window] isMiniaturized]) {
if ([self blur]) {
[parentWindow_ enableBlur:[self blurRadius]];
if ([[[self realParentWindow] window] isKeyWindow]) {
if ([self blur]) {
[parentWindow_ enableBlur:[self blurRadius]];
} else {
[parentWindow_ disableBlur];
}
} else {
[parentWindow_ disableBlur];
if ([self inactiveBlur]) {
[parentWindow_ enableBlur:[self inactiveBlurRadius]];
} else if (![self useInactiveTransparency] && [self blur]) {
[parentWindow_ enableBlur:[self blurRadius]];
} else {
[parentWindow_ disableBlur];
}
}
}
}
Expand Down Expand Up @@ -2271,7 +2307,7 @@ - (void)addToTerminal:(NSWindowController<iTermWindowController> *)term
}

[self numberOfSessionsDidChange];
[term setDimmingForSessions];
[term updateDimAndBlurForSessions];
[term updateTabColors];
}

Expand Down Expand Up @@ -3006,7 +3042,7 @@ - (void)replaceViewHierarchyWithParseTree:(NSMutableDictionary *)parseTree
[realParentWindow_ tmuxTabLayoutDidChange:YES];
[realParentWindow_ endTmuxOriginatedResize];
--tmuxOriginatedResizeInProgress_;
[realParentWindow_ setDimmingForSessions];
[realParentWindow_ updateDimAndBlurForSessions];
}

- (void)setTmuxLayout:(NSMutableDictionary *)parseTree
Expand Down
11 changes: 11 additions & 0 deletions sources/PTYTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,16 @@ typedef enum {
// Transparency level. 0 to 1.
@property(nonatomic, assign) double transparency;

// Inactive Window Transparency level. 0 to 1.
@property(nonatomic, assign) double inactiveTransparency;

// Blending level for background color over background image
@property(nonatomic, assign) double blend;

// Should transparency be used?
@property(nonatomic, readonly) BOOL useTransparency;
@property(nonatomic, readonly) BOOL useInactiveTransparency;
@property(nonatomic, readonly) BOOL windowInactive;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this isn't used externally it can be removed.


// Indicates if the last key pressed was a repeat.
@property(nonatomic, readonly) BOOL keyIsARepeat;
Expand Down Expand Up @@ -419,5 +424,11 @@ typedef enum {
prefix:(NSString *)prefix
suffix:(NSString *)suffix;

// Get the transparency value for view based on if this window is key or not.
- (double)transparencyAlpha;

// Allow a special transparency for inactive windows.
- (void)setUseInactiveTransparency:(BOOL)useInactiveTransparency;

@end

Loading