From f8464866ebacb8d17b37bab77c4ff9b1c1a34371 Mon Sep 17 00:00:00 2001 From: ArchSav <96357545+ArchSav@users.noreply.github.com> Date: Tue, 30 Dec 2025 23:45:56 +1100 Subject: keybinds: add inhibiting gestures under shortcut inhibitors (#12692) --- src/managers/input/trackpad/TrackpadGestures.cpp | 24 +++++++++++++++++++----- src/managers/input/trackpad/TrackpadGestures.hpp | 6 ++++-- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'src/managers/input') diff --git a/src/managers/input/trackpad/TrackpadGestures.cpp b/src/managers/input/trackpad/TrackpadGestures.cpp index d41b8ede..e054c2f9 100644 --- a/src/managers/input/trackpad/TrackpadGestures.cpp +++ b/src/managers/input/trackpad/TrackpadGestures.cpp @@ -1,6 +1,8 @@ #include "TrackpadGestures.hpp" #include "../InputManager.hpp" +#include "../../../config/ConfigValue.hpp" +#include "../../../protocols/ShortcutsInhibit.hpp" #include @@ -54,7 +56,7 @@ const char* CTrackpadGestures::stringForDir(eTrackpadGestureDirection dir) { } std::expected CTrackpadGestures::addGesture(UP&& gesture, size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, - float deltaScale) { + float deltaScale, bool disableInhibit) { for (const auto& g : m_gestures) { if (g->fingerCount != fingerCount) continue; @@ -84,14 +86,16 @@ std::expected CTrackpadGestures::addGesture(UP(std::move(gesture), fingerCount, modMask, direction, deltaScale)); + m_gestures.emplace_back(makeShared(std::move(gesture), fingerCount, modMask, direction, deltaScale, disableInhibit)); return {}; } -std::expected CTrackpadGestures::removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale) { - const auto IT = std::ranges::find_if( - m_gestures, [&](const auto& g) { return g->fingerCount == fingerCount && g->direction == direction && g->modMask == modMask && g->deltaScale == deltaScale; }); +std::expected CTrackpadGestures::removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale, + bool disableInhibit) { + const auto IT = std::ranges::find_if(m_gestures, [&](const auto& g) { + return g->fingerCount == fingerCount && g->direction == direction && g->modMask == modMask && g->deltaScale == deltaScale && g->disableInhibit == disableInhibit; + }); if (IT == m_gestures.end()) return std::unexpected("Can't remove a non-existent gesture"); @@ -114,6 +118,8 @@ void CTrackpadGestures::gestureBegin(const IPointer::SSwipeBeginEvent& e) { } void CTrackpadGestures::gestureUpdate(const IPointer::SSwipeUpdateEvent& e) { + static auto PDISABLEINHIBIT = CConfigValue("binds:disable_keybind_grabbing"); + if (m_gestureFindFailed) return; @@ -148,6 +154,9 @@ void CTrackpadGestures::gestureUpdate(const IPointer::SSwipeUpdateEvent& e) { if (g->modMask != MODS) continue; + if (PROTO::shortcutsInhibit->isInhibited() && !*PDISABLEINHIBIT && !g->disableInhibit) + continue; + m_activeGesture = g; g->currentDirection = g->gesture->isDirectionSensitive() ? g->direction : direction; m_activeGesture->gesture->begin({.swipe = &e, .direction = direction, .scale = g->deltaScale}); @@ -184,6 +193,8 @@ void CTrackpadGestures::gestureBegin(const IPointer::SPinchBeginEvent& e) { } void CTrackpadGestures::gestureUpdate(const IPointer::SPinchUpdateEvent& e) { + static auto PDISABLEINHIBIT = CConfigValue("binds:disable_keybind_grabbing"); + if (m_gestureFindFailed) return; @@ -211,6 +222,9 @@ void CTrackpadGestures::gestureUpdate(const IPointer::SPinchUpdateEvent& e) { if (g->modMask != MODS) continue; + if (PROTO::shortcutsInhibit->isInhibited() && !*PDISABLEINHIBIT && !g->disableInhibit) + continue; + m_activeGesture = g; g->currentDirection = g->gesture->isDirectionSensitive() ? g->direction : direction; m_activeGesture->gesture->begin({.pinch = &e, .direction = direction}); diff --git a/src/managers/input/trackpad/TrackpadGestures.hpp b/src/managers/input/trackpad/TrackpadGestures.hpp index 7f96761f..ecf11c40 100644 --- a/src/managers/input/trackpad/TrackpadGestures.hpp +++ b/src/managers/input/trackpad/TrackpadGestures.hpp @@ -11,8 +11,9 @@ class CTrackpadGestures { public: void clearGestures(); - std::expected addGesture(UP&& gesture, size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale); - std::expected removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale); + std::expected addGesture(UP&& gesture, size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale, + bool disableInhibit); + std::expected removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale, bool disableInhibit); void gestureBegin(const IPointer::SSwipeBeginEvent& e); void gestureUpdate(const IPointer::SSwipeUpdateEvent& e); @@ -32,6 +33,7 @@ class CTrackpadGestures { uint32_t modMask = 0; eTrackpadGestureDirection direction = TRACKPAD_GESTURE_DIR_NONE; // configured dir float deltaScale = 1.F; + bool disableInhibit = false; eTrackpadGestureDirection currentDirection = TRACKPAD_GESTURE_DIR_NONE; // actual dir of that select swipe }; -- cgit v1.2.3