summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authordjvs <2954343+djvs@users.noreply.github.com>2024-03-17 11:41:43 -0400
committerGitHub <noreply@github.com>2024-03-17 15:41:43 +0000
commit3ed3b34c4aea77484fa3325f9f95c001b8d6a0fa (patch)
treeed832d5dee66a4bb016eff307b1e7eb3ebf2e459 /src/managers/KeybindManager.cpp
parente68c07d8096ee5f83e29508c8762279ab80a924b (diff)
keybinds: add Dispatchers for "force float" and "force tiling" (non-toggle) (#5137)
--------- Co-authored-by: djvs <djvs@users.noreply.github.com>
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 2125e9ba..e45930af 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -25,6 +25,8 @@ CKeybindManager::CKeybindManager() {
m_mDispatchers["killactive"] = killActive;
m_mDispatchers["closewindow"] = kill;
m_mDispatchers["togglefloating"] = toggleActiveFloating;
+ m_mDispatchers["setfloating"] = setActiveFloating;
+ m_mDispatchers["settiled"] = setActiveTiled;
m_mDispatchers["workspace"] = changeworkspace;
m_mDispatchers["renameworkspace"] = renameWorkspace;
m_mDispatchers["fullscreen"] = fullscreenActive;
@@ -828,6 +830,18 @@ void CKeybindManager::clearKeybinds() {
}
void CKeybindManager::toggleActiveFloating(std::string args) {
+ return toggleActiveFloatingCore(args, std::nullopt);
+}
+
+void CKeybindManager::setActiveFloating(std::string args) {
+ return toggleActiveFloatingCore(args, true);
+}
+
+void CKeybindManager::setActiveTiled(std::string args) {
+ return toggleActiveFloatingCore(args, false);
+}
+
+void toggleActiveFloatingCore(std::string args, std::optional<bool> floatState) {
CWindow* PWINDOW = nullptr;
if (args != "active" && args.length() > 1)
@@ -838,12 +852,15 @@ void CKeybindManager::toggleActiveFloating(std::string args) {
if (!PWINDOW)
return;
+ if (floatState.has_value() && floatState == PWINDOW->m_bIsFloating)
+ return;
+
// remove drag status
g_pInputManager->currentlyDraggedWindow = nullptr;
if (PWINDOW->m_sGroupData.pNextWindow && PWINDOW->m_sGroupData.pNextWindow != PWINDOW) {
+ const auto PCURRENT = PWINDOW->getGroupCurrent();
- const auto PCURRENT = PWINDOW->getGroupCurrent();
PCURRENT->m_bIsFloating = !PCURRENT->m_bIsFloating;
g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PCURRENT);