diff options
| author | James Bingen <47846774+CptHuba@users.noreply.github.com> | 2026-03-10 11:04:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-10 10:04:50 +0000 |
| commit | 8217dabc80814b6d2741dc0a75c8398fc770b26c (patch) | |
| tree | c4bfd348f58bac2b66f6232aeaed4b02c43397db /src | |
| parent | 8a12d6cf7e3b11ea46e6d76f219b1d1cdde9e797 (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')
| -rw-r--r-- | src/layout/LayoutManager.cpp | 3 | ||||
| -rw-r--r-- | src/layout/algorithm/ModeAlgorithm.cpp | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/layout/LayoutManager.cpp b/src/layout/LayoutManager.cpp index 3f28085f..d5103fb5 100644 --- a/src/layout/LayoutManager.cpp +++ b/src/layout/LayoutManager.cpp @@ -125,6 +125,9 @@ void CLayoutManager::moveInDirection(SP<ITarget> target, const std::string& dire return; } + if (!target->space()) + return; + target->space()->moveTargetInDirection(target, dir, silent); } 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; |
