Skip to content

Commit 8aa089e

Browse files
authored
Merge pull request #1448 from ychin/fix-macos14-non-native-fullscreen-background-color
Fix macOS 14 Sonoma non-native full screen background color
2 parents 784b26c + 3d73af4 commit 8aa089e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/MacVim/MMCoreTextView.m

+18
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,17 @@ - (void)drawRect:(NSRect)rect
760760
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
761761
const BOOL clipTextToRow = [ud boolForKey:MMRendererClipToRowKey]; // Specify whether to clip tall characters by the row boundary.
762762

763+
764+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_14_0
765+
// On macOS 14+ by default views don't clip their content, which is good as it allows tall texts
766+
// on first line to be drawn fully without getting clipped. However, in this case we should make
767+
// sure the background color fill is clipped properly, as otherwise it will interfere with
768+
// non-native fullscreen's background color setting.
769+
const BOOL clipBackground = !self.clipsToBounds;
770+
#else
771+
const BOOL clipBackground = NO;
772+
#endif
773+
763774
NSGraphicsContext *context = [NSGraphicsContext currentContext];
764775
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
765776
CGContextRef ctx = context.CGContext;
@@ -791,7 +802,14 @@ - (void)drawRect:(NSRect)rect
791802
const unsigned defaultBg = defaultBackgroundColor.argbInt;
792803
CGContextSetFillColor(ctx, COMPONENTS(defaultBg));
793804

805+
if (clipBackground) {
806+
CGContextSaveGState(ctx);
807+
CGContextClipToRect(ctx, self.bounds);
808+
}
794809
CGContextFillRect(ctx, rect);
810+
if (clipBackground) {
811+
CGContextRestoreGState(ctx);
812+
}
795813

796814
// Function to draw all rows
797815
void (^drawAllRows)(void (^)(CGContextRef,CGRect,int)) = ^(void (^drawFunc)(CGContextRef,CGRect,int)){

src/MacVim/MacVim.h

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
#ifndef MAC_OS_VERSION_13_0
5353
# define MAC_OS_VERSION_13_0 130000
5454
#endif
55+
#ifndef MAC_OS_VERSION_14_0
56+
# define MAC_OS_VERSION_14_0 140000
57+
#endif
5558

5659
#ifndef NSAppKitVersionNumber10_10
5760
# define NSAppKitVersionNumber10_10 1343

0 commit comments

Comments
 (0)