diff options
author | Vaxry <[email protected]> | 2023-09-20 16:47:05 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2023-09-20 16:47:05 +0100 |
commit | 0dbd9970031940b50f9cce4c88989c2830d2a15f (patch) | |
tree | 0dd50dd13e19e663444b1e78d14104c40dabbf76 /src/helpers/WLClasses.cpp | |
parent | 3785defaf12b9d99137b2f4c74ab82c51cf733e1 (diff) | |
download | Hyprland-0dbd9970031940b50f9cce4c88989c2830d2a15f.tar.gz Hyprland-0dbd9970031940b50f9cce4c88989c2830d2a15f.zip |
input: Various constraint handling fixes (#3381)
Fixes #3204
Diffstat (limited to 'src/helpers/WLClasses.cpp')
-rw-r--r-- | src/helpers/WLClasses.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/helpers/WLClasses.cpp b/src/helpers/WLClasses.cpp index c257b6b8..1fa807fa 100644 --- a/src/helpers/WLClasses.cpp +++ b/src/helpers/WLClasses.cpp @@ -1,5 +1,6 @@ #include "WLClasses.hpp" #include "../config/ConfigManager.hpp" +#include "../Compositor.hpp" SLayerSurface::SLayerSurface() { alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE); @@ -37,4 +38,80 @@ void SLayerSurface::applyRules() { } catch (...) {} } } +} + +CRegion SConstraint::getLogicCoordsRegion() { + CRegion result; + + if (!constraint) + return result; + + const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface); + + if (!PWINDOWOWNER) + return result; + + result.add(&constraint->region); // surface-local coords + + if (!PWINDOWOWNER->m_bIsX11) { + result.translate(PWINDOWOWNER->m_vRealPosition.goalv()); + return result; + } + + const auto COORDS = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealPosition.goalv() : + g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y}); + + const auto PMONITOR = PWINDOWOWNER->m_bIsMapped ? g_pCompositor->getMonitorFromID(PWINDOWOWNER->m_iMonitorID) : g_pCompositor->getMonitorFromVector(COORDS); + + if (!PMONITOR) + return CRegion{}; + + result.scale(PMONITOR->xwaylandScale); + + result.translate(COORDS); + + return result; +} + +Vector2D SConstraint::getLogicConstraintPos() { + if (!constraint) + return {}; + + const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface); + + if (!PWINDOWOWNER) + return {}; + + if (!PWINDOWOWNER->m_bIsX11) + return PWINDOWOWNER->m_vRealPosition.goalv(); + + const auto COORDS = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealPosition.goalv() : + g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y}); + + 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 |