Skip to content

Commit 30d4a3e

Browse files
committed
fixes
1 parent 0792758 commit 30d4a3e

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

src/desktop/reserved/ReservedArea.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "ReservedArea.hpp"
2+
#include "../../macros.hpp"
23

34
using namespace Desktop;
45

@@ -13,6 +14,18 @@ CReservedArea::CReservedArea(double top, double right, double bottom, double lef
1314
calculate();
1415
}
1516

17+
CReservedArea::CReservedArea(const CBox& parent, const CBox& child) {
18+
ASSERT(!parent.empty() && !child.empty());
19+
20+
ASSERT(parent.containsPoint(child.pos() + Vector2D{0.0001, 0.0001}));
21+
ASSERT(parent.containsPoint(child.pos() + child.size() - Vector2D{0.0001, 0.0001}));
22+
23+
m_initialTopLeft = child.pos() - parent.pos();
24+
m_initialBottomRight = (parent.pos() + parent.size()) - (child.pos() + child.size());
25+
26+
calculate();
27+
}
28+
1629
void CReservedArea::calculate() {
1730
m_bottomRight = m_initialBottomRight;
1831
m_topLeft = m_initialTopLeft;
@@ -70,3 +83,7 @@ void CReservedArea::addType(eReservedDynamicType t, const Vector2D& topLeft, con
7083
ref.bottomRight += bottomRight;
7184
calculate();
7285
}
86+
87+
void CReservedArea::addType(eReservedDynamicType t, const CReservedArea& area) {
88+
addType(t, {area.left(), area.top()}, {area.right(), area.bottom()});
89+
}

src/desktop/reserved/ReservedArea.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ namespace Desktop {
1616
CReservedArea() = default;
1717
CReservedArea(const Vector2D& tl, const Vector2D& br);
1818
CReservedArea(double top, double right, double bottom, double left);
19+
CReservedArea(const CBox& parent, const CBox& child);
1920
~CReservedArea() = default;
2021

2122
CBox apply(const CBox& other) const;
2223
void applyip(CBox& other) const;
2324

2425
void resetType(eReservedDynamicType);
2526
void addType(eReservedDynamicType, const Vector2D& topLeft, const Vector2D& bottomRight);
27+
void addType(eReservedDynamicType, const CReservedArea& area);
2628

2729
double left() const;
2830
double right() const;

src/render/Renderer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,8 +1856,7 @@ void CHyprRenderer::arrangeLayersForMonitor(const MONITORID& monitor) {
18561856
for (auto const& la : PMONITOR->m_layerSurfaceLayers)
18571857
arrangeLayerArray(PMONITOR, la, false, &usableArea);
18581858

1859-
PMONITOR->m_reservedArea.addType(Desktop::RESERVED_DYNAMIC_TYPE_LS, Vector2D{usableArea.x, usableArea.y} - PMONITOR->m_position,
1860-
ORIGINAL_USABLE_AREA.size() - Vector2D{usableArea.w, usableArea.h});
1859+
PMONITOR->m_reservedArea.addType(Desktop::RESERVED_DYNAMIC_TYPE_LS, Desktop::CReservedArea{ORIGINAL_USABLE_AREA, usableArea});
18611860

18621861
// damage the monitor if can
18631862
damageMonitor(PMONITOR);

tests/desktop/Reserved.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ TEST(Desktop, reservedArea) {
2828
EXPECT_EQ(box.y, 1000 + 30 + 20);
2929
EXPECT_EQ(box.w, 1000 - 20 - 40 - 10 - 30);
3030
EXPECT_EQ(box.h, 1000 - 30 - 50 - 20 - 40);
31+
32+
Desktop::CReservedArea b{CBox{10, 10, 1000, 1000}, CBox{20, 30, 900, 900}};
33+
34+
EXPECT_EQ(b.left(), 20 - 10);
35+
EXPECT_EQ(b.top(), 30 - 10);
36+
EXPECT_EQ(b.right(), 1010 - 920);
37+
EXPECT_EQ(b.bottom(), 1010 - 930);
3138
}

0 commit comments

Comments
 (0)