From 0730f2910f0593c779345f49e92723a9c8c3458f Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Wed, 27 Sep 2023 14:56:47 +0900 Subject: [PATCH] When a touch-up occurs, a hover-down event is generated. Change-Id: Ia1bafd5250992a6337efcc1ceb935b93e9aa4bb4 --- .../src/dali/utc-Dali-TouchEventCombiner.cpp | 55 ++++++++++++++++++++++ .../events/touch-event-combiner.cpp | 10 ++++ 2 files changed, 65 insertions(+) diff --git a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp index 1b6eb75..f9664c4 100644 --- a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp @@ -911,3 +911,58 @@ int UtcDaliTouchEventCombinerInvalidState(void) } END_TEST; } + +int UtcDaliTouchEventCombinerHoverDownAfterTouchUp(void) +{ + TouchEventCombiner combiner; + unsigned long time(0u); + + // Motion event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::MOTION, 100.0f, 100.0f); + point.SetDeviceClass(Device::Class::Type::MOUSE); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.GetPointCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION); + } + + + time++; + + // down event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::DOWN, 100.0f, 100.0f); + point.SetDeviceClass(Device::Class::Type::MOUSE); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.GetPointCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetState(), PointState::FINISHED, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION); + } + + time++; + + // up event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::UP, 103.0f, 103.0f); + point.SetDeviceClass(Device::Class::Type::MOUSE); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.GetPointCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetState(), PointState::DOWN, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), 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 9aa64a8..7423590 100644 --- a/dali/integration-api/events/touch-event-combiner.cpp +++ b/dali/integration-api/events/touch-event-combiner.cpp @@ -188,6 +188,16 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(cons iter = mHoveredPoints.erase(iter); } } + + if(deviceType == Device::Class::Type::MOUSE) + { + hoverEvent.time = time; + Point hoverPoint(point); + hoverPoint.SetState(PointState::STARTED); // The first hover event received + mHoveredPoints.push_back(PointInfo(hoverPoint, time)); + hoverEvent.AddPoint(hoverPoint); + dispatchEvent = TouchEventCombiner::DISPATCH_BOTH; + } } break; } -- 2.7.4