diff options
| author | Sniffy Gumbles <155901370+SGumbles@users.noreply.github.com> | 2026-03-22 16:24:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-22 23:24:03 +0000 |
| commit | c54d7bf647b211192b9c4519b12c47e8f598fdbf (patch) | |
| tree | 3c327d187891046608af6928e8fe0064faeb0c14 /src/Compositor.cpp | |
| parent | bf31f642b08a8d8ca796a1b713285f2580805c2f (diff) | |
compositor: be more selective about how we expand the window box in getting coord (#13720)
* Be more selective about how we expand the window box here so that we're not overlapping with any neighbouring windows.
* Don't use getWindowInDirection to see if we're clear to expand the hit box. Instead, just see if our edge is close to the edge of the workspace.
* Clang-format changes
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index b6aaad00..844a19f9 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1043,8 +1043,55 @@ PHLWINDOW CCompositor::vectorToWindowUnified(const Vector2D& pos, uint8_t proper if (!w->m_isFloating && w->m_isMapped && w->workspaceID() == WSPID && !w->isHidden() && !w->m_X11ShouldntFocus && !w->m_ruleApplicator->noFocus().valueOrDefault() && w != pIgnoreWindow && !isShadowedByModal(w)) { CBox box = (properties & Desktop::View::USE_PROP_TILED) ? w->getWindowBoxUnified(properties) : CBox{w->m_position, w->m_size}; - if ((properties & Desktop::View::INPUT_EXTENTS) && BORDER_GRAB_AREA > 0 && !w->isX11OverrideRedirect()) - box.expand(BORDER_GRAB_AREA); + if ((properties & Desktop::View::INPUT_EXTENTS) && BORDER_GRAB_AREA > 0 && !w->isX11OverrideRedirect()) { + const auto WORKAREA = PWORKSPACE->m_space->workArea(); + static auto isWindowCloseToWorkAreaEdge = [&](const Math::eDirection dir) -> bool { + constexpr double STICK_THRESHOLD = 2.0; // This constant is taken from isAdjacent in CCompositor::getWindowInDirection + double aEdge = -1; + double bEdge = -1; + + switch (dir) { + case Math::DIRECTION_LEFT: + aEdge = WORKAREA.x; + bEdge = box.x; + break; + case Math::DIRECTION_RIGHT: + aEdge = WORKAREA.x + WORKAREA.width; + bEdge = box.x + box.width; + break; + case Math::DIRECTION_UP: + aEdge = WORKAREA.y; + bEdge = box.y; + break; + case Math::DIRECTION_DOWN: + aEdge = WORKAREA.y + WORKAREA.height; + bEdge = box.y + box.height; + break; + default: break; + } + const double delta = aEdge - bEdge; + if (std::abs(delta) < STICK_THRESHOLD) + return true; + else + return false; + }; + + if (isWindowCloseToWorkAreaEdge(Math::eDirection::DIRECTION_LEFT)) { + box.x -= BORDER_GRAB_AREA; + box.width += BORDER_GRAB_AREA; + } + + if (isWindowCloseToWorkAreaEdge(Math::eDirection::DIRECTION_RIGHT)) + box.width += BORDER_GRAB_AREA; + + if (isWindowCloseToWorkAreaEdge(Math::eDirection::DIRECTION_UP)) { + box.y -= BORDER_GRAB_AREA; + box.height += BORDER_GRAB_AREA; + } + + if (isWindowCloseToWorkAreaEdge(Math::eDirection::DIRECTION_DOWN)) + box.height += BORDER_GRAB_AREA; + } if (box.containsPoint(pos)) return w; } |
