Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
Expand Down Expand Up @@ -100,14 +101,15 @@ private void SetupTitleBar()
}
else if (OperatingSystem.IsLinux())
{
// Linux: remove the native title bar entirely; our toolbar is the
// only chrome. Custom min/max/close buttons appear on the right.
WindowDecorations = WindowDecorations.None;
// WSLg can report incorrect maximize/input bounds with frameless windows.
// Keep native decorations there and use the in-app toolbar only.
bool isWsl = IsRunningUnderWsl();
WindowDecorations = isWsl ? WindowDecorations.Full : WindowDecorations.None;
TitleBarGrid.ClearValue(HeightProperty);
TitleBarGrid.Height = 44;
HamburgerPanel.Margin = new Thickness(10, 0, 8, 0);
AvatarControl.Height = 32;
LinuxWindowButtons.IsVisible = true;
LinuxWindowButtons.IsVisible = !isWsl;
MainContentGrid.Margin = new Thickness(0, 44, 0, 0);
// Keep maximize icon in sync with window state
this.GetObservable(WindowStateProperty).Subscribe(state =>
Expand All @@ -123,6 +125,13 @@ private void SetupTitleBar()
}
}

private static bool IsRunningUnderWsl()
{
string? wslDistro = Environment.GetEnvironmentVariable("WSL_DISTRO_NAME");
string? wslInterop = Environment.GetEnvironmentVariable("WSL_INTEROP");
return !string.IsNullOrWhiteSpace(wslDistro) || !string.IsNullOrWhiteSpace(wslInterop);
}

private void MinimizeButton_Click(object? sender, RoutedEventArgs e)
=> WindowState = WindowState.Minimized;

Expand Down
Loading