mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
shifting naming (#5190)
Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
This commit is contained in:
parent
2bd2ec7a2e
commit
592d3afe6d
@ -2,9 +2,6 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using interop;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
@ -15,41 +12,41 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
|
||||
public class HotkeySettingsControlHook
|
||||
{
|
||||
const int WM_KEYDOWN = 0x100;
|
||||
const int WM_KEYUP = 0x101;
|
||||
const int WM_SYSKEYDOWN = 0x0104;
|
||||
const int WM_SYSKEYUP = 0x0105;
|
||||
private const int WmKeyDown = 0x100;
|
||||
private const int WmKeyUp = 0x101;
|
||||
private const int WmSysKeyDown = 0x0104;
|
||||
private const int WmSysKeyUp = 0x0105;
|
||||
|
||||
private KeyboardHook hook;
|
||||
private KeyEvent keyDown;
|
||||
private KeyEvent keyUp;
|
||||
private IsActive isActive;
|
||||
private KeyboardHook _hook;
|
||||
private KeyEvent _keyDown;
|
||||
private KeyEvent _keyUp;
|
||||
private IsActive _isActive;
|
||||
|
||||
public HotkeySettingsControlHook(KeyEvent keyDown, KeyEvent keyUp, IsActive isActive)
|
||||
{
|
||||
this.keyDown = keyDown;
|
||||
this.keyUp = keyUp;
|
||||
this.isActive = isActive;
|
||||
hook = new KeyboardHook(HotkeySettingsHookCallback, IsActive, null);
|
||||
hook.Start();
|
||||
_keyDown = keyDown;
|
||||
_keyUp = keyUp;
|
||||
_isActive = isActive;
|
||||
_hook = new KeyboardHook(HotkeySettingsHookCallback, IsActive, null);
|
||||
_hook.Start();
|
||||
}
|
||||
|
||||
private bool IsActive()
|
||||
{
|
||||
return isActive();
|
||||
return _isActive();
|
||||
}
|
||||
|
||||
private void HotkeySettingsHookCallback(KeyboardEvent ev)
|
||||
{
|
||||
switch (ev.message)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
keyDown(ev.key);
|
||||
case WmKeyDown:
|
||||
case WmSysKeyDown:
|
||||
_keyDown(ev.key);
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
keyUp(ev.key);
|
||||
case WmKeyUp:
|
||||
case WmSysKeyUp:
|
||||
_keyUp(ev.key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -57,7 +54,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
public void Dispose()
|
||||
{
|
||||
// Dispose the KeyboardHook object to terminate the hook threads
|
||||
hook.Dispose();
|
||||
_hook.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user