Synchronize GlobalHotKeys library and update HotKeyManager

This commit is contained in:
2dust
2026-07-06 16:07:42 +08:00
parent 52766d66bf
commit 66b48c231f
3 changed files with 4 additions and 5 deletions
@@ -8,6 +8,7 @@ public sealed class HotkeyManager
private static readonly Lazy<HotkeyManager> _instance = new(() => new()); private static readonly Lazy<HotkeyManager> _instance = new(() => new());
public static HotkeyManager Instance = _instance.Value; public static HotkeyManager Instance = _instance.Value;
private readonly Dictionary<int, EGlobalHotkey> _hotkeyTriggerDic = new(); private readonly Dictionary<int, EGlobalHotkey> _hotkeyTriggerDic = new();
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]
private GlobalHotKeys.HotKeyManager? _hotKeyManager; private GlobalHotKeys.HotKeyManager? _hotKeyManager;
@@ -74,9 +75,7 @@ public sealed class HotkeyManager
} }
} }
_hotKeyManager?.HotKeyPressed _hotKeyManager.HotKeyPressed += OnNext;
.ObserveOn(AvaloniaScheduler.Instance)
.Subscribe(OnNext);
} }
private void OnNext(HotKey key) private void OnNext(HotKey key)
@@ -257,7 +257,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
switch (e) switch (e)
{ {
case EGlobalHotkey.ShowForm: case EGlobalHotkey.ShowForm:
ShowHideWindow(null); Dispatcher.UIThread.Post(() => ShowHideWindow(null));
break; break;
case EGlobalHotkey.SystemProxyClear: case EGlobalHotkey.SystemProxyClear: