From: joogab.yun Date: Mon, 9 Sep 2024 07:23:01 +0000 (+0900) Subject: Different mouse button types must be handled as separate events. X-Git-Tag: accepted/tizen/unified/20240912.084751~2^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3c2bccc47bb0a91f5debe93d86c921b46fa56c7;p=platform%2Fcore%2Fuifw%2Fdali-core.git Different mouse button types must be handled as separate events. Change-Id: I7081ca145f61dd1240cc9f8f2b662001dae3b393 --- diff --git a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp index 8c8fc306f..46f46b58a 100644 --- a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp @@ -1034,3 +1034,67 @@ int UtcDaliTouchEventCombinerHoverDownAfterTouchUp(void) END_TEST; } + + +int UtcDaliTouchEventCombinerMultipleMouseButton(void) +{ + TouchEventCombiner combiner; + unsigned long time(0u); + + // Primary down + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::DOWN, 100.0f, 100.0f); + point.SetMouseButton(MouseButton::PRIMARY); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(touchEvent.GetPointCount(), 1, TEST_LOCATION); + } + + // secondary down + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::DOWN, 100.0f, 100.0f); + point.SetMouseButton(MouseButton::SECONDARY); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, ++time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(touchEvent.GetPointCount(), 2, TEST_LOCATION); + } + + // move + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::MOTION, 150.0f, 150.0f); + point.SetMouseButton(MouseButton::PRIMARY); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, ++time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(touchEvent.GetPointCount(), 2, TEST_LOCATION); + } + + // up event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::UP, 150.0f, 150.0f); + point.SetMouseButton(MouseButton::PRIMARY); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, ++time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(touchEvent.GetPointCount(), 2, TEST_LOCATION); + } + + // up event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::UP, 150.0f, 150.0f); + point.SetMouseButton(MouseButton::SECONDARY); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, ++time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(touchEvent.GetPointCount(), 1, TEST_LOCATION); + } + + END_TEST; +} diff --git a/dali/integration-api/events/touch-event-combiner.cpp b/dali/integration-api/events/touch-event-combiner.cpp index 879df14ad..a9e423107 100644 --- a/dali/integration-api/events/touch-event-combiner.cpp +++ b/dali/integration-api/events/touch-event-combiner.cpp @@ -35,6 +35,13 @@ namespace { const unsigned long DEFAULT_MINIMUM_MOTION_TIME(1u); const Vector2 DEFAULT_MINIMUM_MOTION_DISTANCE(1.0f, 1.0f); + +inline bool CheckEqualInputSource(const Point& lhs, const int deviceId, const MouseButton::Type mouseButton) +{ + return (lhs.GetDeviceId() == deviceId) && /// Check device id is equal and + ((mouseButton == MouseButton::INVALID) || /// ...Check whether input point is not from mouse + (mouseButton == lhs.GetMouseButton())); /// ...or from same mouse button +} } // unnamed namespace struct TouchEventCombiner::PointInfo @@ -86,6 +93,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(cons const PointState::Type state = point.GetState(); const int deviceId = point.GetDeviceId(); const Device::Class::Type deviceType = point.GetDeviceClass(); + const MouseButton::Type mouseButton = point.GetMouseButton(); switch(state) { @@ -97,7 +105,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(cons // Iterate through already stored touch points and add to TouchEvent for(PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter) { - if(iter->point.GetDeviceId() != deviceId) + if(!CheckEqualInputSource(iter->point, deviceId, mouseButton)) { if(!isMultiTouchEvent) { @@ -164,7 +172,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(cons PointInfoContainer::iterator match(mPressedPoints.end()); for(PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter) { - if(deviceId == iter->point.GetDeviceId()) + if(CheckEqualInputSource(iter->point, deviceId, mouseButton)) { match = iter; @@ -259,6 +267,7 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(cons if(match != mPressedPoints.end()) { PointInfo matchedPoint(point, time); + matchedPoint.point.SetMouseButton(match->point.GetMouseButton()); std::swap(*match, matchedPoint); dispatchEvent = TouchEventCombiner::DISPATCH_TOUCH; // Dispatch touch event