diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 799a08e6..6efca86c 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -983,7 +983,9 @@ void CKeybindManager::moveFocusTo(std::string args) { g_pCompositor->focusWindow(PWINDOWTOCHANGETO); Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f; g_pCompositor->warpCursorTo(middle); + g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO; g_pInputManager->simulateMouseMovement(); + g_pInputManager->m_pForcedFocus = nullptr; if (PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID) { // event diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 79b71c95..9f72603f 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -98,6 +98,12 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { if (*PZOOMFACTOR != 1.f) g_pHyprRenderer->damageMonitor(PMONITOR); + if (m_pForcedFocus) { + pFoundWindow = m_pForcedFocus; + surfacePos = pFoundWindow->m_vRealPosition.vec(); + foundSurface = m_pForcedFocus->m_pWLSurface.wlr(); + } + // constraints // All constraints TODO: multiple mice? if (g_pCompositor->m_sSeat.mouse && g_pCompositor->m_sSeat.mouse->currentConstraint && !g_pCompositor->m_sSeat.exclusiveClient && !g_pSessionLockManager->isSessionLocked()) { diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 5cc3c6a6..5c496117 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -7,21 +7,18 @@ #include "../../helpers/Timer.hpp" #include "InputMethodRelay.hpp" -enum eClickBehaviorMode -{ +enum eClickBehaviorMode { CLICKMODE_DEFAULT = 0, CLICKMODE_KILL }; -enum eMouseBindMode -{ +enum eMouseBindMode { MBIND_INVALID = -1, MBIND_MOVE = 0, MBIND_RESIZE }; -enum eBorderIconDirection -{ +enum eBorderIconDirection { BORDERICON_NONE, BORDERICON_UP, BORDERICON_DOWN, @@ -111,8 +108,11 @@ class CInputManager { STouchData m_sTouchData; // for dragging floating windows - CWindow* currentlyDraggedWindow = nullptr; - eMouseBindMode dragMode = MBIND_INVALID; + CWindow* currentlyDraggedWindow = nullptr; + eMouseBindMode dragMode = MBIND_INVALID; + + // for refocus to be forced + CWindow* m_pForcedFocus = nullptr; SDrag m_sDrag;