aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-09-28 20:02:00 +0100
committervaxerski <[email protected]>2023-09-28 20:02:00 +0100
commitd48c11cc3f12dc12315008b5574be6455238db7b (patch)
tree8fd8c74529532a139763405879cfaf5e18819947 /src/managers
parent08595f839b6c1fb02edd490ff2c2da4e0db7b226 (diff)
downloadHyprland-d48c11cc3f12dc12315008b5574be6455238db7b.tar.gz
Hyprland-d48c11cc3f12dc12315008b5574be6455238db7b.zip
input: minor constraint fixes
Better adjust to constraints that do not set a hint. Fixes #3436
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/input/InputManager.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 02ccfd1b..beb55c5d 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1207,24 +1207,30 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
return;
const auto MOUSECOORDS = getMouseCoordsInternal();
+ const auto PCONSTRAINT = constraintFromWlr(constraint);
pMouse->hyprListener_commitConstraint.removeCallback();
- if (pMouse->currentConstraint) {
- if (constraint) {
- const auto PCONSTRAINT = constraintFromWlr(constraint);
- if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
- PCONSTRAINT->hintSet = true;
- PCONSTRAINT->positionHint = {constraint->current.cursor_hint.x, constraint->current.cursor_hint.y};
- }
+ if (pMouse->currentConstraint)
+ wlr_pointer_constraint_v1_send_deactivated(pMouse->currentConstraint);
- if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT && constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED)
- warpMouseToConstraintMiddle(PCONSTRAINT);
- }
+ if (const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface); PWINDOW) {
+ const auto RELATIVETO = PWINDOW->m_bIsX11 ?
+ (PWINDOW->m_bIsMapped ? PWINDOW->m_vRealPosition.goalv() :
+ g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y})) :
+ PWINDOW->m_vRealPosition.goalv();
- wlr_pointer_constraint_v1_send_deactivated(pMouse->currentConstraint);
+ PCONSTRAINT->cursorPosOnActivate = MOUSECOORDS - RELATIVETO;
+ }
+
+ if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
+ PCONSTRAINT->hintSet = true;
+ PCONSTRAINT->positionHint = {constraint->current.cursor_hint.x, constraint->current.cursor_hint.y};
}
+ if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT && constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED)
+ warpMouseToConstraintMiddle(PCONSTRAINT);
+
pMouse->currentConstraint = constraint;
pMouse->constraintActive = true;
@@ -1236,7 +1242,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
// warp to the constraint
recheckConstraint(pMouse);
- constraintFromWlr(constraint)->active = true;
+ PCONSTRAINT->active = true;
wlr_pointer_constraint_v1_send_activated(pMouse->currentConstraint);
@@ -1253,23 +1259,17 @@ void CInputManager::warpMouseToConstraintMiddle(SConstraint* pConstraint) {
const auto PWINDOW = g_pCompositor->getWindowFromSurface(pConstraint->constraint->surface);
if (PWINDOW) {
- const auto RELATIVETO = PWINDOW->m_bIsX11 ?
- (PWINDOW->m_bIsMapped ? PWINDOW->m_vRealPosition.goalv() :
- g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y})) :
- PWINDOW->m_vRealPosition.goalv();
+ const auto RELATIVETO = pConstraint->getLogicConstraintPos();
const auto HINTSCALE = PWINDOW->m_fX11SurfaceScaledBy;
- if (pConstraint->hintSet) {
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, RELATIVETO.x + pConstraint->positionHint.x / HINTSCALE, RELATIVETO.y + pConstraint->positionHint.y / HINTSCALE);
- wlr_seat_pointer_warp(pConstraint->constraint->seat, pConstraint->constraint->current.cursor_hint.x, pConstraint->constraint->current.cursor_hint.y);
- } else {
- const auto RELATIVESIZE = PWINDOW->m_bIsX11 ?
- (PWINDOW->m_bIsMapped ? PWINDOW->m_vRealSize.goalv() :
- g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOW->m_uSurface.xwayland->width, PWINDOW->m_uSurface.xwayland->height})) :
- PWINDOW->m_vRealSize.goalv();
+ auto HINT = pConstraint->hintSet ? pConstraint->positionHint : pConstraint->cursorPosOnActivate;
- wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, RELATIVETO.x + RELATIVESIZE.x / 2.f, RELATIVETO.y + RELATIVESIZE.y / 2.f);
- wlr_seat_pointer_warp(pConstraint->constraint->seat, RELATIVESIZE.x / 2.f, RELATIVESIZE.y / 2.f);
+ if (HINT == Vector2D{-1, -1})
+ HINT = pConstraint->getLogicConstraintSize() / 2.f;
+
+ if (HINT != Vector2D{-1, -1}) {
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, RELATIVETO.x + HINT.x / HINTSCALE, RELATIVETO.y + HINT.y / HINTSCALE);
+ wlr_seat_pointer_warp(pConstraint->constraint->seat, pConstraint->constraint->current.cursor_hint.x, pConstraint->constraint->current.cursor_hint.y);
}
}
}
@@ -1597,7 +1597,7 @@ void CInputManager::setCursorIconOnBorder(CWindow* w) {
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
eBorderIconDirection direction = BORDERICON_NONE;
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)) {
direction = BORDERICON_NONE;