@@ -420,6 +420,7 @@ - (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
420
420
vimView.pendingLiveResize = NO ;
421
421
if (blockRenderUntilResize) {
422
422
blockRenderUntilResize = NO ;
423
+ blockedRenderTextViewFrame = NSZeroRect ;
423
424
[vimView.textView setDrawRectOffset: NSZeroSize ];
424
425
}
425
426
if (vimView.pendingLiveResizeQueued ) {
@@ -506,6 +507,9 @@ - (void)resizeVimViewBlockRender
506
507
shouldResizeVimView = YES ;
507
508
shouldKeepGUISize = YES ;
508
509
blockRenderUntilResize = YES ;
510
+ blockedRenderTextViewFrame = [self .window convertRectToScreen:
511
+ [vimView convertRect: vimView.textView.frame
512
+ toView: nil ]];
509
513
if (!vimController.isHandlingInputQueue )
510
514
[self processInputQueueDidFinish ];
511
515
}
@@ -884,7 +888,6 @@ - (void)processInputQueueDidFinish
884
888
885
889
const int oldTextViewRows = vimView.textView .pendingMaxRows ;
886
890
const int oldTextViewCols = vimView.textView .pendingMaxColumns ;
887
- const NSRect oldTextViewFrame = vimView.textView .frame ;
888
891
BOOL vimViewSizeChanged = NO ;
889
892
890
893
// NOTE: If the window has not been presented then we must avoid resizing
@@ -899,8 +902,6 @@ - (void)processInputQueueDidFinish
899
902
// Setting 'guioptions+=k' will make shouldKeepGUISize true, which
900
903
// means avoid resizing the window. Instead, resize the view instead
901
904
// to keep the GUI window's size consistent.
902
- // Note: Vim should always have requested shouldKeepGUISize to be true
903
- // when in full screen, but we check for it anyway for safety.
904
905
bool avoidWindowResize = shouldKeepGUISize || fullScreenEnabled;
905
906
906
907
if (!avoidWindowResize) {
@@ -939,16 +940,18 @@ - (void)processInputQueueDidFinish
939
940
940
941
if (blockRenderUntilResize) {
941
942
if (vimViewSizeChanged) {
942
- const NSRect newTextViewFrame = vimView.textView .frame ;
943
+ const NSRect newTextViewFrame = [ self .window convertRectToScreen: [ vimView convertRect: vimView .textView.frame toView: nil ]] ;
943
944
944
945
// We are currently blocking all rendering to prevent flicker. If
945
- // the view frame moved (this happens if the tab or left scroll bar
946
- // were shown/ hidden) the user will see a temporary flicker as the
947
- // text view was moved before Vim has udpated us with new draw calls
946
+ // the view frame moved (this happens if say the tab bar was shown
947
+ // or hidden) the user will see a temporary flicker as the text
948
+ // view was moved before Vim has updated us with new draw calls
948
949
// to match the new size. To alleviate this, we temporarily apply
949
950
// a drawing offset in the text view to counter the offset. To the
950
951
// user it would appear that the text view hasn't moved at all.
951
- [vimView.textView setDrawRectOffset: NSMakeSize (NSMinX (oldTextViewFrame) - NSMinX (newTextViewFrame), NSMaxY (oldTextViewFrame) - NSMaxY (newTextViewFrame))];
952
+ [vimView.textView setDrawRectOffset:
953
+ NSMakeSize (NSMinX (blockedRenderTextViewFrame) - NSMinX (newTextViewFrame),
954
+ NSMaxY (blockedRenderTextViewFrame) - NSMaxY (newTextViewFrame))];
952
955
} else {
953
956
// We were blocking all rendering until Vim has been resized. However
954
957
// in situations where we turned out to not need to resize Vim to
@@ -959,6 +962,7 @@ - (void)processInputQueueDidFinish
959
962
// we need to resize) but turned out we set it to the same font so
960
963
// the grid size is the same and no need to resize.
961
964
blockRenderUntilResize = NO ;
965
+ blockedRenderTextViewFrame = NSZeroRect ;
962
966
[vimView.textView setDrawRectOffset: NSZeroSize ];
963
967
964
968
[vimController sendMessage: RedrawMsgID data: nil ];
@@ -1139,6 +1143,22 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back
1139
1143
// custom full-screen can appear on any screen, as opposed to native
1140
1144
// full-screen which always uses the main screen.)
1141
1145
if (windowPresented) {
1146
+ const BOOL shouldPreventFlicker = (fuoptions & FUOPT_MAXVERT) && (fuoptions & FUOPT_MAXHORZ);
1147
+ if (shouldPreventFlicker) {
1148
+ // Prevent visual flickering by temporarily blocking new render
1149
+ // until Vim has updated/resized itself.
1150
+ // We don't do the same when exiting full screen because when
1151
+ // going in this direction the flickering is less noticeable
1152
+ // and it looks odd when the user sees a clamped view.
1153
+ // Also, don't do this if maxvert/maxhorz not set because it
1154
+ // looks quite off in that situation as Vim is supposed to move
1155
+ // visually.
1156
+ blockRenderUntilResize = YES ;
1157
+ blockedRenderTextViewFrame = [decoratedWindow convertRectToScreen:
1158
+ [vimView convertRect: vimView.textView.frame
1159
+ toView: nil ]];
1160
+ }
1161
+
1142
1162
[fullScreenWindow enterFullScreen ];
1143
1163
fullScreenEnabled = YES ;
1144
1164
@@ -1149,8 +1169,6 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back
1149
1169
if (blurRadius != 0 )
1150
1170
[MMWindow setBlurRadius: blurRadius onWindow: fullScreenWindow];
1151
1171
1152
- // The resize handle disappears so the vim view needs to update the
1153
- // scrollbars.
1154
1172
shouldResizeVimView = YES ;
1155
1173
}
1156
1174
}
@@ -1664,8 +1682,6 @@ - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard
1664
1682
}
1665
1683
1666
1684
1667
- #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
1668
-
1669
1685
// -- Full-screen delegate ---------------------------------------------------
1670
1686
1671
1687
- (NSApplicationPresentationOptions )window : (NSWindow *)window
@@ -1795,8 +1811,6 @@ - (void)windowDidFailToExitFullScreen:(NSWindow *)window
1795
1811
[vimController addVimInput: @" <C-\\ ><C-N>:set fu<CR>" ];
1796
1812
}
1797
1813
1798
- #endif // (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
1799
-
1800
1814
- (void )runAfterWindowPresentedUsingBlock : (void (^)(void ))block
1801
1815
{
1802
1816
if (windowPresented) { // no need to defer block, just run it now
0 commit comments