mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-01 20:51:58 -07:00
fix mouse binds being stuck
This commit is contained in:
@@ -129,6 +129,19 @@ void CKeybindManager::updateXKBTranslationState() {
|
|||||||
m_pXKBTranslationState = xkb_state_new(PKEYMAP);
|
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) {
|
bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
|
||||||
if (!g_pCompositor->m_bSessionActive) {
|
if (!g_pCompositor->m_bSessionActive) {
|
||||||
m_dPressedKeycodes.clear();
|
m_dPressedKeycodes.clear();
|
||||||
@@ -161,6 +174,8 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
|||||||
m_uLastCode = KEYCODE;
|
m_uLastCode = KEYCODE;
|
||||||
m_uLastMouseCode = 0;
|
m_uLastMouseCode = 0;
|
||||||
|
|
||||||
|
ensureMouseBindState();
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||||
// clean repeat
|
// clean repeat
|
||||||
@@ -1587,11 +1602,15 @@ void CKeybindManager::mouse(std::string args) {
|
|||||||
|
|
||||||
if (TRUEARG == "movewindow") {
|
if (TRUEARG == "movewindow") {
|
||||||
if (PRESSED) {
|
if (PRESSED) {
|
||||||
|
g_pKeybindManager->m_bIsMouseBindActive = true;
|
||||||
|
|
||||||
g_pInputManager->currentlyDraggedWindow = g_pCompositor->windowFromCursor();
|
g_pInputManager->currentlyDraggedWindow = g_pCompositor->windowFromCursor();
|
||||||
g_pInputManager->dragMode = MBIND_MOVE;
|
g_pInputManager->dragMode = MBIND_MOVE;
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
||||||
} else {
|
} else {
|
||||||
|
g_pKeybindManager->m_bIsMouseBindActive = false;
|
||||||
|
|
||||||
if (g_pInputManager->currentlyDraggedWindow) {
|
if (g_pInputManager->currentlyDraggedWindow) {
|
||||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||||
@@ -1600,11 +1619,15 @@ void CKeybindManager::mouse(std::string args) {
|
|||||||
}
|
}
|
||||||
} else if (TRUEARG == "resizewindow") {
|
} else if (TRUEARG == "resizewindow") {
|
||||||
if (PRESSED) {
|
if (PRESSED) {
|
||||||
|
g_pKeybindManager->m_bIsMouseBindActive = true;
|
||||||
|
|
||||||
g_pInputManager->currentlyDraggedWindow = g_pCompositor->windowFromCursor();
|
g_pInputManager->currentlyDraggedWindow = g_pCompositor->windowFromCursor();
|
||||||
g_pInputManager->dragMode = MBIND_RESIZE;
|
g_pInputManager->dragMode = MBIND_RESIZE;
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
||||||
} else {
|
} else {
|
||||||
|
g_pKeybindManager->m_bIsMouseBindActive = false;
|
||||||
|
|
||||||
if (g_pInputManager->currentlyDraggedWindow) {
|
if (g_pInputManager->currentlyDraggedWindow) {
|
||||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||||
|
@@ -64,6 +64,8 @@ private:
|
|||||||
uint32_t m_uLastCode = 0;
|
uint32_t m_uLastCode = 0;
|
||||||
uint32_t m_uLastMouseCode = 0;
|
uint32_t m_uLastMouseCode = 0;
|
||||||
|
|
||||||
|
bool m_bIsMouseBindActive = false;
|
||||||
|
|
||||||
int m_iPassPressed = -1; // used for pass
|
int m_iPassPressed = -1; // used for pass
|
||||||
|
|
||||||
CTimer m_tScrollTimer;
|
CTimer m_tScrollTimer;
|
||||||
@@ -76,6 +78,7 @@ private:
|
|||||||
xkb_state* m_pXKBTranslationState = nullptr;
|
xkb_state* m_pXKBTranslationState = nullptr;
|
||||||
|
|
||||||
void updateXKBTranslationState();
|
void updateXKBTranslationState();
|
||||||
|
void ensureMouseBindState();
|
||||||
|
|
||||||
// -------------- Dispatchers -------------- //
|
// -------------- Dispatchers -------------- //
|
||||||
static void killActive(std::string);
|
static void killActive(std::string);
|
||||||
|
Reference in New Issue
Block a user