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
32 changes: 28 additions & 4 deletions Trdo/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
private readonly UISettings _uiSettings = new();
private Mutex? _singleInstanceMutex;
private EventWaitHandle? _trayIconRestoreEvent;
private DispatcherQueueTimer? _trayIconWatchdogTimer;

Check warning on line 29 in Trdo/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

The field 'App._trayIconWatchdogTimer' is never used
private DispatcherQueueTimer? _restoreEventMonitorTimer;

/// <summary>
Expand Down Expand Up @@ -156,18 +156,36 @@

private void TrayIcon_ContextMenu(TrayIcon sender, TrayIconEventArgs args)
{
WindowPlacementService.CapturePointerAnchor();
args.Flyout = CreateFlyout();
if (SettingsService.TrayClickBehavior == 1)
{
// Swapped: right click plays/pauses (fall back to flyout if no station selected)
if (_playerVm.CanPlay)
{
_playerVm.Toggle();
_ = UpdateTrayIconAsync();
return;
}
}

// Default: right click opens flyout; also fallback when no station is available
ShowFlyout(args);
}

private void TrayIcon_Selected(TrayIcon sender, TrayIconEventArgs args)
{
if (SettingsService.TrayClickBehavior == 1)
{
// Swapped: left click opens flyout
ShowFlyout(args);
return;
}

// Default: left click plays/pauses
// Check if we can play (have stations available and one selected)
if (!_playerVm.CanPlay)
{
// No stations available, show the flyout to encourage user to add a station
WindowPlacementService.CapturePointerAnchor();
args.Flyout = CreateFlyout();
ShowFlyout(args);
return;
}

Expand All @@ -176,6 +194,12 @@
_ = UpdateTrayIconAsync();
}

private void ShowFlyout(TrayIconEventArgs args)
{
WindowPlacementService.CapturePointerAnchor();
args.Flyout = CreateFlyout();
}

private Flyout CreateFlyout()
{
Flyout flyout = new()
Expand Down
Loading
Loading