diff options
author | vaxerski <[email protected]> | 2022-04-25 13:40:46 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-04-25 13:40:46 +0200 |
commit | 9eae3b3c3bdef052f93c9d63fe29aca77c2df206 (patch) | |
tree | 4b87c319c1439ae61cd1082621f929791a69e35a | |
parent | 68605c2ccfc74cdc5238e730a97d7a6de9882489 (diff) | |
download | Hyprland-9eae3b3c3bdef052f93c9d63fe29aca77c2df206.tar.gz Hyprland-9eae3b3c3bdef052f93c9d63fe29aca77c2df206.zip |
minor xwayland constraint fixes
-rw-r--r-- | src/Compositor.cpp | 18 | ||||
-rw-r--r-- | src/Compositor.hpp | 1 | ||||
-rw-r--r-- | src/managers/InputManager.cpp | 27 |
3 files changed, 39 insertions, 7 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 8cdd9889..56e8e8ff 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -769,4 +769,22 @@ bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) { } return false; +} + +CWindow* CCompositor::getConstraintWindow(SMouse* pMouse) { + if (!pMouse->currentConstraint) + return nullptr; + + const auto PSURFACE = pMouse->currentConstraint->surface; + + for (auto& w : m_lWindows) { + if (PSURFACE == g_pXWaylandManager->getWindowSurface(&w)) { + if (!w.m_bIsX11 && !windowValidMapped(&w)) + continue; + + return &w; + } + } + + return nullptr; }
\ No newline at end of file diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 71e0f310..f91772a8 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -112,6 +112,7 @@ public: CWindow* getNextWindowOnWorkspace(CWindow*); int getNextAvailableNamedWorkspace(); bool isPointOnAnyMonitor(const Vector2D&); + CWindow* getConstraintWindow(SMouse*); private: void initAllSignals(); diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index 2b59ea51..e450775e 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -140,12 +140,15 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // constraints // All constraints TODO: multiple mice? if (g_pCompositor->m_sSeat.mouse->currentConstraint) { - const auto CONSTRAINTWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_sSeat.mouse->currentConstraint->surface); + const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse); - if (g_pCompositor->m_pLastWindow == CONSTRAINTWINDOW) { + const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec(); + const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); + + if (VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x + CONSTRAINTSIZE.x, CONSTRAINTPOS.y + CONSTRAINTSIZE.y)) { // todo: this is incorrect, but it will work in most cases for now // i made this cuz i wanna play minecraft lol - Vector2D deltaToMiddle = (CONSTRAINTWINDOW->m_vRealPosition.vec() + CONSTRAINTWINDOW->m_vRealSize.vec() / 2.f) - mouseCoords; + Vector2D deltaToMiddle = CONSTRAINTPOS + CONSTRAINTSIZE / 2.f - mouseCoords; wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToMiddle.x, deltaToMiddle.y); } } @@ -371,7 +374,10 @@ void CInputManager::recheckConstraint(SMouse* pMouse) { pixman_region32_clear(&pMouse->confinedTo); } - Debug::log(LOG, "Constraint rechecked: %i, %i to %i, %i", PREGION->extents.x1, PREGION->extents.y1, PREGION->extents.x2, PREGION->extents.y2); + const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse); + const auto PWINDOWNAME = PWINDOW ? PWINDOW->m_szTitle : ""; + + Debug::log(LOG, "Constraint rechecked: %i, %i to %i, %i for %x (window name: %s)", PREGION->extents.x1, PREGION->extents.y1, PREGION->extents.x2, PREGION->extents.y2, pMouse->currentConstraint->surface, PWINDOWNAME.c_str()); } void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* constraint) { @@ -390,10 +396,17 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) { if (PWINDOW) { - wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, - constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x, constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y); + if (PWINDOW->m_bIsX11) { + wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, + constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y + PWINDOW->m_vRealPosition.vec().y); + + wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y); + } else { + wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, + constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x, constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y); - wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y); + wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y); + } } } } |