Skip to content

Commit

Permalink
Prevent shortcuts from auto repeating when keeping the keys pressed down
Browse files Browse the repository at this point in the history
  • Loading branch information
traies committed Jun 8, 2020
1 parent f8f676e commit bf89bbe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/common/interop/HotkeyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ bool HotkeyManager::IsActiveProc()
// KeyboardEvent callback is only fired for relevant key events.
bool HotkeyManager::FilterKeyboardProc(KeyboardEvent^ ev)
{
auto oldHandle = GetHotkeyHandle(pressedKeys);

// Updating the pressed keys here so we know if the keypress event
// should be propagated or not.
UpdatePressedKeys(ev);

auto pressedKeysHandle = GetHotkeyHandle(pressedKeys);
if (hotkeys->ContainsKey(pressedKeysHandle))

// Check if the hotkey matches the pressed keys, and check if the pressed keys aren't duplicate
// (there shouldn't be auto repeating hotkeys)
if (hotkeys->ContainsKey(pressedKeysHandle) && oldHandle != pressedKeysHandle)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/interop/KeyboardHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void KeyboardHook::Start()
hookHandle = SetWindowsHookEx(
WH_KEYBOARD_LL,
(HOOKPROC)(void*)Marshal::GetFunctionPointerForDelegate(hookProc),
GetModuleHandle(msclr::interop::marshal_as<std::wstring>(curModule->ModuleName).c_str()),
0,
0);
if (hookHandle == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion src/modules/launcher/Wox/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ private void SetCustomPluginHotkey()

private void OnHotkey()
{
App.Current.Dispatcher.Invoke(() =>
Application.Current.Dispatcher.Invoke(() =>
{
if (!ShouldIgnoreHotkeys())
{
Expand Down

0 comments on commit bf89bbe

Please # to comment.