1212using Flow . Launcher . Infrastructure ;
1313using Flow . Launcher . Infrastructure . Logger ;
1414using Flow . Launcher . Infrastructure . UserSettings ;
15- using System . Runtime . InteropServices ;
16- using System . Windows . Interop ;
1715using Microsoft . Win32 ;
1816using Flow . Launcher . Plugin ;
1917using TextBox = System . Windows . Controls . TextBox ;
@@ -70,43 +68,11 @@ public Theme(IPublicAPI publicAPI, Settings settings)
7068 }
7169
7270 #region Blur Handling
73- private const int DWMWA_WINDOW_CORNER_PREFERENCE = 33 ;
74- public enum DWM_WINDOW_CORNER_PREFERENCE
75- {
76- Default = 0 ,
77- DoNotRound = 1 ,
78- Round = 2 ,
79- RoundSmall = 3
80- }
81- [ DllImport ( "dwmapi.dll" ) ]
82- private static extern int DwmSetWindowAttribute ( IntPtr hwnd , int dwAttribute , ref DWM_WINDOW_CORNER_PREFERENCE pvAttribute , int cbAttribute ) ;
83- public static void SetWindowCornerPreference ( System . Windows . Window window , DWM_WINDOW_CORNER_PREFERENCE preference )
84- {
85- IntPtr hWnd = new WindowInteropHelper ( window ) . Handle ;
86- DwmSetWindowAttribute ( hWnd , DWMWA_WINDOW_CORNER_PREFERENCE , ref preference , sizeof ( int ) ) ;
87- }
88-
89- private Window GetMainWindow ( )
90- {
91- return Application . Current . Dispatcher . Invoke ( ( ) => Application . Current . MainWindow ) ;
92- }
9371
9472 public void RefreshFrame ( )
9573 {
9674 Application . Current . Dispatcher . Invoke ( ( ) =>
9775 {
98- Window mainWindow = Application . Current . MainWindow ;
99- if ( mainWindow == null )
100- return ;
101-
102- IntPtr mainWindowPtr = new WindowInteropHelper ( mainWindow ) . Handle ;
103- if ( mainWindowPtr == IntPtr . Zero )
104- return ;
105-
106- HwndSource mainWindowSrc = HwndSource . FromHwnd ( mainWindowPtr ) ;
107- if ( mainWindowSrc == null )
108- return ;
109-
11076 // Remove OS minimizing/maximizing animation
11177 // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
11278
@@ -124,7 +90,7 @@ public void RefreshFrame()
12490 } , DispatcherPriority . Normal ) ;
12591 }
12692
127- public void AutoDropShadow ( )
93+ private void AutoDropShadow ( )
12894 {
12995 SetWindowCornerPreference ( "Default" ) ;
13096 RemoveDropShadowEffectFromCurrentTheme ( ) ;
@@ -153,24 +119,15 @@ public void AutoDropShadow()
153119 }
154120 }
155121
156- public void SetWindowCornerPreference ( string cornerType )
122+ private void SetWindowCornerPreference ( string cornerType )
157123 {
158124 Application . Current . Dispatcher . Invoke ( ( ) =>
159125 {
160- System . Windows . Window mainWindow = GetMainWindow ( ) ;
126+ Window mainWindow = Application . Current . MainWindow ;
161127 if ( mainWindow == null )
162128 return ;
163129
164- DWM_WINDOW_CORNER_PREFERENCE preference = cornerType switch
165- {
166- "DoNotRound" => DWM_WINDOW_CORNER_PREFERENCE . DoNotRound ,
167- "Round" => DWM_WINDOW_CORNER_PREFERENCE . Round ,
168- "RoundSmall" => DWM_WINDOW_CORNER_PREFERENCE . RoundSmall ,
169- "Default" => DWM_WINDOW_CORNER_PREFERENCE . Default ,
170- _ => DWM_WINDOW_CORNER_PREFERENCE . Default ,
171- } ;
172-
173- SetWindowCornerPreference ( mainWindow , preference ) ;
130+ Win32Helper . DWMSetCornerPreferenceForWindow ( mainWindow , cornerType ) ;
174131 } , DispatcherPriority . Normal ) ;
175132 }
176133
@@ -189,7 +146,7 @@ public void SetBlurForWindow()
189146 if ( windowBorderStyle == null )
190147 return ;
191148
192- Window mainWindow = GetMainWindow ( ) ;
149+ Window mainWindow = Application . Current . MainWindow ;
193150 if ( mainWindow == null )
194151 return ;
195152
@@ -309,7 +266,7 @@ private void ApplyPreviewBackground(Color? bgColor = null)
309266 } , DispatcherPriority . Render ) ;
310267 }
311268
312- public void ColorizeWindow ( string Mode )
269+ private void ColorizeWindow ( string mode )
313270 {
314271 Application . Current . Dispatcher . Invoke ( ( ) =>
315272 {
0 commit comments