summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-08-30 17:23:35 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-08-30 17:23:35 +0200
commitc98a00678c1f3b051c2440b72f58cd9ecfdae70d (patch)
treea2e37f1eecf618efe82c5d85438a363a351456d8 /src
parentb4f123d1f2af8e7b42c730789d863aa22ea9fb56 (diff)
input: fix xwayland constraint calcs
some minor adjustments, fixes #3028
Diffstat (limited to 'src')
-rw-r--r--src/events/Devices.cpp2
-rw-r--r--src/helpers/WLClasses.hpp6
-rw-r--r--src/managers/input/InputManager.cpp8
3 files changed, 10 insertions, 6 deletions
diff --git a/src/events/Devices.cpp b/src/events/Devices.cpp
index 7a836edd..c80337f8 100644
--- a/src/events/Devices.cpp
+++ b/src/events/Devices.cpp
@@ -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;
diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp
index 7b7eecbd..dca7f1e0 100644
--- a/src/helpers/WLClasses.hpp
+++ b/src/helpers/WLClasses.hpp
@@ -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.
@@ -310,8 +312,8 @@ struct SSwipeGesture {
double delta = 0;
int initialDirection = 0;
- float avgSpeed = 0;
- int speedPoints = 0;
+ float avgSpeed = 0;
+ int speedPoints = 0;
CMonitor* pMonitor = nullptr;
};
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 679c1bca..bdb5c527 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -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;