diff options
| author | Kamikadze <40305144+Kam1k4dze@users.noreply.github.com> | 2025-05-30 18:25:59 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-30 14:25:59 +0100 |
| commit | 9190443d951c21ab24201d033accf90b4d172f46 (patch) | |
| tree | 28a5e4a1fa9c7424733ac7065a71cead7e141b6f /src/managers/KeybindManager.cpp | |
| parent | 9bf1b491440eac6f9c0d6853013ad5666c12d1d9 (diff) | |
refactor: use std::ranges whenever possible (#10584)
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c4c6d4ab..58951281 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -225,7 +225,7 @@ void CKeybindManager::removeKeybind(uint32_t mod, const SParsedKey& key) { uint32_t CKeybindManager::stringToModMask(std::string mods) { uint32_t modMask = 0; - std::transform(mods.begin(), mods.end(), mods.begin(), ::toupper); + std::ranges::transform(mods, mods.begin(), ::toupper); if (mods.contains("SHIFT")) modMask |= HL_MODIFIER_SHIFT; if (mods.contains("CAPS")) @@ -624,10 +624,8 @@ eMultiKeyCase CKeybindManager::mkKeysymSetMatches(const std::set<xkb_keysym_t> k std::set<xkb_keysym_t> boundKeysNotPressed; std::set<xkb_keysym_t> pressedKeysNotBound; - std::set_difference(keybindKeysyms.begin(), keybindKeysyms.end(), pressedKeysyms.begin(), pressedKeysyms.end(), - std::inserter(boundKeysNotPressed, boundKeysNotPressed.begin())); - std::set_difference(pressedKeysyms.begin(), pressedKeysyms.end(), keybindKeysyms.begin(), keybindKeysyms.end(), - std::inserter(pressedKeysNotBound, pressedKeysNotBound.begin())); + std::ranges::set_difference(keybindKeysyms, pressedKeysyms, std::inserter(boundKeysNotPressed, boundKeysNotPressed.begin())); + std::ranges::set_difference(pressedKeysyms, keybindKeysyms, std::inserter(pressedKeysNotBound, pressedKeysNotBound.begin())); if (boundKeysNotPressed.empty() && pressedKeysNotBound.empty()) return MK_FULL_MATCH; @@ -670,8 +668,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP for (auto& k : m_keybinds) { const bool SPECIALDISPATCHER = k->handler == "global" || k->handler == "pass" || k->handler == "sendshortcut" || k->handler == "mouse"; - const bool SPECIALTRIGGERED = - std::find_if(m_pressedSpecialBinds.begin(), m_pressedSpecialBinds.end(), [&](const auto& other) { return other == k; }) != m_pressedSpecialBinds.end(); + const bool SPECIALTRIGGERED = std::ranges::find_if(m_pressedSpecialBinds, [&](const auto& other) { return other == k; }) != m_pressedSpecialBinds.end(); const bool IGNORECONDITIONS = SPECIALDISPATCHER && !pressed && SPECIALTRIGGERED; // ignore mods. Pass, global dispatchers should be released immediately once the key is released. @@ -1106,7 +1103,7 @@ SDispatchResult CKeybindManager::signalWindow(std::string args) { return {.success = false, .error = "signalWindow: no window"}; } - if (!std::all_of(SIGNAL.begin(), SIGNAL.end(), ::isdigit)) + if (!std::ranges::all_of(SIGNAL, ::isdigit)) return {.success = false, .error = "signalWindow: signal has to be int"}; try { |
