From b0c56a8a5b0637a1af9f5b9745f8f87d053210f7 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 16 Feb 2008 19:55:44 +0100 Subject: [PATCH] Add MMZoomBoth user default If MMZoomBoth user default is enabled, then the green zoom button will maximize horizontally as well as vertically. --- runtime/doc/gui_mac.txt | 1 + src/MacVim/MMAppController.m | 1 + src/MacVim/MMWindowController.m | 19 ++++++++++++------- src/MacVim/MacVim.h | 1 + src/MacVim/MacVim.m | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/runtime/doc/gui_mac.txt b/runtime/doc/gui_mac.txt index 88ea5f76..d98e4a3d 100644 --- a/runtime/doc/gui_mac.txt +++ b/runtime/doc/gui_mac.txt @@ -230,6 +230,7 @@ MMTextInsetRight text area offset in pixels [int] MMTextInsetTop text area offset in pixels [int] MMTexturedWindow use brushed metal window (Tiger only) [bool] MMTranslateCtrlClick interpret ctrl-click as right-click [bool] +MMZoomBoth zoom button maximizes both directions [bool] As an example, if you have more than one mouse button and would wish to free up Ctrl-click so you can bind it to something else, then the appropriate diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index ea3e2f16..05d2cd4c 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -115,6 +115,7 @@ typedef struct [NSNumber numberWithInt:MMUntitledWindowAlways], MMUntitledWindowKey, [NSNumber numberWithBool:NO], MMTexturedWindowKey, + [NSNumber numberWithBool:NO], MMZoomBothKey, nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dict]; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 3a284936..38b8d3a2 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -683,14 +683,19 @@ defaultFrame:(NSRect)frame { // Keep old width and horizontal position unless user clicked while the - // Command key is held down. + // Command key is held down, or if the MMZoomBoth user default is set. + NSEvent *event = [NSApp currentEvent]; - if (!([event type] == NSLeftMouseUp - && [event modifierFlags] & NSCommandKeyMask)) { - NSRect currentFrame = [win frame]; - frame.size.width = currentFrame.size.width; - frame.origin.x = currentFrame.origin.x; - } + BOOL cmdLeftClick = [event type] == NSLeftMouseUp + && [event modifierFlags] & NSCommandKeyMask; + BOOL zoomBoth = [[NSUserDefaults standardUserDefaults] + boolForKey:MMZoomBothKey]; + if (zoomBoth || cmdLeftClick) + return frame; + + NSRect currentFrame = [win frame]; + frame.size.width = currentFrame.size.width; + frame.origin.x = currentFrame.origin.x; return frame; } diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index 4fc596ae..ebfcf854 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -220,6 +220,7 @@ extern NSString *MMLoginShellKey; extern NSString *MMAtsuiRendererKey; extern NSString *MMUntitledWindowKey; extern NSString *MMTexturedWindowKey; +extern NSString *MMZoomBothKey; // Enum for MMUntitledWindowKey enum { diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index 23566f77..8ec6aa5a 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -100,6 +100,7 @@ NSString *MMLoginShellKey = @"MMLoginShell"; NSString *MMAtsuiRendererKey = @"MMAtsuiRenderer"; NSString *MMUntitledWindowKey = @"MMUntitledWindow"; NSString *MMTexturedWindowKey = @"MMTexturedWindow"; +NSString *MMZoomBothKey = @"MMZoomBoth"; -- 2.11.4.GIT