11
11
using Flow . Launcher . Infrastructure ;
12
12
using Flow . Launcher . Infrastructure . Logger ;
13
13
using Flow . Launcher . Infrastructure . UserSettings ;
14
+ using System . Windows . Shell ;
14
15
15
16
namespace Flow . Launcher . Core . Resource
16
17
{
@@ -306,12 +307,15 @@ public void AddDropShadowEffectToCurrentTheme()
306
307
var marginSetter = windowBorderStyle . Setters . FirstOrDefault ( setterBase => setterBase is Setter setter && setter . Property == Border . MarginProperty ) as Setter ;
307
308
if ( marginSetter == null )
308
309
{
310
+ var margin = new Thickness ( ShadowExtraMargin , 12 , ShadowExtraMargin , ShadowExtraMargin ) ;
309
311
marginSetter = new Setter ( )
310
312
{
311
313
Property = Border . MarginProperty ,
312
- Value = new Thickness ( ShadowExtraMargin , 12 , ShadowExtraMargin , ShadowExtraMargin ) ,
314
+ Value = margin ,
313
315
} ;
314
316
windowBorderStyle . Setters . Add ( marginSetter ) ;
317
+
318
+ SetResizeBoarderThickness ( margin ) ;
315
319
}
316
320
else
317
321
{
@@ -322,6 +326,8 @@ public void AddDropShadowEffectToCurrentTheme()
322
326
baseMargin . Right + ShadowExtraMargin ,
323
327
baseMargin . Bottom + ShadowExtraMargin ) ;
324
328
marginSetter . Value = newMargin ;
329
+
330
+ SetResizeBoarderThickness ( newMargin ) ;
325
331
}
326
332
327
333
windowBorderStyle . Setters . Add ( effectSetter ) ;
@@ -352,9 +358,36 @@ public void RemoveDropShadowEffectFromCurrentTheme()
352
358
marginSetter . Value = newMargin ;
353
359
}
354
360
361
+ SetResizeBoarderThickness ( null ) ;
362
+
355
363
UpdateResourceDictionary ( dict ) ;
356
364
}
357
365
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
+
358
391
public record ThemeData ( string FileNameWithoutExtension , string Name , bool ? IsDark = null , bool ? HasBlur = null ) ;
359
392
}
360
393
}
0 commit comments