From 2957a9049a443b47e66bee0ca8a607b183857a4d Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 13 Feb 2010 23:50:53 +0100 Subject: [PATCH] Allow window resizing across multiple screens It is now possible to drag to resize a window to be larger than one screen. However, if the window size changes programmatically (due to scrollbars or toolbar hiding/showing, etc.) then the window will be constrained to fit on the screen holding most of the window. This is perhaps annoying but at least it is consistent with the way Terminal.app works (try opening a new tab when a Terminal window spans two screens). --- src/MacVim/MMWindowController.m | 43 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 14c454eb..4909d71a 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -447,7 +447,8 @@ NSSize originalSize = [vimView frame].size; NSSize contentSize = [vimView desiredSize]; - contentSize = [self constrainContentSizeToScreenSize:contentSize]; + if (keepOnScreen) + contentSize = [self constrainContentSizeToScreenSize:contentSize]; contentSize = [vimView constrainRows:NULL columns:NULL toSize:contentSize]; [vimView setFrameSize:contentSize]; @@ -799,28 +800,6 @@ } } -- (NSSize)windowWillResize:(NSWindow *)win toSize:(NSSize)proposedFrameSize -{ - // Make sure the window isn't resized to be larger than the "visible frame" - // for the current screen. Do this here instead of setting the window max - // size in updateResizeConstraints since the screen's visible frame may - // change at any time (dock could move, resolution could change, window - // could be moved to another screen, ...). - if (![win screen]) - return proposedFrameSize; - - // NOTE: Not called in full-screen mode so use "visibleFrame" instead of - // "frame". - NSRect maxFrame = [self constrainFrame:[[win screen] visibleFrame]]; - - if (proposedFrameSize.width > maxFrame.size.width) - proposedFrameSize.width = maxFrame.size.width; - if (proposedFrameSize.height > maxFrame.size.height) - proposedFrameSize.height = maxFrame.size.height; - - return proposedFrameSize; -} - - (void)windowDidResize:(id)sender { if (!setupDone || fullscreenEnabled) return; @@ -968,8 +947,10 @@ shouldRestoreUserTopLeft = NO; } - if ([decoratedWindow screen]) { + if (onScreen && [decoratedWindow screen]) { // Ensure that the window fits inside the visible part of the screen. + // If there are more than one screen the window will be moved to fit + // entirely in the screen that most of it occupies. // NOTE: Not called in full-screen mode so use "visibleFrame' instead // of "frame". NSRect maxFrame = [[decoratedWindow screen] visibleFrame]; @@ -984,12 +965,14 @@ newFrame.origin.y = maxFrame.origin.y; } - if (onScreen) { - if (newFrame.origin.y < maxFrame.origin.y) - newFrame.origin.y = maxFrame.origin.y; - if (NSMaxX(newFrame) > NSMaxX(maxFrame)) - newFrame.origin.x = NSMaxX(maxFrame) - newFrame.size.width; - } + if (newFrame.origin.y < maxFrame.origin.y) + newFrame.origin.y = maxFrame.origin.y; + if (NSMaxY(newFrame) > NSMaxY(maxFrame)) + newFrame.origin.y = NSMaxY(maxFrame) - newFrame.size.height; + if (newFrame.origin.x < maxFrame.origin.x) + newFrame.origin.x = maxFrame.origin.x; + if (NSMaxX(newFrame) > NSMaxX(maxFrame)) + newFrame.origin.x = NSMaxX(maxFrame) - newFrame.size.width; } [decoratedWindow setFrame:newFrame display:YES]; -- 2.11.4.GIT