Skip to content
Snippets Groups Projects
Commit 6e5844bd authored by George Nachman's avatar George Nachman
Browse files

Fix a bug where full-screen flash would sometimes not draw a full frame...

Fix a bug where full-screen flash would sometimes not draw a full frame without any flash. What would happen is that further updates were canceled from within drawRect:, but if the rect being drawn were small and ill-timed, most of the screen would never get redrawn. Now, a call to setNeedsDisplay:YES always gets made after the alpha reaches 0.
parent d2cbe752
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -21,6 +21,7 @@ NSString *const kiTermIndicatorAlert = @"kiTermIndicatorAlert";
NSString *const kiTermIndicatorAllOutputSuppressed = @"kiTermIndicatorAllOutputSuppressed";
NSString *const kiTermIndicatorZoomedIn = @"kiTermIndicatorZoomedIn";
 
static const NSTimeInterval kFullScreenFlashDuration = 0.3;
static const NSTimeInterval kFlashDuration = 0.3;
CGFloat kiTermIndicatorStandardHeight = 20;
 
Loading
Loading
@@ -57,6 +58,9 @@ CGFloat kiTermIndicatorStandardHeight = 20;
NSTimeInterval _fullScreenFlashStartTime;
// Rate limits calls to setNeedsDisplay: to not be faster than drawRect can be called.
BOOL _haveSetNeedsDisplay;
// Alpha value for fullscreen flash.
CGFloat _fullScreenAlpha;
}
 
+ (NSDictionary *)indicatorImages {
Loading
Loading
@@ -167,17 +171,13 @@ CGFloat kiTermIndicatorStandardHeight = 20;
 
// Draw full screen flash.
NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _fullScreenFlashStartTime;
const CGFloat kMaxFullScreenFlashAlpha = 0.5;
static const NSTimeInterval kFullScreenFlashDuration = 0.3;
CGFloat fullScreenAlpha = MAX(0, 1.0 - elapsed / kFullScreenFlashDuration) * kMaxFullScreenFlashAlpha;
DLog(@"elapsed=%@, fullScreenAlpha=%@", @(elapsed), @(fullScreenAlpha));
if (fullScreenAlpha > 0) {
DLog(@"elapsed=%@, fullScreenAlpha=%@", @(elapsed), @(_fullScreenAlpha));
if (_fullScreenAlpha > 0) {
DLog(@"Drawing full screen flash overlay");
[[[_delegate indicatorFullScreenFlashColor] colorWithAlphaComponent:fullScreenAlpha] set];
[[[_delegate indicatorFullScreenFlashColor] colorWithAlphaComponent:_fullScreenAlpha] set];
NSRectFillUsingOperation(frame, NSCompositeSourceOver);
} else if (_fullScreenFlashStartTime > 0 && fullScreenAlpha == 0) {
DLog(@"Not drawing full screen flash overlay and resetting fullScreenFlashStartTime");
_fullScreenFlashStartTime = 0;
} else if (_fullScreenFlashStartTime > 0 && _fullScreenAlpha == 0) {
DLog(@"Not drawing full screen flash overlay");
}
DLog(@"Set haveSetNeedsDisplay=NO");
_haveSetNeedsDisplay = NO;
Loading
Loading
@@ -186,13 +186,23 @@ CGFloat kiTermIndicatorStandardHeight = 20;
- (void)checkForFlashUpdate {
DLog(@"Check for flash update. full screen flash start time is %@, haveSetNeedsDisplay=%@",
@(_fullScreenFlashStartTime), @(_haveSetNeedsDisplay));
NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _fullScreenFlashStartTime;
if (_fullScreenFlashStartTime > 0 || [self haveFlashingIndicator]) {
const CGFloat kMaxFullScreenFlashAlpha = 0.5;
_fullScreenAlpha = MAX(0, 1.0 - elapsed / kFullScreenFlashDuration) * kMaxFullScreenFlashAlpha;
DLog(@"Set fullScreenAlpha=%@", @(_fullScreenAlpha));
if (!_haveSetNeedsDisplay) {
DLog(@"Tell delegate %@ setNeedsDisplay", _delegate);
[_delegate setNeedsDisplay:YES];
}
DLog(@"Set haveSetNeedsDisplay=YES");
_haveSetNeedsDisplay = YES;
// Ensure that the screen gets redrawn with alpha = 0.
if (_fullScreenAlpha == 0) {
DLog(@"Reset fullScreenFlashStartTime");
_fullScreenFlashStartTime = 0;
}
}
 
// Remove any indicators that became invisible since the last check.
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment