diff --git a/src/GestureManager.cpp b/src/GestureManager.cpp index 8e6010a..4b01bf0 100644 --- a/src/GestureManager.cpp +++ b/src/GestureManager.cpp @@ -60,10 +60,10 @@ void GestureManager::emulateSwipeUpdate(uint32_t time) { } bool GestureManager::handleGesture(const CompletedGesture& gev) { - if (gev.type == GESTURE_TYPE_SWIPE_HOLD) { + if (gev.type == TouchGestureType::SWIPE_HOLD) { return this->handleWorkspaceSwipe(gev); } - if (gev.type == GESTURE_TYPE_SWIPE && this->dragGestureIsActive()) { + if (gev.type == TouchGestureType::SWIPE && this->dragGestureIsActive()) { this->emulateSwipeEnd(0, false); return true; } @@ -111,7 +111,7 @@ bool GestureManager::handleWorkspaceSwipe(const CompletedGesture& gev) { ->m_vRenderOffset.getConfig() ->pValues->internalStyle == "slidevert"; - if (gev.type == GESTURE_TYPE_SWIPE_HOLD && gev.finger_count == *PWORKSPACEFINGERS) { + if (gev.type == TouchGestureType::SWIPE_HOLD && gev.finger_count == *PWORKSPACEFINGERS) { const auto horizontal = GESTURE_DIRECTION_LEFT | GESTURE_DIRECTION_RIGHT; const auto vertical = GESTURE_DIRECTION_UP | GESTURE_DIRECTION_DOWN; const auto workspace_directions = VERTANIMS ? vertical : horizontal; diff --git a/src/gestures/Gestures.cpp b/src/gestures/Gestures.cpp index 39a438c..0f13bef 100644 --- a/src/gestures/Gestures.cpp +++ b/src/gestures/Gestures.cpp @@ -30,20 +30,20 @@ std::string stringifyDirection(gestureDirection direction) { std::string CompletedGesture::to_string() const { std::string bind = ""; switch (type) { - case GESTURE_TYPE_EDGE_SWIPE: + case TouchGestureType::EDGE_SWIPE: bind += "edge"; break; - case GESTURE_TYPE_SWIPE: + case TouchGestureType::SWIPE: bind += "swipe"; break; - case GESTURE_TYPE_SWIPE_HOLD: + case TouchGestureType::SWIPE_HOLD: // this gesture is only used internally for workspace swipe return "workspace_swipe"; } bind += ":"; - if (type == GESTURE_TYPE_EDGE_SWIPE) { + if (type == TouchGestureType::EDGE_SWIPE) { bind += stringifyDirection(this->edge_origin); } else { bind += std::to_string(finger_count); @@ -215,9 +215,9 @@ void IGestureManager::addTouchGesture(std::unique_ptr gest // Adds a Multi-fingered swipe: // * inhibits events to client windows/surfaces when enough fingers touch // down within a short duration. -// * emits a GESTURE_TYPE_SWIPE_HOLD event once fingers moved over the +// * emits a TouchGestureType::SWIPE_HOLD event once fingers moved over the // threshold. -// * further emits a GESTURE_TYPE_SWIPE event if the SWIPE_HOLD event was +// * further emits a TouchGestureType::SWIPE event if the SWIPE_HOLD event was // emitted and once a finger is lifted void IGestureManager::addMultiFingerGesture(const float* sensitivity) { auto multi_down = std::make_unique([this]() { this->cancelTouchEventsOnAllWindows(); }); @@ -233,7 +233,7 @@ void IGestureManager::addMultiFingerGesture(const float* sensitivity) { if (this->dragGestureActive) { return; } - const auto gesture = CompletedGesture{GESTURE_TYPE_SWIPE_HOLD, swipe_ptr->target_direction, + const auto gesture = CompletedGesture{TouchGestureType::SWIPE_HOLD, swipe_ptr->target_direction, static_cast(this->m_sGestureState.fingers.size())}; this->dragGestureActive = this->handleGesture(gesture); @@ -250,7 +250,7 @@ void IGestureManager::addMultiFingerGesture(const float* sensitivity) { swipe_actions.emplace_back(std::move(swipe_liftoff)); auto ack = [swipe_ptr, this]() { - const auto gesture = CompletedGesture{GESTURE_TYPE_SWIPE, swipe_ptr->target_direction, + const auto gesture = CompletedGesture{TouchGestureType::SWIPE, swipe_ptr->target_direction, static_cast(this->m_sGestureState.fingers.size())}; this->handleGesture(gesture); }; @@ -289,7 +289,7 @@ void IGestureManager::addEdgeSwipeGesture(const float* sensitivity) { return; } auto direction = edge_ptr->target_direction; - auto gesture = CompletedGesture{GESTURE_TYPE_EDGE_SWIPE, direction, edge_ptr->finger_count, origin_edges}; + auto gesture = CompletedGesture{TouchGestureType::EDGE_SWIPE, direction, edge_ptr->finger_count, origin_edges}; this->handleGesture(gesture); }; auto cancel = [this]() { this->handleCancelledGesture(); }; diff --git a/src/gestures/Gestures.hpp b/src/gestures/Gestures.hpp index 48bca56..1bf62dc 100644 --- a/src/gestures/Gestures.hpp +++ b/src/gestures/Gestures.hpp @@ -24,17 +24,15 @@ constexpr static uint32_t GESTURE_BASE_DURATION = 400; constexpr static uint32_t SEND_CANCEL_EVENT_FINGER_COUNT = 3; -enum eTouchGestureType -{ +enum class TouchGestureType { // Invalid Gesture - GESTURE_TYPE_SWIPE, - GESTURE_TYPE_SWIPE_HOLD, // same as SWIPE but fingers were not lifted - GESTURE_TYPE_EDGE_SWIPE, - // GESTURE_TYPE_PINCH, + SWIPE, + SWIPE_HOLD, // same as SWIPE but fingers were not lifted + EDGE_SWIPE, + // PINCH, }; -enum eTouchGestureDirection -{ +enum TouchGestureDirection { /* Swipe-specific */ GESTURE_DIRECTION_LEFT = (1 << 0), GESTURE_DIRECTION_RIGHT = (1 << 1), @@ -54,7 +52,7 @@ using gestureDirection = uint32_t; * Finger count can be arbitrary (might be a good idea to limit to >3) */ struct CompletedGesture { - eTouchGestureType type; + TouchGestureType type; gestureDirection direction; int finger_count; diff --git a/src/gestures/test/MockGestureManager.cpp b/src/gestures/test/MockGestureManager.cpp index 9263604..5c39a13 100644 --- a/src/gestures/test/MockGestureManager.cpp +++ b/src/gestures/test/MockGestureManager.cpp @@ -9,7 +9,7 @@ CMockGestureManager::CMockGestureManager() {} bool CMockGestureManager::handleGesture(const CompletedGesture& gev) { std::cout << "gesture triggered: " << gev.to_string() << "\n"; - this->triggered = this->triggered || gev.type != GESTURE_TYPE_SWIPE_HOLD; + this->triggered = this->triggered || gev.type != TouchGestureType::SWIPE_HOLD; return true; }