Skip to content
Merged
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
8 changes: 4 additions & 4 deletions App.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@ public override void OnFrameworkInitializationCompleted()
}
}

// Not desktop.MainWindow: the lifetime always shows that at startup.
// Hiding it again right away races the X11 window manager, which can
// leave an empty window on screen.
_trayWindow = _services.GetRequiredService<TrayWindow>();

// Make TrayWindow the MainWindow so dialogs can use it as an owner.
desktop.MainWindow = _trayWindow;

// If launched with --minimized (e.g. XDG autostart), keep startup
// behavior as tray-first. Otherwise, show the tray window so manual
// launches are visible even when tray icon integration is missing.
if (startMinimized)
{
AppBootstrapLogger.Info("Startup mode: minimized to tray (--minimized)");
_trayWindow.RequestHideOnFirstOpen();
}
else
{
AppBootstrapLogger.Info("Startup mode: showing tray window");
_trayWindow.Show();
}

_trayIconViewModel = new TrayIconViewModel(ToggleTrayWindow, () => desktop.Shutdown());
Expand Down
2 changes: 1 addition & 1 deletion App.Avalonia/Services/AvaloniaClipboardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public async Task SetTextAsync(string text)
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
var clipboard = desktop.MainWindow?.Clipboard;
var clipboard = desktop.Windows.FirstOrDefault()?.Clipboard;
if (clipboard != null)
await clipboard.SetTextAsync(text);
}
Expand Down
5 changes: 3 additions & 2 deletions App.Avalonia/Services/AvaloniaWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ private static void ShowWindow(Window window, bool useOwner)
{
var desktop = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;

if (desktop?.MainWindow is TrayWindow trayWindow && trayWindow != window && trayWindow.IsVisible)
var trayWindow = desktop?.Windows.OfType<TrayWindow>().FirstOrDefault();
if (trayWindow != null && trayWindow != window && trayWindow.IsVisible)
trayWindow.Hide();

var owner = useOwner ? desktop?.MainWindow : null;
var owner = useOwner ? trayWindow : null;
if (owner != null && owner != window && owner.IsVisible)
window.Show(owner);
else
Expand Down
13 changes: 0 additions & 13 deletions App.Avalonia/Views/TrayWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public partial class TrayWindow : Window
private TrayWindowLoginRequiredPage _loginRequiredPage;
private TrayWindowMainPage _mainPage;

private bool _hideOnFirstOpen;
private DateTime _suppressAutoHideUntilUtc;
private bool _positionUpdateQueued;
private int _sizeChangedCount;
Expand Down Expand Up @@ -63,13 +62,6 @@ public TrayWindow()
Opened += (_, _) =>
{
AppBootstrapLogger.Info("Tray window opened");
if (_hideOnFirstOpen)
{
_hideOnFirstOpen = false;
Hide();
return;
}

PositionInBottomRight();
};

Expand Down Expand Up @@ -127,11 +119,6 @@ public TrayWindow(
SetPageByState(_rpcController.GetState(), _credentialManager.GetCachedCredentials());
}

public void RequestHideOnFirstOpen()
{
_hideOnFirstOpen = true;
}

public void ShowNearSystemTray()
{
// Show() must be called before Activate() will do anything.
Expand Down
Loading