mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-07 16:58:07 +02:00
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
This commit is contained in:
parent
aaea8547d6
commit
fec5ff333e
1 changed files with 49 additions and 2 deletions
|
|
@ -1033,8 +1033,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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue