feature: supports using native window frame on Linux (#390)

This commit is contained in:
leo 2024-08-22 12:37:26 +08:00
parent eaf5eba0e7
commit d5e51d1f32
No known key found for this signature in database
26 changed files with 218 additions and 39 deletions

View file

@ -8,6 +8,25 @@ namespace SourceGit.Views
{
public partial class Launcher : ChromelessWindow
{
public static readonly StyledProperty<GridLength> CaptionHeightProperty =
AvaloniaProperty.Register<Launcher, GridLength>(nameof(CaptionHeight));
public GridLength CaptionHeight
{
get => GetValue(CaptionHeightProperty);
set => SetValue(CaptionHeightProperty, value);
}
public bool IsRightCaptionButtonsVisible
{
get
{
if (OperatingSystem.IsLinux())
return !ViewModels.Preference.Instance.UseSystemWindowFrame;
return OperatingSystem.IsWindows();
}
}
public Launcher()
{
var layout = ViewModels.Preference.Instance.Layout;
@ -17,6 +36,11 @@ namespace SourceGit.Views
Height = layout.LauncherHeight;
}
if (UseSystemWindowFrame)
CaptionHeight = new GridLength(30);
else
CaptionHeight = new GridLength(38);
InitializeComponent();
}
@ -38,13 +62,15 @@ namespace SourceGit.Views
{
base.OnPropertyChanged(change);
if (change.Property == WindowStateProperty && MainLayout != null)
if (change.Property == WindowStateProperty)
{
var state = (WindowState)change.NewValue!;
if (state == WindowState.Maximized)
MainLayout.RowDefinitions[0].Height = new GridLength(OperatingSystem.IsMacOS() ? 34 : 30);
if (OperatingSystem.IsLinux() && UseSystemWindowFrame)
CaptionHeight = new GridLength(30);
else if (state == WindowState.Maximized)
CaptionHeight = new GridLength(OperatingSystem.IsMacOS() ? 34 : 30);
else
MainLayout.RowDefinitions[0].Height = new GridLength(38);
CaptionHeight = new GridLength(38);
ViewModels.Preference.Instance.Layout.LauncherWindowState = state;
}