Skip to content

Add new appearance option for hiding title bar #1056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/MacVim/English.lproj/Preferences.nib/designable.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib
Binary file not shown.
2 changes: 2 additions & 0 deletions src/MacVim/MMFullScreenWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ - (void)enterFullScreen
// we have to do it manually.
[NSApp changeWindowsItem:self title:[target title] filename:NO];
}

[self setAppearance:target.appearance];

[self setOpaque:[target isOpaque]];

Expand Down
6 changes: 1 addition & 5 deletions src/MacVim/MMVimController.m
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,7 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
NSString *string = [[NSString alloc] initWithBytes:(void*)bytes
length:len encoding:NSUTF8StringEncoding];

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

[string release];
} else if (SetDocumentFilenameMsgID == msgid) {
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/MMWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
- (void)setScrollbarThumbValue:(float)val proportion:(float)prop
identifier:(int32_t)ident;

- (unsigned int)calculateStyleMask;
- (void)setBackgroundOption:(int)dark;
- (void)refreshApperanceMode;

Expand Down
43 changes: 31 additions & 12 deletions src/MacVim/MMWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,17 @@ - (void)zoomWithRows:(int)rows columns:(int)cols state:(int)state

- (void)setTitle:(NSString *)title
{
// Save the original title, if we haven't already.
[lastSetTitle release];
lastSetTitle = [title retain];

// While in live resize the window title displays the dimensions of the
// window so don't clobber this with the new title. We have already set
// lastSetTitle above so once live resize is done we will set it back.
if ([vimView inLiveResize]) {
return;
}

if (!title)
return;

Expand Down Expand Up @@ -579,40 +590,55 @@ - (void)refreshApperanceMode
// Transparent title bar setting
decoratedWindow.titlebarAppearsTransparent = [[NSUserDefaults standardUserDefaults]
boolForKey:MMTitlebarAppearsTransparentKey];

// No title bar setting
if ([[NSUserDefaults standardUserDefaults]
boolForKey:MMNoTitleBarWindowKey]) {
[decoratedWindow setStyleMask:([decoratedWindow styleMask] & ~NSWindowStyleMaskTitled)];
} else {
[decoratedWindow setStyleMask:([decoratedWindow styleMask] | NSWindowStyleMaskTitled)];
}

// Title may have been lost if we hid the title-bar. Reset it.
[self setTitle:lastSetTitle];

// Dark mode only works on 10.14+ because that's when dark mode was
// introduced.
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
if (@available(macos 10.14, *)) {
NSAppearance* desiredAppearance;
switch ([[NSUserDefaults standardUserDefaults] integerForKey:MMAppearanceModeSelectionKey])
{
case MMAppearanceModeSelectionLight:
{
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
break;
}
case MMAppearanceModeSelectionDark:
{
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
break;
}
case MMAppearanceModeSelectionBackgroundOption:
{
if (backgroundDark) {
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
} else {
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
}
break;
}
case MMAppearanceModeSelectionAuto:
default:
{
// Use the system appearance. This will also auto-switch when OS changes mode.
decoratedWindow.appearance = nil;
desiredAppearance = nil;
break;
}
}

decoratedWindow.appearance = desiredAppearance;
fullScreenWindow.appearance = desiredAppearance;
}
#endif
}
Expand Down Expand Up @@ -821,11 +847,6 @@ - (void)liveResizeWillStart
{
if (!setupDone) return;

// Save the original title, if we haven't already.
if (lastSetTitle == nil) {
lastSetTitle = [[decoratedWindow title] retain];
}

// NOTE: During live resize Cocoa goes into "event tracking mode". We have
// to add the backend connection to this mode in order for resize messages
// from Vim to reach MacVim. We do not wish to always listen to requests
Expand All @@ -849,8 +870,6 @@ - (void)liveResizeDidEnd
// If we saved the original title while resizing, restore it.
if (lastSetTitle != nil) {
[decoratedWindow setTitle:lastSetTitle];
[lastSetTitle release];
lastSetTitle = nil;
}

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