From 6295cbe9cb39b67e8d2dae1e4edeb281d84f5483 Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:52:20 +0000 Subject: keybinds: Keep aspect ratio (#2907) --- src/managers/KeybindManager.cpp | 14 ++++++++++---- src/managers/input/InputManager.hpp | 17 ++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src/managers') 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; diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 862dc886..1a3eac0c 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -7,21 +7,20 @@ #include "../../helpers/Timer.hpp" #include "InputMethodRelay.hpp" -enum eClickBehaviorMode -{ +enum eClickBehaviorMode { CLICKMODE_DEFAULT = 0, CLICKMODE_KILL }; -enum eMouseBindMode -{ - MBIND_INVALID = -1, - MBIND_MOVE = 0, - MBIND_RESIZE +enum eMouseBindMode { + MBIND_INVALID = -1, + MBIND_MOVE = 0, + MBIND_RESIZE = 1, + MBIND_RESIZE_BLOCK_RATIO = 2, + MBIND_RESIZE_FORCE_RATIO = 3 }; -enum eBorderIconDirection -{ +enum eBorderIconDirection { BORDERICON_NONE, BORDERICON_UP, BORDERICON_DOWN, -- cgit v1.2.3