mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
Added unique lock mutexes to KeyboardManagerState (dev/keyboardManager) (#1789)
* Added unique lock mutexes for thread safety * Fixed a bug in detect key logic * Added early unlock statements to fix issue with shortcut guide * Added comments for unlocks before SendInput and changed some unique_locks to lock_guards
This commit is contained in:
committed by
Udit Singh
parent
467cf919be
commit
ac26818005
@@ -150,7 +150,12 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan
|
||||
{
|
||||
DWORD originalKey = std::stoi(originalKeyString.c_str());
|
||||
DWORD newKey = std::stoi(newKeyString.c_str());
|
||||
keyboardManagerState.AddSingleKeyRemap(originalKey, newKey);
|
||||
|
||||
bool result = keyboardManagerState.AddSingleKeyRemap(originalKey, newKey);
|
||||
if (!result)
|
||||
{
|
||||
isSuccess = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -181,10 +186,12 @@ void createEditKeyboardWindow(HINSTANCE hInst, KeyboardManagerState& keyboardMan
|
||||
SingleKeyRemapControl::keyboardManagerState = &keyboardManagerState;
|
||||
|
||||
// Load existing remaps into UI
|
||||
std::unique_lock<std::mutex> lock(keyboardManagerState.singleKeyReMap_mutex);
|
||||
for (const auto& it : keyboardManagerState.singleKeyReMap)
|
||||
{
|
||||
SingleKeyRemapControl::AddNewControlKeyRemapRow(keyRemapTable, it.first, it.second);
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
// Add remap key button
|
||||
Windows::UI::Xaml::Controls::Button addRemapKey;
|
||||
|
||||
Reference in New Issue
Block a user