summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-17 11:52:54 +0200
committerGitHub <noreply@github.com>2022-04-17 11:52:54 +0200
commitbaa9e0caea3ce76f72def6e89659dd851f25831d (patch)
tree3ac4837b91661afe55eaef5abcdd438f436911ee /src/managers/KeybindManager.cpp
parenta4f07ea9f7a3e5f882055d9cddb8d048405ad683 (diff)
parent24df15105ee2fc7f2975ef2958c2e7b1258569d1 (diff)
Merge branch 'main' into damage-tracking
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 1d3379c3..4a5cce5a 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -56,6 +56,9 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
else if (k.handler == "movefocus") { moveFocusTo(k.arg); }
else if (k.handler == "togglegroup") { toggleGroup(k.arg); }
else if (k.handler == "changegroupactive") { changeGroupActive(k.arg); }
+ else {
+ Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
+ }
found = true;
}
@@ -130,10 +133,28 @@ void CKeybindManager::toggleActivePseudo(std::string args) {
void CKeybindManager::changeworkspace(std::string args) {
int workspaceToChangeTo = 0;
- try {
- workspaceToChangeTo = stoi(args);
- } catch (...) {
- Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
+
+ if (args.find_first_of("+") == 0) {
+ try {
+ workspaceToChangeTo = g_pCompositor->m_pLastMonitor->activeWorkspace + std::stoi(args.substr(1));
+ } catch (...) {
+ Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
+ return;
+ }
+ } else if (args.find_first_of("-") == 0) {
+ try {
+ workspaceToChangeTo = std::clamp(g_pCompositor->m_pLastMonitor->activeWorkspace - std::stoi(args.substr(1)), 1, INT_MAX);
+ } catch (...) {
+ Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
+ return;
+ }
+ } else {
+ try {
+ workspaceToChangeTo = stoi(args);
+ } catch (...) {
+ Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
+ return;
+ }
}
// if it exists, we warp to it
@@ -171,6 +192,9 @@ void CKeybindManager::changeworkspace(std::string args) {
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
+ // focus
+ g_pInputManager->refocus();
+
return;
}
@@ -201,6 +225,9 @@ void CKeybindManager::changeworkspace(std::string args) {
// mark the monitor dirty
g_pHyprRenderer->damageMonitor(PMONITOR);
+ // focus (clears the last)
+ g_pInputManager->refocus();
+
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
}