When a touch-up occurs, a hover-down event is generated. 87/299387/5
authorjoogab.yun <joogab.yun@samsung.com>
Wed, 27 Sep 2023 05:56:47 +0000 (14:56 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Wed, 4 Oct 2023 05:32:53 +0000 (14:32 +0900)
Change-Id: Ia1bafd5250992a6337efcc1ceb935b93e9aa4bb4

automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp
dali/integration-api/events/touch-event-combiner.cpp

index 1b6eb75..f9664c4 100644 (file)
@@ -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;
+}
index 9aa64a8..7423590 100644 (file)
@@ -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;
     }