refactor: use contains to find if an item is in a container
This commit is contained in:
parent
07a217f54f
commit
b29c5b1bb2
7 changed files with 15 additions and 15 deletions
|
|
@ -90,7 +90,7 @@ bool HelloBack::shouldDowngrade(int major, int minor) const
|
||||||
auto versions = map.find(minor);
|
auto versions = map.find(minor);
|
||||||
if (versions != map.end()) {
|
if (versions != map.end()) {
|
||||||
auto compatibleVersions = versions->second;
|
auto compatibleVersions = versions->second;
|
||||||
if (compatibleVersions.find(m_minorVersion) != compatibleVersions.end()) {
|
if (compatibleVersions.contains(m_minorVersion)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -784,7 +784,7 @@ bool KeyMap::keysToRestoreModifiers(
|
||||||
// release unwanted keys
|
// release unwanted keys
|
||||||
for (ModifierToKeys::const_iterator i = oldModifiers.begin(); i != oldModifiers.end(); ++i) {
|
for (ModifierToKeys::const_iterator i = oldModifiers.begin(); i != oldModifiers.end(); ++i) {
|
||||||
KeyButton button = i->second.m_button;
|
KeyButton button = i->second.m_button;
|
||||||
if (button != keyItem.m_button && newKeys.count(button) == 0) {
|
if (button != keyItem.m_button && !newKeys.contains(button)) {
|
||||||
EKeystroke type = kKeystrokeRelease;
|
EKeystroke type = kKeystrokeRelease;
|
||||||
if (i->second.m_lock) {
|
if (i->second.m_lock) {
|
||||||
type = kKeystrokeUnmodify;
|
type = kKeystrokeUnmodify;
|
||||||
|
|
@ -796,7 +796,7 @@ bool KeyMap::keysToRestoreModifiers(
|
||||||
// press wanted keys
|
// press wanted keys
|
||||||
for (auto i = desiredModifiers.begin(); i != desiredModifiers.end(); ++i) {
|
for (auto i = desiredModifiers.begin(); i != desiredModifiers.end(); ++i) {
|
||||||
const KeyButton button = i->second.m_button;
|
const KeyButton button = i->second.m_button;
|
||||||
if (button != keyItem.m_button && oldKeys.count(button) == 0) {
|
if (button != keyItem.m_button && !oldKeys.contains(button)) {
|
||||||
EKeystroke type = kKeystrokePress;
|
EKeystroke type = kKeystrokePress;
|
||||||
if (i->second.m_lock) {
|
if (i->second.m_lock) {
|
||||||
type = kKeystrokeModify;
|
type = kKeystrokeModify;
|
||||||
|
|
@ -943,7 +943,7 @@ void KeyMap::addKeystrokes(
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no more keys for this modifier then deactivate modifier
|
// if no more keys for this modifier then deactivate modifier
|
||||||
if (activeModifiers.count(keyItem.m_generates) == 0) {
|
if (!activeModifiers.contains(keyItem.m_generates)) {
|
||||||
currentState &= ~keyItem.m_generates;
|
currentState &= ~keyItem.m_generates;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -965,7 +965,7 @@ void KeyMap::addKeystrokes(
|
||||||
case kKeystrokeUnmodify:
|
case kKeystrokeUnmodify:
|
||||||
if (keyItem.m_lock) {
|
if (keyItem.m_lock) {
|
||||||
// we assume there's just one button for this modifier
|
// we assume there's just one button for this modifier
|
||||||
if (m_halfDuplex.count(button) > 0) {
|
if (m_halfDuplex.contains(button)) {
|
||||||
if (type == kKeystrokeModify) {
|
if (type == kKeystrokeModify) {
|
||||||
// turn half-duplex toggle on (press)
|
// turn half-duplex toggle on (press)
|
||||||
keystrokes.push_back(Keystroke(button, true, false, data));
|
keystrokes.push_back(Keystroke(button, true, false, data));
|
||||||
|
|
@ -1084,13 +1084,13 @@ std::string KeyMap::formatKey(KeyID key, KeyModifierMask mask)
|
||||||
std::string x;
|
std::string x;
|
||||||
for (int32_t i = 0; i < kKeyModifierNumBits; ++i) {
|
for (int32_t i = 0; i < kKeyModifierNumBits; ++i) {
|
||||||
KeyModifierMask mod = (1u << i);
|
KeyModifierMask mod = (1u << i);
|
||||||
if ((mask & mod) != 0 && s_modifierToNameMap->count(mod) > 0) {
|
if ((mask & mod) != 0 && s_modifierToNameMap->contains(mod)) {
|
||||||
x += s_modifierToNameMap->find(mod)->second;
|
x += s_modifierToNameMap->find(mod)->second;
|
||||||
x += "+";
|
x += "+";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (key != kKeyNone) {
|
if (key != kKeyNone) {
|
||||||
if (s_keyToNameMap->count(key) > 0) {
|
if (s_keyToNameMap->contains(key)) {
|
||||||
x += s_keyToNameMap->find(key)->second;
|
x += s_keyToNameMap->find(key)->second;
|
||||||
}
|
}
|
||||||
// XXX -- we're assuming ASCII here
|
// XXX -- we're assuming ASCII here
|
||||||
|
|
@ -1113,7 +1113,7 @@ bool KeyMap::parseKey(const std::string &x, KeyID &key)
|
||||||
|
|
||||||
// parse the key
|
// parse the key
|
||||||
key = kKeyNone;
|
key = kKeyNone;
|
||||||
if (s_nameToKeyMap->count(x) > 0) {
|
if (s_nameToKeyMap->contains(x)) {
|
||||||
key = s_nameToKeyMap->find(x)->second;
|
key = s_nameToKeyMap->find(x)->second;
|
||||||
}
|
}
|
||||||
// XXX -- we're assuming ASCII encoding here
|
// XXX -- we're assuming ASCII encoding here
|
||||||
|
|
@ -1157,7 +1157,7 @@ bool KeyMap::parseModifiers(std::string &x, KeyModifierMask &mask)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_nameToModifierMap->count(c) > 0) {
|
if (s_nameToModifierMap->contains(c)) {
|
||||||
KeyModifierMask mod = s_nameToModifierMap->find(c)->second;
|
KeyModifierMask mod = s_nameToModifierMap->find(c)->second;
|
||||||
if ((mask & mod) != 0) {
|
if ((mask & mod) != 0) {
|
||||||
// modifier appears twice
|
// modifier appears twice
|
||||||
|
|
|
||||||
|
|
@ -924,7 +924,7 @@ bool KeyState::fakeKeyUp(KeyButton serverID)
|
||||||
++i;
|
++i;
|
||||||
m_activeModifiers.erase(tmp);
|
m_activeModifiers.erase(tmp);
|
||||||
|
|
||||||
if (m_activeModifiers.count(mask) == 0) {
|
if (!m_activeModifiers.contains(mask)) {
|
||||||
// no key for modifier is down so deactivate modifier
|
// no key for modifier is down so deactivate modifier
|
||||||
m_mask &= ~mask;
|
m_mask &= ~mask;
|
||||||
LOG((CLOG_DEBUG1 "new state %04x", m_mask));
|
LOG((CLOG_DEBUG1 "new state %04x", m_mask));
|
||||||
|
|
|
||||||
|
|
@ -814,7 +814,7 @@ void XWindowsClipboard::insertReply(Reply *reply)
|
||||||
// find the right reply when handling property notify events we stick
|
// find the right reply when handling property notify events we stick
|
||||||
// to just the requestor.
|
// to just the requestor.
|
||||||
|
|
||||||
const bool newWindow = (m_replies.count(reply->m_requestor) == 0);
|
const bool newWindow = !m_replies.contains(reply->m_requestor);
|
||||||
m_replies[reply->m_requestor].push_back(reply);
|
m_replies[reply->m_requestor].push_back(reply);
|
||||||
|
|
||||||
// adjust requestor's event mask if we haven't done so already. we
|
// adjust requestor's event mask if we haven't done so already. we
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ void XWindowsKeyState::updateKeysymMap(deskflow::KeyMap &keyMap)
|
||||||
for (int j = 0; j < maxKeysyms; ++j) {
|
for (int j = 0; j < maxKeysyms; ++j) {
|
||||||
item.m_id = XWindowsUtil::mapKeySymToKeyID(keysyms[j]);
|
item.m_id = XWindowsUtil::mapKeySymToKeyID(keysyms[j]);
|
||||||
if (item.m_id == kKeyNone) {
|
if (item.m_id == kKeyNone) {
|
||||||
if (j != 0 && modifierButtons.count(keycode) > 0) {
|
if (j != 0 && modifierButtons.contains(keycode)) {
|
||||||
// pretend the modifier works in other shift levels
|
// pretend the modifier works in other shift levels
|
||||||
// because it probably does.
|
// because it probably does.
|
||||||
if (keysyms[1] == NoSymbol || j != 3) {
|
if (keysyms[1] == NoSymbol || j != 3) {
|
||||||
|
|
@ -509,7 +509,7 @@ void XWindowsKeyState::updateKeysymMap(deskflow::KeyMap &keyMap)
|
||||||
|
|
||||||
item.m_generates = 0;
|
item.m_generates = 0;
|
||||||
item.m_lock = false;
|
item.m_lock = false;
|
||||||
if (modifierButtons.count(keycode) > 0) {
|
if (modifierButtons.contains(keycode)) {
|
||||||
// get flags for modifier keys
|
// get flags for modifier keys
|
||||||
deskflow::KeyMap::initModifierKey(item);
|
deskflow::KeyMap::initModifierKey(item);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1175,7 +1175,7 @@ void XWindowsScreen::handleSystemEvent(const Event &event)
|
||||||
|
|
||||||
// discard matching key releases for key presses that were
|
// discard matching key releases for key presses that were
|
||||||
// filtered and remove them from our filtered list.
|
// filtered and remove them from our filtered list.
|
||||||
else if (xevent->type == KeyRelease && m_filtered.count(xevent->xkey.keycode) > 0) {
|
else if (xevent->type == KeyRelease && m_filtered.contains(xevent->xkey.keycode)) {
|
||||||
m_filtered.erase(xevent->xkey.keycode);
|
m_filtered.erase(xevent->xkey.keycode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1203,7 +1203,7 @@ void Server::handleClipboardGrabbed(const Event &event, BaseClientProxy *grabber
|
||||||
void Server::handleClipboardChanged(const Event &event, BaseClientProxy *client)
|
void Server::handleClipboardChanged(const Event &event, BaseClientProxy *client)
|
||||||
{
|
{
|
||||||
// ignore events from unknown clients
|
// ignore events from unknown clients
|
||||||
if (m_clientSet.count(client) == 0) {
|
if (!m_clientSet.contains(client)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto *info = static_cast<const IScreen::ClipboardInfo *>(event.getData());
|
const auto *info = static_cast<const IScreen::ClipboardInfo *>(event.getData());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue