From e75ed4fd0bbc9a97cbaabe3450acc948fd31a869 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Fri, 30 May 2025 22:22:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=E9=80=82=E9=85=8D-=E6=8B=96=E6=8B=BD=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6capi=E4=BE=A7=E5=92=8Cts=E4=BE=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- adapter/ohos/entrance/ace_container.cpp | 4 ++++ adapter/ohos/entrance/mmi_event_convertor.cpp | 2 ++ .../engine/functions/js_drag_function.cpp | 16 ++++++++++++++ .../engine/functions/js_drag_function.h | 2 ++ .../event/gesture_event_hub_drag.cpp | 2 ++ .../gestures/recognizers/click_recognizer.cpp | 1 + .../recognizers/long_press_recognizer.cpp | 1 + .../gestures/recognizers/pan_recognizer.cpp | 2 ++ .../drag_drop/drag_drop_func_wrapper.cpp | 2 ++ .../manager/drag_drop/drag_drop_manager.cpp | 2 ++ frameworks/core/event/pointer_event.h | 12 ++++++++++ frameworks/core/gestures/drag_event.h | 22 +++++++++++++++++++ frameworks/core/gestures/gesture_event.h | 12 ++++++++++ .../core/gestures/long_press_recognizer.cpp | 1 + .../core/interfaces/arkoala/arkoala_api.h | 2 ++ .../native/node/node_drag_modifier.cpp | 2 ++ interfaces/native/drag_and_drop.h | 3 +++ .../native/event/drag_and_drop_impl.cpp | 20 +++++++++++++++++ 18 files changed, 108 insertions(+) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 242381cd118..a464d93344c 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -3781,6 +3781,8 @@ bool AceContainer::GetCurPointerEventInfo(DragPointerEvent& dragPointerEvent, St dragPointerEvent.displayY = pointerItem.GetDisplayY(); dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); + dragPointerEvent.globalDisplayX = pointerItem.GetGlobalX(); + dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY(); dragPointerEvent.deviceId = pointerItem.GetDeviceId(); dragPointerEvent.sourceTool = static_cast(pointerItem.GetToolType()); dragPointerEvent.displayId = currentPointerEvent->GetTargetDisplayId(); @@ -3829,6 +3831,8 @@ bool AceContainer::GetLastMovingPointerPosition(DragPointerEvent& dragPointerEve dragPointerEvent.displayY = pointerItem.GetDisplayY(); dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); + dragPointerEvent.globalDisplayX = pointerItem.GetGlobalX(); + dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY(); return true; } diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index 5fac041735d..f9318a77e53 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -779,6 +779,8 @@ void ConvertPointerEvent(const std::shared_ptr& pointerEvent, event.windowY = pointerItem.GetWindowY(); event.displayX = pointerItem.GetDisplayX(); event.displayY = pointerItem.GetDisplayY(); + event.globalDisplayX = pointerItem.GetGlobalX(); + event.globalDisplayY = pointerItem.GetGlobalY(); event.displayId = pointerEvent->GetTargetDisplayId(); event.size = std::max(pointerItem.GetWidth(), pointerItem.GetHeight()) / SIZE_DIVIDE; event.force = static_cast(pointerItem.GetPressure()); diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp index 2705e43c5e6..04a4385c1d9 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp @@ -107,6 +107,8 @@ void JsDragEvent::JSBind(BindingTarget globalObj) JSClass::CustomMethod("getPasteData", &JsDragEvent::GetJsPasteData); JSClass::CustomMethod("getDisplayX", &JsDragEvent::GetScreenX); JSClass::CustomMethod("getDisplayY", &JsDragEvent::GetScreenY); + JSClass::CustomMethod("getGlobalDisplayX", &JsDragEvent::GetGlobalDisplayX); + JSClass::CustomMethod("getGlobalDisplayY", &JsDragEvent::GetGlobalDisplayY); JSClass::CustomMethod("getDragSource", &JsDragEvent::GetDragSource); JSClass::CustomMethod("isRemote", &JsDragEvent::IsRemote); JSClass::CustomMethod("getWindowX", &JsDragEvent::GetX); @@ -168,6 +170,20 @@ void JsDragEvent::GetScreenY(const JSCallbackInfo& args) args.SetReturnValue(yValueRef); } +void JsDragEvent::GetGlobalDisplayX(const JSCallbackInfo& args) +{ + auto xValue = JSVal(ToJSValue(PipelineBase::Px2VpWithCurrentDensity(dragEvent_->GetGlobalDisplayX()))); + auto xValueRef = JSRef::Make(xValue); + args.SetReturnValue(xValueRef); +} + +void JsDragEvent::GetGlobalDisplayY(const JSCallbackInfo& args) +{ + auto yValue = JSVal(ToJSValue(PipelineBase::Px2VpWithCurrentDensity(dragEvent_->GetGlobalDisplayY()))); + auto yValueRef = JSRef::Make(yValue); + args.SetReturnValue(yValueRef); +} + void JsDragEvent::GetDragSource(const JSCallbackInfo& args) { JSRef dragSource = JSRef::Make(ToJSValue(dragEvent_->GetDragSource())); diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h index 2693fede315..2dd55561fb1 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h @@ -54,6 +54,8 @@ public: void GetJsPasteData(const JSCallbackInfo& args); void GetScreenX(const JSCallbackInfo& args); void GetScreenY(const JSCallbackInfo& args); + void GetGlobalDisplayX(const JSCallbackInfo& args); + void GetGlobalDisplayY(const JSCallbackInfo& args); void GetDisplayId(const JSCallbackInfo& args); void GetX(const JSCallbackInfo& args); void GetY(const JSCallbackInfo& args); diff --git a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp index d51b30e5e7e..f4b3319110c 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp @@ -1820,6 +1820,8 @@ RefPtr GestureEventHub::CreateDragEvent(const GestureEvent event->SetScreenY(info.GetScreenLocation().GetY()); event->SetDisplayX(info.GetScreenLocation().GetX()); event->SetDisplayY(info.GetScreenLocation().GetY()); + event->SetGlobalDisplayX(info.GetGlobalDisplayLocation().GetX()); + event->SetGlobalDisplayY(info.GetGlobalDisplayLocation().GetY()); event->SetSourceTool(info.GetSourceTool()); auto container = Container::Current(); CHECK_NULL_RETURN(container, event); diff --git a/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp index 83267fa9669..e23921c44c8 100644 --- a/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp @@ -488,6 +488,7 @@ GestureEvent ClickRecognizer::GetGestureEventInfo() info.SetTimeStamp(touchPoint.time); info.SetScreenLocation(touchPoint.GetScreenOffset()); info.SetGlobalLocation(touchPoint.GetOffset()).SetLocalLocation(Offset(localPoint.GetX(), localPoint.GetY())); + info.SetGlobalDisplayLocation(touchPoint.GetGlobalDisplayOffset()); info.SetSourceDevice(deviceType_); info.SetDeviceId(deviceId_); info.SetTarget(GetEventTarget().value_or(EventTarget())); diff --git a/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp index e4e198a8661..a0f120e8262 100644 --- a/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp @@ -410,6 +410,7 @@ void LongPressRecognizer::SendCallbackMsg( info.SetScreenLocation(lastTouchEvent_.GetScreenOffset()); info.SetGlobalLocation(lastTouchEvent_.GetOffset()) .SetLocalLocation(lastTouchEvent_.GetOffset() - coordinateOffset_); + info.SetGlobalDisplayLocation(lastTouchEvent_.GetGlobalDisplayOffset()); info.SetTarget(GetEventTarget().value_or(EventTarget())); info.SetForce(lastTouchEvent_.force); if (lastTouchEvent_.tiltX.has_value()) { diff --git a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp index 0d1641baebb..fabfd0a7d5f 100644 --- a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp @@ -776,6 +776,7 @@ GestureEvent PanRecognizer::GetGestureEventInfo() info.SetMainDelta(mainDelta_ / static_cast(touchPoints_.size())); if (inputEventType_ == InputEventType::AXIS) { info.SetScreenLocation(lastAxisEvent_.GetScreenOffset()); + info.SetGlobalDisplayLocation(lastAxisEvent_.GetGlobalDisplayOffset()); info.SetSourceTool(lastAxisEvent_.sourceTool); info.SetVerticalAxis(lastAxisEvent_.verticalAxis); info.SetHorizontalAxis(lastAxisEvent_.horizontalAxis); @@ -784,6 +785,7 @@ GestureEvent PanRecognizer::GetGestureEventInfo() info.CopyConvertInfoFrom(lastAxisEvent_.convertInfo); } else { info.SetScreenLocation(lastTouchEvent_.GetScreenOffset()); + info.SetGlobalDisplayLocation(lastTouchEvent_.GetGlobalDisplayOffset()); info.SetSourceTool(lastTouchEvent_.sourceTool); info.SetPressedKeyCodes(lastTouchEvent_.pressedKeyCodes_); info.SetPointerEventId(lastTouchEvent_.touchEventId); diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp index 8336d9e53a7..81b06a59121 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp @@ -724,6 +724,8 @@ void DragDropFuncWrapper::ConvertPointerEvent(const TouchEvent& touchPoint, Drag event.windowY = touchPoint.y; event.displayX = touchPoint.screenX; event.displayY = touchPoint.screenY; + event.globalDisplayX = touchPoint.globalDisplayX; + event.globalDisplayY = touchPoint.globalDisplayY; event.deviceId = touchPoint.deviceId; event.displayId = touchPoint.targetDisplayId; event.x = event.windowX; 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 fcc20c0c396..18277dec653 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 @@ -2072,6 +2072,8 @@ void DragDropManager::UpdateDragEvent( event->SetScreenY(point.GetScreenY()); event->SetDisplayX((double)pointerEvent.GetDisplayX()); event->SetDisplayY((double)pointerEvent.GetDisplayY()); + event->SetGlobalDisplayX(pointerEvent.GetGlobalDisplayX()); + event->SetGlobalDisplayY(pointerEvent.GetGlobalDisplayY()); event->SetVelocity(velocityTracker_.GetVelocity()); event->SetSummary(summaryMap_); event->SetPreviewRect(GetDragWindowRect(point)); diff --git a/frameworks/core/event/pointer_event.h b/frameworks/core/event/pointer_event.h index 490c1719e44..7e48aad90d0 100644 --- a/frameworks/core/event/pointer_event.h +++ b/frameworks/core/event/pointer_event.h @@ -66,6 +66,8 @@ struct DragPointerEvent final : public PointerEvent { int32_t windowY = 0; int32_t displayX = 0; int32_t displayY = 0; + double globalDisplayX = 0.0; + double globalDisplayY = 0.0; double size = 0.0; float force = 0.0f; int32_t deviceId = 0; @@ -110,6 +112,16 @@ struct DragPointerEvent final : public PointerEvent { return displayY; } + double GetGlobalDisplayX() const + { + return globalDisplayX; + } + + double GetGlobalDisplayY() const + { + return globalDisplayY; + } + int32_t GetDisplayId() const { return displayId; diff --git a/frameworks/core/gestures/drag_event.h b/frameworks/core/gestures/drag_event.h index 303308c3867..a7ad9373f5e 100644 --- a/frameworks/core/gestures/drag_event.h +++ b/frameworks/core/gestures/drag_event.h @@ -173,6 +173,26 @@ public: displayY_ = y; } + double GetGlobalDisplayX() const + { + return globalDisplayX_; + } + + double GetGlobalDisplayY() const + { + return globalDisplayY_; + } + + void SetGlobalDisplayX(double x) + { + globalDisplayX_ = x; + } + + void SetGlobalDisplayY(double y) + { + globalDisplayY_ = y; + } + void SetDescription(const std::string& description) { description_ = description; @@ -397,6 +417,8 @@ private: double y_ = 0.0; double displayX_ = 0.0; double displayY_ = 0.0; + double globalDisplayX_ = 0.0; + double globalDisplayY_ = 0.0; std::string description_; RefPtr pixelMap_; std::map summary_; diff --git a/frameworks/core/gestures/gesture_event.h b/frameworks/core/gestures/gesture_event.h index cb6b9205623..acfe457781b 100644 --- a/frameworks/core/gestures/gesture_event.h +++ b/frameworks/core/gestures/gesture_event.h @@ -126,6 +126,17 @@ public: return globalLocation_; } + GestureEvent& SetGlobalDisplayLocation(const Offset& globalDisplayLocation) + { + globalDisplayLocation_ = globalDisplayLocation; + return *this; + } + + const Offset& GetGlobalDisplayLocation() const + { + return globalDisplayLocation_; + } + const Offset& GetPinchCenter() const { return pinchCenter_; @@ -364,6 +375,7 @@ private: Offset localLocation_; // Will be used in drag. Offset screenLocation_; + Offset globalDisplayLocation_; // Raw last touchPoint global location. Offset rawGlobalLocation_; Offset pinchCenter_; diff --git a/frameworks/core/gestures/long_press_recognizer.cpp b/frameworks/core/gestures/long_press_recognizer.cpp index 14c253a4728..ded228592d3 100644 --- a/frameworks/core/gestures/long_press_recognizer.cpp +++ b/frameworks/core/gestures/long_press_recognizer.cpp @@ -245,6 +245,7 @@ void LongPressRecognizer::SendCallbackMsg(const std::unique_ptr& info, ArkUINodeEve event.dragEvent.displayY = info->GetDisplayY(); event.dragEvent.screenX = info->GetScreenX(); event.dragEvent.screenY = info->GetScreenY(); + event.dragEvent.globalDisplayX = info->GetGlobalDisplayX(); + event.dragEvent.globalDisplayY = info->GetGlobalDisplayY(); event.dragEvent.previewRectWidth = info->GetPreviewRect().Width(); event.dragEvent.previewRectHeight = info->GetPreviewRect().Height(); diff --git a/interfaces/native/drag_and_drop.h b/interfaces/native/drag_and_drop.h index 8f172410019..7543724d4c4 100644 --- a/interfaces/native/drag_and_drop.h +++ b/interfaces/native/drag_and_drop.h @@ -414,6 +414,9 @@ float OH_ArkUI_DragEvent_GetTouchPointXToDisplay(ArkUI_DragEvent* event); */ float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event); +float OH_ArkUI_DragEvent_GetTouchPointXToGlobalDisplay(ArkUI_DragEvent* event); +float OH_ArkUI_DragEvent_GetTouchPointYToGlobalDisplay(ArkUI_DragEvent* event); + /** * @brief Obtains the dragging velocity along the x-axis. * diff --git a/interfaces/native/event/drag_and_drop_impl.cpp b/interfaces/native/event/drag_and_drop_impl.cpp index 5e8227e475e..978cf5ee04d 100644 --- a/interfaces/native/event/drag_and_drop_impl.cpp +++ b/interfaces/native/event/drag_and_drop_impl.cpp @@ -687,6 +687,26 @@ float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event) return result; } +float OH_ArkUI_DragEvent_GetTouchPointXToGllobalDisplay(ArkUI_DragEvent* event) +{ + if (!event) { + return 0.0f; + } + auto* dragEvent = reinterpret_cast(event); + auto result = static_cast(dragEvent->globalDisplayX); + return result; +} + +float OH_ArkUI_DragEvent_GetTouchPointYToGlobalDisplay(ArkUI_DragEvent* event) +{ + if (!event) { + return 0.0f; + } + auto* dragEvent = reinterpret_cast(event); + auto result = static_cast(dragEvent->globalDisplayY); + return result; +} + float OH_ArkUI_DragEvent_GetVelocityX(ArkUI_DragEvent* event) { if (!event) { -- Gitee From 8a2b2ceb94dda490050ee1099597661b99e9735e Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 10:03:20 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- frameworks/core/components_ng/event/gesture_event_hub_drag.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp index f4b3319110c..5d2fef20de1 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp @@ -1189,6 +1189,8 @@ void GestureEventHub::HandleOnDragEnd(const GestureEvent& info) } event->SetScreenX(info.GetScreenLocation().GetX()); event->SetScreenY(info.GetScreenLocation().GetY()); + event->SetGlobalDisplayX(info.GetGlobalLocation().GetX()); + event->SetGlobalDisplayY(info.GetGlobalLocation().GetY()); event->SetPressedKeyCodes(info.GetPressedKeyCodes()); eventHub->FireCustomerOnDragFunc(DragFuncType::DRAG_DROP, event); eventHub->HandleInternalOnDrop(event, ""); -- Gitee From 70f6e434e11802321301c0f4e0b2dffa2686a2b4 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 10:08:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- .../core/components_ng/event/gesture_event_hub_drag.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp index 5d2fef20de1..236bcee5986 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp @@ -1189,8 +1189,8 @@ void GestureEventHub::HandleOnDragEnd(const GestureEvent& info) } event->SetScreenX(info.GetScreenLocation().GetX()); event->SetScreenY(info.GetScreenLocation().GetY()); - event->SetGlobalDisplayX(info.GetGlobalLocation().GetX()); - event->SetGlobalDisplayY(info.GetGlobalLocation().GetY()); + event->SetGlobalDisplayX(info.GetGlobalDisplayLocation().GetX()); + event->SetGlobalDisplayY(info.GetGlobalDisplayLocation().GetY()); event->SetPressedKeyCodes(info.GetPressedKeyCodes()); eventHub->FireCustomerOnDragFunc(DragFuncType::DRAG_DROP, event); eventHub->HandleInternalOnDrop(event, ""); -- Gitee From 59d73dc83ec219010767eff69ed90242632fc3b1 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 20:27:44 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=A1=A5=E5=85=85DragPointerEvent=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- frameworks/core/event/pointer_event.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frameworks/core/event/pointer_event.h b/frameworks/core/event/pointer_event.h index 7e48aad90d0..443c650f7a2 100644 --- a/frameworks/core/event/pointer_event.h +++ b/frameworks/core/event/pointer_event.h @@ -92,6 +92,13 @@ struct DragPointerEvent final : public PointerEvent { DragPointerEvent(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) {} + DragPointerEvent(int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY, double globalDisplayX, double globalDisplayY) + : windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY), globalDisplayX(globalDisplayX), globalDisplayY(globalDisplayY) + {} + DragPointerEvent(int32_t pointerEventId, int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY, + double globalDisplayX, double globalDisplayY) : pointerEventId(pointerEventId), windowX(windowX), windowY(windowY), + displayX(displayX), displayY(displayY), globalDisplayX(globalDisplayX), globalDisplayY(globalDisplayY) + {} Point GetPoint() const { -- Gitee From 4777b0aa24cdd79b154f7dcc350c18960a33160a Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 21:43:48 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=A1=A5=E5=85=85dragpointerevent=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E5=87=BD=E6=95=B0=E8=B0=83=E7=94=A8=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- .../manager/drag_drop/drag_drop_manager.cpp | 10 +++++++--- .../manager/drag_drop/drag_drop_proxy.cpp | 11 +++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) 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 18277dec653..c7f47cd6a3c 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 @@ -2053,6 +2053,8 @@ void DragDropManager::UpdateNotifyDragEvent( notifyEvent->SetY((double)point.GetY()); notifyEvent->SetScreenX((double)point.GetScreenX()); notifyEvent->SetScreenY((double)point.GetScreenY()); + notifyEvent->SetGlobalDisplayX((double)point.GetGlobalDisplayX()); + notifyEvent->SetGlobalDisplayY((double)point.GetGlobalDisplayY()); if (dragEventType != DragEventType::START) { if (dragEventType != DragEventType::DROP) { notifyEvent->SetVelocity(velocityTracker_.GetVelocity()); @@ -2450,11 +2452,13 @@ void DragDropManager::InitDragAnimationPointerEvent(const GestureEvent& event, b if (isDragStartPending) { auto dragMoveLastPoint = GetDragMoveLastPointByCurrentPointer(event.GetPointerId()); dragAnimationPointerEvent_ = DragPointerEvent(dragMoveLastPoint.GetX(), - dragMoveLastPoint.GetY(), dragMoveLastPoint.GetScreenX(), dragMoveLastPoint.GetScreenY()); + dragMoveLastPoint.GetY(), dragMoveLastPoint.GetScreenX(), dragMoveLastPoint.GetScreenY(), + dragMoveLastPoint.GetGlobalDisplayX(), dragMoveLastPoint.GetGlobalDisplayY()); return; } dragAnimationPointerEvent_ = DragPointerEvent(event.GetGlobalLocation().GetX(), - event.GetGlobalLocation().GetY(), event.GetScreenLocation().GetX(), event.GetScreenLocation().GetY()); + event.GetGlobalLocation().GetY(), event.GetScreenLocation().GetX(), event.GetScreenLocation().GetY(), + event.GetGlobalDisplayLocation().GetX(), event.GetGlobalDisplayLocation().GetY()); } void DragDropManager::DoDragStartAnimation(const RefPtr& overlayManager, const GestureEvent& event, @@ -3243,7 +3247,7 @@ void DragDropManager::HandleTouchEvent(const TouchEvent& event) if (!IsDragging() || !IsSameDraggingPointer(event.id)) { return; } - auto pointerEvent = DragPointerEvent(event.x, event.y, event.screenX, event.screenY); + auto pointerEvent = DragPointerEvent(event.x, event.y, event.screenX, event.screenY, event.globalDisplayX, event.globalDisplayX); SetDragAnimationPointerEvent(pointerEvent); } else if ((event.type == TouchType::UP) || (event.type == TouchType::CANCEL)) { ResetDraggingStatus(event); diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp index fc48d5ab189..cc125cf260d 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp @@ -47,7 +47,7 @@ void HandleExtraDragMoveReporting(const RefPtr& frameNode, const std: CHECK_NULL_VOID(dragDropManager); auto touchDownPoint = actuator->GetTouchDownPoint(); auto pointerEvent = DragPointerEvent(touchDownPoint.x, touchDownPoint.y, - touchDownPoint.screenX, touchDownPoint.screenY); + touchDownPoint.screenX, touchDownPoint.screenY, touchDownPoint.globalDisplayX, touchDownPoint.globalDisplayY); dragDropManager->OnDragMove(pointerEvent, extraInfo); } @@ -63,7 +63,8 @@ void DragDropProxy::OnDragStart( auto point = Point(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY(), info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY()); auto pointerEvent = DragPointerEvent(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY(), - info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY()); + info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY(), + info.GetGlobalDisplayLocation().GetX(), info.GetGlobalDisplayLocation().GetY()); pointerEvent.UpdatePressedKeyCodes(info.GetPressedKeyCodes()); manager->OnDragStart(point, frameNode); manager->SetExtraInfo(extraInfo); @@ -84,7 +85,8 @@ void DragDropProxy::OnDragMove(const GestureEvent& info) std::string extraInfo = manager->GetExtraInfo(); manager->OnDragMove(DragPointerEvent(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY(), - info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY()), extraInfo); + info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY(), + info.GetGlobalDisplayLocation().GetX(), info.GetGlobalDisplayLocation().GetY()), extraInfo); } void DragDropProxy::OnDragEnd(const GestureEvent& info, bool isTextDragEnd) @@ -100,7 +102,8 @@ void DragDropProxy::OnDragEnd(const GestureEvent& info, bool isTextDragEnd) static_cast(info.GetGlobalPoint().GetY()), extraInfo); } else { manager->OnDragEnd(DragPointerEvent(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY(), - info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY()), extraInfo); + info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY(), + info.GetGlobalDisplayLocation().GetX(), info.GetGlobalDisplayLocation().GetY()), extraInfo); } } -- Gitee