mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use Instance class with static method
This commit is contained in:
parent
8f18e2f603
commit
84528ae8a7
1 changed files with 7 additions and 3 deletions
|
|
@ -9,7 +9,7 @@ namespace Flow.Launcher.Infrastructure.Hotkey
|
|||
/// Listens keyboard globally.
|
||||
/// <remarks>Uses WH_KEYBOARD_LL.</remarks>
|
||||
/// </summary>
|
||||
public static unsafe class GlobalHotkey
|
||||
public unsafe class GlobalHotkey : IDisposable
|
||||
{
|
||||
private static readonly IntPtr hookId;
|
||||
|
||||
|
|
@ -28,7 +28,6 @@ namespace Flow.Launcher.Infrastructure.Hotkey
|
|||
{
|
||||
// Set the hook
|
||||
hookId = InterceptKeys.SetHook(& LowLevelKeyboardProc);
|
||||
AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose();
|
||||
}
|
||||
|
||||
public static SpecialKeyState CheckModifiers()
|
||||
|
|
@ -82,9 +81,14 @@ namespace Flow.Launcher.Infrastructure.Hotkey
|
|||
return (IntPtr)(-1);
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
InterceptKeys.UnhookWindowsHookEx(hookId);
|
||||
}
|
||||
|
||||
~GlobalHotkey()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue