DragAndDrop: clean up drop target's resources when drag window is left 32/275832/1
authorTaehyub Kim <taehyub.kim@samsung.com>
Thu, 2 Jun 2022 10:43:37 +0000 (19:43 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Thu, 2 Jun 2022 10:43:37 +0000 (19:43 +0900)
Change-Id: I0cd231065469349a6165caa2d4ab7fd216da5620

dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.cpp
dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.h

index 1f81f63d54533d9990354c5080d9ddb258da05a3..b6654e6458fc37c283f113cf87cdcd950200ca43 100644 (file)
@@ -104,6 +104,13 @@ static Eina_Bool EcoreEventDataEnter(void* data, int type, void* event)
 
   // Set default offer is reject
   ecore_wl2_offer_accept(ev->offer, NULL);
+  return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool EcoreEventDataLeave(void* data, int type, void* event)
+{
+  DragAndDropEcoreWl* dndImpl = reinterpret_cast<DragAndDropEcoreWl*>(data);
+  dndImpl->ResetDropTargets();
 
   return ECORE_CALLBACK_PASS_ON;
 }
@@ -147,6 +154,7 @@ DragAndDropEcoreWl::DragAndDropEcoreWl()
   mMotionHandler     = ecore_event_handler_add(ECORE_WL2_EVENT_DND_MOTION, EcoreEventDataMotion, this);
   mDropHandler       = ecore_event_handler_add(ECORE_WL2_EVENT_DND_DROP, EcoreEventDataDrop, this);
   mEnterHandler      = ecore_event_handler_add(ECORE_WL2_EVENT_DND_ENTER, EcoreEventDataEnter, this);
+  mLeaveHandler      = ecore_event_handler_add(ECORE_WL2_EVENT_DND_LEAVE, EcoreEventDataLeave, this);
 }
 
 DragAndDropEcoreWl::~DragAndDropEcoreWl()
@@ -248,6 +256,15 @@ void DragAndDropEcoreWl::CallSourceEvent(Dali::DragAndDrop::SourceEventType type
   }
 }
 
+void DragAndDropEcoreWl::ResetDropTargets()
+{
+  for(std::size_t i = 0; i < mDropTargets.size(); i++)
+  {
+     mDropTargets[i].inside = false;
+  }
+}
+
+
 void DragAndDropEcoreWl::SendData(void* event)
 {
   Ecore_Wl2_Event_Data_Source_Send* ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_Send*>(event);
index 4727222aa29b1abd4f260ff3ca443b47ab394e77..162c3d02e65ade18aeb105c0b014f9ff86b4e4e6 100644 (file)
@@ -93,6 +93,11 @@ public:
    */
   void CallSourceEvent(Dali::DragAndDrop::SourceEventType type);
 
+  /**
+   * @brief Reset drop targets.
+   */
+  void ResetDropTargets();
+
 private:
   DragAndDropEcoreWl(const DragAndDropEcoreWl&) = delete;
   DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&) = delete;
@@ -109,6 +114,7 @@ private:
   Ecore_Event_Handler*              mMotionHandler{nullptr};
   Ecore_Event_Handler*              mDropHandler{nullptr};
   Ecore_Event_Handler*              mEnterHandler{nullptr};
+  Ecore_Event_Handler*              mLeaveHandler{nullptr};
   int                               mTargetIndex{0};
   std::string                       mMimeType;
   std::string                       mData;