Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion src/AvaDM.UI/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,23 @@ public override void OnFrameworkInitializationCompleted()
// so hiding it in the Opened handler (rather than skipping the MainWindow assignment
// above) is what avoids that - it costs a brief window flash instead of a more
// invasive change to how MainWindow/TrayIconService are wired up.
//
// ShowInTaskbar = false right after Hide() works around a real Avalonia rendering bug
// on Linux (and, per the upstream reports, macOS) where a window hidden this way comes
// back from the next Show() with no content ever drawn - visible on the desktop only as
// an inert, blank taskbar/dock entry the user has to close by hand, since there's
// nothing on screen to interact with. Windows already hides the taskbar entry itself
// when the window is hidden, so this is a no-op there. See
// https://github.com/AvaloniaUI/Avalonia/issues/2994 and
// https://github.com/AvaloniaUI/Avalonia/issues/18148 - TrayIconService.RestoreWindow
// sets ShowInTaskbar back to true before the matching Show().
if (desktop.Args?.Contains("--minimized") == true)
{
window.Opened += (_, _) => window.Hide();
window.Opened += (_, _) =>
{
window.Hide();
window.ShowInTaskbar = false;
};
}

var trayIcon = TrayIcon.GetIcons(this)![0];
Expand Down
9 changes: 9 additions & 0 deletions src/AvaDM.UI/Services/TrayIconService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ private void UpdateLiveProgress()
/// a second launch signals this instance instead of starting its own.</summary>
public void RestoreWindow()
{
// ShowInTaskbar back to true before Show() - the other half of the workaround documented
// on the Hide() calls in this class and in App.axaml.cs, for the Avalonia rendering bug
// that otherwise leaves the restored window blank on Linux/macOS.
_window.ShowInTaskbar = true;
_window.Show();
_window.WindowState = WindowState.Normal;
_window.Activate();
Expand All @@ -241,7 +245,11 @@ private void ToggleWindow()
{
if (_window.IsVisible && _window.WindowState != WindowState.Minimized)
{
// See App.axaml.cs's --minimized handling for why ShowInTaskbar is toggled alongside
// Hide()/Show() - same Avalonia rendering-after-restore bug applies to this manual
// toggle, not just the autostart path.
_window.Hide();
_window.ShowInTaskbar = false;
}
else
{
Expand All @@ -256,6 +264,7 @@ private void OnWindowClosing(object? sender, WindowClosingEventArgs e)

e.Cancel = true;
_window.Hide();
_window.ShowInTaskbar = false;
}

/// <summary>The tray menu's own Exit item - always performs a real shutdown, bypassing the
Expand Down