diff --git a/frameworks/core/components_ng/event/gesture_event_hub.cpp b/frameworks/core/components_ng/event/gesture_event_hub.cpp index 085688b04370d60af5d9cf96c1ff9e9f7bc03ca1..b3149a00256f2e7e692f961f010e6638ecee7356 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub.cpp @@ -782,6 +782,7 @@ void GestureEventHub::OnDragStart(const GestureEvent& info, const RefPtrSetDraggingPointer(info.GetPointerId()); dragDropManager->ResetRecordSize(static_cast(recordsSize)); auto eventManager = pipeline->GetEventManager(); CHECK_NULL_VOID(eventManager); @@ -1107,6 +1108,7 @@ OnDragCallbackCore GestureEventHub::GetDragCallback(const RefPtr& [eventHub, dragEvent, dragDropManager, eventManager]() { dragDropManager->SetIsDragged(false); dragDropManager->ResetDragging(); + dragDropManager->SetDraggingPointer(-1); if (eventManager) { eventManager->DoMouseActionRelease(); } diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h index 852381241c2afd90417680d33d639e07c8d64e24..4ae79321e2c25ff8c5d9c44afc3cad8fd12c7101 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.h @@ -109,7 +109,7 @@ public: RefPtr& notifyEvent, const Point& point, const DragEventType dragEventType); bool CheckDragDropProxy(int64_t id) const; - bool IsWindowConsumed() + bool IsWindowConsumed() const { return isWindowConsumed_; } @@ -147,7 +147,7 @@ public: isDragWindowShow_ = isDragWindowShow; } - bool IsDragWindowShow() + bool IsDragWindowShow() const { return isDragWindowShow_; } @@ -180,7 +180,7 @@ public: notifyInDraggedCallback_ = callback; } - bool IsDragging() + bool IsDragging() const { return dragDropState_ == DragDropMgrState::DRAGGING; } @@ -190,7 +190,7 @@ public: return dragDropState_ == DragDropMgrState::DRAGGING && draggedGridFrameNode_ != nullptr; } - bool IsAboutToPreview() + bool IsAboutToPreview() const { return dragDropState_ == DragDropMgrState::ABOUT_TO_PREVIEW; } @@ -200,6 +200,16 @@ public: dragDropState_ = dragDropMgrState; } + bool IsSameDraggingPointer(int32_t currentPointerId) const + { + return currentPointerId_ == currentPointerId; + } + + void SetDraggingPointer(int32_t currentPointerId) + { + currentPointerId_ = currentPointerId; + } + private: RefPtr FindDragFrameNodeByPosition(float globalX, float globalY, DragType dragType, bool findDrop); void FireOnDragEvent( @@ -241,6 +251,7 @@ private: uint32_t recordSize_ = 0; #endif // ENABLE_DRAG_FRAMEWORK int64_t currentId_ = -1; + int32_t currentPointerId_ = -1; std::function notifyInDraggedCallback_ = nullptr; bool isDragged_ = false; diff --git a/frameworks/core/pipeline_ng/pipeline_context.cpp b/frameworks/core/pipeline_ng/pipeline_context.cpp index 5af485b7c10b77ce2a40c7286b7844f8c7912469..f1666309df48caf7a131ea66f4ef97a410fb81a9 100755 --- a/frameworks/core/pipeline_ng/pipeline_context.cpp +++ b/frameworks/core/pipeline_ng/pipeline_context.cpp @@ -1156,12 +1156,22 @@ void PipelineContext::OnTouchEvent(const TouchEvent& point, bool isSubPipe) // need to reset touchPluginPipelineContext_ for next touch down event. touchPluginPipelineContext_.clear(); RemoveEtsCardTouchEventCallback(point.id); + ResetDraggingStatus(scalePoint); } hasIdleTasks_ = true; RequestFrame(); } +void PipelineContext::ResetDraggingStatus(const TouchEvent& touchPoint) +{ + auto manager = GetDragDropManager(); + CHECK_NULL_VOID(manager); + if (manager->IsDragging() && manager->IsSameDraggingPointer(touchPoint.id)) { + manager->OnDragEnd({ touchPoint.x, touchPoint.y }, ""); + } +} + void PipelineContext::OnSurfaceDensityChanged(double density) { CHECK_RUN_ON(UI); diff --git a/frameworks/core/pipeline_ng/pipeline_context.h b/frameworks/core/pipeline_ng/pipeline_context.h index c886e9aeaa2036b026f351090a1ac1b80a35ac5b..18cdf11097eb7b8bdc5f0a547bf0fc2f02b67c43 100644 --- a/frameworks/core/pipeline_ng/pipeline_context.h +++ b/frameworks/core/pipeline_ng/pipeline_context.h @@ -443,6 +443,8 @@ private: void RegisterRootEvent(); + void ResetDraggingStatus(const TouchEvent& touchPoint); + FrameInfo* GetCurrentFrameInfo(uint64_t recvTime, uint64_t timeStamp); void AnimateOnSafeAreaUpdate();