Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
natural-title-bar.patch
--- mituharu-emacs-mac-b5e5c4a6234d/src/macappkit.m 2017-02-04 13:21:43.000000000 +0800
+++ mituharu-emacs-mac/src/macappkit.m 2017-04-03 14:10:01.000000000 +0800
@@ -1824,6 +1824,18 @@
@implementation EmacsWindow
++ (NSButton *)standardWindowButton:(NSWindowButton)b forStyleMask:(NSWindowStyleMask)styleMask
+{
+
+ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+ NSString *hideDocumentIcon = [userDefaults stringForKey: @"HideDocumentIcon"];
+
+ if([hideDocumentIcon isEqualToString: @"YES"] && (b == NSWindowDocumentIconButton || b == NSWindowDocumentVersionsButton)) {
+ return nil;
+ }
+ return [NSWindow standardWindowButton:b forStyleMask:styleMask];
+}
+
- (instancetype)initWithContentRect:(NSRect)contentRect
styleMask:(NSWindowStyleMask)windowStyle
backing:(NSBackingStoreType)bufferingType
@@ -2267,6 +2279,19 @@
[window setOpaque:NO];
FRAME_BACKGROUND_ALPHA_ENABLED_P (f) = true;
}
+
+ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+ NSString *transparentTitleBar = [userDefaults stringForKey: @"TransparentTitleBar"];
+
+ if ([transparentTitleBar isEqualToString: @"DARK"]) {
+ window.titlebarAppearsTransparent = true;
+ window.appearance = [NSAppearance appearanceNamed: NSAppearanceNameVibrantDark];
+ }
+
+ if ([transparentTitleBar isEqualToString: @"LIGHT"]) {
+ window.titlebarAppearsTransparent = true;
+ }
+
[[window contentView] addSubview:emacsView];
[self updateBackingScaleFactor];
@@ -4498,8 +4523,7 @@
if ([defaults objectForKey:@"ApplePressAndHoldEnabled"] == nil)
{
NSDictionaryOf (NSString *, NSString *) *appDefaults =
- [NSDictionary dictionaryWithObject:@"NO"
- forKey:@"ApplePressAndHoldEnabled"];
+ [NSDictionary dictionaryWithObjectsAndKeys:@"NO", @"ApplePressAndHoldEnabled", @"NO", @"TransparentTitleBar", @"NO", @"HideDocumentIcon", nil];
[defaults registerDefaults:appDefaults];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.