From e12a38b992ee38cd7fabc6d4e0109b76b85bd917 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Wed, 8 Aug 2007 12:00:17 +0000 Subject: [PATCH] - Added processCommandQueueDidFinish notification to MMWindowController - Window resizing is delayed until processCommandQueueDidFinish (no more need for performSelectionOnMainThread:::) git-svn-id: http://macvim.googlecode.com/svn/trunk@102 96c4425d-ca35-0410-94e5-3396d5c13a8f --- MMVimController.m | 11 +++-------- MMWindowController.h | 2 ++ MMWindowController.m | 44 +++++++++++++++++++++++++++++++------------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/MMVimController.m b/MMVimController.m index f22306bdbe..a4f955f013 100644 --- a/MMVimController.m +++ b/MMVimController.m @@ -213,6 +213,8 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag) [self updateMainMenu]; } + [windowController processCommandQueueDidFinish]; + inProcessCommandQueue = NO; count = [sendQueue count]; @@ -301,14 +303,7 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag) [windowController updateTabsWithData:data]; } else if (ShowTabBarMsgID == msgid) { //NSLog(@"Showing tab bar"); - - // HACK! Vim sends several draw commands etc. after the show message - // and these can mess up the display when showing the tab bar results - // in the window having to resize to fit the screen; delaying this - // message alleviates this problem. - [windowController performSelectorOnMainThread:@selector(showTabBar:) - withObject:self waitUntilDone:NO]; - //[windowController showTabBar:self]; + [windowController showTabBar:self]; } else if (HideTabBarMsgID == msgid) { //NSLog(@"Hiding tab bar"); [windowController hideTabBar:self]; diff --git a/MMWindowController.h b/MMWindowController.h index 69c95ec3e6..144c2f43a2 100644 --- a/MMWindowController.h +++ b/MMWindowController.h @@ -31,6 +31,7 @@ MMTextStorage *textStorage; NSMutableArray *scrollbars; BOOL setupDone; + BOOL shouldUpdateWindowSize; } - (id)initWithVimController:(MMVimController *)controller; @@ -51,6 +52,7 @@ identifier:(long)ident; - (void)setDefaultColorsBackground:(NSColor *)back foreground:(NSColor *)fore; - (void)setFont:(NSFont *)font; +- (void)processCommandQueueDidFinish; - (IBAction)addNewTab:(id)sender; - (IBAction)showTabBar:(id)sender; diff --git a/MMWindowController.m b/MMWindowController.m index 0e330f56c8..8bc91167b5 100644 --- a/MMWindowController.m +++ b/MMWindowController.m @@ -304,7 +304,7 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) [textStorage setMaxRows:rows columns:cols]; if (setupDone && ![textView inLiveResize]) - [self resizeWindowToFit:self]; + shouldUpdateWindowSize = YES; } - (void)setStatusText:(NSString *)text @@ -361,9 +361,9 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) if (![scroller isHidden]) { // A visible scroller was removed, so the window must resize to // fit. - // TODO! Should only do this once per update. - [self performSelectorOnMainThread:@selector(resizeWindowToFit:) - withObject:self waitUntilDone:NO]; + //NSLog(@"Visible scroller %d was destroyed, resizing window.", + // ident); + shouldUpdateWindowSize = YES; } } } @@ -380,10 +380,9 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) if (wasVisible != visible) { // A scroller was hidden or shown, so the window must resize to fit. - //NSLog(@"%s scroller %d", visible ? "Show" : "Hide", ident); - // TODO! Should only do this once per update. - [self performSelectorOnMainThread:@selector(resizeWindowToFit:) - withObject:self waitUntilDone:NO]; + //NSLog(@"%s scroller %d and resize.", visible ? "Show" : "Hide", + // ident); + shouldUpdateWindowSize = YES; } } @@ -421,6 +420,14 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) [self updateResizeIncrements]; } +- (void)processCommandQueueDidFinish +{ + if (shouldUpdateWindowSize) { + shouldUpdateWindowSize = NO; + [self resizeWindowToFit:self]; + } +} + - (IBAction)addNewTab:(id)sender { // NOTE! This can get called a lot if the user holds down the key @@ -435,7 +442,7 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) [tabBarControl setHidden:NO]; if (setupDone) - [self resizeWindowToFit:self]; + shouldUpdateWindowSize = YES; } - (IBAction)hideTabBar:(id)sender @@ -444,10 +451,12 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) [tabBarControl setHidden:YES]; if (setupDone) - [self resizeWindowToFit:self]; + shouldUpdateWindowSize = YES; } + + // -- PSMTabBarControl delegate ---------------------------------------------- @@ -559,6 +568,11 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) return frame; } + + + +// -- Services menu delegate ------------------------------------------------- + - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { @@ -567,9 +581,11 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) id backendProxy = [vimController backendProxy]; if ((!sendType || [sendType isEqual:NSStringPboardType]) - && (!returnType || [returnType isEqual:NSStringPboardType])) { - if ((!sendType || [backendProxy starRegisterToPasteboard:nil]) - && (!returnType || [backendProxy starRegisterFromPasteboard:nil])) { + && (!returnType || [returnType isEqual:NSStringPboardType])) + { + if ((!sendType || [backendProxy starRegisterToPasteboard:nil]) && + (!returnType || [backendProxy starRegisterFromPasteboard:nil])) + { return self; } } @@ -697,6 +713,8 @@ NSMutableArray *buildMenuAddress(NSMenu *menu) frame = [self fitWindowToFrame:maxFrame]; } + //NSLog(@"%s %@", _cmd, NSStringFromRect(frame)); + // HACK! If the window does resize, then windowDidResize is called which in // turn calls placeViews. In case the computed new size of the window is // no different from the current size, then we need to call placeViews