From 8804a085487d7f14d42285022486cb9ea19a0733 Mon Sep 17 00:00:00 2001 From: hct95 Date: Sat, 4 Nov 2023 10:09:09 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8B=96=E6=8B=BD=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E6=97=B6=E5=BF=AB=E9=80=9F=E6=8A=AC=E6=89=8B=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hct95 Change-Id: Iad3dea7648df99703d889d6d94619145db1790a7 --- .../components_ng/event/gesture_event_hub.cpp | 2 ++ .../manager/drag_drop/drag_drop_manager.h | 19 +++++++++++++++---- .../core/pipeline_ng/pipeline_context.cpp | 10 ++++++++++ .../core/pipeline_ng/pipeline_context.h | 2 ++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/frameworks/core/components_ng/event/gesture_event_hub.cpp b/frameworks/core/components_ng/event/gesture_event_hub.cpp index 085688b0437..b3149a00256 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 852381241c2..4ae79321e2c 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 5af485b7c10..f1666309df4 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 c886e9aeaa2..18cdf11097e 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(); -- Gitee