keybinds: Keep aspect ratio (#2907)

This commit is contained in:
MightyPlaza 2023-08-08 16:52:20 +00:00 committed by GitHub
parent b68292340c
commit 6295cbe9cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 39 deletions

View file

@ -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;

View file

@ -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,