From ea3c2ef74ab938fba5986740216ff6c2be52ddac Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sun, 23 Sep 2007 15:16:30 +0000 Subject: [PATCH] Fixed focus stealing bug git-svn-id: http://macvim.googlecode.com/svn/trunk@275 96c4425d-ca35-0410-94e5-3396d5c13a8f --- MMAppController.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/MMAppController.m b/MMAppController.m index 32ba89f3fe..496cf53f0f 100644 --- a/MMAppController.m +++ b/MMAppController.m @@ -119,7 +119,9 @@ static NSTimeInterval MMTerminateTimeout = 3; { // NOTE! This way it possible to start the app with the command-line // argument '-nowindow yes' and no window will be opened by default. - return ![[NSUserDefaults standardUserDefaults] boolForKey:MMNoWindowKey]; + untitledWindowOpening = + ![[NSUserDefaults standardUserDefaults] boolForKey:MMNoWindowKey]; + return untitledWindowOpening; } - (BOOL)applicationOpenUntitledFile:(NSApplication *)sender @@ -436,8 +438,14 @@ static NSTimeInterval MMTerminateTimeout = 3; [vimControllers addObject:vc]; // HACK! MacVim does not get activated if it is launched from the - // terminal, so we forcibly activate here. - [NSApp activateIgnoringOtherApps:YES]; + // terminal, so we forcibly activate here unless it is an untitled window + // opening (i.e. MacVim was opened from the Finder). Untitled windows are + // treated differently, else MacVim would steal the focus if another app + // was activated while the untitled window was loading. + if (!untitledWindowOpening) + [NSApp activateIgnoringOtherApps:YES]; + + untitledWindowOpening = NO; return vc; }