Skip to content

Commit

Permalink
Only cascade from windows belonging to Vim process
Browse files Browse the repository at this point in the history
This ensures that a newly opened window isn't cascaded from e.g. the
preferences panel.
  • Loading branch information
b4winckler committed Apr 6, 2008
1 parent 296634f commit 6e8e205
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/MacVim/MMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,15 @@ - (void)removeVimController:(id)controller
- (void)windowControllerWillOpen:(MMWindowController *)windowController
{
NSPoint topLeft = NSZeroPoint;
NSWindow *keyWin = [NSApp keyWindow];
NSWindow *topWin = [[[self topmostVimController] windowController] window];
NSWindow *win = [windowController window];

if (!win) return;

// If there is a key window, cascade from it, otherwise use the autosaved
// window position (if any).
if (keyWin) {
NSRect frame = [keyWin frame];
// If there is a window belonging to a Vim process, cascade from it,
// otherwise use the autosaved window position (if any).
if (topWin) {
NSRect frame = [topWin frame];
topLeft = NSMakePoint(frame.origin.x, NSMaxY(frame));
} else {
NSString *topLeftString = [[NSUserDefaults standardUserDefaults]
Expand All @@ -487,7 +487,7 @@ - (void)windowControllerWillOpen:(MMWindowController *)windowController
}

if (!NSEqualPoints(topLeft, NSZeroPoint)) {
if (keyWin)
if (topWin)
topLeft = [win cascadeTopLeftFromPoint:topLeft];

[win setFrameTopLeftPoint:topLeft];
Expand Down

0 comments on commit 6e8e205

Please sign in to comment.