mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 22:05:59 +01:00
Added unbind keyword
This commit is contained in:
parent
07080498fd
commit
064e40d25f
4 changed files with 27 additions and 4 deletions
|
@ -215,6 +215,17 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
|
|||
g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND});
|
||||
}
|
||||
|
||||
void CConfigManager::handleUnbind(const std::string& command, const std::string& value) {
|
||||
auto valueCopy = value;
|
||||
|
||||
const auto MOD = g_pKeybindManager->stringToModMask(valueCopy.substr(0, valueCopy.find_first_of(",")));
|
||||
valueCopy = valueCopy.substr(valueCopy.find_first_of(",") + 1);
|
||||
|
||||
const auto KEY = valueCopy;
|
||||
|
||||
g_pKeybindManager->removeKeybind(MOD, KEY);
|
||||
}
|
||||
|
||||
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
|
||||
const auto RULE = value.substr(0, value.find_first_of(","));
|
||||
const auto VALUE = value.substr(value.find_first_of(",") + 1);
|
||||
|
@ -271,6 +282,8 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
|||
handleMonitor(COMMAND, VALUE);
|
||||
} else if (COMMAND == "bind") {
|
||||
handleBind(COMMAND, VALUE);
|
||||
} else if (COMMAND == "unbind") {
|
||||
handleUnbind(COMMAND, VALUE);
|
||||
} else if (COMMAND == "workspace") {
|
||||
handleDefaultWorkspace(COMMAND, VALUE);
|
||||
} else if (COMMAND == "windowrule") {
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
void handleRawExec(const std::string&, const std::string&);
|
||||
void handleMonitor(const std::string&, const std::string&);
|
||||
void handleBind(const std::string&, const std::string&);
|
||||
void handleUnbind(const std::string&, const std::string&);
|
||||
void handleWindowRule(const std::string&, const std::string&);
|
||||
void handleDefaultWorkspace(const std::string&, const std::string&);
|
||||
};
|
||||
|
|
|
@ -18,7 +18,15 @@ CKeybindManager::CKeybindManager() {
|
|||
}
|
||||
|
||||
void CKeybindManager::addKeybind(SKeybind kb) {
|
||||
m_dKeybinds.push_back(kb);
|
||||
m_lKeybinds.push_back(kb);
|
||||
}
|
||||
|
||||
void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) {
|
||||
for (auto it = m_lKeybinds.begin(); it != m_lKeybinds.end(); ++it) {
|
||||
if (it->modmask == mod && it->key == key) {
|
||||
it = m_lKeybinds.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CKeybindManager::stringToModMask(std::string mods) {
|
||||
|
@ -54,7 +62,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
|||
return false;
|
||||
}
|
||||
|
||||
for (auto& k : m_dKeybinds) {
|
||||
for (auto& k : m_lKeybinds) {
|
||||
if (modmask != k.modmask)
|
||||
continue;
|
||||
|
||||
|
@ -126,7 +134,7 @@ void CKeybindManager::killActive(std::string args) {
|
|||
}
|
||||
|
||||
void CKeybindManager::clearKeybinds() {
|
||||
m_dKeybinds.clear();
|
||||
m_lKeybinds.clear();
|
||||
}
|
||||
|
||||
void CKeybindManager::toggleActiveFloating(std::string args) {
|
||||
|
|
|
@ -19,13 +19,14 @@ public:
|
|||
|
||||
bool handleKeybinds(const uint32_t&, const xkb_keysym_t&);
|
||||
void addKeybind(SKeybind);
|
||||
void removeKeybind(uint32_t, const std::string&);
|
||||
uint32_t stringToModMask(std::string);
|
||||
void clearKeybinds();
|
||||
|
||||
std::unordered_map<std::string, std::function<void(std::string)>> m_mDispatchers;
|
||||
|
||||
private:
|
||||
std::deque<SKeybind> m_dKeybinds;
|
||||
std::list<SKeybind> m_lKeybinds;
|
||||
|
||||
bool handleInternalKeybinds(xkb_keysym_t);
|
||||
|
||||
|
|
Loading…
Reference in a new issue