88using System . Windows . Markup ;
99using System . Windows . Media ;
1010using System . Windows . Media . Effects ;
11+ using System . Windows . Shell ;
1112using Flow . Launcher . Infrastructure ;
1213using Flow . Launcher . Infrastructure . Logger ;
1314using Flow . Launcher . Infrastructure . UserSettings ;
@@ -309,12 +310,15 @@ public void AddDropShadowEffectToCurrentTheme()
309310 var marginSetter = windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . MarginProperty ) as Setter ;
310311 if ( marginSetter == null )
311312 {
313+ var margin = new Thickness ( ShadowExtraMargin , 12 , ShadowExtraMargin , ShadowExtraMargin ) ;
312314 marginSetter = new Setter ( )
313315 {
314316 Property = Border . MarginProperty ,
315- Value = new Thickness ( ShadowExtraMargin , 12 , ShadowExtraMargin , ShadowExtraMargin ) ,
317+ Value = margin ,
316318 } ;
317319 windowBorderStyle . Setters . Add ( marginSetter ) ;
320+
321+ SetResizeBoarderThickness ( margin ) ;
318322 }
319323 else
320324 {
@@ -325,6 +329,8 @@ public void AddDropShadowEffectToCurrentTheme()
325329 baseMargin . Right + ShadowExtraMargin ,
326330 baseMargin . Bottom + ShadowExtraMargin ) ;
327331 marginSetter . Value = newMargin ;
332+
333+ SetResizeBoarderThickness ( newMargin ) ;
328334 }
329335
330336 windowBorderStyle . Setters . Add ( effectSetter ) ;
@@ -355,9 +361,36 @@ public void RemoveDropShadowEffectFromCurrentTheme()
355361 marginSetter . Value = newMargin ;
356362 }
357363
364+ SetResizeBoarderThickness ( null ) ;
365+
358366 UpdateResourceDictionary ( dict ) ;
359367 }
360368
369+ // because adding drop shadow effect will change the margin of the window,
370+ // we need to update the window chrome thickness to correct set the resize border
371+ private static void SetResizeBoarderThickness ( Thickness ? effectMargin )
372+ {
373+ var window = Application . Current . MainWindow ;
374+ if ( WindowChrome . GetWindowChrome ( window ) is WindowChrome windowChrome )
375+ {
376+ Thickness thickness ;
377+ if ( effectMargin == null )
378+ {
379+ thickness = SystemParameters . WindowResizeBorderThickness ;
380+ }
381+ else
382+ {
383+ thickness = new Thickness (
384+ effectMargin . Value . Left + SystemParameters . WindowResizeBorderThickness . Left ,
385+ effectMargin . Value . Top + SystemParameters . WindowResizeBorderThickness . Top ,
386+ effectMargin . Value . Right + SystemParameters . WindowResizeBorderThickness . Right ,
387+ effectMargin . Value . Bottom + SystemParameters . WindowResizeBorderThickness . Bottom ) ;
388+ }
389+
390+ windowChrome . ResizeBorderThickness = thickness ;
391+ }
392+ }
393+
361394 public record ThemeData ( string FileNameWithoutExtension , string Name , bool ? IsDark = null , bool ? HasBlur = null ) ;
362395 }
363396}
0 commit comments