Skip to content

Commit 337c049

Browse files
committed
ux: hide tracffic lights spacer on Windows and Linux
Signed-off-by: leo <longshuang@msn.cn>
1 parent e9e2be1 commit 337c049

3 files changed

Lines changed: 4 additions & 27 deletions

File tree

‎src/Views/Launcher.axaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
<!-- Caption Buttons (macOS) -->
3131
<v:MacOSTrafficLightsSpacer Grid.Column="0"
3232
Zoom="{Binding Source={x:Static vm:Preferences.Instance}, Path=Zoom, Mode=OneWay}"
33-
IsFullScreen="{Binding !#ThisControl.HasLeftCaptionButton, Mode=OneWay}"/>
33+
IsFullScreen="{Binding #ThisControl.WindowState, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static WindowState.FullScreen}}"
34+
IsVisible="{OnPlatform False, macOS=True}"/>
3435

3536
<!-- Menu (Windows/Linux) -->
3637
<Button Grid.Column="0" Classes="icon_button" VerticalAlignment="Bottom" Margin="6,0,0,3" IsVisible="{OnPlatform True, macOS=False}">

‎src/Views/Launcher.axaml.cs‎

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ public GridLength CaptionHeight
2121
set => SetAndRaise(CaptionHeightProperty, ref _captionHeight, value);
2222
}
2323

24-
public static readonly DirectProperty<Launcher, bool> HasLeftCaptionButtonProperty =
25-
AvaloniaProperty.RegisterDirect<Launcher, bool>(
26-
nameof(HasLeftCaptionButton),
27-
o => o.HasLeftCaptionButton);
28-
29-
public bool HasLeftCaptionButton
30-
{
31-
get => _hasLeftCaptionButton;
32-
set => SetAndRaise(HasLeftCaptionButtonProperty, ref _hasLeftCaptionButton, value);
33-
}
34-
3524
public bool HasRightCaptionButton
3625
{
3726
get
@@ -46,18 +35,11 @@ public bool HasRightCaptionButton
4635
public Launcher()
4736
{
4837
if (OperatingSystem.IsMacOS())
49-
{
50-
HasLeftCaptionButton = true;
5138
CaptionHeight = new GridLength(34);
52-
}
5339
else if (UseSystemWindowFrame)
54-
{
5540
CaptionHeight = new GridLength(30);
56-
}
5741
else
58-
{
5942
CaptionHeight = new GridLength(38);
60-
}
6143

6244
InitializeComponent();
6345
PositionChanged += OnPositionChanged;
@@ -112,9 +94,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
11294
var state = (WindowState)change.NewValue!;
11395
_lastWindowState = (WindowState)change.OldValue!;
11496

115-
if (OperatingSystem.IsMacOS())
116-
HasLeftCaptionButton = state != WindowState.FullScreen;
117-
else if (!UseSystemWindowFrame)
97+
if (!OperatingSystem.IsMacOS() && !UseSystemWindowFrame)
11898
CaptionHeight = new GridLength(state == WindowState.Maximized ? 30 : 38);
11999

120100
ViewModels.Preferences.Instance.Layout.LauncherWindowState = state;
@@ -125,7 +105,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
125105
vm.CommandPalette = null;
126106
}
127107

128-
if (HasLeftCaptionButton && OperatingSystem.IsMacOS())
108+
if (OperatingSystem.IsMacOS() && WindowState != WindowState.FullScreen)
129109
{
130110
if (change.Property == WindowStateProperty ||
131111
change.Property == BoundsProperty ||
@@ -444,7 +424,6 @@ private void OnCloseCommandPalette(object sender, PointerPressedEventArgs e)
444424
}
445425

446426
private GridLength _captionHeight = new(32);
447-
private bool _hasLeftCaptionButton = false;
448427
private WindowState _lastWindowState = WindowState.Normal;
449428
}
450429
}

‎src/Views/MacOSTrafficLightsSpacer.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
4545

4646
protected override Size MeasureOverride(Size availableSize)
4747
{
48-
if (!OperatingSystem.IsMacOS())
49-
return new Size(0, 0);
50-
5148
return _isFullScreen ? new Size(4, 24) : new Size(76.0 / Math.Max(_zoom, 1.0), 24.0);
5249
}
5350

0 commit comments

Comments
 (0)