!45957 增加是否是此次拖拽的实时判断

Merge pull request !45957 from Zenix/fixDragSummary
This commit is contained in:
openharmony_ci 2024-10-21 16:14:22 +00:00 committed by Gitee
commit e144e8392f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 32 additions and 7 deletions

View File

@ -520,6 +520,7 @@ void ConvertPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
event.rawPointerEvent = pointerEvent;
event.pointerEventId = pointerEvent->GetId();
event.pointerId = pointerEvent->GetPointerId();
event.pullId = pointerEvent->GetPullId();
MMI::PointerEvent::PointerItem pointerItem;
pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem);
event.pressed = pointerItem.IsPressed();

View File

@ -712,6 +712,7 @@ void DragDropManager::HandleOnDragMove(const PointerEvent& pointerEvent, const s
void DragDropManager::OnDragMove(const PointerEvent& pointerEvent, const std::string& extraInfo,
const RefPtr<FrameNode>& node)
{
RequireSummaryIfNecessary(pointerEvent);
Point point = pointerEvent.GetPoint();
auto container = Container::Current();
CHECK_NULL_VOID(container);
@ -766,8 +767,7 @@ void DragDropManager::ResetDragDropStatus(const Point& point, const DragDropRet&
}
InteractionInterface::GetInstance()->StopDrag(dragDropRet);
NotifyDragFrameNode(point, DragEventType::DROP, dragDropRet.result);
summaryMap_.clear();
parentHitNodes_.clear();
ResetPullId();
dragCursorStyleCore_ = DragCursorStyleCore::DEFAULT;
}
@ -1052,8 +1052,7 @@ void DragDropManager::OnDragDrop(RefPtr<OHOS::Ace::DragEvent>& event, const RefP
});
NotifyDragFrameNode(point, DragEventType::DROP, event->GetResult());
dragFrameNode->MarkDirtyNode();
summaryMap_.clear();
parentHitNodes_.clear();
ResetPullId();
dragCursorStyleCore_ = DragCursorStyleCore::DEFAULT;
pipeline->RequestFrame();
}
@ -1111,8 +1110,7 @@ Rect DragDropManager::GetDragWindowRect(const Point& point)
void DragDropManager::ClearSummary()
{
previewRect_ = Rect(-1, -1, -1, -1);
summaryMap_.clear();
parentHitNodes_.clear();
ResetPullId();
ResetRecordSize();
}
@ -2291,4 +2289,17 @@ bool DragDropManager::IsAllAnimationFinished()
currentAnimationCnt_--;
return currentAnimationCnt_ == 0;
}
bool DragDropManager::CheckIsNewDrag(const PointerEvent& pointerEvent) const
{
return (pointerEvent.pullId != -1) && (pointerEvent.pullId != currentPullId_);
}
void DragDropManager::RequireSummaryIfNecessary(const PointerEvent& pointerEvent)
{
if (CheckIsNewDrag(pointerEvent)) {
currentPullId_ = pointerEvent.pullId;
RequireSummary();
}
}
} // namespace OHOS::Ace::NG

View File

@ -470,6 +470,17 @@ public:
menuWrapperNode_ = frameNode;
}
bool CheckIsNewDrag(const PointerEvent& pointerEvent) const;
void RequireSummaryIfNecessary(const PointerEvent& pointerEvent);
inline void ResetPullId()
{
summaryMap_.clear();
parentHitNodes_.clear();
currentPullId_ = -1;
}
private:
double CalcDragPreviewDistanceWithPoint(
const OHOS::Ace::Dimension& preserverHeight, int32_t x, int32_t y, const DragPreviewInfo& info);
@ -541,6 +552,7 @@ private:
uint32_t recordSize_ = 0;
int64_t currentId_ = -1;
int32_t currentPointerId_ = -1;
int32_t currentPullId_ = -1;
bool draggingPressedState_ = false;
std::function<void(void)> notifyInDraggedCallback_ = nullptr;

View File

@ -58,6 +58,7 @@ enum class PointerAction : int32_t {
struct PointerEvent final {
int32_t pointerEventId = 0;
int32_t pointerId = 0;
int32_t pullId = -1;
bool pressed = false;
int32_t windowX = 0;
int32_t windowY = 0;

View File

@ -4405,7 +4405,7 @@ void PipelineContext::OnDragEvent(const PointerEvent& pointerEvent, DragEventAct
if (action == DragEventAction::DRAG_EVENT_START) {
manager->ResetPreTargetFrameNode(GetInstanceId());
manager->RequireSummary();
manager->RequireSummaryIfNecessary(pointerEvent);
manager->SetDragCursorStyleCore(DragCursorStyleCore::DEFAULT);
TAG_LOGI(AceLogTag::ACE_DRAG, "start drag, current windowId is %{public}d", container->GetWindowId());
}