refactor: KeyMap::keysToRestoreModifiers, use ranged for loops
This commit is contained in:
parent
7785c954d5
commit
902f5823f2
1 changed files with 8 additions and 9 deletions
|
|
@ -780,29 +780,28 @@ bool KeyMap::keysToRestoreModifiers(
|
||||||
collectButtons(desiredModifiers, newKeys);
|
collectButtons(desiredModifiers, newKeys);
|
||||||
|
|
||||||
// release unwanted keys
|
// release unwanted keys
|
||||||
for (ModifierToKeys::const_iterator i = oldModifiers.begin(); i != oldModifiers.end(); ++i) {
|
for (const auto &[_mask, _keyItem] : oldModifiers) {
|
||||||
KeyButton button = i->second.m_button;
|
KeyButton button = _keyItem.m_button;
|
||||||
if (button != keyItem.m_button && !newKeys.contains(button)) {
|
if (button != keyItem.m_button && !newKeys.contains(button)) {
|
||||||
EKeystroke type = kKeystrokeRelease;
|
EKeystroke type = kKeystrokeRelease;
|
||||||
if (i->second.m_lock) {
|
if (_keyItem.m_lock) {
|
||||||
type = kKeystrokeUnmodify;
|
type = kKeystrokeUnmodify;
|
||||||
}
|
}
|
||||||
addKeystrokes(type, i->second, activeModifiers, currentState, keystrokes);
|
addKeystrokes(type, _keyItem, activeModifiers, currentState, keystrokes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// press wanted keys
|
// press wanted keys
|
||||||
for (auto i = desiredModifiers.begin(); i != desiredModifiers.end(); ++i) {
|
for (const auto &[_mask, _keyItem] : desiredModifiers) {
|
||||||
const KeyButton button = i->second.m_button;
|
const KeyButton button = _keyItem.m_button;
|
||||||
if (button != keyItem.m_button && !oldKeys.contains(button)) {
|
if (button != keyItem.m_button && !oldKeys.contains(button)) {
|
||||||
EKeystroke type = kKeystrokePress;
|
EKeystroke type = kKeystrokePress;
|
||||||
if (i->second.m_lock) {
|
if (_keyItem.m_lock) {
|
||||||
type = kKeystrokeModify;
|
type = kKeystrokeModify;
|
||||||
}
|
}
|
||||||
addKeystrokes(type, i->second, activeModifiers, currentState, keystrokes);
|
addKeystrokes(type, _keyItem, activeModifiers, currentState, keystrokes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue