code_style: move platform dependent code to initialize window to namespace SourceGit.Native

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-12 21:52:50 +08:00
parent c62b4a031f
commit ef4b639f8e
No known key found for this signature in database
9 changed files with 41 additions and 68 deletions

View file

@ -3,7 +3,6 @@
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Platform;
namespace SourceGit.Views
{
@ -11,7 +10,7 @@ namespace SourceGit.Views
{
public bool UseSystemWindowFrame
{
get => OperatingSystem.IsLinux() && ViewModels.Preferences.Instance.UseSystemWindowFrame;
get => Native.OS.UseSystemWindowFrame;
}
protected override Type StyleKeyOverride => typeof(Window);
@ -19,33 +18,6 @@ namespace SourceGit.Views
public ChromelessWindow()
{
Focusable = true;
if (OperatingSystem.IsLinux())
{
if (UseSystemWindowFrame)
{
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.Default;
ExtendClientAreaToDecorationsHint = false;
}
else
{
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
ExtendClientAreaToDecorationsHint = true;
Classes.Add("custom_window_frame");
}
}
else if (OperatingSystem.IsWindows())
{
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
ExtendClientAreaToDecorationsHint = true;
Classes.Add("fix_maximized_padding");
}
else
{
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome;
ExtendClientAreaToDecorationsHint = true;
}
Native.OS.SetupForWindow(this);
}