Skip to content

Commit 02ae966

Browse files
committed
Revert "Support guioptions 'k' flag in MacVim, prevents unnecessary window resize"
This reverts commit 1333bc6. The previous change broke external monitors and zoom button. Revert the change before a proper fix can be implemented.
1 parent d0807a4 commit 02ae966

12 files changed

Lines changed: 22 additions & 95 deletions

src/MacVim/MMBackend.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ extern NSTimeInterval MMBalloonEvalInternalDelay;
105105
- (BOOL)tabBarVisible;
106106
- (void)showTabBar:(BOOL)enable;
107107
- (void)setRows:(int)rows columns:(int)cols;
108-
- (void)resizeView;
109108
- (void)setWindowTitle:(char *)title;
110109
- (void)setDocumentFilename:(char *)filename;
111110
- (char *)browseForFileWithAttributes:(NSDictionary *)attr;

src/MacVim/MMBackend.m

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,6 @@ - (void)setRows:(int)rows columns:(int)cols
836836
[self queueMessage:SetTextDimensionsMsgID data:data];
837837
}
838838

839-
- (void)resizeView
840-
{
841-
[self queueMessage:ResizeViewMsgID data:nil];
842-
}
843-
844839
- (void)setWindowTitle:(char *)title
845840
{
846841
NSMutableData *data = [NSMutableData data];
@@ -2002,7 +1997,6 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
20021997

20031998
tabpage_move(idx);
20041999
} else if (SetTextDimensionsMsgID == msgid || LiveResizeMsgID == msgid
2005-
|| SetTextDimensionsNoResizeWindowMsgID == msgid
20062000
|| SetTextRowsMsgID == msgid || SetTextColumnsMsgID == msgid) {
20072001
if (!data) return;
20082002
const void *bytes = [data bytes];
@@ -2034,8 +2028,6 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
20342028
[self queueMessage:msgid data:d];
20352029

20362030
gui_resize_shell(cols, rows);
2037-
} else if (ResizeViewMsgID == msgid) {
2038-
[self queueMessage:msgid data:data];
20392031
} else if (ExecuteMenuMsgID == msgid) {
20402032
NSDictionary *attrs = [NSDictionary dictionaryWithData:data];
20412033
if (attrs) {

src/MacVim/MMVimController.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
629629
[windowController showTabBar:NO];
630630
[self sendMessage:BackingPropertiesChangedMsgID data:nil];
631631
} else if (SetTextDimensionsMsgID == msgid || LiveResizeMsgID == msgid ||
632-
SetTextDimensionsNoResizeWindowMsgID == msgid ||
633632
SetTextDimensionsReplyMsgID == msgid) {
634633
const void *bytes = [data bytes];
635634
int rows = *((int*)bytes); bytes += sizeof(int);
@@ -639,16 +638,11 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
639638
// acknowledges it with a reply message. When this happens the window
640639
// should not move (the frontend would already have moved the window).
641640
BOOL onScreen = SetTextDimensionsReplyMsgID!=msgid;
642-
643-
BOOL keepGUISize = SetTextDimensionsNoResizeWindowMsgID == msgid;
644641

645642
[windowController setTextDimensionsWithRows:rows
646643
columns:cols
647644
isLive:(LiveResizeMsgID==msgid)
648-
keepGUISize:keepGUISize
649645
keepOnScreen:onScreen];
650-
} else if (ResizeViewMsgID == msgid) {
651-
[windowController resizeView];
652646
} else if (SetWindowTitleMsgID == msgid) {
653647
const void *bytes = [data bytes];
654648
int len = *((int*)bytes); bytes += sizeof(int);

src/MacVim/MMVimView.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
- (void)viewWillStartLiveResize;
5656
- (void)viewDidEndLiveResize;
5757
- (void)setFrameSize:(NSSize)size;
58-
- (void)setFrameSizeKeepGUISize:(NSSize)size;
5958
- (void)setFrame:(NSRect)frame;
6059

6160
@end

src/MacVim/MMVimView.m

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ - (MMScroller *)scrollbarForIdentifier:(int32_t)ident index:(unsigned *)idx;
6060
- (NSSize)vimViewSizeForTextViewSize:(NSSize)textViewSize;
6161
- (NSRect)textViewRectForVimViewSize:(NSSize)contentSize;
6262
- (NSTabView *)tabView;
63-
- (void)frameSizeMayHaveChanged:(BOOL)keepGUISize;
63+
- (void)frameSizeMayHaveChanged;
6464
@end
6565

6666

@@ -610,25 +610,14 @@ - (void)setFrameSize:(NSSize)size
610610
// row will result in the vim view holding more rows than the can fit
611611
// inside the window.)
612612
[super setFrameSize:size];
613-
[self frameSizeMayHaveChanged:NO];
614-
}
615-
616-
- (void)setFrameSizeKeepGUISize:(NSSize)size
617-
{
618-
// NOTE: Instead of only acting when a frame was resized, we do some
619-
// updating each time a frame may be resized. (At the moment, if we only
620-
// respond to actual frame changes then typing ":set lines=1000" twice in a
621-
// row will result in the vim view holding more rows than the can fit
622-
// inside the window.)
623-
[super setFrameSize:size];
624-
[self frameSizeMayHaveChanged:YES];
613+
[self frameSizeMayHaveChanged];
625614
}
626615

627616
- (void)setFrame:(NSRect)frame
628617
{
629618
// See comment in setFrameSize: above.
630619
[super setFrame:frame];
631-
[self frameSizeMayHaveChanged:NO];
620+
[self frameSizeMayHaveChanged];
632621
}
633622

634623
@end // MMVimView
@@ -878,7 +867,7 @@ - (NSTabView *)tabView
878867
return tabView;
879868
}
880869

881-
- (void)frameSizeMayHaveChanged:(BOOL)keepGUISize
870+
- (void)frameSizeMayHaveChanged
882871
{
883872
// NOTE: Whenever a call is made that may have changed the frame size we
884873
// take the opportunity to make sure all subviews are in place and that the
@@ -914,7 +903,7 @@ - (void)frameSizeMayHaveChanged:(BOOL)keepGUISize
914903
if (constrained[0] != rows || constrained[1] != cols) {
915904
NSData *data = [NSData dataWithBytes:constrained length:2*sizeof(int)];
916905
int msgid = [self inLiveResize] ? LiveResizeMsgID
917-
: (keepGUISize ? SetTextDimensionsNoResizeWindowMsgID : SetTextDimensionsMsgID);
906+
: SetTextDimensionsMsgID;
918907

919908
ASLogDebug(@"Notify Vim that text dimensions changed from %dx%d to "
920909
"%dx%d (%s)", cols, rows, constrained[1], constrained[0],

src/MacVim/MMWindowController.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
BOOL setupDone;
2525
BOOL windowPresented;
2626
BOOL shouldResizeVimView;
27-
BOOL shouldKeepGUISize;
2827
BOOL shouldRestoreUserTopLeft;
2928
BOOL shouldMaximizeWindow;
3029
int updateToolbarFlag;
@@ -60,9 +59,7 @@
6059
- (void)updateTabsWithData:(NSData *)data;
6160
- (void)selectTabWithIndex:(int)idx;
6261
- (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
63-
keepGUISize:(BOOL)keepGUISize
6462
keepOnScreen:(BOOL)onScreen;
65-
- (void)resizeView;
6663
- (void)zoomWithRows:(int)rows columns:(int)cols state:(int)state;
6764
- (void)setTitle:(NSString *)title;
6865
- (void)setDocumentFilename:(NSString *)filename;

src/MacVim/MMWindowController.m

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ - (id)initWithVimController:(MMVimController *)controller
174174

175175
[win setDelegate:self];
176176
[win setInitialFirstResponder:[vimView textView]];
177-
177+
178178
if ([win styleMask] & NSWindowStyleMaskTexturedBackground) {
179179
// On Leopard, we want to have a textured window to have nice
180180
// looking tabs. But the textured window look implies rounded
@@ -381,7 +381,6 @@ - (void)selectTabWithIndex:(int)idx
381381
}
382382

383383
- (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
384-
keepGUISize:(BOOL)keepGUISize
385384
keepOnScreen:(BOOL)onScreen
386385
{
387386
ASLogDebug(@"setTextDimensionsWithRows:%d columns:%d isLive:%d "
@@ -400,7 +399,7 @@ - (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
400399

401400
[vimView setDesiredRows:rows columns:cols];
402401

403-
if (setupDone && !live && !keepGUISize) {
402+
if (setupDone && !live) {
404403
shouldResizeVimView = YES;
405404
keepOnScreen = onScreen;
406405
}
@@ -429,15 +428,6 @@ - (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live
429428
}
430429
}
431430

432-
- (void)resizeView
433-
{
434-
if (setupDone)
435-
{
436-
shouldResizeVimView = YES;
437-
shouldKeepGUISize = YES;
438-
}
439-
}
440-
441431
- (void)zoomWithRows:(int)rows columns:(int)cols state:(int)state
442432
{
443433
[self setTextDimensionsWithRows:rows
@@ -513,13 +503,19 @@ - (void)createScrollbarWithIdentifier:(int32_t)ident type:(int)type
513503
- (BOOL)destroyScrollbarWithIdentifier:(int32_t)ident
514504
{
515505
BOOL scrollbarHidden = [vimView destroyScrollbarWithIdentifier:ident];
506+
shouldResizeVimView = shouldResizeVimView || scrollbarHidden;
507+
shouldMaximizeWindow = shouldMaximizeWindow || scrollbarHidden;
508+
516509
return scrollbarHidden;
517510
}
518511

519512
- (BOOL)showScrollbarWithIdentifier:(int32_t)ident state:(BOOL)visible
520513
{
521514
BOOL scrollbarToggled = [vimView showScrollbarWithIdentifier:ident
522515
state:visible];
516+
shouldResizeVimView = shouldResizeVimView || scrollbarToggled;
517+
shouldMaximizeWindow = shouldMaximizeWindow || scrollbarToggled;
518+
523519
return scrollbarToggled;
524520
}
525521

@@ -604,18 +600,7 @@ - (void)processInputQueueDidFinish
604600
fullScreenWindow ? [fullScreenWindow frame].size :
605601
fullScreenEnabled ? desiredWindowSize :
606602
[self constrainContentSizeToScreenSize:[vimView desiredSize]]];
607-
608-
// Setting 'guioptions+=k' will make shouldKeepGUISize true, which
609-
// means avoid resizing the window. Instead, resize the view instead
610-
// to keep the GUI window's size consistent.
611-
bool avoidWindowResize = shouldKeepGUISize && !fullScreenEnabled;
612-
613-
if (!avoidWindowResize) {
614-
[vimView setFrameSize:contentSize];
615-
}
616-
else {
617-
[vimView setFrameSizeKeepGUISize:originalSize];
618-
}
603+
[vimView setFrameSize:contentSize];
619604

620605
if (fullScreenWindow) {
621606
// NOTE! Don't mark the full-screen content view as needing an
@@ -628,15 +613,12 @@ - (void)processInputQueueDidFinish
628613
[fullScreenWindow centerView];
629614
}
630615
} else {
631-
if (!avoidWindowResize) {
632-
[self resizeWindowToFitContentSize:contentSize
633-
keepOnScreen:keepOnScreen];
634-
}
616+
[self resizeWindowToFitContentSize:contentSize
617+
keepOnScreen:keepOnScreen];
635618
}
636619
}
637620

638621
keepOnScreen = NO;
639-
shouldKeepGUISize = NO;
640622
}
641623
}
642624

@@ -675,13 +657,15 @@ - (void)adjustLinespace:(int)linespace
675657
{
676658
if (vimView && [vimView textView]) {
677659
[[vimView textView] setLinespace:(float)linespace];
660+
shouldMaximizeWindow = shouldResizeVimView = YES;
678661
}
679662
}
680663

681664
- (void)adjustColumnspace:(int)columnspace
682665
{
683666
if (vimView && [vimView textView]) {
684667
[[vimView textView] setColumnspace:(float)columnspace];
668+
shouldMaximizeWindow = shouldResizeVimView = YES;
685669
}
686670
}
687671

@@ -1203,7 +1187,7 @@ - (void)window:(NSWindow *)window
12031187
[[window animator] setAlphaValue:0];
12041188
} completionHandler:^{
12051189
[self maximizeWindow:fullScreenOptions];
1206-
1190+
12071191
// Fade in
12081192
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
12091193
[context setDuration:0.5*duration];
@@ -1222,7 +1206,7 @@ - (void)windowWillEnterFullScreen:(NSNotification *)notification
12221206

12231207
// The separator should never be visible in fullscreen or split-screen.
12241208
[decoratedWindow hideTablineSeparator:YES];
1225-
1209+
12261210
// ASSUMPTION: fullScreenEnabled always reflects the state of Vim's 'fu'.
12271211
if (!fullScreenEnabled) {
12281212
ASLogDebug(@"Full-screen out of sync, tell Vim to set 'fu'");
@@ -1324,7 +1308,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification
13241308
// full-screen by moving the window out from Split View.
13251309
[vimController sendMessage:BackingPropertiesChangedMsgID data:nil];
13261310
}
1327-
1311+
13281312
[self updateTablineSeparator];
13291313
}
13301314

@@ -1552,6 +1536,7 @@ - (void)hideTablineSeparator:(BOOL)hide
15521536
// The tabline separator was toggled so the content view must change
15531537
// size.
15541538
[self updateResizeConstraints];
1539+
shouldResizeVimView = YES;
15551540
}
15561541
}
15571542

src/MacVim/MacVim.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,8 @@ enum {
176176
SetTextRowsMsgID,
177177
SetTextColumnsMsgID,
178178
SetTextDimensionsMsgID,
179-
SetTextDimensionsNoResizeWindowMsgID,
180179
LiveResizeMsgID,
181180
SetTextDimensionsReplyMsgID,
182-
ResizeViewMsgID,
183181
SetWindowTitleMsgID,
184182
ScrollWheelMsgID,
185183
MouseDownMsgID,

src/MacVim/MacVim.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@
3030
"SetTextRowsMsgID",
3131
"SetTextColumnsMsgID",
3232
"SetTextDimensionsMsgID",
33-
"SetTextDimensionsNoResizeWindowMsgID",
3433
"LiveResizeMsgID",
3534
"SetTextDimensionsReplyMsgID",
36-
"ResizeViewMsgID",
3735
"SetWindowTitleMsgID",
3836
"ScrollWheelMsgID",
3937
"MouseDownMsgID",

src/MacVim/gui_macvim.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,18 +1739,6 @@
17391739
}
17401740

17411741

1742-
/*
1743-
* Re-calculates size of the Vim view to fit within the window without having
1744-
* to resize the window. Usually happens after UI elements have changed (e.g.
1745-
* adding / removing a toolbar) when guioptions 'k' is set.
1746-
*/
1747-
void
1748-
gui_mch_resize_view()
1749-
{
1750-
[[MMBackend sharedInstance] resizeView];
1751-
}
1752-
1753-
17541742
/*
17551743
* Set the position of the top left corner of the window to the given
17561744
* coordinates.

0 commit comments

Comments
 (0)