summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-09-20 10:02:20 +0100
committervaxerski <vaxry@vaxry.net>2022-09-20 10:02:20 +0100
commitb82621c4ecd2697ac397ca0e47d5d75bf028632a (patch)
tree8beed7ba0486007b314cd99e6450af012083b7eb /src/managers/KeybindManager.cpp
parent5b6c8d5b0f9a807eaf61d7286d41a75f5e6e61e9 (diff)
fix mouse binds being stuck
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 47f42e2b..58da358c 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -129,6 +129,19 @@ void CKeybindManager::updateXKBTranslationState() {
m_pXKBTranslationState = xkb_state_new(PKEYMAP);
}
+void CKeybindManager::ensureMouseBindState() {
+ if (!m_bIsMouseBindActive)
+ return;
+
+ if (g_pInputManager->currentlyDraggedWindow) {
+ g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
+ g_pInputManager->currentlyDraggedWindow = nullptr;
+ g_pInputManager->dragMode = MBIND_INVALID;
+ }
+
+ m_bIsMouseBindActive = false;
+}
+
bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
if (!g_pCompositor->m_bSessionActive) {
m_dPressedKeycodes.clear();
@@ -161,6 +174,8 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
m_uLastCode = KEYCODE;
m_uLastMouseCode = 0;
+ ensureMouseBindState();
+
bool found = false;
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
// clean repeat
@@ -1587,11 +1602,15 @@ void CKeybindManager::mouse(std::string args) {
if (TRUEARG == "movewindow") {
if (PRESSED) {
+ g_pKeybindManager->m_bIsMouseBindActive = true;
+
g_pInputManager->currentlyDraggedWindow = g_pCompositor->windowFromCursor();
g_pInputManager->dragMode = MBIND_MOVE;
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
} else {
+ g_pKeybindManager->m_bIsMouseBindActive = false;
+
if (g_pInputManager->currentlyDraggedWindow) {
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
g_pInputManager->currentlyDraggedWindow = nullptr;
@@ -1600,11 +1619,15 @@ void CKeybindManager::mouse(std::string args) {
}
} else if (TRUEARG == "resizewindow") {
if (PRESSED) {
+ g_pKeybindManager->m_bIsMouseBindActive = true;
+
g_pInputManager->currentlyDraggedWindow = g_pCompositor->windowFromCursor();
g_pInputManager->dragMode = MBIND_RESIZE;
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
} else {
+ g_pKeybindManager->m_bIsMouseBindActive = false;
+
if (g_pInputManager->currentlyDraggedWindow) {
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
g_pInputManager->currentlyDraggedWindow = nullptr;