From 9162e2c802b6de922495be06c2bbc0b42d0f0456 Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Tue, 4 Feb 2025 02:26:08 -0800 Subject: [PATCH] Fix non-native full screen to support 'blurradius' --- src/MacVim/MMWindow.h | 1 + src/MacVim/MMWindow.m | 7 ++++++- src/MacVim/MMWindowController.m | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/MacVim/MMWindow.h b/src/MacVim/MMWindow.h index ce6fa39e57..52c0362105 100644 --- a/src/MacVim/MMWindow.h +++ b/src/MacVim/MMWindow.h @@ -29,6 +29,7 @@ - (void)setContentMaxSize:(NSSize)size; - (void)setContentSize:(NSSize)size; - (void)setBlurRadius:(int)radius; ++ (void)setBlurRadius:(int)radius onWindow:(NSWindow *)win; - (IBAction)toggleFullScreen:(id)sender; - (IBAction)realToggleFullScreen:(id)sender; diff --git a/src/MacVim/MMWindow.m b/src/MacVim/MMWindow.m index 3af65742a0..cd722d9fa2 100644 --- a/src/MacVim/MMWindow.m +++ b/src/MacVim/MMWindow.m @@ -162,6 +162,11 @@ - (void)setContentSize:(NSSize)size } - (void)setBlurRadius:(int)radius +{ + [MMWindow setBlurRadius:radius onWindow:self]; +} + ++ (void)setBlurRadius:(int)radius onWindow:(NSWindow *)win { if (radius >= 0) { CGSConnectionID con = CGSMainConnectionID(); @@ -170,7 +175,7 @@ - (void)setBlurRadius:(int)radius } CGSSetWindowBackgroundBlurRadiusFunction* function = GetCGSSetWindowBackgroundBlurRadiusFunction(); if (function) { - function(con, (int)[self windowNumber], radius); + function(con, (int)[win windowNumber], radius); } } } diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 727e35e7d4..8b195e28e5 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -367,6 +367,8 @@ - (BOOL)presentWindow:(id)unused // GUIEnter auto command could cause this). [fullScreenWindow enterFullScreen]; fullScreenEnabled = YES; + if (blurRadius != 0) + [MMWindow setBlurRadius:blurRadius onWindow:fullScreenWindow]; shouldResizeVimView = YES; } else if (delayEnterFullScreen) { [self enterNativeFullScreen]; @@ -1017,6 +1019,9 @@ - (void)setBlurRadius:(int)radius blurRadius = radius; if (windowPresented) { [decoratedWindow setBlurRadius:radius]; + if (fullScreenWindow) { + [MMWindow setBlurRadius:radius onWindow:fullScreenWindow]; + } } } @@ -1045,8 +1050,9 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back NSColor *fullscreenBg = back; - // See setDefaultColorsBackground: for why set a transparent - // background color, and why 0.001 instead of 0. + // Copy option: 'transparency' + // See setDefaultColorsBackground: for why set a transparent + // background color, and why 0.001 instead of 0. if ([fullscreenBg alphaComponent] != 1) { fullscreenBg = [fullscreenBg colorWithAlphaComponent:0.001]; } @@ -1069,6 +1075,13 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back [fullScreenWindow enterFullScreen]; fullScreenEnabled = YES; + // Copy option: 'blurradius' + // Do this here instead of in full screen window since this + // involves calling private APIs and we want to limit where we + // do that. + if (blurRadius != 0) + [MMWindow setBlurRadius:blurRadius onWindow:fullScreenWindow]; + // The resize handle disappears so the vim view needs to update the // scrollbars. shouldResizeVimView = YES;