Skip to content

Commit 32e1fc9

Browse files
committed
Fix artifacts when entering full screen.
This changes MMFullScreenWindow to release the fade in a completion handler for the current transaction, so that the app flushes updates while the screen is black. It also fixes up the fadeReservationTime math and bumps the slack to a full second so that a slightly slow draw doesn't cause artifacts (in practice, the fade will be released as soon as the window draws — the reservation time is just a failsafe).
1 parent 98496b9 commit 32e1fc9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/MacVim/MMFullScreenWindow.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ - (MMFullScreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v
110110
// Each fade goes in and then out, so the fade hardware must be reserved accordingly and the
111111
// actual fade time can't exceed half the allowable reservation time... plus some slack to
112112
// prevent visual artifacts caused by defaulting on the fade hardware lease.
113-
fadeTime = MIN(fadeTime, 0.45 * kCGMaxDisplayReservationInterval);
114-
fadeReservationTime = 2.0 * fadeTime + 0.1;
113+
fadeTime = MIN(fadeTime, 0.5 * (kCGMaxDisplayReservationInterval - 1));
114+
fadeReservationTime = 2.0 * fadeTime + 1;
115115

116116
return self;
117117
}
@@ -218,9 +218,11 @@ - (void)enterFullScreen
218218

219219
// fade back in
220220
if (didBlend) {
221-
CGDisplayFade(token, fadeTime, kCGDisplayBlendSolidColor,
222-
kCGDisplayBlendNormal, .0, .0, .0, false);
223-
CGReleaseDisplayFadeReservation(token);
221+
[NSAnimationContext currentContext].completionHandler = ^{
222+
CGDisplayFade(token, fadeTime, kCGDisplayBlendSolidColor,
223+
kCGDisplayBlendNormal, .0, .0, .0, false);
224+
CGReleaseDisplayFadeReservation(token);
225+
};
224226
}
225227

226228
state = InFullScreen;

0 commit comments

Comments
 (0)