diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 3654699edd..36055df0d6 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -128,8 +128,7 @@ namespace osu.Desktop LoadComponentAsync(new ElevatedPrivilegesChecker(), Add); - if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows) - LoadComponentAsync(new BossKeyManager(), Add); + LoadComponentAsync(new BossKeyManager(), Add); osuSchemeLinkIPCChannel = new OsuSchemeLinkIPCChannel(Host, this); archiveImportIPCChannel = new ArchiveImportIPCChannel(Host, this); diff --git a/osu.Desktop/Platform/BossKeyManager.cs b/osu.Desktop/Platform/BossKeyManager.cs index 42855f59f2..9500bd46d8 100644 --- a/osu.Desktop/Platform/BossKeyManager.cs +++ b/osu.Desktop/Platform/BossKeyManager.cs @@ -2,11 +2,13 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework.Allocation; using osu.Framework.Platform; +using osu.Framework.Platform.SDL3; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Input.Bindings; using osu.Game.Overlays; using osu.Framework.Logging; +using System; namespace osu.Desktop.Platform { @@ -18,6 +20,8 @@ namespace osu.Desktop.Platform [Resolved] private VolumeOverlay volumeOverlay { get; set; } = null!; + private IDisposable? activeTrayIcon = null!; + [BackgroundDependencyLoader] private void load() { @@ -27,14 +31,40 @@ namespace osu.Desktop.Platform { if (e.Action == GlobalAction.BossKey && !e.Repeat) { - host.Window.Hide(); bool previousState = volumeOverlay.IsMuted.Value; - - host.Window.CreateNotificationTrayIcon("osu!", () => Schedule(() => onShow(previousState))); - Logger.Log($"Created notification tray icon"); - volumeOverlay.IsMuted.Value = true; - return true; + if (host.Window is ISDLWindow window) + { + // TODO: add icon + var icon = new TrayIcon + { + Label = "osu!", + Menu = new TrayMenuEntry[] + { + new TrayButton + { + Label = "Open osu!", + Action = () => Schedule(() => onShow(previousState)), + }, + } + }; + + try + { + Schedule(() => { activeTrayIcon = window.CreateTrayIcon(icon); }); + } + catch (PlatformNotSupportedException ex) + { + Logger.Log($"aaaa"); + return false; + } + + host.Window.Hide(); + Logger.Log($"Created notification tray icon"); + volumeOverlay.IsMuted.Value = true; + + return true; + } } return false; @@ -45,7 +75,8 @@ namespace osu.Desktop.Platform Logger.Log($"Notification tray icon clicked"); host.Window.Show(); host.Window.Raise(); - host.Window.RemoveNotificationTrayIcon(); + + activeTrayIcon.Dispose(); Logger.Log($"Notification tray icon removed"); volumeOverlay.IsMuted.Value = previousState; }