diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-06-19 16:20:06 +0200 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-06-19 16:20:15 +0200 |
| commit | fb15b7aa2a9bba0f0693f84d0c65d386942583f8 (patch) | |
| tree | d4403944b5d6a3e03d2262f03a7d0b3ed6ffae24 /src/render/decorations | |
| parent | 6e5804b53de753f24953d9d647940df66bc68f6d (diff) | |
core: Move to hyprutils for Math
Moves CRegion, CBox and Vector2D over to hyprutils.
Requires hyprutils>=0.1.4
Diffstat (limited to 'src/render/decorations')
| -rw-r--r-- | src/render/decorations/CHyprBorderDecoration.hpp | 16 | ||||
| -rw-r--r-- | src/render/decorations/CHyprDropShadowDecoration.cpp | 2 | ||||
| -rw-r--r-- | src/render/decorations/CHyprDropShadowDecoration.hpp | 14 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.hpp | 2 | ||||
| -rw-r--r-- | src/render/decorations/DecorationPositioner.cpp | 30 | ||||
| -rw-r--r-- | src/render/decorations/DecorationPositioner.hpp | 28 | ||||
| -rw-r--r-- | src/render/decorations/IHyprWindowDecoration.hpp | 2 |
7 files changed, 47 insertions, 47 deletions
diff --git a/src/render/decorations/CHyprBorderDecoration.hpp b/src/render/decorations/CHyprBorderDecoration.hpp index 3fa0946e..8ad3263e 100644 --- a/src/render/decorations/CHyprBorderDecoration.hpp +++ b/src/render/decorations/CHyprBorderDecoration.hpp @@ -26,16 +26,16 @@ class CHyprBorderDecoration : public IHyprWindowDecoration { virtual std::string getDisplayName(); private: - SWindowDecorationExtents m_seExtents; - SWindowDecorationExtents m_seReportedExtents; + SBoxExtents m_seExtents; + SBoxExtents m_seReportedExtents; - PHLWINDOWREF m_pWindow; + PHLWINDOWREF m_pWindow; - Vector2D m_vLastWindowPos; - Vector2D m_vLastWindowSize; + Vector2D m_vLastWindowPos; + Vector2D m_vLastWindowSize; - CBox m_bAssignedGeometry = {0}; + CBox m_bAssignedGeometry = {0}; - CBox assignedBoxGlobal(); - bool doesntWantBorders(); + CBox assignedBoxGlobal(); + bool doesntWantBorders(); }; diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index fba279cc..6893d78c 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -130,7 +130,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) { const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f); // scale the box in relation to the center of the box - fullBox.scaleFromCenter(SHADOWSCALE).translate(*PSHADOWOFFSET); + fullBox.scaleFromCenter(SHADOWSCALE).translate({(*PSHADOWOFFSET).x, (*PSHADOWOFFSET).y}); updateWindow(PWINDOW); m_vLastWindowPos += WORKSPACEOFFSET; diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp index 06319cb7..ecd5a47b 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.hpp +++ b/src/render/decorations/CHyprDropShadowDecoration.hpp @@ -26,14 +26,14 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration { virtual std::string getDisplayName(); private: - SWindowDecorationExtents m_seExtents; - SWindowDecorationExtents m_seReportedExtents; + SBoxExtents m_seExtents; + SBoxExtents m_seReportedExtents; - PHLWINDOWREF m_pWindow; + PHLWINDOWREF m_pWindow; - Vector2D m_vLastWindowPos; - Vector2D m_vLastWindowSize; + Vector2D m_vLastWindowPos; + Vector2D m_vLastWindowSize; - CBox m_bLastWindowBox = {0}; - CBox m_bLastWindowBoxWithDecos = {0}; + CBox m_bLastWindowBox = {0}; + CBox m_bLastWindowBoxWithDecos = {0}; }; diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 1af24717..bfb15d5c 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -48,7 +48,7 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration { virtual std::string getDisplayName(); private: - SWindowDecorationExtents m_seExtents; + SBoxExtents m_seExtents; CBox m_bAssignedBox = {0}; diff --git a/src/render/decorations/DecorationPositioner.cpp b/src/render/decorations/DecorationPositioner.cpp index 17f6d913..d66a5760 100644 --- a/src/render/decorations/DecorationPositioner.cpp +++ b/src/render/decorations/DecorationPositioner.cpp @@ -33,11 +33,11 @@ Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pW if (EDGESNO == 1) { if (TOP) - return wb.pos() + Vector2D{wb.size().x / 2.0, 0}; + return wb.pos() + Vector2D{wb.size().x / 2.0, 0.0}; else if (BOTTOM) return wb.pos() + Vector2D{wb.size().x / 2.0, wb.size().y}; else if (LEFT) - return wb.pos() + Vector2D{0, wb.size().y / 2.0}; + return wb.pos() + Vector2D{0.0, wb.size().y / 2.0}; else if (RIGHT) return wb.pos() + Vector2D{wb.size().x, wb.size().y / 2.0}; UNREACHABLE(); @@ -45,11 +45,11 @@ Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pW if (TOP && LEFT) return wb.pos(); if (TOP && RIGHT) - return wb.pos() + Vector2D{wb.size().x, 0}; + return wb.pos() + Vector2D{wb.size().x, 0.0}; if (BOTTOM && RIGHT) return wb.pos() + wb.size(); if (BOTTOM && LEFT) - return wb.pos() + Vector2D{0, wb.size().y}; + return wb.pos() + Vector2D{0.0, wb.size().y}; UNREACHABLE(); } UNREACHABLE(); @@ -234,26 +234,26 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) { } else if (LEFT) { pos = wb.pos() - EDGEPOINT - Vector2D{stickyOffsetXL, -stickyOffsetYT}; pos.x -= desiredSize; - size = {desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT}; + size = {(double)desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT}; if (SOLID) stickyOffsetXL += desiredSize; } else if (RIGHT) { - pos = wb.pos() + Vector2D{wb.size().x, 0} - EDGEPOINT + Vector2D{stickyOffsetXR, -stickyOffsetYT}; - size = {desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT}; + pos = wb.pos() + Vector2D{wb.size().x, 0.0} - EDGEPOINT + Vector2D{stickyOffsetXR, -stickyOffsetYT}; + size = {(double)desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT}; if (SOLID) stickyOffsetXR += desiredSize; } else if (TOP) { pos = wb.pos() - EDGEPOINT - Vector2D{stickyOffsetXL, stickyOffsetYT}; pos.y -= desiredSize; - size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, desiredSize}; + size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, (double)desiredSize}; if (SOLID) stickyOffsetYT += desiredSize; } else { - pos = wb.pos() + Vector2D{0, wb.size().y} - EDGEPOINT - Vector2D{stickyOffsetXL, stickyOffsetYB}; - size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, desiredSize}; + pos = wb.pos() + Vector2D{0.0, wb.size().y} - EDGEPOINT - Vector2D{stickyOffsetXL, stickyOffsetYB}; + size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, (double)desiredSize}; if (SOLID) stickyOffsetYB += desiredSize; @@ -271,7 +271,7 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) { } } - if (WINDOWDATA->extents != SWindowDecorationExtents{{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}}) { + if (WINDOWDATA->extents != SBoxExtents{{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}}) { WINDOWDATA->extents = {{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}}; g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow); } @@ -286,14 +286,14 @@ void CDecorationPositioner::onWindowMap(PHLWINDOW pWindow) { m_mWindowDatas[pWindow] = {}; } -SWindowDecorationExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow) { +SBoxExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow) { try { const auto E = m_mWindowDatas.at(pWindow); return E.reserved; } catch (std::out_of_range& e) { return {}; } } -SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) { +SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) { CBox accum = pWindow->getWindowMainSurfaceBox(); for (auto& data : m_vWindowPositioningDatas) { @@ -317,7 +317,7 @@ SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(PHLWI decoBox.translate(EDGEPOINT); } - SWindowDecorationExtents extentsToAdd; + SBoxExtents extentsToAdd; if (decoBox.x < accum.x) extentsToAdd.topLeft.x = accum.x - decoBox.x; @@ -355,7 +355,7 @@ CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) { decoBox.translate(EDGEPOINT); } - SWindowDecorationExtents extentsToAdd; + SBoxExtents extentsToAdd; if (decoBox.x < accum.x) extentsToAdd.topLeft.x = accum.x - decoBox.x; diff --git a/src/render/decorations/DecorationPositioner.hpp b/src/render/decorations/DecorationPositioner.hpp index 880dc3f8..27e56f0b 100644 --- a/src/render/decorations/DecorationPositioner.hpp +++ b/src/render/decorations/DecorationPositioner.hpp @@ -3,7 +3,7 @@ #include <cstdint> #include <vector> #include <map> -#include "../../helpers/Box.hpp" +#include "../../helpers/math/Math.hpp" #include "../../desktop/DesktopTypes.hpp" class CWindow; @@ -37,7 +37,7 @@ struct SDecorationPositioningInfo { eDecorationPositioningPolicy policy = DECORATION_POSITION_ABSOLUTE; uint32_t edges = 0; // enum eDecorationEdges uint32_t priority = 10; // priority, decos will be evaluated high -> low - SWindowDecorationExtents desiredExtents; + SBoxExtents desiredExtents; bool reserved = false; // if true, geometry will use reserved area }; @@ -62,14 +62,14 @@ class CDecorationPositioner { Vector2D getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pWindow); // called on resize, or insert/removal of a new deco - void onWindowUpdate(PHLWINDOW pWindow); - void uncacheDecoration(IHyprWindowDecoration* deco); - SWindowDecorationExtents getWindowDecorationReserved(PHLWINDOW pWindow); - SWindowDecorationExtents getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly = false); - CBox getBoxWithIncludedDecos(PHLWINDOW pWindow); - void repositionDeco(IHyprWindowDecoration* deco); - CBox getWindowDecorationBox(IHyprWindowDecoration* deco); - void forceRecalcFor(PHLWINDOW pWindow); + void onWindowUpdate(PHLWINDOW pWindow); + void uncacheDecoration(IHyprWindowDecoration* deco); + SBoxExtents getWindowDecorationReserved(PHLWINDOW pWindow); + SBoxExtents getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly = false); + CBox getBoxWithIncludedDecos(PHLWINDOW pWindow); + void repositionDeco(IHyprWindowDecoration* deco); + CBox getWindowDecorationBox(IHyprWindowDecoration* deco); + void forceRecalcFor(PHLWINDOW pWindow); private: struct SWindowPositioningData { @@ -81,10 +81,10 @@ class CDecorationPositioner { }; struct SWindowData { - Vector2D lastWindowSize = {}; - SWindowDecorationExtents reserved = {}; - SWindowDecorationExtents extents = {}; - bool needsRecalc = false; + Vector2D lastWindowSize = {}; + SBoxExtents reserved = {}; + SBoxExtents extents = {}; + bool needsRecalc = false; }; std::map<PHLWINDOWREF, SWindowData> m_mWindowDatas; diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp index 2346106f..a58560f3 100644 --- a/src/render/decorations/IHyprWindowDecoration.hpp +++ b/src/render/decorations/IHyprWindowDecoration.hpp @@ -2,7 +2,7 @@ #include <any> #include "../../defines.hpp" -#include "../../helpers/Region.hpp" +#include "../../helpers/math/Math.hpp" #include "DecorationPositioner.hpp" enum eDecorationType { |
