mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 00:29:49 +01:00
input: fix xwayland constraint calcs
some minor adjustments, fixes #3028
This commit is contained in:
parent
b4f123d1f2
commit
c98a00678c
3 changed files with 10 additions and 6 deletions
|
@ -122,7 +122,7 @@ void Events::listener_destroyConstraint(void* owner, void* data) {
|
|||
|
||||
const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
|
||||
|
||||
if (PWINDOW && PCONSTRAINT->positionHint != Vector2D{-1, -1})
|
||||
if (PWINDOW && PCONSTRAINT->active)
|
||||
g_pInputManager->warpMouseToConstraintMiddle(PCONSTRAINT);
|
||||
|
||||
PCONSTRAINT->pMouse->currentConstraint = nullptr;
|
||||
|
|
|
@ -166,6 +166,8 @@ struct SConstraint {
|
|||
SMouse* pMouse = nullptr;
|
||||
wlr_pointer_constraint_v1* constraint = nullptr;
|
||||
|
||||
bool active = false;
|
||||
|
||||
bool hintSet = false;
|
||||
Vector2D positionHint; // the position hint, but will be set to the current cursor pos if not set.
|
||||
|
||||
|
|
|
@ -1193,6 +1193,8 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
|
|||
// warp to the constraint
|
||||
recheckConstraint(pMouse);
|
||||
|
||||
constraintFromWlr(constraint)->active = true;
|
||||
|
||||
wlr_pointer_constraint_v1_send_activated(pMouse->currentConstraint);
|
||||
|
||||
pMouse->hyprListener_commitConstraint.initCallback(&pMouse->currentConstraint->surface->events.commit, &Events::listener_commitConstraint, pMouse, "Mouse constraint commit");
|
||||
|
@ -1212,7 +1214,8 @@ void CInputManager::warpMouseToConstraintMiddle(SConstraint* pConstraint) {
|
|||
|
||||
if (PWINDOW) {
|
||||
const auto RELATIVETO = PWINDOW->m_bIsX11 ?
|
||||
g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y}) / PWINDOW->m_fX11SurfaceScaledBy :
|
||||
(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 HINTSCALE = PWINDOW->m_fX11SurfaceScaledBy;
|
||||
|
||||
|
@ -1234,8 +1237,7 @@ void CInputManager::unconstrainMouse() {
|
|||
|
||||
const auto PCONSTRAINT = constraintFromWlr(g_pCompositor->m_sSeat.mouse->currentConstraint);
|
||||
warpMouseToConstraintMiddle(PCONSTRAINT);
|
||||
PCONSTRAINT->hintSet = false;
|
||||
PCONSTRAINT->positionHint = {-1, -1};
|
||||
PCONSTRAINT->active = false;
|
||||
|
||||
g_pCompositor->m_sSeat.mouse->constraintActive = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue