summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorMightyPlaza <123664421+MightyPlaza@users.noreply.github.com>2023-08-08 16:52:20 +0000
committerGitHub <noreply@github.com>2023-08-08 18:52:20 +0200
commit6295cbe9cb39b67e8d2dae1e4edeb281d84f5483 (patch)
treebfa75a2ddfe6ec9c8abae0a30467ab02f7160b89 /src/managers/KeybindManager.cpp
parentb68292340c910292b6df3d504c9ee706027d8407 (diff)
keybinds: Keep aspect ratio (#2907)
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 8c0cfab4..9cdf05d0 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -1942,10 +1942,10 @@ void CKeybindManager::pinActive(std::string args) {
}
void CKeybindManager::mouse(std::string args) {
- const auto TRUEARG = args.substr(1);
+ const auto ARGS = CVarList(args.substr(1), 2, ' ');
const auto PRESSED = args[0] == '1';
- if (TRUEARG == "movewindow") {
+ if (ARGS[0] == "movewindow") {
if (PRESSED) {
g_pKeybindManager->m_bIsMouseBindActive = true;
@@ -1962,13 +1962,19 @@ void CKeybindManager::mouse(std::string args) {
g_pInputManager->dragMode = MBIND_INVALID;
}
}
- } else if (TRUEARG == "resizewindow") {
+ } else if (ARGS[0] == "resizewindow") {
if (PRESSED) {
g_pKeybindManager->m_bIsMouseBindActive = true;
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
- g_pInputManager->dragMode = MBIND_RESIZE;
+ try {
+ switch (std::stoi(ARGS[1])) {
+ case 1: g_pInputManager->dragMode = MBIND_RESIZE_FORCE_RATIO; break;
+ case 2: g_pInputManager->dragMode = MBIND_RESIZE_BLOCK_RATIO; break;
+ default: g_pInputManager->dragMode = MBIND_RESIZE;
+ }
+ } catch (std::exception& e) { g_pInputManager->dragMode = MBIND_RESIZE; }
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
} else {
g_pKeybindManager->m_bIsMouseBindActive = false;