summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-05-18 13:10:22 +0200
committerGitHub <noreply@github.com>2022-05-18 13:10:22 +0200
commit6c437763f65489b7c720c56d2f2f69781a39e497 (patch)
tree81d0fd4a54d5891558b62969ba3b41853dd761ff /src/managers/KeybindManager.cpp
parentc2922b6b0941fc5fd4e82877df179e14cc2d3f93 (diff)
parentba573a529afdbf368aa632cf70b41c9a0595578b (diff)
Merge branch 'main' into scaling
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp107
1 files changed, 73 insertions, 34 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index e58819d8..54258529 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -3,20 +3,21 @@
CKeybindManager::CKeybindManager() {
// initialize all dispatchers
- m_mDispatchers["exec"] = spawn;
- m_mDispatchers["killactive"] = killActive;
- m_mDispatchers["togglefloating"] = toggleActiveFloating;
- m_mDispatchers["workspace"] = changeworkspace;
- m_mDispatchers["fullscreen"] = fullscreenActive;
- m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
- m_mDispatchers["pseudo"] = toggleActivePseudo;
- m_mDispatchers["movefocus"] = moveFocusTo;
- m_mDispatchers["movewindow"] = moveActiveTo;
- m_mDispatchers["togglegroup"] = toggleGroup;
- m_mDispatchers["changegroupactive"] = changeGroupActive;
- m_mDispatchers["togglesplit"] = toggleSplit;
- m_mDispatchers["splitratio"] = alterSplitRatio;
- m_mDispatchers["focusmonitor"] = focusMonitor;
+ m_mDispatchers["exec"] = spawn;
+ m_mDispatchers["killactive"] = killActive;
+ m_mDispatchers["togglefloating"] = toggleActiveFloating;
+ m_mDispatchers["workspace"] = changeworkspace;
+ m_mDispatchers["fullscreen"] = fullscreenActive;
+ m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
+ m_mDispatchers["movetoworkspacesilent"] = moveActiveToWorkspaceSilent;
+ m_mDispatchers["pseudo"] = toggleActivePseudo;
+ m_mDispatchers["movefocus"] = moveFocusTo;
+ m_mDispatchers["movewindow"] = moveActiveTo;
+ m_mDispatchers["togglegroup"] = toggleGroup;
+ m_mDispatchers["changegroupactive"] = changeGroupActive;
+ m_mDispatchers["togglesplit"] = toggleSplit;
+ m_mDispatchers["splitratio"] = alterSplitRatio;
+ m_mDispatchers["focusmonitor"] = focusMonitor;
}
void CKeybindManager::addKeybind(SKeybind kb) {
@@ -167,19 +168,7 @@ void CKeybindManager::changeworkspace(std::string args) {
int workspaceToChangeTo = 0;
std::string workspaceName = "";
- if (args.find("name:") == 0) {
- const auto WORKSPACENAME = args.substr(args.find_first_of(':') + 1);
- const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME);
- if (!WORKSPACE) {
- workspaceToChangeTo = g_pCompositor->getNextAvailableNamedWorkspace();
- } else {
- workspaceToChangeTo = WORKSPACE->m_iID;
- }
- workspaceName = WORKSPACENAME;
- } else {
- workspaceToChangeTo = std::clamp((int)getPlusMinusKeywordResult(args, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX);
- workspaceName = std::to_string(workspaceToChangeTo);
- }
+ workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName);
if (workspaceToChangeTo == INT_MAX) {
Debug::log(ERR, "Error in changeworkspace, invalid value");
@@ -209,11 +198,10 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACEID;
// start anim on old workspace
- g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0);
+ g_pCompositor->getWorkspaceByID(OLDWORKSPACEID)->startAnim(false, ANIMTOLEFT);
// start anim on new workspace
- g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_vRenderOffset.setValueAndWarp(Vector2D(ANIMTOLEFT ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0));
- g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->m_vRenderOffset = Vector2D(0, 0);
+ g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->startAnim(true, ANIMTOLEFT);
}
@@ -250,14 +238,13 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto ANIMTOLEFT = workspaceToChangeTo > OLDWORKSPACE;
// start anim on old workspace
- g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->m_vRenderOffset = Vector2D(ANIMTOLEFT ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0);
+ g_pCompositor->getWorkspaceByID(OLDWORKSPACE)->startAnim(false, ANIMTOLEFT);
g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID);
const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back();
// start anim on new workspace
- PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(ANIMTOLEFT ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0));
- PWORKSPACE->m_vRenderOffset = Vector2D(0, 0);
+ PWORKSPACE->startAnim(true, ANIMTOLEFT);
// We are required to set the name here immediately
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, workspaceName.c_str());
@@ -351,6 +338,58 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
}
}
+void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
+ // hacky, but works lol
+
+ int workspaceToMoveTo = 0;
+ std::string workspaceName = "";
+
+ workspaceToMoveTo = getWorkspaceIDFromString(args, workspaceName);
+
+ if (workspaceToMoveTo == INT_MAX) {
+ Debug::log(ERR, "Error in moveActiveToWorkspaceSilent, invalid value");
+ return;
+ }
+
+ const auto PWINDOW = g_pCompositor->m_pLastWindow;
+
+ if (!g_pCompositor->windowValidMapped(PWINDOW))
+ return;
+
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
+
+ if (workspaceToMoveTo == PMONITOR->activeWorkspace)
+ return;
+
+ // may be null until later!
+ auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToMoveTo);
+
+ const auto PMONITORNEW = PWORKSPACE ? g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID) : PMONITOR;
+
+ const auto OLDWORKSPACEIDONMONITOR = PMONITORNEW->activeWorkspace;
+ const auto OLDWORKSPACEIDRETURN = PMONITOR->activeWorkspace;
+
+ const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR);
+ const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN);
+
+ moveActiveToWorkspace(args);
+
+ PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToMoveTo);
+
+ changeworkspace(std::to_string(OLDWORKSPACEIDONMONITOR));
+ changeworkspace(std::to_string(OLDWORKSPACEIDRETURN));
+
+ // revert animations
+ PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
+ PWORKSPACE->m_fAlpha.setValueAndWarp(0.f);
+
+ POLDWORKSPACEIDRETURN->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
+ POLDWORKSPACEIDRETURN->m_fAlpha.setValueAndWarp(255.f);
+
+ POLDWORKSPACEONMON->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
+ POLDWORKSPACEONMON->m_fAlpha.setValueAndWarp(255.f);
+}
+
void CKeybindManager::moveFocusTo(std::string args) {
char arg = args[0];
@@ -510,4 +549,4 @@ void CKeybindManager::focusMonitor(std::string arg) {
Debug::log(ERR, "Error in focusMonitor: no such monitor");
}
-} \ No newline at end of file
+}