Skip to content

Commit

Permalink
keybinds: add safeguard to mousebinds (#7034)
Browse files Browse the repository at this point in the history
modified:   src/managers/KeybindManager.cpp
  • Loading branch information
MightyPlaza authored Jul 24, 2024
1 parent 391f1ae commit 4beac91
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2366,7 +2366,7 @@ void CKeybindManager::mouse(std::string args) {
const auto PRESSED = args[0] == '1';

if (ARGS[0] == "movewindow") {
if (PRESSED) {
if (PRESSED && g_pInputManager->dragMode == MBIND_INVALID) {
g_pKeybindManager->m_bIsMouseBindActive = true;

const auto mouseCoords = g_pInputManager->getMouseCoordsInternal();
Expand All @@ -2380,7 +2380,7 @@ void CKeybindManager::mouse(std::string args) {

g_pInputManager->dragMode = MBIND_MOVE;
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
} else {
} else if (!PRESSED && g_pInputManager->dragMode == MBIND_MOVE) {
g_pKeybindManager->m_bIsMouseBindActive = false;

if (!g_pInputManager->currentlyDraggedWindow.expired()) {
Expand All @@ -2390,7 +2390,7 @@ void CKeybindManager::mouse(std::string args) {
}
}
} else if (ARGS[0] == "resizewindow") {
if (PRESSED) {
if (PRESSED && g_pInputManager->dragMode == MBIND_INVALID) {
g_pKeybindManager->m_bIsMouseBindActive = true;

g_pInputManager->currentlyDraggedWindow =
Expand All @@ -2404,7 +2404,8 @@ void CKeybindManager::mouse(std::string args) {
}
} catch (std::exception& e) { g_pInputManager->dragMode = MBIND_RESIZE; }
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
} else {
} else if (!PRESSED &&
(g_pInputManager->dragMode == MBIND_RESIZE_FORCE_RATIO || g_pInputManager->dragMode == MBIND_RESIZE_BLOCK_RATIO || g_pInputManager->dragMode == MBIND_RESIZE)) {
g_pKeybindManager->m_bIsMouseBindActive = false;

if (!g_pInputManager->currentlyDraggedWindow.expired()) {
Expand Down

0 comments on commit 4beac91

Please sign in to comment.