| 204 | } |
| 205 | |
| 206 | bool HotkeyManager::removeKeybind(const KeySpec& spec, bool match_focus, std::string_view cmdline) { |
| 207 | std::lock_guard<std::mutex> l(lock); |
| 208 | if (!bindings.contains(spec.sym)) |
| 209 | return false; |
| 210 | auto& binds = bindings[spec.sym]; |
| 211 | |
| 212 | auto new_end = std::remove_if(binds.begin(), binds.end(), [match_focus, spec, &cmdline](const auto& v) { |
| 213 | return v.spec.sym == spec.sym |
| 214 | && v.spec.modifiers == spec.modifiers |
| 215 | && (!match_focus || v.spec.focus == spec.focus) |
| 216 | && (cmdline.empty() || v.cmdline == cmdline); |
| 217 | }); |
| 218 | if (new_end == binds.end()) |
| 219 | return false; // No bindings removed |
| 220 | |
| 221 | binds.erase(new_end, binds.end()); |
| 222 | return true; |
| 223 | } |
| 224 | |
| 225 | bool HotkeyManager::removeKeybind(std::string keyspec, bool match_focus, std::string_view cmdline) { |
| 226 | std::optional<KeySpec> spec_opt = KeySpec::parse(std::move(keyspec)); |
no test coverage detected