From 85081fc75a73c55424c68cf8d564e81f27b14d44 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 20 Sep 2023 11:44:37 +0100 Subject: [PATCH] use logical size for inputmgr --- src/helpers/WLClasses.cpp | 25 +++++++++++++++++++++++++ src/helpers/WLClasses.hpp | 1 + src/managers/input/InputManager.cpp | 3 +-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/helpers/WLClasses.cpp b/src/helpers/WLClasses.cpp index 455dd890..1fa807fa 100644 --- a/src/helpers/WLClasses.cpp +++ b/src/helpers/WLClasses.cpp @@ -90,3 +90,28 @@ Vector2D SConstraint::getLogicConstraintPos() { return COORDS; } + +Vector2D SConstraint::getLogicConstraintSize() { + if (!constraint) + return {}; + + const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface); + + if (!PWINDOWOWNER) + return {}; + + if (!PWINDOWOWNER->m_bIsX11) + return PWINDOWOWNER->m_vRealSize.goalv(); + + const auto PMONITOR = PWINDOWOWNER->m_bIsMapped ? + g_pCompositor->getMonitorFromID(PWINDOWOWNER->m_iMonitorID) : + g_pCompositor->getMonitorFromVector(g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y})); + + if (!PMONITOR) + return {}; + + const auto SIZE = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealSize.goalv() : + Vector2D{PWINDOWOWNER->m_uSurface.xwayland->width, PWINDOWOWNER->m_uSurface.xwayland->height} * PMONITOR->xwaylandScale; + + return SIZE; +} \ No newline at end of file diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 2c6a6781..d66ebdfd 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -176,6 +176,7 @@ struct SConstraint { CRegion getLogicCoordsRegion(); Vector2D getLogicConstraintPos(); + Vector2D getLogicConstraintSize(); bool operator==(const SConstraint& b) const { return constraint == b.constraint; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 485fe6f6..ec1534d5 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -145,8 +145,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // Native Wayland apps know how 2 constrain themselves. // XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya. const auto CONSTRAINTPOS = PCONSTRAINT->getLogicConstraintPos(); - const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : - CONSTRAINTWINDOW->m_vRealSize.vec(); + const auto CONSTRAINTSIZE = PCONSTRAINT->getLogicConstraintSize(); if (g_pCompositor->m_sSeat.mouse->currentConstraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) { // we just snap the cursor to where it should be.