From 6d2e8f8dca684a8162bcad802c7179906acee62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sidney=20San=20Mart=C3=ADn?= Date: Mon, 3 Apr 2017 14:25:35 -0400 Subject: [PATCH] Choose how to resize the Vim view based on the full screen mode. - Native full screen: Use the last externally-set window size. This lets Split View work without slowly growing or shrinking. - Non-native full screen: Use the size of the full screen window. - Not full screen: Use [vimView desiredSize] (unchanged). This is somewhat nasty, but the different full screen code paths behave differently enough that there doesn't seem to be one universally-correct answer. It would be great to simplify them. --- src/MacVim/MMWindowController.h | 1 + src/MacVim/MMWindowController.m | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/MacVim/MMWindowController.h b/src/MacVim/MMWindowController.h index 26feb38774..8c92ed537d 100644 --- a/src/MacVim/MMWindowController.h +++ b/src/MacVim/MMWindowController.h @@ -40,6 +40,7 @@ int userCols; NSPoint userTopLeft; NSPoint defaultTopLeft; + NSSize desiredWindowSize; NSToolbar *toolbar; BOOL resizingDueToMove; int blurRadius; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 8a966793b2..25ccffeb96 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -594,11 +594,12 @@ // TODO: What if the resize message fails to make it back? if (!didMaximize) { NSSize originalSize = [vimView frame].size; - NSSize contentSize = [vimView desiredSize]; - contentSize = [self constrainContentSizeToScreenSize:contentSize]; int rows = 0, cols = 0; - contentSize = [vimView constrainRows:&rows columns:&cols - toSize:contentSize]; + NSSize contentSize = [vimView constrainRows:&rows columns:&cols + toSize: + fullScreenWindow ? [fullScreenWindow frame].size : + fullScreenEnabled ? desiredWindowSize : + [self constrainContentSizeToScreenSize:[vimView desiredSize]]]; [vimView setFrameSize:contentSize]; if (fullScreenWindow) { @@ -1003,6 +1004,11 @@ [vimController sendMessage:SetWindowPositionMsgID data:data]; } +- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize { + desiredWindowSize = frameSize; + return frameSize; +} + - (void)windowDidResize:(id)sender { if (resizingDueToMove) {