Skip to content

Instantly share code, notes, and snippets.

@lululau
Created November 30, 2021 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lululau/f0f593bff13dc98eab25fffb9de30161 to your computer and use it in GitHub Desktop.
Save lululau/f0f593bff13dc98eab25fffb9de30161 to your computer and use it in GitHub Desktop.
diff --git a/src/macappkit.m b/src/macappkit.m
index fb7bf2a..732fbed 100644
--- a/src/macappkit.m
+++ b/src/macappkit.m
@@ -2262,6 +2262,18 @@ - (void)showMenuBar
@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
@@ -2854,6 +2866,20 @@ - (void)setupWindow
MRC_RELEASE (visualEffectView);
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.appearance = [NSAppearance appearanceNamed: NSAppearanceNameVibrantLight];
+ }
+
if (FRAME_MAC_DOUBLE_BUFFERED_P (f))
{
FRAME_SYNTHETIC_BOLD_WORKAROUND_DISABLED_P (f) = true;
@@ -6906,8 +6932,7 @@ + (void)initialize
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