diff --git a/src/MacVim/MMVimView.h b/src/MacVim/MMVimView.h index 002ce9df70..ba04f90553 100644 --- a/src/MacVim/MMVimView.h +++ b/src/MacVim/MMVimView.h @@ -27,6 +27,7 @@ NSMutableArray *scrollbars; } +@property BOOL pendingPlaceScrollbars; @property BOOL pendingLiveResize; - (MMVimView *)initWithFrame:(NSRect)frame vimController:(MMVimController *)c; @@ -51,6 +52,7 @@ - (void)setScrollbarThumbValue:(float)val proportion:(float)prop identifier:(int32_t)ident; - (void)setScrollbarPosition:(int)pos length:(int)len identifier:(int32_t)ident; +- (void)finishPlaceScrollbars; - (void)setDefaultColorsBackground:(NSColor *)back foreground:(NSColor *)fore; diff --git a/src/MacVim/MMVimView.m b/src/MacVim/MMVimView.m index ef0e55fb30..127b381aff 100644 --- a/src/MacVim/MMVimView.m +++ b/src/MacVim/MMVimView.m @@ -198,9 +198,12 @@ - (void)drawRect:(NSRect)rect // looking tabs. However, the textured window background looks really // weird behind the window resize throbber, so emulate the look of an // NSScrollView in the bottom right corner. - if (![[self window] showsResizeIndicator] // XXX: make this a flag + if (![[self window] showsResizeIndicator] || !([[self window] styleMask] & NSWindowStyleMaskTexturedBackground)) return; + + // This should not be reachable in 10.7 or above and is deprecated code. + // See documentation for showsResizeIndicator and placeScrollbars: comments. #if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) int sw = [NSScroller scrollerWidthForControlSize:NSControlSizeRegular scrollerStyle:NSScrollerStyleLegacy]; @@ -389,7 +392,7 @@ - (void)selectTabWithIndex:(int)idx vimTaskSelectedTab = NO; // We might need to change the scrollbars that are visible. - [self placeScrollbars]; + self.pendingPlaceScrollbars = YES; } } @@ -424,6 +427,8 @@ - (void)createScrollbarWithIdentifier:(int32_t)ident type:(int)type [self addSubview:scroller]; [scrollbars addObject:scroller]; [scroller release]; + + self.pendingPlaceScrollbars = YES; } - (BOOL)destroyScrollbarWithIdentifier:(int32_t)ident @@ -434,6 +439,8 @@ - (BOOL)destroyScrollbarWithIdentifier:(int32_t)ident [scroller removeFromSuperview]; [scrollbars removeObjectAtIndex:idx]; + + self.pendingPlaceScrollbars = YES; // If a visible scroller was removed then the vim view must resize. This // is handled by the window controller (the vim view never resizes itself). @@ -447,6 +454,8 @@ - (BOOL)showScrollbarWithIdentifier:(int32_t)ident state:(BOOL)visible BOOL wasVisible = ![scroller isHidden]; [scroller setHidden:!visible]; + + self.pendingPlaceScrollbars = YES; // If a scroller was hidden or shown then the vim view must resize. This // is handled by the window controller (the vim view never resizes itself). @@ -483,10 +492,16 @@ - (void)setScrollbarPosition:(int)pos length:(int)len identifier:(int32_t)ident NSRange range = NSMakeRange(pos, len); if (!NSEqualRanges(range, [scroller range])) { [scroller setRange:range]; - // TODO! Should only do this once per update. - // This could be sent because a text window was created or closed, so // we might need to update which scrollbars are visible. + } + self.pendingPlaceScrollbars = YES; +} + +- (void)finishPlaceScrollbars +{ + if (self.pendingPlaceScrollbars) { + self.pendingPlaceScrollbars = NO; [self placeScrollbars]; } } @@ -789,7 +804,7 @@ - (void)placeScrollbars // Vertical scrollers must not cover the resize box in the // bottom-right corner of the window. - if ([[self window] showsResizeIndicator] // XXX: make this a flag + if ([[self window] showsResizeIndicator] // Note: This is deprecated as of 10.7, see below comment. && rect.origin.y < scrollerWidth) { rect.size.height -= scrollerWidth - rect.origin.y; rect.origin.y = scrollerWidth; @@ -914,7 +929,7 @@ - (void)frameSizeMayHaveChanged:(BOOL)keepGUISize NSRect textViewRect = [self textViewRectForVimViewSize:[self frame].size]; [textView setFrame:textViewRect]; - [self placeScrollbars]; + self.pendingPlaceScrollbars = YES; // It is possible that the current number of (rows,columns) is too big or // too small to fit the new frame. If so, notify Vim that the text diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 9e2bcf4e1d..2d72d2d0a3 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -661,6 +661,11 @@ - (void)processInputQueueDidFinish keepOnScreen = NO; shouldKeepGUISize = NO; } + + // Tell Vim view to update its scrollbars which is done once per update. + // Do it last so whatever resizing we have done above will take effect + // immediate too instead of waiting till next frame. + [vimView finishPlaceScrollbars]; } - (void)showTabBar:(BOOL)on