summaryrefslogtreecommitdiff
path: root/src/managers/input/Touch.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-26 19:11:28 +0100
committerVaxry <vaxry@vaxry.net>2024-04-26 19:11:28 +0100
commitf94264928a8ab4da8759d4ded25a46af44451d38 (patch)
tree0144116047e9a5a90beb811fb4e5ccc60b85a21c /src/managers/input/Touch.cpp
parentd9ec2785cb7f6493576232057752688e57925655 (diff)
swipe: fix crashes with invalid distance
fixes #5758
Diffstat (limited to 'src/managers/input/Touch.cpp')
-rw-r--r--src/managers/input/Touch.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index 71129ef8..36bf79b7 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -107,22 +107,23 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e) {
return;
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert" ||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle.starts_with("slidefadevert");
- static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_invert");
- static auto PSWIPEDIST = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_distance");
+ static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_invert");
+ static auto PSWIPEDIST = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_distance");
+ const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX);
// Handle the workspace swipe if there is one
if (m_sActiveSwipe.initialDirection == -1) {
if (*PSWIPEINVR)
- // go from 0 to -PSWIPEDIST
- updateWorkspaceSwipe(*PSWIPEDIST * ((VERTANIMS ? e->y : e->x) - 1));
+ // go from 0 to -SWIPEDISTANCE
+ updateWorkspaceSwipe(SWIPEDISTANCE * ((VERTANIMS ? e->y : e->x) - 1));
else
- // go from 0 to -PSWIPEDIST
- updateWorkspaceSwipe(*PSWIPEDIST * (-1 * (VERTANIMS ? e->y : e->x)));
+ // go from 0 to -SWIPEDISTANCE
+ updateWorkspaceSwipe(SWIPEDISTANCE * (-1 * (VERTANIMS ? e->y : e->x)));
} else if (*PSWIPEINVR)
- // go from 0 to PSWIPEDIST
- updateWorkspaceSwipe(*PSWIPEDIST * (VERTANIMS ? e->y : e->x));
+ // go from 0 to SWIPEDISTANCE
+ updateWorkspaceSwipe(SWIPEDISTANCE * (VERTANIMS ? e->y : e->x));
else
- // go from 0 to PSWIPEDIST
- updateWorkspaceSwipe(*PSWIPEDIST * (1 - (VERTANIMS ? e->y : e->x)));
+ // go from 0 to SWIPEDISTANCE
+ updateWorkspaceSwipe(SWIPEDISTANCE * (1 - (VERTANIMS ? e->y : e->x)));
return;
}
if (m_sTouchData.touchFocusWindow && g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {