mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3232 from Jack251970/resize_boarder_thickness
Fix main window resize border thickness issue
This commit is contained in:
commit
0370c96a82
2 changed files with 35 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ using System.Windows.Media.Effects;
|
|||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System.Windows.Shell;
|
||||
|
||||
namespace Flow.Launcher.Core.Resource
|
||||
{
|
||||
|
|
@ -306,12 +307,15 @@ namespace Flow.Launcher.Core.Resource
|
|||
var marginSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) as Setter;
|
||||
if (marginSetter == null)
|
||||
{
|
||||
var margin = new Thickness(ShadowExtraMargin, 12, ShadowExtraMargin, ShadowExtraMargin);
|
||||
marginSetter = new Setter()
|
||||
{
|
||||
Property = Border.MarginProperty,
|
||||
Value = new Thickness(ShadowExtraMargin, 12, ShadowExtraMargin, ShadowExtraMargin),
|
||||
Value = margin,
|
||||
};
|
||||
windowBorderStyle.Setters.Add(marginSetter);
|
||||
|
||||
SetResizeBoarderThickness(margin);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -322,6 +326,8 @@ namespace Flow.Launcher.Core.Resource
|
|||
baseMargin.Right + ShadowExtraMargin,
|
||||
baseMargin.Bottom + ShadowExtraMargin);
|
||||
marginSetter.Value = newMargin;
|
||||
|
||||
SetResizeBoarderThickness(newMargin);
|
||||
}
|
||||
|
||||
windowBorderStyle.Setters.Add(effectSetter);
|
||||
|
|
@ -352,9 +358,36 @@ namespace Flow.Launcher.Core.Resource
|
|||
marginSetter.Value = newMargin;
|
||||
}
|
||||
|
||||
SetResizeBoarderThickness(null);
|
||||
|
||||
UpdateResourceDictionary(dict);
|
||||
}
|
||||
|
||||
// because adding drop shadow effect will change the margin of the window,
|
||||
// we need to update the window chrome thickness to correct set the resize border
|
||||
private static void SetResizeBoarderThickness(Thickness? effectMargin)
|
||||
{
|
||||
var window = Application.Current.MainWindow;
|
||||
if (WindowChrome.GetWindowChrome(window) is WindowChrome windowChrome)
|
||||
{
|
||||
Thickness thickness;
|
||||
if (effectMargin == null)
|
||||
{
|
||||
thickness = SystemParameters.WindowResizeBorderThickness;
|
||||
}
|
||||
else
|
||||
{
|
||||
thickness = new Thickness(
|
||||
effectMargin.Value.Left + SystemParameters.WindowResizeBorderThickness.Left,
|
||||
effectMargin.Value.Top + SystemParameters.WindowResizeBorderThickness.Top,
|
||||
effectMargin.Value.Right + SystemParameters.WindowResizeBorderThickness.Right,
|
||||
effectMargin.Value.Bottom + SystemParameters.WindowResizeBorderThickness.Bottom);
|
||||
}
|
||||
|
||||
windowChrome.ResizeBorderThickness = thickness;
|
||||
}
|
||||
}
|
||||
|
||||
public record ThemeData(string FileNameWithoutExtension, string Name, bool? IsDark = null, bool? HasBlur = null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
mc:Ignorable="d">
|
||||
<!-- WindowChrome -->
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="9" ResizeBorderThickness="32 4 32 32" />
|
||||
<WindowChrome CaptionHeight="9" />
|
||||
</WindowChrome.WindowChrome>
|
||||
<Window.Resources>
|
||||
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue