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 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/managers/KeybindManager.cpp') 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; -- cgit v1.2.3