input: fix xwayland constraint calcs

some minor adjustments, fixes #3028
This commit is contained in:
vaxerski 2023-08-30 17:23:35 +02:00
parent b4f123d1f2
commit c98a00678c
3 changed files with 10 additions and 6 deletions

View file

@ -122,7 +122,7 @@ void Events::listener_destroyConstraint(void* owner, void* data) {
const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse); 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); g_pInputManager->warpMouseToConstraintMiddle(PCONSTRAINT);
PCONSTRAINT->pMouse->currentConstraint = nullptr; PCONSTRAINT->pMouse->currentConstraint = nullptr;

View file

@ -166,6 +166,8 @@ struct SConstraint {
SMouse* pMouse = nullptr; SMouse* pMouse = nullptr;
wlr_pointer_constraint_v1* constraint = nullptr; wlr_pointer_constraint_v1* constraint = nullptr;
bool active = false;
bool hintSet = false; bool hintSet = false;
Vector2D positionHint; // the position hint, but will be set to the current cursor pos if not set. Vector2D positionHint; // the position hint, but will be set to the current cursor pos if not set.
@ -310,8 +312,8 @@ struct SSwipeGesture {
double delta = 0; double delta = 0;
int initialDirection = 0; int initialDirection = 0;
float avgSpeed = 0; float avgSpeed = 0;
int speedPoints = 0; int speedPoints = 0;
CMonitor* pMonitor = nullptr; CMonitor* pMonitor = nullptr;
}; };

View file

@ -1193,6 +1193,8 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
// warp to the constraint // warp to the constraint
recheckConstraint(pMouse); recheckConstraint(pMouse);
constraintFromWlr(constraint)->active = true;
wlr_pointer_constraint_v1_send_activated(pMouse->currentConstraint); wlr_pointer_constraint_v1_send_activated(pMouse->currentConstraint);
pMouse->hyprListener_commitConstraint.initCallback(&pMouse->currentConstraint->surface->events.commit, &Events::listener_commitConstraint, pMouse, "Mouse constraint commit"); 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) { if (PWINDOW) {
const auto RELATIVETO = PWINDOW->m_bIsX11 ? 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(); PWINDOW->m_vRealPosition.goalv();
const auto HINTSCALE = PWINDOW->m_fX11SurfaceScaledBy; const auto HINTSCALE = PWINDOW->m_fX11SurfaceScaledBy;
@ -1234,8 +1237,7 @@ void CInputManager::unconstrainMouse() {
const auto PCONSTRAINT = constraintFromWlr(g_pCompositor->m_sSeat.mouse->currentConstraint); const auto PCONSTRAINT = constraintFromWlr(g_pCompositor->m_sSeat.mouse->currentConstraint);
warpMouseToConstraintMiddle(PCONSTRAINT); warpMouseToConstraintMiddle(PCONSTRAINT);
PCONSTRAINT->hintSet = false; PCONSTRAINT->active = false;
PCONSTRAINT->positionHint = {-1, -1};
g_pCompositor->m_sSeat.mouse->constraintActive = false; g_pCompositor->m_sSeat.mouse->constraintActive = false;