Skip to content

Commit 21c19b4

Browse files
committed
Revert "Use Safe Delegate Instead"
This reverts commit 5f90365.
1 parent ec96028 commit 21c19b4

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Flow.Launcher.Infrastructure/Hotkey/GlobalHotkey.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace Flow.Launcher.Infrastructure.Hotkey
1212
public unsafe class GlobalHotkey : IDisposable
1313
{
1414
private static readonly IntPtr hookId;
15-
16-
private static InterceptKeys.LowLevelKeyboardProc _hookedKeyboardProc;
15+
16+
1717

1818
public delegate bool KeyboardCallback(KeyEvent keyEvent, int vkCode, SpecialKeyState state);
1919
internal static Func<KeyEvent, int, SpecialKeyState, bool> hookedKeyboardCallback;
@@ -26,9 +26,8 @@ public unsafe class GlobalHotkey : IDisposable
2626

2727
static GlobalHotkey()
2828
{
29-
_hookedKeyboardProc = LowLevelKeyboardProc;
3029
// Set the hook
31-
hookId = InterceptKeys.SetHook(_hookedKeyboardProc);
30+
hookId = InterceptKeys.SetHook(& LowLevelKeyboardProc);
3231
}
3332

3433
public static SpecialKeyState CheckModifiers()

Flow.Launcher.Infrastructure/Hotkey/InterceptKeys.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal static unsafe class InterceptKeys
1010

1111
private const int WH_KEYBOARD_LL = 13;
1212

13-
public static IntPtr SetHook(LowLevelKeyboardProc proc)
13+
public static IntPtr SetHook(delegate*<int, UIntPtr, IntPtr, IntPtr> proc)
1414
{
1515
using (Process curProcess = Process.GetCurrentProcess())
1616
using (ProcessModule curModule = curProcess.MainModule)
@@ -20,7 +20,7 @@ public static IntPtr SetHook(LowLevelKeyboardProc proc)
2020
}
2121

2222
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
23-
public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
23+
public static extern IntPtr SetWindowsHookEx(int idHook, delegate*<int, UIntPtr, IntPtr, IntPtr> lpfn, IntPtr hMod, uint dwThreadId);
2424

2525
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
2626
[return: MarshalAs(UnmanagedType.Bool)]

0 commit comments

Comments
 (0)