Optimize Window Template for linux

This commit is contained in:
qinware
2025-09-16 18:42:32 +08:00
parent 650cef3836
commit a264194772
2 changed files with 26 additions and 17 deletions
@@ -12,7 +12,9 @@
<Border Name="WindowFrame"
Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}"
BackgroundSizing="InnerBorderEdge"
BackgroundSizing="InnerBorderEdge"/>
<Border Name="BodyFrame"
CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="True">
<atom:VisualLayerManager Padding="{TemplateBinding OffScreenMargin, Mode=OneWay}">
<DockPanel LastChildFill="True" Name="{x:Static atom:WindowThemeConstants.ContentLayoutPart}">
@@ -33,12 +35,10 @@
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</DockPanel>
</atom:VisualLayerManager>
</Border>
</Panel>
</ControlTemplate>
</Setter>
@@ -80,12 +80,28 @@
</Setter>
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorBorder}}" />
</Style>
<Style Selector="^ /template/ Border#BodyFrame">
<Setter Property="Padding">
<OnPlatform>
<On Options="Default">
<Thickness>0</Thickness>
</On>
<On Options="Linux">
<Thickness>1</Thickness>
</On>
</OnPlatform>
</Setter>
</Style>
<Style Selector="^[WindowState=FullScreen], ^[WindowState=Maximized]">
<Setter Property="CornerRadius" Value="0" />
<Style Selector="^ /template/ Border#WindowFrame">
<Setter Property="BorderThickness" Value="0" />
</Style>
<Style Selector="^ /template/ Border#BodyFrame">
<Setter Property="Padding" Value="0" />
</Style>
</Style>
<Setter Property="SystemDecorations">
+7 -14
View File
@@ -62,7 +62,6 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
public static readonly StyledProperty<bool> IsResizeEnabledProperty =
AvaloniaProperty.Register<Window, bool>(nameof(IsResizeEnabled), defaultValue: true);
#if PLATFORM_MACOS
public static readonly StyledProperty<Point> MacOSCaptionGroupOffsetProperty =
AvaloniaProperty.Register<Window, Point>(nameof(MacOSCaptionGroupOffset), defaultValue: new Point(10, 0));
@@ -72,10 +71,9 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
public static readonly DirectProperty<Window, Thickness> MacOSTitleBarMarginProperty =
AvaloniaProperty.RegisterDirect<Window, Thickness>(nameof (MacOSTitleBarMargin),
o => o.MacOSTitleBarMargin);
public static readonly StyledProperty<OperationSystemType> OperationSystemTypeProperty =
OperationSystemAwareControlProperty.OperationSystemTypeProperty.AddOwner<Window>();
#endif
public double TitleFontSize
{
@@ -161,7 +159,6 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
set => SetValue(IsResizeEnabledProperty, value);
}
#if PLATFORM_MACOS
public Point MacOSCaptionGroupOffset
{
get => GetValue(MacOSCaptionGroupOffsetProperty);
@@ -182,7 +179,6 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
private Thickness _macOSTitleBarMargin;
public OperationSystemType OperationSystemType => GetValue(OperationSystemTypeProperty);
#endif
#endregion
@@ -238,16 +234,15 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
}
HandleWindowStateChanged(oldWindowState, newWindowState);
}
#if PLATFORM_MACOS
if (this.IsAttachedToVisualTree())
{
if (change.Property == IsCloseCaptionButtonEnabledProperty)
{
#if PLATFORM_MACOS
this.SetMacOSWindowClosable(IsCloseCaptionButtonEnabled);
#endif
}
}
#endif
}
private void HandleWindowStateChanged(WindowState oldState, WindowState newState)
@@ -404,14 +399,11 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
_disposeActions.Clear();
}
#if PLATFORM_MACOS
protected override void OnSizeChanged(SizeChangedEventArgs e)
{
base.OnSizeChanged(e);
if (OperatingSystem.IsMacCatalyst() || OperatingSystem.IsMacOS())
{
ConfigureMacOSCaptionGroupOffset();
}
ConfigureMacOSCaptionGroupOffset();
}
private void ConfigureMacOSCaptionGroupOffset()
@@ -420,7 +412,8 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
var cationsSize = this.GetMacOSOptionsSize(MacOSCaptionGroupSpacing);
MacOSTitleBarMargin = new Thickness(cationsSize.Width + MacOSCaptionGroupOffset.X, 0, 0, 0);
}
#endif
void IOperationSystemAware.SetOperationSystemType(OperationSystemType operationSystemType)
{
SetValue(OperationSystemTypeProperty, operationSystemType);