summaryrefslogtreecommitdiff
path: root/src/layout/algorithm
diff options
context:
space:
mode:
authorJames Bingen <47846774+CptHuba@users.noreply.github.com>2026-03-10 11:04:50 +0100
committerGitHub <noreply@github.com>2026-03-10 10:04:50 +0000
commit8217dabc80814b6d2741dc0a75c8398fc770b26c (patch)
treec4bfd348f58bac2b66f6232aeaed4b02c43397db /src/layout/algorithm
parent8a12d6cf7e3b11ea46e6d76f219b1d1cdde9e797 (diff)
layout: fix null deref in focalPointForDir and moveInDirection (#13652)
Added a guard against expired m_parent weak pointer in IModeAlgorithm::focalPointForDir when the fullscreen monitor path is taken, and also added a null check in CLayoutManager::moveInDirection. This seemed to have fixed a segfault triggered by a 3-finger swipe gesture end on a fullscreen tiled window.
Diffstat (limited to 'src/layout/algorithm')
-rw-r--r--src/layout/algorithm/ModeAlgorithm.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/layout/algorithm/ModeAlgorithm.cpp b/src/layout/algorithm/ModeAlgorithm.cpp
index dea5bb17..2fea2b68 100644
--- a/src/layout/algorithm/ModeAlgorithm.cpp
+++ b/src/layout/algorithm/ModeAlgorithm.cpp
@@ -18,8 +18,21 @@ std::optional<Vector2D> IModeAlgorithm::predictSizeForNewTarget() {
std::optional<Vector2D> IModeAlgorithm::focalPointForDir(SP<ITarget> t, Math::eDirection dir) {
Vector2D focalPoint;
- const auto WINDOWIDEALBB =
- t->fullscreenMode() != FSMODE_NONE ? m_parent->space()->workspace()->m_monitor->logicalBox() : t->window()->getWindowIdealBoundingBoxIgnoreReserved();
+ const auto getFullscreenBB = [&]() -> std::optional<CBox> {
+ const auto PARENT = m_parent.lock();
+ if (!PARENT)
+ return std::nullopt;
+ const auto SPACE = PARENT->space();
+ if (!SPACE)
+ return std::nullopt;
+ const auto WS = SPACE->workspace();
+ if (!WS || !WS->m_monitor)
+ return std::nullopt;
+ return WS->m_monitor->logicalBox();
+ };
+
+ const auto WINDOWIDEALBB = t->fullscreenMode() != FSMODE_NONE ? getFullscreenBB().value_or(t->window()->getWindowIdealBoundingBoxIgnoreReserved()) :
+ t->window()->getWindowIdealBoundingBoxIgnoreReserved();
switch (dir) {
case Math::DIRECTION_UP: focalPoint = WINDOWIDEALBB.pos() + Vector2D{WINDOWIDEALBB.size().x / 2.0, -1.0}; break;