From 110caf244a93338b0561e028e9fe9f4cb9b4391c Mon Sep 17 00:00:00 2001 From: cyren Date: Fri, 29 Aug 2025 16:14:13 -0500 Subject: [PATCH 1/3] allow workspace swipe wraparound when workspace_swipe_create_new is false --- src/managers/input/UnifiedWorkspaceSwipeGesture.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp b/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp index 01b92b480..d704b6e2b 100644 --- a/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp +++ b/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp @@ -65,7 +65,8 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { m_delta = std::clamp(m_delta, sc(-SWIPEDISTANCE), sc(SWIPEDISTANCE)); if ((m_workspaceBegin->m_id == workspaceIDLeft && *PSWIPENEW && (m_delta < 0)) || - (m_delta > 0 && m_workspaceBegin->getWindows() == 0 && workspaceIDRight <= m_workspaceBegin->m_id) || (m_delta < 0 && m_workspaceBegin->m_id <= workspaceIDLeft)) { + (m_delta > 0 && m_workspaceBegin->getWindows() == 0 && workspaceIDRight <= m_workspaceBegin->m_id) || + (m_delta < 0 && m_workspaceBegin->m_id <= workspaceIDLeft && *PSWIPENEW)) { m_delta = 0; g_pHyprRenderer->damageMonitor(m_monitor.lock()); @@ -83,7 +84,7 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { if (m_delta < 0) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft); - if (workspaceIDLeft > m_workspaceBegin->m_id || !PWORKSPACE) { + if ((workspaceIDLeft > m_workspaceBegin->m_id && *PSWIPENEW) || !PWORKSPACE) { if (*PSWIPENEW) { g_pHyprRenderer->damageMonitor(m_monitor.lock()); @@ -123,7 +124,7 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { } else { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight); - if (workspaceIDRight < m_workspaceBegin->m_id || !PWORKSPACE) { + if ((workspaceIDRight < m_workspaceBegin->m_id && *PSWIPENEW) || !PWORKSPACE) { if (*PSWIPENEW) { g_pHyprRenderer->damageMonitor(m_monitor.lock()); From 290c3efa40872ea506f8649d85cdf587b44ac428 Mon Sep 17 00:00:00 2001 From: cyren Date: Tue, 7 Oct 2025 21:02:36 -0500 Subject: [PATCH 2/3] add a third value to workspace_swipe_create_new supporting wrapping, renaming it --- src/config/ConfigDescriptions.hpp | 9 +++++---- src/config/ConfigManager.cpp | 2 +- .../input/UnifiedWorkspaceSwipeGesture.cpp | 20 +++++++++---------- .../gestures/WorkspaceSwipeGesture.cpp | 4 ++-- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 0308dde06..c242c288f 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -800,10 +800,11 @@ inline static const std::vector CONFIG_OPTIONS = { .data = SConfigOptionDescription::SFloatData{0.5, 0, 1}, }, SConfigOptionDescription{ - .value = "gestures:workspace_swipe_create_new", - .description = "whether a swipe right on the last workspace should create a new one.", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{true}, + .value = "gestures:workspace_swipe_bound", + .description = + "what to do when swiping to before the first or after the last workspace. Options: 0 (do nothing), 1 (create new after last), 2 (wrap between first and last)", + .type = CONFIG_OPTION_INT, + .data = SConfigOptionDescription::SRangeData{1, 0, 2}, }, SConfigOptionDescription{ .value = "gestures:workspace_swipe_direction_lock", diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 3e75f2ab3..60536a6ec 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -719,7 +719,7 @@ CConfigManager::CConfigManager() { registerConfigVar("gestures:workspace_swipe_invert", Hyprlang::INT{1}); registerConfigVar("gestures:workspace_swipe_min_speed_to_force", Hyprlang::INT{30}); registerConfigVar("gestures:workspace_swipe_cancel_ratio", {0.5f}); - registerConfigVar("gestures:workspace_swipe_create_new", Hyprlang::INT{1}); + registerConfigVar("gestures:workspace_swipe_bound", Hyprlang::INT{1}); registerConfigVar("gestures:workspace_swipe_direction_lock", Hyprlang::INT{1}); registerConfigVar("gestures:workspace_swipe_direction_lock_threshold", Hyprlang::INT{10}); registerConfigVar("gestures:workspace_swipe_forever", Hyprlang::INT{0}); diff --git a/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp b/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp index d704b6e2b..ab31f5eef 100644 --- a/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp +++ b/src/managers/input/UnifiedWorkspaceSwipeGesture.cpp @@ -34,7 +34,7 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { return; static auto PSWIPEDIST = CConfigValue("gestures:workspace_swipe_distance"); - static auto PSWIPENEW = CConfigValue("gestures:workspace_swipe_create_new"); + static auto PSWIPEBOUND = CConfigValue("gestures:workspace_swipe_bound"); static auto PSWIPEDIRLOCK = CConfigValue("gestures:workspace_swipe_direction_lock"); static auto PSWIPEDIRLOCKTHRESHOLD = CConfigValue("gestures:workspace_swipe_direction_lock_threshold"); static auto PSWIPEFOREVER = CConfigValue("gestures:workspace_swipe_forever"); @@ -55,7 +55,7 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { auto workspaceIDLeft = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r-1" : "m-1")).id; auto workspaceIDRight = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r+1" : "m+1")).id; - if ((workspaceIDLeft == WORKSPACE_INVALID || workspaceIDRight == WORKSPACE_INVALID || workspaceIDLeft == m_workspaceBegin->m_id) && !*PSWIPENEW) { + if ((workspaceIDLeft == WORKSPACE_INVALID || workspaceIDRight == WORKSPACE_INVALID || workspaceIDLeft == m_workspaceBegin->m_id) && *PSWIPEBOUND != 1) { m_workspaceBegin = nullptr; // invalidate the swipe return; } @@ -64,9 +64,9 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { m_delta = std::clamp(m_delta, sc(-SWIPEDISTANCE), sc(SWIPEDISTANCE)); - if ((m_workspaceBegin->m_id == workspaceIDLeft && *PSWIPENEW && (m_delta < 0)) || + if ((m_workspaceBegin->m_id == workspaceIDLeft && *PSWIPEBOUND == 1 && (m_delta < 0)) || (m_delta > 0 && m_workspaceBegin->getWindows() == 0 && workspaceIDRight <= m_workspaceBegin->m_id) || - (m_delta < 0 && m_workspaceBegin->m_id <= workspaceIDLeft && *PSWIPENEW)) { + (m_delta < 0 && m_workspaceBegin->m_id <= workspaceIDLeft && *PSWIPEBOUND != 2)) { m_delta = 0; g_pHyprRenderer->damageMonitor(m_monitor.lock()); @@ -84,8 +84,8 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { if (m_delta < 0) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft); - if ((workspaceIDLeft > m_workspaceBegin->m_id && *PSWIPENEW) || !PWORKSPACE) { - if (*PSWIPENEW) { + if ((workspaceIDLeft > m_workspaceBegin->m_id && *PSWIPEBOUND != 2) || !PWORKSPACE) { + if (*PSWIPEBOUND == 1) { g_pHyprRenderer->damageMonitor(m_monitor.lock()); if (VERTANIMS) @@ -124,8 +124,8 @@ void CUnifiedWorkspaceSwipeGesture::update(double delta) { } else { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight); - if ((workspaceIDRight < m_workspaceBegin->m_id && *PSWIPENEW) || !PWORKSPACE) { - if (*PSWIPENEW) { + if ((workspaceIDRight < m_workspaceBegin->m_id && *PSWIPEBOUND != 2) || !PWORKSPACE) { + if (*PSWIPEBOUND) { g_pHyprRenderer->damageMonitor(m_monitor.lock()); if (VERTANIMS) @@ -182,7 +182,7 @@ void CUnifiedWorkspaceSwipeGesture::end() { static auto PSWIPEPERC = CConfigValue("gestures:workspace_swipe_cancel_ratio"); static auto PSWIPEDIST = CConfigValue("gestures:workspace_swipe_distance"); static auto PSWIPEFORC = CConfigValue("gestures:workspace_swipe_min_speed_to_force"); - static auto PSWIPENEW = CConfigValue("gestures:workspace_swipe_create_new"); + static auto PSWIPEBOUND = CConfigValue("gestures:workspace_swipe_bound"); static auto PSWIPEUSER = CConfigValue("gestures:workspace_swipe_use_r"); static auto PWORKSPACEGAP = CConfigValue("general:gaps_workspaces"); const auto ANIMSTYLE = m_workspaceBegin->m_renderOffset->getStyle(); @@ -195,7 +195,7 @@ void CUnifiedWorkspaceSwipeGesture::end() { // If we've been swiping off the right end with PSWIPENEW enabled, there is // no workspace there yet, and we need to choose an ID for a new one now. - if (workspaceIDRight <= m_workspaceBegin->m_id && *PSWIPENEW) + if (workspaceIDRight <= m_workspaceBegin->m_id && *PSWIPEBOUND == 1) workspaceIDRight = getWorkspaceIDNameFromString("r+1").id; auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW || PSWIPENUMBER diff --git a/src/managers/input/trackpad/gestures/WorkspaceSwipeGesture.cpp b/src/managers/input/trackpad/gestures/WorkspaceSwipeGesture.cpp index 793bfd77c..2abeff6dc 100644 --- a/src/managers/input/trackpad/gestures/WorkspaceSwipeGesture.cpp +++ b/src/managers/input/trackpad/gestures/WorkspaceSwipeGesture.cpp @@ -9,7 +9,7 @@ void CWorkspaceSwipeGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) { ITrackpadGesture::begin(e); - static auto PSWIPENEW = CConfigValue("gestures:workspace_swipe_create_new"); + static auto PSWIPEBOUND = CConfigValue("gestures:workspace_swipe_bound"); if (g_pSessionLockManager->isSessionLocked() || g_pUnifiedWorkspaceSwipe->isGestureInProgress()) return; @@ -20,7 +20,7 @@ void CWorkspaceSwipeGesture::begin(const ITrackpadGesture::STrackpadGestureBegin onMonitor++; } - if (onMonitor < 2 && !*PSWIPENEW) + if (onMonitor < 2 && *PSWIPEBOUND != 1) return; // disallow swiping when there's 1 workspace on a monitor g_pUnifiedWorkspaceSwipe->begin(); From 9b3bebaab4297633c09eaba058b04e5abdb63dd8 Mon Sep 17 00:00:00 2001 From: cyren Date: Tue, 7 Oct 2025 22:18:04 -0500 Subject: [PATCH 3/3] edit tests --- hyprtester/src/tests/main/gestures.cpp | 2 +- pointer-scroll.txt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 pointer-scroll.txt diff --git a/hyprtester/src/tests/main/gestures.cpp b/hyprtester/src/tests/main/gestures.cpp index 4c56e904d..f39d3caef 100644 --- a/hyprtester/src/tests/main/gestures.cpp +++ b/hyprtester/src/tests/main/gestures.cpp @@ -121,7 +121,7 @@ static bool test() { } OK(getFromSocket("/keyword gestures:workspace_swipe_invert 1")); - OK(getFromSocket("/keyword gestures:workspace_swipe_create_new 0")); + OK(getFromSocket("/keyword gestures:workspace_swipe_bound 0")); OK(getFromSocket("/dispatch plugin:test:gesture left,3")); diff --git a/pointer-scroll.txt b/pointer-scroll.txt new file mode 100644 index 000000000..69fe62f73 --- /dev/null +++ b/pointer-scroll.txt @@ -0,0 +1,14 @@ + > binding to global: wl_seat (version 9) with id 1 + > binding to global: wl_compositor (version 6) with id 3 + > binding to global: wl_shm (version 1) with id 5 + > binding to global: xdg_wm_base (version 7) with id 37 +started +Got pointer enter event, serial 807, x 240128, y 132608 +axis: ax 0 delta 10 +10.00 +axis: ax 0 delta 20 +20.00 +axis: ax 0 delta 30 +30.00 +axis: ax 0 delta 40 +40.00