Skip to content

Commit 4b43070

Browse files
authored
Merge pull request #1056 from ychin/add-titlebar-hidden-pref-panel
Add new appearance option for hiding title bar
2 parents 81627ee + 812dc65 commit 4b43070

File tree

6 files changed

+57
-23
lines changed

6 files changed

+57
-23
lines changed

src/MacVim/English.lproj/Preferences.nib/designable.nib

Lines changed: 22 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

src/MacVim/MMFullScreenWindow.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ - (void)enterFullScreen
191191
// we have to do it manually.
192192
[NSApp changeWindowsItem:self title:[target title] filename:NO];
193193
}
194+
195+
[self setAppearance:target.appearance];
194196

195197
[self setOpaque:[target isOpaque]];
196198

src/MacVim/MMVimController.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,7 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
686686
NSString *string = [[NSString alloc] initWithBytes:(void*)bytes
687687
length:len encoding:NSUTF8StringEncoding];
688688

689-
// While in live resize the window title displays the dimensions of the
690-
// window so don't clobber this with a spurious "set title" message
691-
// from Vim.
692-
if (![[windowController vimView] inLiveResize])
693-
[windowController setTitle:string];
689+
[windowController setTitle:string];
694690

695691
[string release];
696692
} else if (SetDocumentFilenameMsgID == msgid) {

src/MacVim/MMWindowController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
- (void)setScrollbarThumbValue:(float)val proportion:(float)prop
7676
identifier:(int32_t)ident;
7777

78+
- (unsigned int)calculateStyleMask;
7879
- (void)setBackgroundOption:(int)dark;
7980
- (void)refreshApperanceMode;
8081

src/MacVim/MMWindowController.m

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,17 @@ - (void)zoomWithRows:(int)rows columns:(int)cols state:(int)state
477477

478478
- (void)setTitle:(NSString *)title
479479
{
480+
// Save the original title, if we haven't already.
481+
[lastSetTitle release];
482+
lastSetTitle = [title retain];
483+
484+
// While in live resize the window title displays the dimensions of the
485+
// window so don't clobber this with the new title. We have already set
486+
// lastSetTitle above so once live resize is done we will set it back.
487+
if ([vimView inLiveResize]) {
488+
return;
489+
}
490+
480491
if (!title)
481492
return;
482493

@@ -579,40 +590,55 @@ - (void)refreshApperanceMode
579590
// Transparent title bar setting
580591
decoratedWindow.titlebarAppearsTransparent = [[NSUserDefaults standardUserDefaults]
581592
boolForKey:MMTitlebarAppearsTransparentKey];
593+
594+
// No title bar setting
595+
if ([[NSUserDefaults standardUserDefaults]
596+
boolForKey:MMNoTitleBarWindowKey]) {
597+
[decoratedWindow setStyleMask:([decoratedWindow styleMask] & ~NSWindowStyleMaskTitled)];
598+
} else {
599+
[decoratedWindow setStyleMask:([decoratedWindow styleMask] | NSWindowStyleMaskTitled)];
600+
}
601+
602+
// Title may have been lost if we hid the title-bar. Reset it.
603+
[self setTitle:lastSetTitle];
582604

583605
// Dark mode only works on 10.14+ because that's when dark mode was
584606
// introduced.
585607
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
586608
if (@available(macos 10.14, *)) {
609+
NSAppearance* desiredAppearance;
587610
switch ([[NSUserDefaults standardUserDefaults] integerForKey:MMAppearanceModeSelectionKey])
588611
{
589612
case MMAppearanceModeSelectionLight:
590613
{
591-
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
614+
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
592615
break;
593616
}
594617
case MMAppearanceModeSelectionDark:
595618
{
596-
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
619+
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
597620
break;
598621
}
599622
case MMAppearanceModeSelectionBackgroundOption:
600623
{
601624
if (backgroundDark) {
602-
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
625+
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
603626
} else {
604-
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
627+
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
605628
}
606629
break;
607630
}
608631
case MMAppearanceModeSelectionAuto:
609632
default:
610633
{
611634
// Use the system appearance. This will also auto-switch when OS changes mode.
612-
decoratedWindow.appearance = nil;
635+
desiredAppearance = nil;
613636
break;
614637
}
615638
}
639+
640+
decoratedWindow.appearance = desiredAppearance;
641+
fullScreenWindow.appearance = desiredAppearance;
616642
}
617643
#endif
618644
}
@@ -821,11 +847,6 @@ - (void)liveResizeWillStart
821847
{
822848
if (!setupDone) return;
823849

824-
// Save the original title, if we haven't already.
825-
if (lastSetTitle == nil) {
826-
lastSetTitle = [[decoratedWindow title] retain];
827-
}
828-
829850
// NOTE: During live resize Cocoa goes into "event tracking mode". We have
830851
// to add the backend connection to this mode in order for resize messages
831852
// from Vim to reach MacVim. We do not wish to always listen to requests
@@ -849,8 +870,6 @@ - (void)liveResizeDidEnd
849870
// If we saved the original title while resizing, restore it.
850871
if (lastSetTitle != nil) {
851872
[decoratedWindow setTitle:lastSetTitle];
852-
[lastSetTitle release];
853-
lastSetTitle = nil;
854873
}
855874

856875
// If we are in the middle of rapid resize (e.g. double-clicking on the border/corner

0 commit comments

Comments
 (0)