input: let input-grabbing decos have prio over resize on border

This commit is contained in:
Vaxry 2023-10-29 23:37:12 +00:00
parent 59d6a12a7e
commit 86318ce04f

View file

@ -1621,49 +1621,70 @@ void CInputManager::setCursorIconOnBorder(CWindow* w) {
// give a small leeway (10 px) for corner icon // give a small leeway (10 px) for corner icon
const auto CORNER = *PROUNDING + BORDERSIZE + 10; const auto CORNER = *PROUNDING + BORDERSIZE + 10;
const auto mouseCoords = getMouseCoordsInternal(); const auto mouseCoords = getMouseCoordsInternal();
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; wlr_box box = w->getWindowMainSurfaceBox();
eBorderIconDirection direction = BORDERICON_NONE; eBorderIconDirection direction = BORDERICON_NONE;
wlr_box boxFullGrabInput = {box.x - *PEXTENDBORDERGRAB - BORDERSIZE, box.y - *PEXTENDBORDERGRAB - BORDERSIZE, box.width + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE), wlr_box boxFullGrabInput = {box.x - *PEXTENDBORDERGRAB - BORDERSIZE, box.y - *PEXTENDBORDERGRAB - BORDERSIZE, box.width + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE),
box.height + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE)}; box.height + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE)};
if (!wlr_box_contains_point(&boxFullGrabInput, mouseCoords.x, mouseCoords.y) || (!m_lCurrentlyHeldButtons.empty() && !currentlyDraggedWindow)) { if (w->hasPopupAt(mouseCoords))
direction = BORDERICON_NONE; direction = BORDERICON_NONE;
} else if (wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y)) { else if (!wlr_box_contains_point(&boxFullGrabInput, mouseCoords.x, mouseCoords.y) || (!m_lCurrentlyHeldButtons.empty() && !currentlyDraggedWindow))
if (!w->isInCurvedCorner(mouseCoords.x, mouseCoords.y)) { direction = BORDERICON_NONE;
direction = BORDERICON_NONE; else {
} else {
if (mouseCoords.y < box.y + CORNER) { bool onDeco = false;
if (mouseCoords.x < box.x + CORNER)
direction = BORDERICON_UP_LEFT; for (auto& d : w->m_dWindowDecorations) {
else if (!d->allowsInput())
direction = BORDERICON_UP_RIGHT; continue;
} else {
if (mouseCoords.x < box.x + CORNER) if (d->getWindowDecorationRegion().containsPoint(mouseCoords)) {
direction = BORDERICON_DOWN_LEFT; onDeco = true;
else break;
direction = BORDERICON_DOWN_RIGHT;
} }
} }
} else {
if (mouseCoords.y < box.y + CORNER) { if (onDeco)
if (mouseCoords.x < box.x + CORNER) direction = BORDERICON_NONE;
direction = BORDERICON_UP_LEFT; else {
else if (mouseCoords.x > box.x + box.width - CORNER) if (wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y)) {
direction = BORDERICON_UP_RIGHT; if (!w->isInCurvedCorner(mouseCoords.x, mouseCoords.y)) {
else direction = BORDERICON_NONE;
direction = BORDERICON_UP; } else {
} else if (mouseCoords.y > box.y + box.height - CORNER) { if (mouseCoords.y < box.y + CORNER) {
if (mouseCoords.x < box.x + CORNER) if (mouseCoords.x < box.x + CORNER)
direction = BORDERICON_DOWN_LEFT; direction = BORDERICON_UP_LEFT;
else if (mouseCoords.x > box.x + box.width - CORNER) else
direction = BORDERICON_DOWN_RIGHT; direction = BORDERICON_UP_RIGHT;
else } else {
direction = BORDERICON_DOWN; if (mouseCoords.x < box.x + CORNER)
} else { direction = BORDERICON_DOWN_LEFT;
if (mouseCoords.x < box.x + CORNER) else
direction = BORDERICON_LEFT; direction = BORDERICON_DOWN_RIGHT;
else if (mouseCoords.x > box.x + box.width - CORNER) }
direction = BORDERICON_RIGHT; }
} else {
if (mouseCoords.y < box.y + CORNER) {
if (mouseCoords.x < box.x + CORNER)
direction = BORDERICON_UP_LEFT;
else if (mouseCoords.x > box.x + box.width - CORNER)
direction = BORDERICON_UP_RIGHT;
else
direction = BORDERICON_UP;
} else if (mouseCoords.y > box.y + box.height - CORNER) {
if (mouseCoords.x < box.x + CORNER)
direction = BORDERICON_DOWN_LEFT;
else if (mouseCoords.x > box.x + box.width - CORNER)
direction = BORDERICON_DOWN_RIGHT;
else
direction = BORDERICON_DOWN;
} else {
if (mouseCoords.x < box.x + CORNER)
direction = BORDERICON_LEFT;
else if (mouseCoords.x > box.x + box.width - CORNER)
direction = BORDERICON_RIGHT;
}
}
} }
} }