diff --git a/adapter/ohos/capability/interaction/interaction_impl.cpp b/adapter/ohos/capability/interaction/interaction_impl.cpp index f004277569f..0ddb4ffd2bc 100644 --- a/adapter/ohos/capability/interaction/interaction_impl.cpp +++ b/adapter/ohos/capability/interaction/interaction_impl.cpp @@ -81,9 +81,9 @@ int32_t InteractionImpl::StartDrag(const DragDataCore& dragData, std::make_shared(callbackCore)); } -int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style) +int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style, const int32_t eventId) { - return InteractionManager::GetInstance()->UpdateDragStyle(TranslateDragCursorStyle(style)); + return InteractionManager::GetInstance()->UpdateDragStyle(TranslateDragCursorStyle(style), eventId); } int32_t InteractionImpl::UpdatePreviewStyle(const OHOS::Ace::PreviewStyle& previewStyle) diff --git a/adapter/ohos/capability/interaction/interaction_impl.h b/adapter/ohos/capability/interaction/interaction_impl.h index d266c84dafb..3608882ef13 100644 --- a/adapter/ohos/capability/interaction/interaction_impl.h +++ b/adapter/ohos/capability/interaction/interaction_impl.h @@ -32,7 +32,7 @@ public: int32_t StartDrag(const DragDataCore& dragData, std::function callback) override; - int32_t UpdateDragStyle(DragCursorStyleCore style) override; + int32_t UpdateDragStyle(DragCursorStyleCore style, const int32_t eventId = -1) override; int32_t UpdatePreviewStyle(const PreviewStyle& previewStyle) override; diff --git a/adapter/preview/entrance/msdp/interaction_impl.cpp b/adapter/preview/entrance/msdp/interaction_impl.cpp index e8ba9797acc..5b265657e90 100644 --- a/adapter/preview/entrance/msdp/interaction_impl.cpp +++ b/adapter/preview/entrance/msdp/interaction_impl.cpp @@ -39,7 +39,7 @@ int32_t InteractionImpl::StartDrag(const DragDataCore& dragData, return -1; } -int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style) +int32_t InteractionImpl::UpdateDragStyle(OHOS::Ace::DragCursorStyleCore style, const int32_t eventId) { return -1; } diff --git a/adapter/preview/entrance/msdp/interaction_impl.h b/adapter/preview/entrance/msdp/interaction_impl.h index d0aef53ed54..67658b38bb6 100644 --- a/adapter/preview/entrance/msdp/interaction_impl.h +++ b/adapter/preview/entrance/msdp/interaction_impl.h @@ -31,7 +31,7 @@ public: int32_t StartDrag(const DragDataCore& dragData, std::function callback) override; - int32_t UpdateDragStyle(DragCursorStyleCore style) override; + int32_t UpdateDragStyle(DragCursorStyleCore style, const int32_t eventId = -1) override; int32_t UpdatePreviewStyle(const PreviewStyle& previewStyle) override; diff --git a/frameworks/core/common/interaction/interaction_interface.h b/frameworks/core/common/interaction/interaction_interface.h index 49f04c24cf3..fabc95e725e 100644 --- a/frameworks/core/common/interaction/interaction_interface.h +++ b/frameworks/core/common/interaction/interaction_interface.h @@ -33,7 +33,7 @@ public: virtual int32_t StartDrag(const DragDataCore& dragData, std::function callback) = 0; - virtual int32_t UpdateDragStyle(DragCursorStyleCore style) = 0; + virtual int32_t UpdateDragStyle(DragCursorStyleCore style, const int32_t eventId = -1) = 0; virtual int32_t UpdatePreviewStyle(const PreviewStyle& previewStyle) = 0; diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp index f9e9bb2355c..05ace163012 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp @@ -312,10 +312,11 @@ bool DragDropManager::CheckDragDropProxy(int64_t id) const return currentId_ == id; } -void DragDropManager::UpdateDragAllowDrop(const RefPtr& dragFrameNode, const DragBehavior dragBehavior) +void DragDropManager::UpdateDragAllowDrop( + const RefPtr& dragFrameNode, const DragBehavior dragBehavior, const int32_t eventId) { if (!IsDropAllowed(dragFrameNode)) { - UpdateDragStyle(DragCursorStyleCore::FORBIDDEN); + UpdateDragStyle(DragCursorStyleCore::FORBIDDEN, eventId); return; } @@ -324,7 +325,7 @@ void DragDropManager::UpdateDragAllowDrop(const RefPtr& dragFrameNode const auto& dragFrameNodeAllowDrop = dragFrameNode->GetAllowDrop(); // special handling for no drag data present situation, always show as move if (dragFrameNodeAllowDrop.empty() || summaryMap_.empty()) { - UpdateDragStyle(DragCursorStyleCore::MOVE); + UpdateDragStyle(DragCursorStyleCore::MOVE, eventId); return; } @@ -335,33 +336,34 @@ void DragDropManager::UpdateDragAllowDrop(const RefPtr& dragFrameNode // draggedFrameNode or frameNode is disabled, otherwise use copy auto eventHub = dragFrameNode->GetEventHub(); if (draggedFrameNode_ == dragFrameNode || !(eventHub && eventHub->IsEnabled())) { - UpdateDragStyle(DragCursorStyleCore::MOVE); + UpdateDragStyle(DragCursorStyleCore::MOVE, eventId); } else { - UpdateDragStyle(DragCursorStyleCore::COPY); + UpdateDragStyle(DragCursorStyleCore::COPY, eventId); } break; } case DragBehavior::MOVE: { - UpdateDragStyle(DragCursorStyleCore::MOVE); + UpdateDragStyle(DragCursorStyleCore::MOVE, eventId); break; } case DragBehavior::COPY: { - UpdateDragStyle(DragCursorStyleCore::COPY); + UpdateDragStyle(DragCursorStyleCore::COPY, eventId); break; } default: { - UpdateDragStyle(DragCursorStyleCore::COPY); + UpdateDragStyle(DragCursorStyleCore::COPY, eventId); break; } } } -void DragDropManager::UpdateDragStyle(const DragCursorStyleCore& dragStyle) +void DragDropManager::UpdateDragStyle(const DragCursorStyleCore& dragStyle, int32_t eventId) { if (dragStyle != dragCursorStyleCore_) { dragCursorStyleCore_ = dragStyle; - TAG_LOGI(AceLogTag::ACE_DRAG, "Update DragStyle to %{public}d.", dragCursorStyleCore_); - InteractionInterface::GetInstance()->UpdateDragStyle(dragCursorStyleCore_); + TAG_LOGI(AceLogTag::ACE_DRAG, "Update DragStyle to %{public}d, pointerEventId: %{public}d.", + dragCursorStyleCore_, eventId); + InteractionInterface::GetInstance()->UpdateDragStyle(dragCursorStyleCore_, eventId); } } @@ -673,7 +675,7 @@ void DragDropManager::OnDragMove(const PointerEvent& pointerEvent, const std::st } if (!isMouseDragged_ || isDragWindowShow_) { - UpdateDragStyle(DragCursorStyleCore::MOVE); + UpdateDragStyle(DragCursorStyleCore::MOVE, pointerEvent.pointerEventId); } return; } @@ -947,7 +949,7 @@ void DragDropManager::RequireSummary() std::string str = udkey + "-" + std::to_string(recordSize) + ";"; summarys += str; } - TAG_LOGD(AceLogTag::ACE_DRAG, "require summary: %{public}s", summarys.c_str()); + TAG_LOGI(AceLogTag::ACE_DRAG, "require summary: %{public}s", summarys.c_str()); } std::string extraInfo; ret = InteractionInterface::GetInstance()->GetDragExtraInfo(extraInfo); @@ -1087,14 +1089,14 @@ void DragDropManager::FireOnDragEvent( } if (event->GetResult() == DragRet::ENABLE_DROP) { if (event->GetDragBehavior() == DragBehavior::MOVE) { - UpdateDragStyle(DragCursorStyleCore::MOVE); + UpdateDragStyle(DragCursorStyleCore::MOVE, pointerEvent.pointerEventId); } else { - UpdateDragStyle(DragCursorStyleCore::COPY); + UpdateDragStyle(DragCursorStyleCore::COPY, pointerEvent.pointerEventId); } } else if (event->GetResult() == DragRet::DISABLE_DROP) { - UpdateDragStyle(DragCursorStyleCore::FORBIDDEN); + UpdateDragStyle(DragCursorStyleCore::FORBIDDEN, pointerEvent.pointerEventId); } else { - UpdateDragAllowDrop(frameNode, event->GetDragBehavior()); + UpdateDragAllowDrop(frameNode, event->GetDragBehavior(), pointerEvent.pointerEventId); } } 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 25532fd5093..a70d9d363cb 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 @@ -126,8 +126,10 @@ public: void SetExtraInfo(const std::string& extraInfo); void ClearExtraInfo(); float GetWindowScale() const; - void UpdateDragStyle(const DragCursorStyleCore& dragCursorStyleCore = DragCursorStyleCore::DEFAULT); - void UpdateDragAllowDrop(const RefPtr& dragFrameNode, const DragBehavior dragBehavior); + void UpdateDragStyle( + const DragCursorStyleCore& dragCursorStyleCore = DragCursorStyleCore::DEFAULT, const int32_t eventId = -1); + void UpdateDragAllowDrop( + const RefPtr& dragFrameNode, const DragBehavior dragBehavior, const int32_t eventId = -1); void RequireSummary(); void ClearSummary(); void SetSummaryMap(const std::map& summaryMap) diff --git a/frameworks/core/event/pointer_event.h b/frameworks/core/event/pointer_event.h index 88cec62e22b..8781b9ee3c8 100644 --- a/frameworks/core/event/pointer_event.h +++ b/frameworks/core/event/pointer_event.h @@ -81,6 +81,9 @@ struct PointerEvent final { PointerEvent(int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY) : windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY) {} + PointerEvent(int32_t pointerEventId, int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY) + : pointerEventId(pointerEventId), windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY) + {} Point GetPoint() const { diff --git a/frameworks/core/pipeline_ng/pipeline_context.cpp b/frameworks/core/pipeline_ng/pipeline_context.cpp index 205938aa088..e91331ad2bf 100644 --- a/frameworks/core/pipeline_ng/pipeline_context.cpp +++ b/frameworks/core/pipeline_ng/pipeline_context.cpp @@ -2210,7 +2210,9 @@ void PipelineContext::ResetDraggingStatus(const TouchEvent& touchPoint, const Re manager->SetDraggingPressedState(false); } if (manager->IsDragging() && manager->IsSameDraggingPointer(touchPoint.id)) { - manager->OnDragEnd(PointerEvent(touchPoint.x, touchPoint.y), ""); + manager->OnDragEnd( + PointerEvent(touchPoint.touchEventId, touchPoint.x, touchPoint.y, touchPoint.screenX, touchPoint.screenY), + ""); } } diff --git a/test/mock/core/common/mock_interaction_interface.h b/test/mock/core/common/mock_interaction_interface.h index 8c4613b36c4..5a7e2c3007c 100644 --- a/test/mock/core/common/mock_interaction_interface.h +++ b/test/mock/core/common/mock_interaction_interface.h @@ -34,7 +34,7 @@ public: MOCK_METHOD(int32_t, StartDrag, (const DragDataCore& dragData, std::function callback), (override)); - MOCK_METHOD(int32_t, UpdateDragStyle, (DragCursorStyleCore style), (override)); + MOCK_METHOD(int32_t, UpdateDragStyle, (DragCursorStyleCore style, const int32_t eventId), (override)); MOCK_METHOD(int32_t, UpdatePreviewStyle, (const PreviewStyle& previewStyle), (override)); diff --git a/test/unittest/core/manager/drag_drop_manager_test_ng_coverage.cpp b/test/unittest/core/manager/drag_drop_manager_test_ng_coverage.cpp index a0e0035756f..22a6de8f799 100644 --- a/test/unittest/core/manager/drag_drop_manager_test_ng_coverage.cpp +++ b/test/unittest/core/manager/drag_drop_manager_test_ng_coverage.cpp @@ -370,7 +370,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi PointF point(100.0, 100.0); dragDropManager->OnDragStart({ GLOBAL_X, GLOBAL_Y }, childNode); dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId)); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1); EXPECT_FALSE(dragDropManager->summaryMap_.empty()); /** @@ -380,7 +380,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi dragDropManager->summaryMap_.clear(); dragDropManager->OnDragStart({ GLOBAL_X, GLOBAL_Y }, frameNode); dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId)); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1); EXPECT_FALSE(dragDropManager->summaryMap_.empty()); /** @@ -389,7 +389,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi */ dragDropManager->summaryMap_.clear(); dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId)); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE, -1); EXPECT_FALSE(dragDropManager->summaryMap_.empty()); /** @@ -398,7 +398,7 @@ HWTEST_F(DragDropManagerTestNgCoverage, DragDropManagerTestNgCoverage011, TestSi */ dragDropManager->summaryMap_.clear(); dragDropManager->summaryMap_.insert(make_pair(ROOT_ETS_TAG, frameNodeNullId)); - dragDropManager->UpdateDragAllowDrop(frameNode, static_cast(-100)); + dragDropManager->UpdateDragAllowDrop(frameNode, static_cast(-100), -1); EXPECT_TRUE(allowDrop.find(ROOT_ETS_TAG) == allowDrop.end()); } diff --git a/test/unittest/core/manager/drag_drop_manager_test_ng_property_config.cpp b/test/unittest/core/manager/drag_drop_manager_test_ng_property_config.cpp index f20bbc26a79..1df783cc241 100644 --- a/test/unittest/core/manager/drag_drop_manager_test_ng_property_config.cpp +++ b/test/unittest/core/manager/drag_drop_manager_test_ng_property_config.cpp @@ -1466,7 +1466,7 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest049, TestSize.Level1) * @tc.expected: dragDropManager->summaryMap_.empty() return a true value. */ dragDropManager->summaryMap_.clear(); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY, -1); EXPECT_TRUE(dragDropManager->summaryMap_.empty()); /** @@ -1474,7 +1474,7 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest049, TestSize.Level1) * @tc.expected: dragDropManager->summaryMap_.empty() return a false value. */ dragDropManager->summaryMap_.insert(make_pair(NODE_TAG, frameNodeNullId)); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY, -1); EXPECT_FALSE(dragDropManager->summaryMap_.empty()); /** @@ -1483,7 +1483,7 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest049, TestSize.Level1) */ dragDropManager->summaryMap_.clear(); dragDropManager->summaryMap_.insert(make_pair(ROOT_ETS_TAG, frameNodeNullId)); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::COPY, -1); EXPECT_TRUE(allowDrop.find(ROOT_ETS_TAG) == allowDrop.end()); } @@ -2034,13 +2034,13 @@ HWTEST_F(DragDropManagerTestNgNew, DragDropManagerTest067, TestSize.Level1) frameNode->SetAllowDrop(allowDrop); const auto& dragFrameNodeAllowDrop = frameNode->GetAllowDrop(); EXPECT_NE(dragDropManager->draggedFrameNode_, frameNode); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN); - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::MOVE, -1); EXPECT_FALSE(dragFrameNodeAllowDrop.empty()); EXPECT_FALSE(dragDropManager->summaryMap_.empty()); dragDropManager->draggedFrameNode_ = frameNode; - dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN); + dragDropManager->UpdateDragAllowDrop(frameNode, DragBehavior::UNKNOWN, -1); EXPECT_EQ(dragDropManager->draggedFrameNode_, frameNode); }