mirror of
https://github.com/hyprwm/Hyprland.git
synced 2026-08-24 10:04:19 -05:00
@@ -1,5 +1,6 @@
|
||||
#include "ReservedArea.hpp"
|
||||
#include "../../macros.hpp"
|
||||
#include "../../debug/log/Logger.hpp"
|
||||
|
||||
using namespace Desktop;
|
||||
|
||||
@@ -19,8 +20,15 @@ CReservedArea::CReservedArea(const CBox& parent, const CBox& child) {
|
||||
if (parent.empty() || child.empty())
|
||||
return; // empty reserved area
|
||||
|
||||
ASSERT(parent.containsPoint(child.pos() + Vector2D{0.0001, 0.0001}));
|
||||
ASSERT(parent.containsPoint(child.pos() + child.size() - Vector2D{0.0001, 0.0001}));
|
||||
if (!parent.containsPoint(child.pos() + Vector2D{0.0001, 0.0001}) //
|
||||
|| !parent.containsPoint(child.pos() + child.size() - Vector2D{0.0001, 0.0001})) {
|
||||
|
||||
Log::logger->log(Log::ERR, "CReservedArea: attempted to create a reserved area from parent [{}, {}] and child [{}, {}] which is invalid", parent.pos(), parent.size(),
|
||||
child.pos(), child.size());
|
||||
|
||||
m_ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_initialTopLeft = child.pos() - parent.pos();
|
||||
m_initialBottomRight = (parent.pos() + parent.size()) - (child.pos() + child.size());
|
||||
@@ -28,6 +36,10 @@ CReservedArea::CReservedArea(const CBox& parent, const CBox& child) {
|
||||
calculate();
|
||||
}
|
||||
|
||||
bool CReservedArea::ok() const {
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
void CReservedArea::calculate() {
|
||||
m_bottomRight = m_initialBottomRight;
|
||||
m_topLeft = m_initialTopLeft;
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace Desktop {
|
||||
double top() const;
|
||||
double bottom() const;
|
||||
|
||||
bool ok() const;
|
||||
|
||||
bool operator==(const CReservedArea& other) const;
|
||||
|
||||
private:
|
||||
@@ -39,6 +41,8 @@ namespace Desktop {
|
||||
Vector2D m_topLeft, m_bottomRight;
|
||||
Vector2D m_initialTopLeft, m_initialBottomRight;
|
||||
|
||||
bool m_ok = true;
|
||||
|
||||
struct SDynamicData {
|
||||
Vector2D topLeft, bottomRight;
|
||||
};
|
||||
|
||||
@@ -285,6 +285,9 @@ CBox CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
|
||||
const auto WORKAREA = m_workspace->m_space->workArea();
|
||||
const auto& RESERVED = CReservedArea(PMONITOR->logicalBox(), WORKAREA);
|
||||
|
||||
if (!RESERVED.ok())
|
||||
return CBox{POS, SIZE};
|
||||
|
||||
if (DELTALESSTHAN(POS.x, WORKAREA.x, 1)) {
|
||||
POS.x -= RESERVED.left();
|
||||
SIZE.x += RESERVED.left();
|
||||
|
||||
@@ -49,4 +49,7 @@ TEST(Desktop, reservedArea) {
|
||||
EXPECT_EQ(d.top(), 0);
|
||||
EXPECT_EQ(d.right(), 0);
|
||||
EXPECT_EQ(d.bottom(), 0);
|
||||
|
||||
Desktop::CReservedArea e{CBox{20, 30, 900, 900}, CBox{0, 0, 100, 100}};
|
||||
EXPECT_EQ(e.ok(), false);
|
||||
}
|
||||
Reference in New Issue
Block a user