1212using Flow . Launcher . Infrastructure ;
1313using Flow . Launcher . Infrastructure . Logger ;
1414using Flow . Launcher . Infrastructure . UserSettings ;
15- using static Flow . Launcher . Core . Resource . Theme . ParameterTypes ;
1615using System . Runtime . InteropServices ;
1716using System . Windows . Interop ;
1817using Microsoft . Win32 ;
@@ -86,37 +85,6 @@ public static void SetWindowCornerPreference(System.Windows.Window window, DWM_W
8685 IntPtr hWnd = new WindowInteropHelper ( window ) . Handle ;
8786 DwmSetWindowAttribute ( hWnd , DWMWA_WINDOW_CORNER_PREFERENCE , ref preference , sizeof ( int ) ) ;
8887 }
89- public class ParameterTypes
90- {
91-
92- [ Flags ]
93- public enum DWMWINDOWATTRIBUTE
94- {
95- DWMWA_USE_IMMERSIVE_DARK_MODE = 20 ,
96- DWMWA_SYSTEMBACKDROP_TYPE = 38 ,
97- DWMWA_TRANSITIONS_FORCEDISABLED = 3 ,
98- DWMWA_BORDER_COLOR
99- }
100-
101- [ StructLayout ( LayoutKind . Sequential ) ]
102- public struct MARGINS
103- {
104- public int cxLeftWidth ; // width of left border that retains its size
105- public int cxRightWidth ; // width of right border that retains its size
106- public int cyTopHeight ; // height of top border that retains its size
107- public int cyBottomHeight ; // height of bottom border that retains its size
108- } ;
109- }
110-
111- public static class Methods
112- {
113-
114- [ DllImport ( "dwmapi.dll" ) ]
115- static extern int DwmSetWindowAttribute ( IntPtr hwnd , ParameterTypes . DWMWINDOWATTRIBUTE dwAttribute , ref int pvAttribute , int cbAttribute ) ;
116-
117- public static int SetWindowAttribute ( IntPtr hwnd , ParameterTypes . DWMWINDOWATTRIBUTE attribute , int parameter )
118- => DwmSetWindowAttribute ( hwnd , attribute , ref parameter , Marshal . SizeOf < int > ( ) ) ;
119- }
12088
12189 private Window GetMainWindow ( )
12290 {
@@ -221,7 +189,7 @@ public void SetBlurForWindow()
221189 if ( windowBorderStyle == null )
222190 return ;
223191
224- System . Windows . Window mainWindow = GetMainWindow ( ) ;
192+ Window mainWindow = GetMainWindow ( ) ;
225193 if ( mainWindow == null )
226194 return ;
227195
@@ -232,42 +200,28 @@ public void SetBlurForWindow()
232200 _settings . BackdropType = BackdropTypes . None ;
233201 }
234202
235- // Check the configured BackdropType
236- int backdropValue = _settings . BackdropType switch
237- {
238- BackdropTypes . Acrylic => 3 , // Acrylic
239- BackdropTypes . Mica => 2 , // Mica
240- BackdropTypes . MicaAlt => 4 , // MicaAlt
241- _ => 0 // None
242- } ;
243-
244203 if ( BlurEnabled && hasBlur && Win32Helper . IsBackdropSupported ( ) )
245204 {
246- // If the BackdropType is Mica or MicaAlt, set the windowborderstyle's background to transparent
205+ // If the BackdropType is Mica or MicaAlt, set the windowborderstyle's background to transparent
247206 if ( _settings . BackdropType == BackdropTypes . Mica || _settings . BackdropType == BackdropTypes . MicaAlt )
248207 {
249208 windowBorderStyle . Setters . Remove ( windowBorderStyle . Setters . OfType < Setter > ( ) . FirstOrDefault ( x => x . Property . Name == "Background" ) ) ;
250209 windowBorderStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , new SolidColorBrush ( Color . FromArgb ( 1 , 0 , 0 , 0 ) ) ) ) ;
251- Methods . SetWindowAttribute ( new WindowInteropHelper ( mainWindow ) . Handle , DWMWINDOWATTRIBUTE . DWMWA_SYSTEMBACKDROP_TYPE , backdropValue ) ;
252- ColorizeWindow ( GetSystemBG ( ) ) ;
253210 }
254211 else if ( _settings . BackdropType == BackdropTypes . Acrylic )
255212 {
256213 windowBorderStyle . Setters . Remove ( windowBorderStyle . Setters . OfType < Setter > ( ) . FirstOrDefault ( x => x . Property . Name == "Background" ) ) ;
257214 windowBorderStyle . Setters . Add ( new Setter ( Border . BackgroundProperty , new SolidColorBrush ( Colors . Transparent ) ) ) ;
258- Methods . SetWindowAttribute ( new WindowInteropHelper ( mainWindow ) . Handle , DWMWINDOWATTRIBUTE . DWMWA_SYSTEMBACKDROP_TYPE , backdropValue ) ;
259- ColorizeWindow ( GetSystemBG ( ) ) ;
260- }
261- else
262- {
263- Methods . SetWindowAttribute ( new WindowInteropHelper ( mainWindow ) . Handle , DWMWINDOWATTRIBUTE . DWMWA_SYSTEMBACKDROP_TYPE , backdropValue ) ;
264- ColorizeWindow ( GetSystemBG ( ) ) ;
265215 }
216+
217+ // Apply the blur effect
218+ Win32Helper . DWMSetBackdropForWindow ( mainWindow , _settings . BackdropType ) ;
219+ ColorizeWindow ( GetSystemBG ( ) ) ;
266220 }
267221 else
268222 {
269- // Apply default style when Blur is disabled
270- Methods . SetWindowAttribute ( new WindowInteropHelper ( mainWindow ) . Handle , DWMWINDOWATTRIBUTE . DWMWA_SYSTEMBACKDROP_TYPE , 0 ) ;
223+ // Apply default style when Blur is disabled
224+ Win32Helper . DWMSetBackdropForWindow ( mainWindow , BackdropTypes . None ) ;
271225 ColorizeWindow ( GetSystemBG ( ) ) ;
272226 }
273227
@@ -401,9 +355,9 @@ public void ColorizeWindow(string Mode)
401355 useDarkMode = isSystemDark ; // Auto (based on system setting)
402356 }
403357
404- // Apply DWM Dark Mode
405- Methods . SetWindowAttribute ( new WindowInteropHelper ( mainWindow ) . Handle , DWMWINDOWATTRIBUTE . DWMWA_USE_IMMERSIVE_DARK_MODE , useDarkMode ? 1 : 0 ) ;
406-
358+ // Apply DWM Dark Mode
359+ Win32Helper . DWMSetDarkModeForWindow ( mainWindow , useDarkMode ) ;
360+
407361 Color LightBG ;
408362 Color DarkBG ;
409363
0 commit comments