mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
Fixed KBM interaction with Shortcut Guide (#2220)
This commit is contained in:
@@ -124,6 +124,7 @@
|
|||||||
<ClInclude Include="keyboard_layout.h" />
|
<ClInclude Include="keyboard_layout.h" />
|
||||||
<ClInclude Include="keyboard_layout_impl.h" />
|
<ClInclude Include="keyboard_layout_impl.h" />
|
||||||
<ClInclude Include="notifications.h" />
|
<ClInclude Include="notifications.h" />
|
||||||
|
<ClInclude Include="shared_constants.h" />
|
||||||
<ClInclude Include="timeutil.h" />
|
<ClInclude Include="timeutil.h" />
|
||||||
<ClInclude Include="VersionHelper.h" />
|
<ClInclude Include="VersionHelper.h" />
|
||||||
<ClInclude Include="window_helpers.h" />
|
<ClInclude Include="window_helpers.h" />
|
||||||
|
|||||||
@@ -99,6 +99,9 @@
|
|||||||
<ClInclude Include="com_object_factory.h">
|
<ClInclude Include="com_object_factory.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="shared_constants.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="keyboard_layout_impl.h">
|
<ClInclude Include="keyboard_layout_impl.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
8
src/common/shared_constants.h
Normal file
8
src/common/shared_constants.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
namespace CommonSharedConstants
|
||||||
|
{
|
||||||
|
// Flag that can be set on an input event so that it is ignored by Keyboard Manager
|
||||||
|
const ULONG_PTR KEYBOARDMANAGER_INJECTED_FLAG = 0x1;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <interface/lowlevel_keyboard_event_data.h>
|
#include <interface/lowlevel_keyboard_event_data.h>
|
||||||
#include <interface/win_hook_event_data.h>
|
#include <interface/win_hook_event_data.h>
|
||||||
#include <common/settings_objects.h>
|
#include <common/settings_objects.h>
|
||||||
|
#include <common/shared_constants.h>
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <keyboardmanager/ui/EditKeyboardWindow.h>
|
#include <keyboardmanager/ui/EditKeyboardWindow.h>
|
||||||
@@ -43,7 +44,6 @@ private:
|
|||||||
const std::wstring app_name = GET_RESOURCE_STRING(IDS_KEYBOARDMANAGER);
|
const std::wstring app_name = GET_RESOURCE_STRING(IDS_KEYBOARDMANAGER);
|
||||||
|
|
||||||
// Flags used for distinguishing key events sent by Keyboard Manager
|
// Flags used for distinguishing key events sent by Keyboard Manager
|
||||||
static const ULONG_PTR KEYBOARDMANAGER_INJECTED_FLAG = 0x1;
|
|
||||||
static const ULONG_PTR KEYBOARDMANAGER_SINGLEKEY_FLAG = 0x11;
|
static const ULONG_PTR KEYBOARDMANAGER_SINGLEKEY_FLAG = 0x11;
|
||||||
static const ULONG_PTR KEYBOARDMANAGER_SHORTCUT_FLAG = 0x101;
|
static const ULONG_PTR KEYBOARDMANAGER_SHORTCUT_FLAG = 0x101;
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ public:
|
|||||||
intptr_t HandleSingleKeyRemapEvent(LowlevelKeyboardEvent* data) noexcept
|
intptr_t HandleSingleKeyRemapEvent(LowlevelKeyboardEvent* data) noexcept
|
||||||
{
|
{
|
||||||
// Check if the key event was generated by KeyboardManager to avoid remapping events generated by us.
|
// Check if the key event was generated by KeyboardManager to avoid remapping events generated by us.
|
||||||
if (!(data->lParam->dwExtraInfo & KEYBOARDMANAGER_INJECTED_FLAG))
|
if (!(data->lParam->dwExtraInfo & CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG))
|
||||||
{
|
{
|
||||||
// The mutex should be unlocked before SendInput is called to avoid re-entry into the same mutex. More details can be found at https://github.com/microsoft/PowerToys/pull/1789#issuecomment-607555837
|
// The mutex should be unlocked before SendInput is called to avoid re-entry into the same mutex. More details can be found at https://github.com/microsoft/PowerToys/pull/1789#issuecomment-607555837
|
||||||
std::unique_lock<std::mutex> lock(keyboardManagerState.singleKeyReMap_mutex);
|
std::unique_lock<std::mutex> lock(keyboardManagerState.singleKeyReMap_mutex);
|
||||||
@@ -446,7 +446,7 @@ public:
|
|||||||
intptr_t HandleSingleKeyToggleToModEvent(LowlevelKeyboardEvent* data) noexcept
|
intptr_t HandleSingleKeyToggleToModEvent(LowlevelKeyboardEvent* data) noexcept
|
||||||
{
|
{
|
||||||
// Check if the key event was generated by KeyboardManager to avoid remapping events generated by us.
|
// Check if the key event was generated by KeyboardManager to avoid remapping events generated by us.
|
||||||
if (!(data->lParam->dwExtraInfo & KEYBOARDMANAGER_INJECTED_FLAG))
|
if (!(data->lParam->dwExtraInfo & CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG))
|
||||||
{
|
{
|
||||||
// The mutex should be unlocked before SendInput is called to avoid re-entry into the same mutex. More details can be found at https://github.com/microsoft/PowerToys/pull/1789#issuecomment-607555837
|
// The mutex should be unlocked before SendInput is called to avoid re-entry into the same mutex. More details can be found at https://github.com/microsoft/PowerToys/pull/1789#issuecomment-607555837
|
||||||
std::unique_lock<std::mutex> lock(keyboardManagerState.singleKeyToggleToMod_mutex);
|
std::unique_lock<std::mutex> lock(keyboardManagerState.singleKeyToggleToMod_mutex);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "target_state.h"
|
#include "target_state.h"
|
||||||
#include "common/start_visible.h"
|
#include "common/start_visible.h"
|
||||||
#include "keyboard_state.h"
|
#include "keyboard_state.h"
|
||||||
|
#include "common/shared_constants.h"
|
||||||
|
|
||||||
TargetState::TargetState(int ms_delay) :
|
TargetState::TargetState(int ms_delay) :
|
||||||
delay(std::chrono::milliseconds(ms_delay)), thread(&TargetState::thread_proc, this)
|
delay(std::chrono::milliseconds(ms_delay)), thread(&TargetState::thread_proc, this)
|
||||||
@@ -42,12 +43,15 @@ bool TargetState::signal_event(unsigned vk_code, bool key_down)
|
|||||||
INPUT input[3] = { {}, {}, {} };
|
INPUT input[3] = { {}, {}, {} };
|
||||||
input[0].type = INPUT_KEYBOARD;
|
input[0].type = INPUT_KEYBOARD;
|
||||||
input[0].ki.wVk = 0xCF;
|
input[0].ki.wVk = 0xCF;
|
||||||
|
input[0].ki.dwExtraInfo = CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG;
|
||||||
input[1].type = INPUT_KEYBOARD;
|
input[1].type = INPUT_KEYBOARD;
|
||||||
input[1].ki.wVk = 0xCF;
|
input[1].ki.wVk = 0xCF;
|
||||||
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
|
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||||
|
input[1].ki.dwExtraInfo = CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG;
|
||||||
input[2].type = INPUT_KEYBOARD;
|
input[2].type = INPUT_KEYBOARD;
|
||||||
input[2].ki.wVk = VK_LWIN;
|
input[2].ki.wVk = VK_LWIN;
|
||||||
input[2].ki.dwFlags = KEYEVENTF_KEYUP;
|
input[2].ki.dwFlags = KEYEVENTF_KEYUP;
|
||||||
|
input[2].ki.dwExtraInfo = CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG;
|
||||||
SendInput(3, input, sizeof(INPUT));
|
SendInput(3, input, sizeof(INPUT));
|
||||||
}
|
}
|
||||||
return supress;
|
return supress;
|
||||||
|
|||||||
Reference in New Issue
Block a user