From 97b3f6c89f4b59ba67e722f70ea565a6aa506cc1 Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Mon, 16 Oct 2023 18:27:52 +0900 Subject: [PATCH] INTERRUPTED events are divided into touch and hover. Change-Id: I1474072e22199263922dd2ddb33ae38387999679 --- .../src/dali/utc-Dali-TouchEventCombiner.cpp | 72 +++++++++++++++++++++- .../events/touch-event-combiner.cpp | 16 +++-- 2 files changed, 81 insertions(+), 7 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp index f9664c4..8c8fc30 100644 --- a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp @@ -835,9 +835,45 @@ int UtcDaliTouchEventCombinerSingleTouchInterrupted(void) Integration::HoverEvent hoverEvent; Integration::Point point = GeneratePoint(1, PointState::INTERRUPTED, 100.0f, 100.0f); - DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); DALI_TEST_EQUALS(touchEvent.GetPointCount(), 1u, TEST_LOCATION); DALI_TEST_EQUALS(touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION); + } + + // Send up, should not be able to send as combiner has been reset. + // Up event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::UP, 100.0f, 100.0f); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + } + + // motion event for hover + { + 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++; + + // Interrupted event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::INTERRUPTED, 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].GetState(), point.GetState(), TEST_LOCATION); } @@ -877,9 +913,41 @@ int UtcDaliTouchEventCombinerMultiTouchInterrupted(void) Integration::HoverEvent hoverEvent; Integration::Point point = GeneratePoint(1, PointState::INTERRUPTED, 100.0f, 100.0f); - DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); DALI_TEST_EQUALS(touchEvent.GetPointCount(), 1u, TEST_LOCATION); DALI_TEST_EQUALS(touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION); + } + + // Send up, should not be able to send as combiner has been reset. + // Up event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::UP, 100.0f, 100.0f); + + DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION); + } + + // Several motion for hover + for(unsigned int pointCount = 1u; pointCount < maximum; ++pointCount) + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(pointCount, 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(), pointCount, TEST_LOCATION); + } + + // Interrupted event + { + Integration::TouchEvent touchEvent; + Integration::HoverEvent hoverEvent; + Integration::Point point = GeneratePoint(1, PointState::INTERRUPTED, 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].GetState(), point.GetState(), TEST_LOCATION); } diff --git a/dali/integration-api/events/touch-event-combiner.cpp b/dali/integration-api/events/touch-event-combiner.cpp index 7423590..4f01dfd 100644 --- a/dali/integration-api/events/touch-event-combiner.cpp +++ b/dali/integration-api/events/touch-event-combiner.cpp @@ -336,12 +336,18 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(cons case PointState::INTERRUPTED: { - Reset(); - // We should still tell core about the interruption. - touchEvent.AddPoint(point); - hoverEvent.AddPoint(point); - dispatchEvent = TouchEventCombiner::DISPATCH_BOTH; + if(!mPressedPoints.empty()) + { + touchEvent.AddPoint(point); + dispatchEvent = TouchEventCombiner::DISPATCH_TOUCH; + } + if((!mHoveredPoints.empty())) + { + hoverEvent.AddPoint(point); + dispatchEvent = dispatchEvent == TouchEventCombiner::DISPATCH_TOUCH ? TouchEventCombiner::DISPATCH_BOTH : TouchEventCombiner::DISPATCH_HOVER; + } + Reset(); break; } -- 2.7.4