1111using Flow . Launcher . Infrastructure ;
1212using Flow . Launcher . Infrastructure . Logger ;
1313using Flow . Launcher . Infrastructure . UserSettings ;
14+ using System . Windows . Shell ;
1415
1516namespace Flow . Launcher . Core . Resource
1617{
@@ -306,12 +307,15 @@ public void AddDropShadowEffectToCurrentTheme()
306307 var marginSetter = windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . MarginProperty ) as Setter ;
307308 if ( marginSetter == null )
308309 {
310+ var margin = new Thickness ( ShadowExtraMargin , 12 , ShadowExtraMargin , ShadowExtraMargin ) ;
309311 marginSetter = new Setter ( )
310312 {
311313 Property = Border . MarginProperty ,
312- Value = new Thickness ( ShadowExtraMargin , 12 , ShadowExtraMargin , ShadowExtraMargin ) ,
314+ Value = margin ,
313315 } ;
314316 windowBorderStyle . Setters . Add ( marginSetter ) ;
317+
318+ SetResizeBoarderThickness ( margin ) ;
315319 }
316320 else
317321 {
@@ -322,6 +326,8 @@ public void AddDropShadowEffectToCurrentTheme()
322326 baseMargin . Right + ShadowExtraMargin ,
323327 baseMargin . Bottom + ShadowExtraMargin ) ;
324328 marginSetter . Value = newMargin ;
329+
330+ SetResizeBoarderThickness ( newMargin ) ;
325331 }
326332
327333 windowBorderStyle . Setters . Add ( effectSetter ) ;
@@ -352,9 +358,36 @@ public void RemoveDropShadowEffectFromCurrentTheme()
352358 marginSetter . Value = newMargin ;
353359 }
354360
361+ SetResizeBoarderThickness ( null ) ;
362+
355363 UpdateResourceDictionary ( dict ) ;
356364 }
357365
366+ // because adding drop shadow effect will change the margin of the window,
367+ // we need to update the window chrome thickness to correct set the resize border
368+ private static void SetResizeBoarderThickness ( Thickness ? effectMargin )
369+ {
370+ var window = Application . Current . MainWindow ;
371+ if ( WindowChrome . GetWindowChrome ( window ) is WindowChrome windowChrome )
372+ {
373+ Thickness thickness ;
374+ if ( effectMargin == null )
375+ {
376+ thickness = SystemParameters . WindowResizeBorderThickness ;
377+ }
378+ else
379+ {
380+ thickness = new Thickness (
381+ effectMargin . Value . Left + SystemParameters . WindowResizeBorderThickness . Left ,
382+ effectMargin . Value . Top + SystemParameters . WindowResizeBorderThickness . Top ,
383+ effectMargin . Value . Right + SystemParameters . WindowResizeBorderThickness . Right ,
384+ effectMargin . Value . Bottom + SystemParameters . WindowResizeBorderThickness . Bottom ) ;
385+ }
386+
387+ windowChrome . ResizeBorderThickness = thickness ;
388+ }
389+ }
390+
358391 public record ThemeData ( string FileNameWithoutExtension , string Name , bool ? IsDark = null , bool ? HasBlur = null ) ;
359392 }
360393}
0 commit comments