gestures: add unset

ref https://github.com/hyprwm/Hyprland/pull/11490
This commit is contained in:
Vaxry 2025-09-08 20:24:45 +01:00
parent b619f39555
commit 1e3a06560f
No known key found for this signature in database
GPG key ID: 665806380871D640
3 changed files with 15 additions and 0 deletions

View file

@ -89,6 +89,18 @@ std::expected<void, std::string> CTrackpadGestures::addGesture(UP<ITrackpadGestu
return {};
}
std::expected<void, std::string> 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; });
if (IT == m_gestures.end())
return std::unexpected("Can't remove a non-existent gesture");
std::erase(m_gestures, *IT);
return {};
}
void CTrackpadGestures::gestureBegin(const IPointer::SSwipeBeginEvent& e) {
if (m_activeGesture) {
Debug::log(ERR, "CTrackpadGestures::gestureBegin (swipe) but m_activeGesture is already present");

View file

@ -12,6 +12,7 @@ class CTrackpadGestures {
public:
void clearGestures();
std::expected<void, std::string> addGesture(UP<ITrackpadGesture>&& gesture, size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale);
std::expected<void, std::string> removeGesture(size_t fingerCount, eTrackpadGestureDirection direction, uint32_t modMask, float deltaScale);
void gestureBegin(const IPointer::SSwipeBeginEvent& e);
void gestureUpdate(const IPointer::SSwipeUpdateEvent& e);