summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-03-28 17:38:10 -0400
committerGitHub <noreply@github.com>2026-03-28 21:38:10 +0000
commit83d3babd4e703156b89fcec5bb64390306902f6e (patch)
tree80d74b34743ae93ab5ef96e5a438fa12e1762ed1 /src
parenteb10ecf738b0ed229125768f7b5953494d59cf9d (diff)
desktop/reserved: do not crash on invalid box init (#13880)
ref #13879
Diffstat (limited to 'src')
-rw-r--r--src/desktop/reserved/ReservedArea.cpp16
-rw-r--r--src/desktop/reserved/ReservedArea.hpp4
-rw-r--r--src/desktop/view/Window.cpp3
3 files changed, 21 insertions, 2 deletions
diff --git a/src/desktop/reserved/ReservedArea.cpp b/src/desktop/reserved/ReservedArea.cpp
index 8b4956dd..103beae3 100644
--- a/src/desktop/reserved/ReservedArea.cpp
+++ b/src/desktop/reserved/ReservedArea.cpp
@@ -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;
diff --git a/src/desktop/reserved/ReservedArea.hpp b/src/desktop/reserved/ReservedArea.hpp
index 2aca595d..ca5978a7 100644
--- a/src/desktop/reserved/ReservedArea.hpp
+++ b/src/desktop/reserved/ReservedArea.hpp
@@ -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;
};
diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp
index 287440e8..2a388d68 100644
--- a/src/desktop/view/Window.cpp
+++ b/src/desktop/view/Window.cpp
@@ -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();