From c4d614c3fe014d28cba832292de859b798906779 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Fri, 6 Jun 2025 17:01:42 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcodecheck=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E8=B6=85=E5=A4=A7=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 --- adapter/ohos/entrance/ace_container.cpp | 6 + adapter/ohos/entrance/mmi_event_convertor.cpp | 25 ++ adapter/preview/entrance/event_dispatcher.cpp | 6 + .../external/multimodalinput/pointer_event.h | 4 + .../interfaces/cj_ffi/cj_common_ffi.cpp | 3 + .../interfaces/cj_ffi/cj_common_ffi.h | 2 + .../engine/functions/js_click_function.cpp | 58 ++-- .../engine/functions/js_drag_function.cpp | 16 + .../engine/functions/js_drag_function.h | 2 + .../engine/functions/js_gesture_function.cpp | 5 + .../functions/js_gesture_judge_function.cpp | 5 + .../engine/functions/js_hover_function.cpp | 15 + .../engine/functions/js_touch_function.cpp | 5 + .../declarative_frontend/engine/js_types.cpp | 19 +- .../arkts_native_common_bridge.cpp | 37 +- .../arkts_native_frame_node_bridge.cpp | 29 +- .../jsview/js_base_node.cpp | 6 +- .../jsview/js_location_button.cpp | 5 + .../jsview/js_paste_button.cpp | 5 + .../jsview/js_save_button.cpp | 5 + .../declarative_frontend/jsview/js_web.cpp | 3 + .../accessibility_manager_ng.cpp | 4 + frameworks/core/common/event_manager.cpp | 8 +- frameworks/core/components/box/render_box.cpp | 1 + .../core/components/search/render_search.cpp | 1 + .../render_split_container.cpp | 1 + .../touch_listener/render_touch_listener.cpp | 4 + frameworks/core/components/web/render_web.cpp | 1 + .../core/components_ng/base/frame_node.cpp | 4 + .../components_ng/event/drag_drop_event.cpp | 2 + .../core/components_ng/event/drag_event.cpp | 11 +- .../event/gesture_event_hub_drag.cpp | 4 + .../core/components_ng/event/touch_event.cpp | 7 + .../gestures/recognizers/click_recognizer.cpp | 2 + .../recognizers/long_press_recognizer.cpp | 1 + .../recognizers/multi_fingers_recognizer.cpp | 4 +- .../gestures/recognizers/pan_recognizer.cpp | 2 + .../drag_drop/drag_drop_func_wrapper.cpp | 2 + .../manager/drag_drop/drag_drop_manager.cpp | 13 +- .../manager/drag_drop/drag_drop_proxy.cpp | 14 +- .../pattern/model/model_touch_handler.cpp | 2 + .../pattern/text/text_pattern.cpp | 1 + .../components_ng/pattern/web/web_pattern.cpp | 6 + frameworks/core/event/axis_event.cpp | 30 +- frameworks/core/event/axis_event.h | 29 +- frameworks/core/event/mouse_event.cpp | 6 + frameworks/core/event/mouse_event.h | 53 ++- frameworks/core/event/pointer_event.h | 22 ++ frameworks/core/event/touch_event.cpp | 57 ++++ frameworks/core/event/touch_event.h | 18 + frameworks/core/gestures/drag_event.h | 22 ++ frameworks/core/gestures/gesture_event.h | 12 + frameworks/core/gestures/gesture_info.h | 1 + .../core/gestures/long_press_recognizer.cpp | 2 + .../gestures/multi_fingers_recognizer.cpp | 2 +- .../core/interfaces/arkoala/arkoala_api.h | 6 + .../native/node/node_common_modifier.cpp | 32 ++ .../native/node/node_drag_modifier.cpp | 2 + .../native/node/node_gesture_modifier.cpp | 10 + .../ace_kit/include/ui/base/geometry/point.h | 32 ++ .../kits/observer/ui_observer_listener.cpp | 39 ++- interfaces/native/drag_and_drop.h | 3 + .../native/event/drag_and_drop_impl.cpp | 20 ++ interfaces/native/event/ui_input_event.cpp | 260 ++++++++++++++ interfaces/native/libace.ndk.json | 32 ++ interfaces/native/ui_input_event.h | 10 + .../interfaces/drag_and_drop_test.cpp | 72 ++++ .../interfaces/ui_input_event_test_one.cpp | 322 ++++++++++++++++++ 68 files changed, 1356 insertions(+), 94 deletions(-) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 422b34c0596..0d19384304c 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -3827,6 +3827,9 @@ bool AceContainer::GetCurPointerEventInfo(DragPointerEvent& dragPointerEvent, St dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); } + // Todo change to GetGlobalX() + dragPointerEvent.globalDisplayX = pointerItem.GetDisplayX(); + dragPointerEvent.globalDisplayY = pointerItem.GetDisplayY(); dragPointerEvent.deviceId = pointerItem.GetDeviceId(); dragPointerEvent.sourceTool = static_cast(pointerItem.GetToolType()); dragPointerEvent.displayId = currentPointerEvent->GetTargetDisplayId(); @@ -3882,6 +3885,9 @@ bool AceContainer::GetLastMovingPointerPosition(DragPointerEvent& dragPointerEve dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); } + // Todo change to GetGlobalX() + dragPointerEvent.globalDisplayX = pointerItem.GetDisplayX(); + dragPointerEvent.globalDisplayY = pointerItem.GetDisplayY(); return true; } diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index 0739b895885..f79654dbd9c 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -162,6 +162,9 @@ TouchPoint ConvertTouchPoint(const MMI::PointerEvent::PointerItem& pointerItem, touchPoint.screenX = pointerItem.GetDisplayX(); touchPoint.screenY = pointerItem.GetDisplayY(); } + // Todo change to GetGlobalX() + touchPoint.globalDisplayX = pointerItem.GetDisplayX(); + touchPoint.globalDisplayY = pointerItem.GetDisplayY(); touchPoint.isPressed = pointerItem.IsPressed(); touchPoint.force = static_cast(pointerItem.GetPressure()); touchPoint.tiltX = pointerItem.GetTiltX(); @@ -257,6 +260,9 @@ void UpdateMouseEventForPen(const MMI::PointerEvent::PointerItem& pointerItem, M mouseEvent.screenX = pointerItem.GetDisplayXPos(); mouseEvent.screenY = pointerItem.GetDisplayYPos(); mouseEvent.originalId = mouseEvent.id; + // Todo change to GetGlobalX() + mouseEvent.globalDisplayX = pointerItem.GetDisplayXPos(); + mouseEvent.globalDisplayY = pointerItem.GetDisplayYPos(); } TouchEvent ConvertTouchEventFromTouchPoint(TouchPoint touchPoint) @@ -267,6 +273,8 @@ TouchEvent ConvertTouchEventFromTouchPoint(TouchPoint touchPoint) .SetY(touchPoint.y) .SetScreenX(touchPoint.screenX) .SetScreenY(touchPoint.screenY) + .SetGlobalDisplayX(touchPoint.globalDisplayX) + .SetGlobalDisplayY(touchPoint.globalDisplayY) .SetType(TouchType::UNKNOWN) .SetPullType(TouchType::UNKNOWN) .SetSize(touchPoint.size) @@ -331,6 +339,9 @@ TouchEvent ConvertTouchEvent(const std::shared_ptr& pointerEv event.y = item.GetWindowYPos(); event.screenX = item.GetDisplayXPos(); event.screenY = item.GetDisplayYPos(); + // Todo change to GetGlobalX() + event.globalDisplayX = item.GetDisplayXPos(); + event.globalDisplayY = item.GetDisplayYPos(); } event.pressedKeyCodes_.clear(); for (const auto& curCode : pointerEvent->GetPressedKeys()) { @@ -421,6 +432,9 @@ void ConvertMouseEvent( events.screenX = item.GetDisplayX(); events.screenY = item.GetDisplayY(); } + // Todo change to GetGlobalX() + events.globalDisplayX = item.GetDisplayX(); + events.globalDisplayY = item.GetDisplayY(); events.rawDeltaX = item.GetRawDx(); events.rawDeltaY = item.GetRawDy(); GetMouseEventAction(pointerEvent->GetPointerAction(), events, isSceneBoardWindow); @@ -532,6 +546,9 @@ void ConvertAxisEvent(const std::shared_ptr& pointerEvent, Ax event.screenX = static_cast(item.GetDisplayX()); event.screenY = static_cast(item.GetDisplayY()); } + // Todo change to GetGlobalX() + event.globalDisplayX = item.GetDisplayX(); + event.globalDisplayY = item.GetDisplayY(); event.horizontalAxis = pointerEvent->GetAxisValue(OHOS::MMI::PointerEvent::AxisType::AXIS_TYPE_SCROLL_HORIZONTAL); event.verticalAxis = pointerEvent->GetAxisValue(OHOS::MMI::PointerEvent::AxisType::AXIS_TYPE_SCROLL_VERTICAL); event.pinchAxisScale = pointerEvent->GetAxisValue(OHOS::MMI::PointerEvent::AxisType::AXIS_TYPE_PINCH); @@ -611,6 +628,9 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptrGetAxisValue(OHOS::MMI::PointerEvent::AxisType::AXIS_TYPE_SCROLL_HORIZONTAL); @@ -625,6 +645,8 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptr& pointerEvent, event.displayX = pointerItem.GetDisplayX(); event.displayY = pointerItem.GetDisplayY(); } + // Todo change to GetGlobalX() + event.globalDisplayX = pointerItem.GetDisplayX(); + event.globalDisplayY = pointerItem.GetDisplayY(); event.displayId = pointerEvent->GetTargetDisplayId(); event.size = std::max(pointerItem.GetWidth(), pointerItem.GetHeight()) / SIZE_DIVIDE; event.force = static_cast(pointerItem.GetPressure()); diff --git a/adapter/preview/entrance/event_dispatcher.cpp b/adapter/preview/entrance/event_dispatcher.cpp index 1273da7a64c..cec8f0b2dc9 100644 --- a/adapter/preview/entrance/event_dispatcher.cpp +++ b/adapter/preview/entrance/event_dispatcher.cpp @@ -76,6 +76,8 @@ void ConvertTouchEvent(const std::shared_ptr& pointerEvent, T event.y = pointerEvent->y; event.screenX = pointerEvent->screenX; event.screenY = pointerEvent->screenY; + event.globalDisplayX = pointerEvent->globalDisplayX; + event.globalDisplayY = pointerEvent->globalDisplayY; event.type = static_cast(static_cast(pointerEvent->type)); event.pullType = static_cast(static_cast(pointerEvent->pullType)); event.time = pointerEvent->time; @@ -92,6 +94,8 @@ void ConvertTouchEvent(const std::shared_ptr& pointerEvent, T .y = event.y, .screenX = event.screenX, .screenY = event.screenY, + .globalDisplayX = event.globalDisplayX, + .globalDisplayY = event.globalDisplayY, .downTime = event.time, .size = event.size, .force = event.force, @@ -248,6 +252,8 @@ static void ConvertMouseEvent(const std::shared_ptr& pointerE mouseEvent.y = pointerEvent->y; mouseEvent.screenX = pointerEvent->screenX; mouseEvent.screenY = pointerEvent->screenY; + mouseEvent.globalDisplayX = pointerEvent->globalDisplayX; + mouseEvent.globalDisplayY = pointerEvent->globalDisplayY; GetMouseEventAction(pointerEvent->pointerAction_, mouseEvent); GetMouseEventButton(pointerEvent->buttonId_, mouseEvent); mouseEvent.sourceType = SourceType::MOUSE; diff --git a/adapter/preview/external/multimodalinput/pointer_event.h b/adapter/preview/external/multimodalinput/pointer_event.h index 9dd88541cea..b5f626730d7 100644 --- a/adapter/preview/external/multimodalinput/pointer_event.h +++ b/adapter/preview/external/multimodalinput/pointer_event.h @@ -48,6 +48,8 @@ struct TouchPoint final { float y = 0.0f; float screenX = 0.0f; float screenY = 0.0f; + double globalDisplayX = 0.0; + double globalDisplayY = 0.0; TimeStamp downTime; double size = 0.0; float force = 0.0f; @@ -68,6 +70,8 @@ public: float y = 0.0f; float screenX = 0.0f; float screenY = 0.0f; + double globalDisplayX = 0.0; + double globalDisplayY = 0.0; TouchType type = TouchType::UNKNOWN; TouchType pullType = TouchType::UNKNOWN; TimeStamp time; diff --git a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.cpp b/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.cpp index 99f1c8f56d3..814fbc08dae 100644 --- a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.cpp +++ b/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.cpp @@ -110,6 +110,7 @@ void AssambleCJClickInfo(const OHOS::Ace::GestureEvent& event, CJClickInfo& clic Offset globalOffset = event.GetGlobalLocation(); Offset localOffset = event.GetLocalLocation(); Offset screenOffset = event.GetScreenLocation(); + Offset globalDisplayOffset = event.GetGlobalDisplayLocation(); double currtDensity = PipelineBase::GetCurrentDensity(); clickInfo.x = localOffset.GetX() / currtDensity; clickInfo.y = localOffset.GetY() / currtDensity; @@ -117,6 +118,8 @@ void AssambleCJClickInfo(const OHOS::Ace::GestureEvent& event, CJClickInfo& clic clickInfo.windowY = globalOffset.GetY() / currtDensity; clickInfo.displayX = screenOffset.GetX() / currtDensity; clickInfo.displayY = screenOffset.GetY() / currtDensity; + clickInfo.globalDisplayX = globalDisplayOffset.GetX() / currtDensity; + clickInfo.globalDisplayY = globalDisplayOffset.GetY() / currtDensity; clickInfo.source = static_cast(event.GetSourceDevice()); } diff --git a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h b/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h index 2745cf03dd1..8d94738ebda 100644 --- a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h +++ b/frameworks/bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h @@ -249,6 +249,8 @@ struct CJClickInfo { double windowY; double displayX; double displayY; + double globalDisplayX; + double globalDisplayY; std::string ToString() const; }; diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_click_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_click_function.cpp index 4d0724caa1d..50bfd1878c7 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_click_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_click_function.cpp @@ -37,6 +37,9 @@ void JsClickFunction::Execute(const ClickInfo& info) Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); Offset screenOffset = info.GetScreenLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); + obj->SetProperty("globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + obj->SetProperty("globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX())); obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY())); obj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); @@ -92,6 +95,9 @@ void JsClickFunction::Execute(GestureEvent& info) Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); Offset screenOffset = info.GetScreenLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); + obj->SetProperty("globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + obj->SetProperty("globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); obj->SetProperty("hand", GetOperatingHand(info)); obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX())); obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY())); @@ -129,17 +135,18 @@ void JsClickFunction::Execute(MouseInfo& info) JSRef obj = objectTemplate->NewInstance(); obj->SetProperty("button", static_cast(info.GetButton())); obj->SetProperty("action", static_cast(info.GetAction())); - Offset globalOffset = info.GetGlobalLocation(); - Offset localOffset = info.GetLocalLocation(); - Offset screenOffset = info.GetScreenLocation(); - obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX())); - obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY())); - obj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); - obj->SetProperty("windowY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY())); - obj->SetProperty("screenX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); - obj->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY())); - obj->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX())); - obj->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY())); + obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(info.GetScreenLocation().GetX())); + obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(info.GetScreenLocation().GetY())); + obj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetX())); + obj->SetProperty("windowY", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetY())); + obj->SetProperty("screenX", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetX())); + obj->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetY())); + obj->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(info.GetLocalLocation().GetX())); + obj->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(info.GetLocalLocation().GetY())); + obj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalDisplayLocation().GetX())); + obj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalDisplayLocation().GetY())); obj->SetProperty("timestamp", static_cast(info.GetTimeStamp().time_since_epoch().count())); obj->SetPropertyObject( "stopPropagation", JSRef::New(JsStopPropagation)); @@ -190,6 +197,9 @@ void JsWeakClickFunction::Execute(const ClickInfo& info) Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); Offset screenOffset = info.GetScreenLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); + obj->SetProperty("globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + obj->SetProperty("globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX())); obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY())); obj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); @@ -225,6 +235,9 @@ void JsWeakClickFunction::Execute(GestureEvent& info) Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); Offset screenOffset = info.GetScreenLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); + obj->SetProperty("globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + obj->SetProperty("globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX())); obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY())); obj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); @@ -258,19 +271,20 @@ void JsWeakClickFunction::Execute(MouseInfo& info) JSRef objTemp = JSRef::New(); objTemp->SetInternalFieldCount(1); JSRef obj = objTemp->NewInstance(); - Offset localOffset = info.GetLocalLocation(); - Offset globalOffset = info.GetGlobalLocation(); - Offset screenOffset = info.GetScreenLocation(); obj->SetProperty("button", static_cast(info.GetButton())); obj->SetProperty("action", static_cast(info.GetAction())); - obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX())); - obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY())); - obj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); - obj->SetProperty("windowY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY())); - obj->SetProperty("screenX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); - obj->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY())); - obj->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX())); - obj->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY())); + obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(info.GetScreenLocation().GetX())); + obj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(info.GetScreenLocation().GetY())); + obj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetX())); + obj->SetProperty("windowY", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetY())); + obj->SetProperty("screenX", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetX())); + obj->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalLocation().GetY())); + obj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalDisplayLocation().GetX())); + obj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(info.GetGlobalDisplayLocation().GetY())); + obj->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(info.GetLocalLocation().GetX())); + obj->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(info.GetLocalLocation().GetY())); obj->SetProperty("timestamp", static_cast(info.GetTimeStamp().time_since_epoch().count())); obj->SetPropertyObject( "stopPropagation", JSRef::New(JsStopPropagation)); 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 478f3f8634e..fe82d5ca176 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp @@ -109,6 +109,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); @@ -171,6 +173,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) { CHECK_NULL_VOID(dragEvent_); 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 4bfdec36133..124254e0dab 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/bridge/declarative_frontend/engine/functions/js_gesture_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_function.cpp index 4e6b827827c..e548d624bc4 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_function.cpp @@ -138,6 +138,7 @@ JSRef JsGestureFunction::CreateFingerInfo(const FingerInfo& fingerInfo const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_; const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_; const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_; + const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_; fingerInfoObj->SetProperty("id", fingerInfo.fingerId_); fingerInfoObj->SetProperty("hand", fingerInfo.operatingHand_); fingerInfoObj->SetProperty("globalX", PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetX())); @@ -146,6 +147,10 @@ JSRef JsGestureFunction::CreateFingerInfo(const FingerInfo& fingerInfo fingerInfoObj->SetProperty("localY", PipelineBase::Px2VpWithCurrentDensity(localLocation.GetY())); fingerInfoObj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())); fingerInfoObj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())); + fingerInfoObj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())); + fingerInfoObj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())); return fingerInfoObj; } diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_judge_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_judge_function.cpp index 1c8f20b64a0..147f34c9e3a 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_judge_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_judge_function.cpp @@ -140,6 +140,7 @@ JSRef JsGestureJudgeFunction::CreateFingerInfo(const FingerInfo& finge const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_; const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_; const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_; + const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_; fingerInfoObj->SetProperty("id", fingerInfo.fingerId_); fingerInfoObj->SetProperty("globalX", PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetX())); fingerInfoObj->SetProperty("globalY", PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetY())); @@ -147,6 +148,10 @@ JSRef JsGestureJudgeFunction::CreateFingerInfo(const FingerInfo& finge fingerInfoObj->SetProperty("localY", PipelineBase::Px2VpWithCurrentDensity(localLocation.GetY())); fingerInfoObj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())); fingerInfoObj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())); + fingerInfoObj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())); + fingerInfoObj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())); return fingerInfoObj; } diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_hover_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_hover_function.cpp index 75edd2eba6a..0fc4a444754 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_hover_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_hover_function.cpp @@ -45,6 +45,11 @@ void JsHoverFunction::HoverExecute(bool isHover, HoverInfo& hoverInfo) const OHOS::Ace::Offset& globalLocation = hoverInfo.GetGlobalLocation(); const OHOS::Ace::Offset& localLocation = hoverInfo.GetLocalLocation(); const OHOS::Ace::Offset& screenLocation = hoverInfo.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = hoverInfo.GetGlobalDisplayLocation(); + hoverObj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())); + hoverObj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())); hoverObj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())); hoverObj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())); hoverObj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetX())); @@ -80,6 +85,11 @@ void JsHoverFunction::HoverMoveExecute(HoverInfo& hoverInfo) const OHOS::Ace::Offset& globalLocation = hoverInfo.GetGlobalLocation(); const OHOS::Ace::Offset& localLocation = hoverInfo.GetLocalLocation(); const OHOS::Ace::Offset& screenLocation = hoverInfo.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = hoverInfo.GetGlobalDisplayLocation(); + hoverObj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())); + hoverObj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())); hoverObj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())); hoverObj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())); hoverObj->SetProperty("windowX", PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetX())); @@ -116,6 +126,11 @@ void JsHoverFunction::AccessibilityHoverExecute(bool isHover, AccessibilityHover const OHOS::Ace::Offset& globalLocation = hoverInfo.GetGlobalLocation(); const OHOS::Ace::Offset& localLocation = hoverInfo.GetLocalLocation(); const OHOS::Ace::Offset& screenLocation = hoverInfo.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = hoverInfo.GetGlobalDisplayLocation(); + hoverObj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())); + hoverObj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())); hoverObj->SetProperty("type", static_cast(hoverInfo.GetActionType())); hoverObj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())); hoverObj->SetProperty("displayY", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())); diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_touch_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_touch_function.cpp index 5ca7a56569e..a2c312e5e9f 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_touch_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_touch_function.cpp @@ -30,6 +30,7 @@ JSRef JsTouchFunction::CreateTouchInfo(const TouchLocationInfo& touchI const OHOS::Ace::Offset& globalLocation = touchInfo.GetGlobalLocation(); const OHOS::Ace::Offset& localLocation = touchInfo.GetLocalLocation(); const OHOS::Ace::Offset& screenLocation = touchInfo.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = touchInfo.GetGlobalDisplayLocation(); touchInfoObj->SetProperty("type", static_cast(touchInfo.GetTouchType())); touchInfoObj->SetProperty("id", touchInfo.GetFingerId()); touchInfoObj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())); @@ -40,6 +41,10 @@ JSRef JsTouchFunction::CreateTouchInfo(const TouchLocationInfo& touchI touchInfoObj->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetY())); touchInfoObj->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(localLocation.GetX())); touchInfoObj->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(localLocation.GetY())); + touchInfoObj->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())); + touchInfoObj->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())); touchInfoObj->SetProperty( "pressedTime", static_cast(touchInfo.GetPressedTime().time_since_epoch().count())); touchInfoObj->SetProperty("pressure", PipelineBase::Px2VpWithCurrentDensity(touchInfo.GetForce())); diff --git a/frameworks/bridge/declarative_frontend/engine/js_types.cpp b/frameworks/bridge/declarative_frontend/engine/js_types.cpp index c14d8791f3e..caf8cb7846c 100644 --- a/frameworks/bridge/declarative_frontend/engine/js_types.cpp +++ b/frameworks/bridge/declarative_frontend/engine/js_types.cpp @@ -101,15 +101,14 @@ Local JsGetHistoricalPoints(panda::JsiRuntimeCallInfo *info) auto index = 0; for (auto const &point : history) { Local touchObject = ObjectRef::New(info->GetVM()); - const OHOS::Ace::Offset& globalLocation = point.GetGlobalLocation(); - const OHOS::Ace::Offset& localLocation = point.GetLocalLocation(); - const OHOS::Ace::Offset& screenLocation = point.GetScreenLocation(); - auto x = PipelineBase::Px2VpWithCurrentDensity(localLocation.GetX()); - auto y = PipelineBase::Px2VpWithCurrentDensity(localLocation.GetY()); - auto globalX = PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetX()); - auto globalY = PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetY()); - auto displayX = PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX()); - auto displayY = PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY()); + auto x = PipelineBase::Px2VpWithCurrentDensity(point.GetLocalLocation().GetX()); + auto y = PipelineBase::Px2VpWithCurrentDensity(point.GetLocalLocation().GetY()); + auto globalX = PipelineBase::Px2VpWithCurrentDensity(point.GetGlobalLocation().GetX()); + auto globalY = PipelineBase::Px2VpWithCurrentDensity(point.GetGlobalLocation().GetY()); + auto displayX = PipelineBase::Px2VpWithCurrentDensity(point.GetScreenLocation().GetX()); + auto displayY = PipelineBase::Px2VpWithCurrentDensity(point.GetScreenLocation().GetY()); + auto globalDisplayX = PipelineBase::Px2VpWithCurrentDensity(point.GetGlobalDisplayLocation().GetX()); + auto globalDisplayY = PipelineBase::Px2VpWithCurrentDensity(point.GetGlobalDisplayLocation().GetY()); touchObject->Set(info->GetVM(), ToJSValue("id"), ToJSValue(point.GetFingerId())); touchObject->Set(info->GetVM(), ToJSValue("type"), ToJSValue(static_cast(point.GetTouchType()))); touchObject->Set(info->GetVM(), ToJSValue("x"), ToJSValue(x)); @@ -120,6 +119,8 @@ Local JsGetHistoricalPoints(panda::JsiRuntimeCallInfo *info) touchObject->Set(info->GetVM(), ToJSValue("windowY"), ToJSValue(globalY)); touchObject->Set(info->GetVM(), ToJSValue("displayX"), ToJSValue(displayX)); touchObject->Set(info->GetVM(), ToJSValue("displayY"), ToJSValue(displayY)); + touchObject->Set(info->GetVM(), ToJSValue("globalDisplayX"), ToJSValue(globalDisplayX)); + touchObject->Set(info->GetVM(), ToJSValue("globalDisplayY"), ToJSValue(globalDisplayY)); touchObject->Set(info->GetVM(), ToJSValue("hand"), ToJSValue(point.GetOperatingHand())); touchObject->Set(info->GetVM(), ToJSValue("pressedTime"), ToJSValue(static_cast(point.GetPressedTime().time_since_epoch().count()))); diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp index 601cee69843..ee5b4f142d2 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp @@ -7369,7 +7369,9 @@ Local CommonBridge::CreateTapGestureInfo(EcmaVM* vm, GestureEv const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_; const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_; const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_; - const char* keys[] = { "x", "y", "windowX", "windowY", "displayX", "displayY"}; + const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_; + const char* keys[] = { "x", "y", "windowX", "windowY", "displayX", "displayY", + "globalDisplayX", "globalDisplayY"}; Local values[] = { panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(localLocation.GetX())), panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(localLocation.GetY())), @@ -7377,6 +7379,8 @@ Local CommonBridge::CreateTapGestureInfo(EcmaVM* vm, GestureEv panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetY())), panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())), panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())), + panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())), + panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())), }; return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); } @@ -7460,8 +7464,10 @@ Local CommonBridge::CreateFingerInfo(EcmaVM* vm, const FingerI const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_; const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_; const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_; + const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_; double density = PipelineBase::GetCurrentDensity(); - const char* keys[] = { "id", "globalX", "globalY", "localX", "localY", "displayX", "displayY", "hand" }; + const char* keys[] = { "id", "globalX", "globalY", "localX", "localY", "displayX", "displayY", + "globalDisplayX", "globalDisplayY", "hand" }; Local values[] = { panda::NumberRef::New(vm, fingerInfo.fingerId_), panda::NumberRef::New(vm, globalLocation.GetX() / density), panda::NumberRef::New(vm, globalLocation.GetY() / density), @@ -7469,6 +7475,8 @@ Local CommonBridge::CreateFingerInfo(EcmaVM* vm, const FingerI panda::NumberRef::New(vm, localLocation.GetY() / density), panda::NumberRef::New(vm, screenLocation.GetX() / density), panda::NumberRef::New(vm, screenLocation.GetY() / density), + panda::NumberRef::New(vm, globalDisplayLocation.GetX() / density), + panda::NumberRef::New(vm, globalDisplayLocation.GetY() / density), panda::NumberRef::New(vm, fingerInfo.operatingHand_) }; return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); } @@ -8739,11 +8747,12 @@ ArkUINativeModuleValue CommonBridge::ResetOnBlur(ArkUIRuntimeCallInfo* runtimeCa Local CommonBridge::CreateHoverInfo(EcmaVM* vm, const HoverInfo& hoverInfo) { const char* keys[] = { "stopPropagation", "getModifierKeyState", "timestamp", "source", "target", "deviceId", - "targetDisplayId", "displayX", "displayY", "windowX", "windowY", "x", "y" }; + "targetDisplayId", "displayX", "displayY", "windowX", "windowY", "x", "y", "globalDisplayX", "globalDisplayY" }; double density = PipelineBase::GetCurrentDensity(); const Offset& globalOffset = hoverInfo.GetGlobalLocation(); const Offset& localOffset = hoverInfo.GetLocalLocation(); const Offset& screenOffset = hoverInfo.GetScreenLocation(); + const Offset& globalDisplayOffset = hoverInfo.GetGlobalDisplayLocation(); Local values[] = { panda::FunctionRef::New(vm, Framework::JsStopPropagation), panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), panda::NumberRef::New(vm, static_cast(hoverInfo.GetTimeStamp().time_since_epoch().count())), @@ -8755,7 +8764,9 @@ Local CommonBridge::CreateHoverInfo(EcmaVM* vm, const HoverInf panda::NumberRef::New(vm, density != 0 ? globalOffset.GetX() / density : 0), panda::NumberRef::New(vm, density != 0 ? globalOffset.GetY() / density : 0), panda::NumberRef::New(vm, density != 0 ? localOffset.GetX() / density : 0), - panda::NumberRef::New(vm, density != 0 ? localOffset.GetY() / density : 0) }; + panda::NumberRef::New(vm, density != 0 ? localOffset.GetY() / density : 0), + panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetX() / density : 0), + panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetY() / density : 0) }; return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); } @@ -9041,8 +9052,10 @@ Local CommonBridge::CreateTapGestureLocationInfo( const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_; const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_; const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_; + const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_; double density = PipelineBase::GetCurrentDensity(); - const char* keys[] = { "x", "y", "windowX", "windowY", "displayX", "displayY"}; + const char* keys[] = { "x", "y", "windowX", "windowY", "displayX", "displayY", + "globalDisplayX", "globalDisplayY"}; density = density != 0 ? density : 1; Local values[] = { panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(localLocation.GetX())), @@ -9051,6 +9064,8 @@ Local CommonBridge::CreateTapGestureLocationInfo( panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalLocation.GetY())), panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetX())), panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(screenLocation.GetY())), + panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX())), + panda::NumberRef::New(vm, PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetY())), }; return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); } @@ -10075,10 +10090,12 @@ Local CommonBridge::CreateAxisEventInfo(EcmaVM* vm, AxisInfo& const Offset& globalOffset = info.GetGlobalLocation(); const Offset& localOffset = info.GetLocalLocation(); const Offset& screenOffset = info.GetScreenLocation(); + const Offset& globalDisplayOffset = info.GetGlobalDisplayLocation(); double density = PipelineBase::GetCurrentDensity(); const char* keys[] = { "action", "displayX", "displayY", "windowX", "windowY", "x", "y", "scrollStep", "propagation", "getHorizontalAxisValue", "getVerticalAxisValue", "target", "timestamp", "source", "pressure", - "tiltX", "tiltY", "sourceTool", "deviceId", "getModifierKeyState", "axisVertical", "axisHorizontal" }; + "tiltX", "tiltY", "sourceTool", "deviceId", "getModifierKeyState", "axisVertical", "axisHorizontal", + "globalDisplayX", "globalDisplayY" }; Local values[] = { panda::NumberRef::New(vm, static_cast(info.GetAction())), panda::NumberRef::New(vm, screenOffset.GetX() / density), panda::NumberRef::New(vm, screenOffset.GetY() / density), @@ -10096,10 +10113,10 @@ Local CommonBridge::CreateAxisEventInfo(EcmaVM* vm, AxisInfo& panda::NumberRef::New(vm, static_cast(info.GetTiltX().value_or(0.0f))), panda::NumberRef::New(vm, static_cast(info.GetTiltY().value_or(0.0f))), panda::NumberRef::New(vm, static_cast(static_cast(info.GetSourceTool()))), - panda::NumberRef::New(vm, info.GetDeviceId()), - panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), - panda::NumberRef::New(vm, info.GetVerticalAxis()), - panda::NumberRef::New(vm, info.GetHorizontalAxis()) }; + panda::NumberRef::New(vm, info.GetDeviceId()), panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), + panda::NumberRef::New(vm, info.GetVerticalAxis()), panda::NumberRef::New(vm, info.GetHorizontalAxis()), + panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), + panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); obj->SetNativePointerFieldCount(vm, 1); obj->SetNativePointerField(vm, 0, static_cast(&info)); diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp index fbfd44b4b8b..92cb0b23094 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp @@ -222,8 +222,9 @@ Local FrameNodeBridge::CreateTouchInfo( const Offset& globalOffset = touchInfo.GetGlobalLocation(); const Offset& localOffset = touchInfo.GetLocalLocation(); const Offset& screenOffset = touchInfo.GetScreenLocation(); + const Offset& globalDisplayOffset = touchInfo.GetGlobalDisplayLocation(); const char* keys[] = { "type", "id", "displayX", "displayY", "windowX", "windowY", "screenX", "screenY", "x", "y", - "pressedTime", "pressure", "width", "height", "hand" }; + "pressedTime", "pressure", "width", "height", "hand", "globalDisplayX", "globalDisplayY" }; Local values[] = { panda::NumberRef::New(vm, static_cast(touchInfo.GetTouchType())), panda::NumberRef::New(vm, touchInfo.GetFingerId()), panda::NumberRef::New(vm, screenOffset.GetX() / density), panda::NumberRef::New(vm, screenOffset.GetY() / density), @@ -237,7 +238,9 @@ Local FrameNodeBridge::CreateTouchInfo( panda::NumberRef::New(vm, touchInfo.GetForce()), panda::NumberRef::New(vm, touchInfo.GetWidth() / density), panda::NumberRef::New(vm, touchInfo.GetHeight() / density), - panda::NumberRef::New(vm, touchInfo.GetOperatingHand()) }; + panda::NumberRef::New(vm, touchInfo.GetOperatingHand()), + panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), + panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; auto touchInfoObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); touchInfoObj->SetNativePointerFieldCount(vm, 1); touchInfoObj->SetNativePointerField(vm, 0, static_cast(&info)); @@ -691,9 +694,9 @@ Local FrameNodeBridge::CreateGestureEventInfo(EcmaVM* vm, Gest const Offset& localOffset = info.GetLocalLocation(); const Offset& screenOffset = info.GetScreenLocation(); double density = PipelineBase::GetCurrentDensity(); - + const Offset& globalDisplayOffset = info.GetGlobalDisplayLocation(); const char* keys[] = { "displayX", "displayY", "windowX", "windowY", "screenX", "screenY", "x", "y", "timestamp", - "source", "pressure", "deviceId", "hand" }; + "source", "pressure", "deviceId", "hand", "globalDisplayX", "globalDisplayY" }; Local values[] = { panda::NumberRef::New(vm, screenOffset.GetX() / density), panda::NumberRef::New(vm, screenOffset.GetY() / density), panda::NumberRef::New(vm, globalOffset.GetX() / density), @@ -706,7 +709,9 @@ Local FrameNodeBridge::CreateGestureEventInfo(EcmaVM* vm, Gest panda::NumberRef::New(vm, static_cast(info.GetSourceDevice())), panda::NumberRef::New(vm, info.GetForce()), panda::NumberRef::New(vm, info.GetDeviceId()), - panda::NumberRef::New(vm, GetOperatingHand(info)) }; + panda::NumberRef::New(vm, GetOperatingHand(info)), + panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), + panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); obj->Set( vm, panda::StringRef::NewFromUtf8(vm, "targetDisplayId"), panda::NumberRef::New(vm, info.GetTargetDisplayId())); @@ -1058,11 +1063,12 @@ ArkUINativeModuleValue FrameNodeBridge::SetOnBlur(ArkUIRuntimeCallInfo* runtimeC Local FrameNodeBridge::CreateHoverInfo(EcmaVM* vm, HoverInfo& hoverInfo) { const char* keys[] = { "stopPropagation", "getModifierKeyState", "timestamp", "source", "target", "deviceId", - "displayX", "displayY", "windowX", "windowY", "x", "y", }; + "displayX", "displayY", "windowX", "windowY", "x", "y", "globalDisplayX", "globalDisplayY", }; double density = PipelineBase::GetCurrentDensity(); const Offset& globalOffset = hoverInfo.GetGlobalLocation(); const Offset& localOffset = hoverInfo.GetLocalLocation(); const Offset& screenOffset = hoverInfo.GetScreenLocation(); + const Offset& globalDisplayOffset = hoverInfo.GetGlobalDisplayLocation(); Local values[] = { panda::FunctionRef::New(vm, Framework::JsStopPropagation), panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), panda::NumberRef::New(vm, static_cast(hoverInfo.GetTimeStamp().time_since_epoch().count())), @@ -1074,7 +1080,9 @@ Local FrameNodeBridge::CreateHoverInfo(EcmaVM* vm, HoverInfo& panda::NumberRef::New(vm, density != 0 ? globalOffset.GetX() / density : 0), panda::NumberRef::New(vm, density != 0 ? globalOffset.GetY() / density : 0), panda::NumberRef::New(vm, density != 0 ? localOffset.GetX() / density : 0), - panda::NumberRef::New(vm, density != 0 ? localOffset.GetY() / density : 0) }; + panda::NumberRef::New(vm, density != 0 ? localOffset.GetY() / density : 0), + panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetX() / density : 0), + panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetY() / density : 0) }; auto eventObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); eventObj->Set(vm, panda::StringRef::NewFromUtf8(vm, "rollAngle"), panda::NumberRef::New(vm, static_cast(hoverInfo.GetRollAngle().value_or(0.0f)))); @@ -1163,10 +1171,11 @@ Local FrameNodeBridge::CreateMouseInfoObj(EcmaVM* vm, MouseInf const Offset& globalOffset = info.GetGlobalLocation(); const Offset& localOffset = info.GetLocalLocation(); const Offset& screenOffset = info.GetScreenLocation(); + const Offset& globalDisplayOffset = info.GetGlobalDisplayLocation(); double density = PipelineBase::GetCurrentDensity(); const char* keys[] = { "button", "action", "displayX", "displayY", "windowX", "windowY", "screenX", "screenY", "x", "y", "timestamp", "stopPropagation", "getModifierKeyState", "source", "pressure", "deviceId", "rawDeltaX", - "rawDeltaY", "targetDisplayId" }; + "rawDeltaY", "targetDisplayId", "globalDisplayX", "globalDisplayY" }; Local values[] = { panda::NumberRef::New(vm, static_cast(info.GetButton())), panda::NumberRef::New(vm, static_cast(info.GetAction())), panda::NumberRef::New(vm, screenOffset.GetX() / density), @@ -1184,7 +1193,9 @@ Local FrameNodeBridge::CreateMouseInfoObj(EcmaVM* vm, MouseInf panda::NumberRef::New(vm, info.GetForce()), panda::NumberRef::New(vm, info.GetDeviceId()), panda::NumberRef::New(vm, info.GetRawDeltaX() / density), panda::NumberRef::New(vm, info.GetRawDeltaY() / density), - panda::NumberRef::New(vm, info.GetTargetDisplayId()) }; + panda::NumberRef::New(vm, info.GetTargetDisplayId()), + panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), + panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp b/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp index edfad9912a1..7a0e45d5f14 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp @@ -335,9 +335,7 @@ bool JSBaseNode::GetTouches(const JSCallbackInfo& info, TouchEvent& touchEvent) JSRef touchesArray = JSRef::Cast(touchesJsVal); for (auto index = 0; index < static_cast(touchesArray->Length()); index++) { JSRef item = touchesArray->GetValueAt(index); - if (!item->IsObject()) { - continue; - } + if (!item->IsObject()) { continue; } JSRef itemObj = JSRef::Cast(item); TouchPoint point; point.id = itemObj->GetPropertyValue("id", 0); @@ -345,6 +343,8 @@ bool JSBaseNode::GetTouches(const JSCallbackInfo& info, TouchEvent& touchEvent) point.y = itemObj->GetPropertyValue("y", 0.0f); point.screenX = itemObj->GetPropertyValue("screenX", 0.0f); point.screenY = itemObj->GetPropertyValue("screenY", 0.0f); + point.globalDisplayX = itemObj->GetPropertyValue("globalDisplayX", 0.0f); + point.globalDisplayY = itemObj->GetPropertyValue("globalDisplayY", 0.0f); point.originalId = itemObj->GetPropertyValue("id", 0); touchEvent.pointers.emplace_back(point); } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp index fd6e0647f84..d57c630062f 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp @@ -100,10 +100,15 @@ void JsLocationButtonClickFunction::Execute(GestureEvent& info) JSRef clickEventParam = JSRef::New(); Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); clickEventParam->SetProperty("screenX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); clickEventParam->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY())); clickEventParam->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX())); clickEventParam->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY())); + clickEventParam->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + clickEventParam->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); clickEventParam->SetProperty("timestamp", static_cast(info.GetTimeStamp().time_since_epoch().count())); clickEventParam->SetProperty("source", static_cast(info.GetSourceDevice())); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp index bd56d1b9688..9524bd73d9a 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp @@ -99,10 +99,15 @@ void JsPasteButtonClickFunction::Execute(GestureEvent& info) JSRef clickEventParam = JSRef::New(); Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); clickEventParam->SetProperty("screenX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); clickEventParam->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY())); clickEventParam->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX())); clickEventParam->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY())); + clickEventParam->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + clickEventParam->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); clickEventParam->SetProperty("timestamp", static_cast(info.GetTimeStamp().time_since_epoch().count())); clickEventParam->SetProperty("source", static_cast(info.GetSourceDevice())); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp index 30fb0392850..4b120c01140 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp @@ -104,10 +104,15 @@ void JsSaveButtonClickFunction::Execute(GestureEvent& info) JSRef clickEventParam = JSRef::New(); Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); clickEventParam->SetProperty("screenX", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX())); clickEventParam->SetProperty("screenY", PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY())); clickEventParam->SetProperty("x", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX())); clickEventParam->SetProperty("y", PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY())); + clickEventParam->SetProperty( + "globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + clickEventParam->SetProperty( + "globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); clickEventParam->SetProperty("timestamp", static_cast(info.GetTimeStamp().time_since_epoch().count())); clickEventParam->SetProperty("source", static_cast(info.GetSourceDevice())); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_web.cpp b/frameworks/bridge/declarative_frontend/jsview/js_web.cpp index f521bb4c409..a330a7c8dd0 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_web.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_web.cpp @@ -5107,6 +5107,7 @@ JSRef CreateTouchInfo(const TouchLocationInfo& touchInfo, TouchEventIn const OHOS::Ace::Offset& globalLocation = touchInfo.GetGlobalLocation(); const OHOS::Ace::Offset& localLocation = touchInfo.GetLocalLocation(); const OHOS::Ace::Offset& screenLocation = touchInfo.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = touchInfo.GetGlobalDisplayLocation(); touchInfoObj->SetProperty("type", static_cast(touchInfo.GetTouchType())); touchInfoObj->SetProperty("id", touchInfo.GetFingerId()); touchInfoObj->SetProperty("displayX", screenLocation.GetX()); @@ -5117,6 +5118,8 @@ JSRef CreateTouchInfo(const TouchLocationInfo& touchInfo, TouchEventIn touchInfoObj->SetProperty("screenY", globalLocation.GetY()); touchInfoObj->SetProperty("x", localLocation.GetX()); touchInfoObj->SetProperty("y", localLocation.GetY()); + touchInfoObj->SetProperty("globalDisplayX", globalDisplayLocation.GetX()); + touchInfoObj->SetProperty("globalDisplayY", globalDisplayLocation.GetY()); touchInfoObj->Wrap(&info); return touchInfoObj; } diff --git a/frameworks/core/accessibility/accessibility_manager_ng.cpp b/frameworks/core/accessibility/accessibility_manager_ng.cpp index e6b469c4744..c52e59c14e9 100644 --- a/frameworks/core/accessibility/accessibility_manager_ng.cpp +++ b/frameworks/core/accessibility/accessibility_manager_ng.cpp @@ -31,6 +31,8 @@ void AddTouchEventAllFingersInfo(const RefPtr& node, TouchEventIn float globalY = item.y; float screenX = item.screenX; float screenY = item.screenY; + double globalDisplayX = item.globalDisplayX; + double globalDisplayY = item.globalDisplayY; PointF localPoint(globalX, globalY); NGGestureRecognizer::Transform(localPoint, node, false, false); auto localX = static_cast(localPoint.GetX()); @@ -39,6 +41,7 @@ void AddTouchEventAllFingersInfo(const RefPtr& node, TouchEventIn info.SetGlobalLocation(Offset(globalX, globalY)); info.SetLocalLocation(Offset(localX, localY)); info.SetScreenLocation(Offset(screenX, screenY)); + info.SetGlobalDisplayLocation(Offset(globalDisplayX, globalDisplayY)); info.SetTouchType(event.type); info.SetForce(item.force); info.SetPressedTime(item.downTime); @@ -69,6 +72,7 @@ void ConvertTouchEvent2TouchEventInfo(const RefPtr& node, const T changedInfo.SetLocalLocation(Offset(localX, localY)); changedInfo.SetGlobalLocation(Offset(event.x, event.y)); changedInfo.SetScreenLocation(Offset(event.screenX, event.screenY)); + changedInfo.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); changedInfo.SetTouchType(event.type); changedInfo.SetForce(event.force); changedInfo.SetPressedTime(event.pressedTime); diff --git a/frameworks/core/common/event_manager.cpp b/frameworks/core/common/event_manager.cpp index 755101acaef..a0a89066ea5 100644 --- a/frameworks/core/common/event_manager.cpp +++ b/frameworks/core/common/event_manager.cpp @@ -442,8 +442,8 @@ void EventManager::ExecuteTouchTestDoneCallback( NG::PointF localPoint(point.x, point.y); NG::NGGestureRecognizer::Transform(localPoint, weakNode, false); FingerInfo fingerInfo = { point.originalId, point.operatingHand, Offset(point.x, point.y), - Offset(localPoint.GetX(), localPoint.GetY()), - Offset(point.screenX, point.screenY), touchEvent.sourceType, touchEvent.sourceTool }; + Offset(localPoint.GetX(), localPoint.GetY()), Offset(point.screenX, point.screenY), + Offset(point.globalDisplayX, point.globalDisplayY), touchEvent.sourceType, touchEvent.sourceTool }; fingerList.emplace_back(fingerInfo); } info->SetFingerList(fingerList); @@ -485,6 +485,8 @@ TouchEvent EventManager::ConvertAxisEventToTouchEvent(const AxisEvent& axisEvent .y = axisEvent.y, .screenX = axisEvent.screenX, .screenY = axisEvent.screenY, + .globalDisplayX = axisEvent.globalDisplayX, + .globalDisplayY = axisEvent.globalDisplayY, .downTime = axisEvent.time, .size = 0.0, .isPressed = (type == TouchType::DOWN), @@ -495,6 +497,8 @@ TouchEvent EventManager::ConvertAxisEventToTouchEvent(const AxisEvent& axisEvent .SetY(axisEvent.y) .SetScreenX(axisEvent.screenX) .SetScreenY(axisEvent.screenY) + .SetGlobalDisplayX(axisEvent.globalDisplayX) + .SetGlobalDisplayY(axisEvent.globalDisplayY) .SetType(type) .SetTime(axisEvent.time) .SetSize(0.0) diff --git a/frameworks/core/components/box/render_box.cpp b/frameworks/core/components/box/render_box.cpp index d5db2e3f558..ca330c59bab 100644 --- a/frameworks/core/components/box/render_box.cpp +++ b/frameworks/core/components/box/render_box.cpp @@ -1073,6 +1073,7 @@ bool RenderBox::HandleMouseEvent(const MouseEvent& event) info.SetGlobalLocation(event.GetOffset()); info.SetLocalLocation(event.GetOffset() - Offset(GetCoordinatePoint().GetX(), GetCoordinatePoint().GetY())); info.SetScreenLocation(event.GetScreenOffset()); + info.SetGlobalDisplayLocation(event.GetGlobalDisplayOffset()); info.SetTimeStamp(event.time); info.SetDeviceId(event.deviceId); info.SetSourceDevice(event.sourceType); diff --git a/frameworks/core/components/search/render_search.cpp b/frameworks/core/components/search/render_search.cpp index 5dc0bed26c5..b6c315a7f49 100644 --- a/frameworks/core/components/search/render_search.cpp +++ b/frameworks/core/components/search/render_search.cpp @@ -556,6 +556,7 @@ bool RenderSearch::HandleMouseEvent(const MouseEvent& event) info.SetGlobalLocation(event.GetOffset()); info.SetLocalLocation(event.GetOffset() - Offset(GetCoordinatePoint().GetX(), GetCoordinatePoint().GetY())); info.SetScreenLocation(event.GetScreenOffset()); + info.SetGlobalDisplayLocation(event.GetGlobalDisplayOffset()); info.SetTimeStamp(event.time); auto lowBound = searchReactRect_.GetOffset().GetX(); auto upBound = searchReactRect_.GetOffset().GetX() + searchReactRect_.GetSize().Width(); diff --git a/frameworks/core/components/split_container/render_split_container.cpp b/frameworks/core/components/split_container/render_split_container.cpp index 635619a640b..c1975435d64 100644 --- a/frameworks/core/components/split_container/render_split_container.cpp +++ b/frameworks/core/components/split_container/render_split_container.cpp @@ -275,6 +275,7 @@ bool RenderSplitContainer::HandleMouseEvent(const MouseEvent& event) info.SetGlobalLocation(event.GetOffset()); info.SetLocalLocation(event.GetOffset() - Offset(GetCoordinatePoint().GetX(), GetCoordinatePoint().GetY())); info.SetScreenLocation(event.GetScreenOffset()); + info.SetGlobalDisplayLocation(event.GetGlobalDisplayOffset()); info.SetTimeStamp(event.time); if (splitType_ == SplitType::ROW_SPLIT) { for (int32_t i = 0; i < static_cast(splitRects_.size()) - 1; i++) { diff --git a/frameworks/core/components/touch_listener/render_touch_listener.cpp b/frameworks/core/components/touch_listener/render_touch_listener.cpp index 45058057f70..282fbda28b3 100644 --- a/frameworks/core/components/touch_listener/render_touch_listener.cpp +++ b/frameworks/core/components/touch_listener/render_touch_listener.cpp @@ -148,6 +148,7 @@ bool RenderTouchListener::TriggerTouchCallBack(const TouchEvent& changedPoint) changedInfo.SetLocalLocation(Offset(localX, localY)); changedInfo.SetGlobalLocation(Offset(changedPoint.x, changedPoint.y)); changedInfo.SetScreenLocation(Offset(changedPoint.screenX, changedPoint.screenY)); + changedInfo.SetGlobalDisplayLocation(Offset(changedPoint.globalDisplayX, changedPoint.globalDisplayY)); changedInfo.SetTouchType(changedPoint.type); changedInfo.SetForce(changedPoint.force); if (changedPoint.tiltX.has_value()) { @@ -167,10 +168,13 @@ bool RenderTouchListener::TriggerTouchCallBack(const TouchEvent& changedPoint) float screenY = pointPair.second.screenY; float localX = pointPair.second.x - coordinateOffset_.GetX(); float localY = pointPair.second.y - coordinateOffset_.GetY(); + double globalDisplayX = pointPair.second.globalDisplayX; + double globalDisplayY = pointPair.second.globalDisplayX; TouchLocationInfo info("onTouch", pointPair.second.id); info.SetGlobalLocation(Offset(globalX, globalY)); info.SetLocalLocation(Offset(localX, localY)); info.SetScreenLocation(Offset(screenX, screenY)); + info.SetGlobalDisplayLocation(Offset(globalDisplayX, globalDisplayY)); info.SetTouchType(pointPair.second.type); info.SetForce(pointPair.second.force); if (pointPair.second.tiltX.has_value()) { diff --git a/frameworks/core/components/web/render_web.cpp b/frameworks/core/components/web/render_web.cpp index b538ffad94d..14c9079c207 100755 --- a/frameworks/core/components/web/render_web.cpp +++ b/frameworks/core/components/web/render_web.cpp @@ -325,6 +325,7 @@ bool RenderWeb::HandleMouseEvent(const MouseEvent& event) info.SetGlobalLocation(event.GetOffset()); info.SetLocalLocation(event.GetOffset() - Offset(GetCoordinatePoint().GetX(), GetCoordinatePoint().GetY())); info.SetScreenLocation(event.GetScreenOffset()); + info.SetGlobalDisplayLocation(event.GetGlobalDisplayOffset()); info.SetTimeStamp(event.time); info.SetDeviceId(event.deviceId); info.SetSourceDevice(event.sourceType); diff --git a/frameworks/core/components_ng/base/frame_node.cpp b/frameworks/core/components_ng/base/frame_node.cpp index 5b627690bfb..ba66dec6121 100644 --- a/frameworks/core/components_ng/base/frame_node.cpp +++ b/frameworks/core/components_ng/base/frame_node.cpp @@ -5617,6 +5617,7 @@ void SetChangeInfo(const TouchEvent& touchEvent, TouchLocationInfo &changedInfo) { changedInfo.SetGlobalLocation(Offset(touchEvent.x, touchEvent.y)); changedInfo.SetScreenLocation(Offset(touchEvent.screenX, touchEvent.screenY)); + changedInfo.SetGlobalDisplayLocation(Offset(touchEvent.globalDisplayX, touchEvent.globalDisplayY)); changedInfo.SetTouchType(touchEvent.type); changedInfo.SetForce(touchEvent.force); changedInfo.SetPressedTime(touchEvent.pressedTime); @@ -5680,6 +5681,8 @@ void FrameNode::AddTouchEventAllFingersInfo(TouchEventInfo& event, const TouchEv float globalY = item.y; float screenX = item.screenX; float screenY = item.screenY; + double globalDisplayX = item.globalDisplayX; + double globalDisplayY = item.globalDisplayY; PointF localPoint(globalX, globalY); NGGestureRecognizer::Transform(localPoint, Claim(this), false, false); auto localX = static_cast(localPoint.GetX()); @@ -5688,6 +5691,7 @@ void FrameNode::AddTouchEventAllFingersInfo(TouchEventInfo& event, const TouchEv info.SetGlobalLocation(Offset(globalX, globalY)); info.SetLocalLocation(Offset(localX, localY)); info.SetScreenLocation(Offset(screenX, screenY)); + info.SetGlobalDisplayLocation(Offset(globalDisplayX, globalDisplayY)); info.SetTouchType(touchEvent.type); info.SetForce(item.force); info.SetPressedTime(item.downTime); diff --git a/frameworks/core/components_ng/event/drag_drop_event.cpp b/frameworks/core/components_ng/event/drag_drop_event.cpp index a1c32d86d63..2321b6bf33b 100644 --- a/frameworks/core/components_ng/event/drag_drop_event.cpp +++ b/frameworks/core/components_ng/event/drag_drop_event.cpp @@ -274,6 +274,8 @@ void DragDropEventActuator::HandleTouchEvent(const TouchEventInfo& info, bool is touchEvent.y = info.GetTouches().front().GetGlobalLocation().GetY(); touchEvent.screenX = info.GetTouches().front().GetScreenLocation().GetX(); touchEvent.screenY = info.GetTouches().front().GetScreenLocation().GetY(); + touchEvent.globalDisplayX = info.GetTouches().front().GetGlobalDisplayLocation().GetX(); + touchEvent.globalDisplayY = info.GetTouches().front().GetGlobalDisplayLocation().GetY(); touchEvent.id = info.GetTouches().front().GetFingerId(); dragDropInitiatingHandler_->NotifyTouchEvent(touchEvent); } diff --git a/frameworks/core/components_ng/event/drag_event.cpp b/frameworks/core/components_ng/event/drag_event.cpp index 3f3b2e37521..24f64f0bef6 100644 --- a/frameworks/core/components_ng/event/drag_event.cpp +++ b/frameworks/core/components_ng/event/drag_event.cpp @@ -2023,16 +2023,19 @@ void DragEventActuator::HandleTouchEvent(const TouchEventInfo& info, bool isRest CHECK_NULL_VOID(gestureHub); auto frameNode = gestureHub->GetFrameNode(); CHECK_NULL_VOID(frameNode); - auto touchPoint = Point( - info.GetTouches().front().GetGlobalLocation().GetX(), info.GetTouches().front().GetGlobalLocation().GetY(), - info.GetTouches().front().GetScreenLocation().GetX(), info.GetTouches().front().GetScreenLocation().GetY()); + auto touchPoint = Point(info.GetTouches().front().GetGlobalLocation().GetX(), + info.GetTouches().front().GetGlobalLocation().GetY(), info.GetTouches().front().GetScreenLocation().GetX(), + info.GetTouches().front().GetScreenLocation().GetY(), + info.GetTouches().front().GetGlobalDisplayLocation().GetX(), + info.GetTouches().front().GetGlobalDisplayLocation().GetY()); auto pipeline = frameNode->GetContextRefPtr(); CHECK_NULL_VOID(pipeline); auto dragDropManager = pipeline->GetDragDropManager(); CHECK_NULL_VOID(dragDropManager); for (const auto& touchInfo : info.GetTouches()) { auto point = Point(touchInfo.GetGlobalLocation().GetX(), touchInfo.GetGlobalLocation().GetY(), - touchInfo.GetScreenLocation().GetX(), touchInfo.GetScreenLocation().GetY()); + touchInfo.GetScreenLocation().GetX(), touchInfo.GetScreenLocation().GetY(), + touchInfo.GetGlobalDisplayLocation().GetX(), touchInfo.GetGlobalDisplayLocation().GetY()); dragDropManager->UpdatePointInfoForFinger(touchInfo.GetFingerId(), point); } if (isRestartDrag) { 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 a7eeab3bd73..b4c7fe983bc 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp @@ -1202,6 +1202,8 @@ void GestureEventHub::HandleOnDragEnd(const GestureEvent& info) } event->SetScreenX(info.GetScreenLocation().GetX()); event->SetScreenY(info.GetScreenLocation().GetY()); + event->SetGlobalDisplayX(info.GetGlobalDisplayLocation().GetX()); + event->SetGlobalDisplayY(info.GetGlobalDisplayLocation().GetY()); event->SetPressedKeyCodes(info.GetPressedKeyCodes()); eventHub->FireCustomerOnDragFunc(DragFuncType::DRAG_DROP, event); eventHub->HandleInternalOnDrop(event, ""); @@ -1833,6 +1835,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/event/touch_event.cpp b/frameworks/core/components_ng/event/touch_event.cpp index d85242117d6..44537076e99 100644 --- a/frameworks/core/components_ng/event/touch_event.cpp +++ b/frameworks/core/components_ng/event/touch_event.cpp @@ -155,6 +155,7 @@ TouchLocationInfo TouchEventActuator::CreateChangedTouchInfo(const TouchEvent& l changedInfo.SetLocalLocation(Offset(localX, localY)); changedInfo.SetGlobalLocation(Offset(lastPoint.x, lastPoint.y)); changedInfo.SetScreenLocation(Offset(lastPoint.screenX, lastPoint.screenY)); + changedInfo.SetGlobalDisplayLocation(Offset(lastPoint.globalDisplayX, lastPoint.globalDisplayY)); changedInfo.SetTouchType(lastPoint.type); changedInfo.SetForce(lastPoint.force); changedInfo.SetPressedTime(lastPoint.pressedTime); @@ -178,6 +179,8 @@ TouchLocationInfo TouchEventActuator::CreateTouchItemInfo( float globalY = pointItem.y; float screenX = pointItem.screenX; float screenY = pointItem.screenY; + double globalDisplayX = pointItem.globalDisplayX; + double globalDisplayY = pointItem.globalDisplayY; PointF localPoint(globalX, globalY); NGGestureRecognizer::Transform(localPoint, GetAttachedNode(), false, isPostEventResult_, event.postEventNodeId); auto localX = static_cast(localPoint.GetX()); @@ -186,6 +189,7 @@ TouchLocationInfo TouchEventActuator::CreateTouchItemInfo( info.SetGlobalLocation(Offset(globalX, globalY)); info.SetLocalLocation(Offset(localX, localY)); info.SetScreenLocation(Offset(screenX, screenY)); + info.SetGlobalDisplayLocation(Offset(globalDisplayX, globalDisplayY)); info.SetTouchType(type); info.SetForce(pointItem.force); info.SetPressedTime(pointItem.downTime); @@ -208,6 +212,8 @@ TouchLocationInfo TouchEventActuator::CreateHistoryTouchItemInfo(const TouchEven float globalY = eventItem.y; float screenX = eventItem.screenX; float screenY = eventItem.screenY; + double globalDisplayX = eventItem.globalDisplayX; + double globalDisplayY = eventItem.globalDisplayY; PointF localPoint(globalX, globalY); NGGestureRecognizer::Transform(localPoint, GetAttachedNode(), false, isPostEventResult_, event.postEventNodeId); auto localX = static_cast(localPoint.GetX()); @@ -217,6 +223,7 @@ TouchLocationInfo TouchEventActuator::CreateHistoryTouchItemInfo(const TouchEven historyInfo.SetGlobalLocation(Offset(globalX, globalY)); historyInfo.SetLocalLocation(Offset(localX, localY)); historyInfo.SetScreenLocation(Offset(screenX, screenY)); + historyInfo.SetGlobalDisplayLocation(Offset(globalDisplayX, globalDisplayY)); historyInfo.SetTouchType(eventItem.type); historyInfo.SetForce(eventItem.force); historyInfo.SetPressedTime(eventItem.pressedTime); diff --git a/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp index e3cd2ec3f43..0460170f197 100644 --- a/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp @@ -133,6 +133,7 @@ ClickInfo ClickRecognizer::GetClickInfo() Offset localOffset(localPoint.GetX(), localPoint.GetY()); info.SetTimeStamp(touchPoint.time); info.SetScreenLocation(touchPoint.GetScreenOffset()); + info.SetGlobalDisplayLocation(touchPoint.GetGlobalDisplayOffset()); info.SetGlobalLocation(touchPoint.GetOffset()).SetLocalLocation(localOffset); info.SetSourceDevice(deviceType_); info.SetDeviceId(deviceId_); @@ -488,6 +489,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 768b69f3da6..27ecb9358d7 100644 --- a/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp @@ -421,6 +421,7 @@ void LongPressRecognizer::TriggerCallbackMsg( 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/multi_fingers_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp index 56b5ea4178c..df4b56087fc 100644 --- a/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp @@ -72,8 +72,8 @@ void MultiFingersRecognizer::UpdateFingerListInfo() TransformForRecognizer( localPoint, GetAttachedNode(), false, isPostEventResult_, point.second.postEventNodeId); FingerInfo fingerInfo = { point.second.GetOriginalReCovertId(), point.second.operatingHand, - point.second.GetOffset(), Offset(localPoint.GetX(), localPoint.GetY()), - point.second.GetScreenOffset(), point.second.sourceType, point.second.sourceTool }; + point.second.GetOffset(), Offset(localPoint.GetX(), localPoint.GetY()), point.second.GetScreenOffset(), + point.second.GetGlobalDisplayOffset(), point.second.sourceType, point.second.sourceTool }; fingerList_.emplace_back(fingerInfo); if (maxTimeStamp <= point.second.GetTimeStamp().time_since_epoch().count() && point.second.pointers.size() >= touchPoints_.size()) { diff --git a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp index 059db741583..b1948959618 100644 --- a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp @@ -784,6 +784,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); @@ -792,6 +793,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 3c98f97a63c..9f245d2a15b 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 df47ab6234f..509d139bcb2 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 @@ -2085,6 +2085,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()); @@ -2104,6 +2106,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)); @@ -2480,11 +2484,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, @@ -3281,7 +3287,8 @@ 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..e66416732b3 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); } @@ -61,9 +61,11 @@ void DragDropProxy::OnDragStart( CHECK_NULL_VOID(manager->CheckDragDropProxy(id_)); auto point = Point(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY(), info.GetScreenLocation().GetX(), - info.GetScreenLocation().GetY()); + info.GetScreenLocation().GetY(), info.GetGlobalDisplayLocation().GetX(), + info.GetGlobalDisplayLocation().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 +86,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 +103,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); } } diff --git a/frameworks/core/components_ng/pattern/model/model_touch_handler.cpp b/frameworks/core/components_ng/pattern/model/model_touch_handler.cpp index 7beaca09b36..52041289047 100644 --- a/frameworks/core/components_ng/pattern/model/model_touch_handler.cpp +++ b/frameworks/core/components_ng/pattern/model/model_touch_handler.cpp @@ -70,6 +70,8 @@ TouchEvent ModelTouchHandler::CreateTouchEvent(const TouchEventInfo& info) const .SetY(point.GetLocalLocation().GetY()) .SetScreenX(point.GetGlobalLocation().GetX()) .SetScreenY(point.GetGlobalLocation().GetY()) + .SetGlobalDisplayX(point.GetGlobalDisplayLocation().GetX()) + .SetGlobalDisplayY(point.GetGlobalDisplayLocation().GetY()) .SetType(point.GetTouchType()); } diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index c8460a09ff8..caaf3bb817e 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -2068,6 +2068,7 @@ HoverInfo TextPattern::ConvertHoverInfoFromMouseInfo(const MouseInfo& info) cons result.SetGlobalLocation(info.GetGlobalLocation()); result.SetScreenLocation(info.GetScreenLocation()); result.SetLocalLocation(info.GetLocalLocation()); + result.SetGlobalDisplayLocation(info.GetGlobalDisplayLocation()); result.SetTimeStamp(info.GetTimeStamp()); result.SetTarget(info.GetTarget()); result.SetDeviceId(info.GetDeviceId()); diff --git a/frameworks/core/components_ng/pattern/web/web_pattern.cpp b/frameworks/core/components_ng/pattern/web/web_pattern.cpp index 317df8dcf6c..026197395db 100644 --- a/frameworks/core/components_ng/pattern/web/web_pattern.cpp +++ b/frameworks/core/components_ng/pattern/web/web_pattern.cpp @@ -6676,6 +6676,8 @@ void WebPattern::SetTouchEventInfo(const TouchEvent& touchEvent, touchEvent.y + offset.GetY() + pos.GetY())); changedInfo.SetScreenLocation(Offset(touchEvent.x + offset.GetX() + pos.GetX(), touchEvent.y + offset.GetY() + pos.GetY())); + changedInfo.SetGlobalDisplayLocation(Offset(touchEvent.x + offset.GetX() + pos.GetX(), + touchEvent.y + offset.GetY() + pos.GetY())); changedInfo.SetTouchType(touchEvent.type); SetTouchLocationInfo(touchEvent, changedInfo, tempTouchInfo, touchEventInfo); @@ -6702,14 +6704,18 @@ void WebPattern::SetTouchLocationInfo(const TouchEvent& touchEvent, const TouchL info.SetGlobalLocation(changedInfo.GetGlobalLocation()); info.SetLocalLocation(changedInfo.GetLocalLocation()); info.SetScreenLocation(changedInfo.GetScreenLocation()); + info.SetGlobalDisplayLocation(changedInfo.GetGlobalDisplayLocation()); info.SetTouchType(changedInfo.GetTouchType()); } else { const OHOS::Ace::Offset& localLocation = location.GetLocalLocation(); const OHOS::Ace::Offset& globalLocation = location.GetGlobalLocation(); const OHOS::Ace::Offset& screenLocation = location.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = location.GetGlobalDisplayLocation(); info.SetGlobalLocation(Offset(globalLocation.GetX() - scaleX, globalLocation.GetY() - scaleY)); info.SetLocalLocation(Offset(localLocation.GetX() - scaleX, localLocation.GetY() - scaleY)); info.SetScreenLocation(Offset(screenLocation.GetX() - scaleX, screenLocation.GetY() - scaleY)); + info.SetGlobalDisplayLocation( + Offset(globalDisplayLocation.GetX() - scaleX, globalDisplayLocation.GetY() - scaleY)); info.SetTouchType(location.GetTouchType()); } touchEventInfo.AddTouchLocationInfo(std::move(info)); diff --git a/frameworks/core/event/axis_event.cpp b/frameworks/core/event/axis_event.cpp index 26e45b1f599..b4d037dbdb1 100644 --- a/frameworks/core/event/axis_event.cpp +++ b/frameworks/core/event/axis_event.cpp @@ -22,13 +22,13 @@ namespace OHOS::Ace { AxisEvent AxisEvent::CreateScaleEvent(float scale) const { if (NearZero(scale)) { - return { id, x, y, screenX, screenY, verticalAxis, horizontalAxis, pinchAxisScale, rotateAxisAngle, - isRotationEvent, action, time, deviceId, sourceType, sourceTool, pointerEvent, pressedCodes, - targetDisplayId, originalId, isInjected, scrollStep }; + return { id, x, y, screenX, screenY, globalDisplayX, globalDisplayY, verticalAxis, horizontalAxis, + pinchAxisScale, rotateAxisAngle, isRotationEvent, action, time, deviceId, sourceType, sourceTool, + pointerEvent, pressedCodes, targetDisplayId, originalId, isInjected, scrollStep }; } - return { id, x / scale, y / scale, screenX / scale, screenY / scale, verticalAxis, horizontalAxis, pinchAxisScale, - rotateAxisAngle, isRotationEvent, action, time, deviceId, sourceType, sourceTool, pointerEvent, pressedCodes, - targetDisplayId, originalId, isInjected, scrollStep }; + return { id, x / scale, y / scale, screenX / scale, screenY / scale, globalDisplayX / scale, globalDisplayY / scale, + verticalAxis, horizontalAxis, pinchAxisScale, rotateAxisAngle, isRotationEvent, action, time, deviceId, + sourceType, sourceTool, pointerEvent, pressedCodes, targetDisplayId, originalId, isInjected, scrollStep }; } Offset AxisEvent::GetOffset() const @@ -41,6 +41,11 @@ Offset AxisEvent::GetScreenOffset() const return Offset(screenX, screenY); } +Offset AxisEvent::GetGlobalDisplayOffset() const +{ + return Offset(globalDisplayX, globalDisplayY); +} + AxisDirection AxisEvent::GetDirection() const { uint32_t verticalFlag = 0; @@ -235,6 +240,16 @@ const Offset& AxisInfo::GetGlobalLocation() const return globalLocation_; } +AxisInfo& AxisInfo::SetGlobalDisplayLocation(const Offset& globalDisplayLocation) +{ + globalDisplayLocation_ = globalDisplayLocation; + return *this; +} +const Offset& AxisInfo::GetGlobalDisplayLocation() const +{ + return globalDisplayLocation_; +} + AxisEvent AxisInfo::ConvertToAxisEvent() const { AxisEvent axisEvent; @@ -242,6 +257,8 @@ AxisEvent AxisInfo::ConvertToAxisEvent() const axisEvent.y = static_cast(globalLocation_.GetY()); axisEvent.screenX = static_cast(screenLocation_.GetX()); axisEvent.screenY = static_cast(screenLocation_.GetY()); + axisEvent.globalDisplayX = static_cast(globalDisplayLocation_.GetX()); + axisEvent.globalDisplayY = static_cast(globalDisplayLocation_.GetY()); axisEvent.scrollStep = scrollStep_; axisEvent.horizontalAxis = horizontalAxis_; axisEvent.verticalAxis = verticalAxis_; @@ -312,6 +329,7 @@ bool AxisEventTarget::HandleAxisEvent(const AxisEvent& event) event.GetOffset().GetX() - coordinateOffset_.GetX(), event.GetOffset().GetY() - coordinateOffset_.GetY()); AxisInfo info = AxisInfo(event, localLocation, GetEventTarget().value_or(EventTarget())); info.SetScreenLocation(Offset(event.screenX, event.screenY)); + info.SetGlobalDisplayLocation(Offset(event.screenX, event.screenY)); info.SetSourceTool(event.sourceTool); info.SetStopPropagation(true); onAxisCallback_(info); diff --git a/frameworks/core/event/axis_event.h b/frameworks/core/event/axis_event.h index e0242153bba..f9cdf91bebc 100644 --- a/frameworks/core/event/axis_event.h +++ b/frameworks/core/event/axis_event.h @@ -39,8 +39,8 @@ struct UIInputEvent { struct PointerEvent : public UIInputEvent { virtual ~PointerEvent() = default; explicit PointerEvent(float x = {}, float y = {}, float screenX = {}, - float screenY = {}, TimeStamp time = {}) - :x(x), y(y), screenX(screenX), screenY(screenY) + float screenY = {}, double globalDisplayX = {}, double globalDisplayY = {}, TimeStamp time = {}) + :x(x), y(y), screenX(screenX), screenY(screenY), globalDisplayX(globalDisplayX), globalDisplayY(globalDisplayY) { this->time = time; } @@ -51,6 +51,8 @@ struct PointerEvent : public UIInputEvent { bool passThrough = {}; // ID of the node to which this event is being explicitly posted (not necessarily the original target) int32_t postEventNodeId = {}; + double globalDisplayX = {}; + double globalDisplayY = {}; }; struct AxisEvent final : public PointerEvent { @@ -91,17 +93,17 @@ struct AxisEvent final : public PointerEvent { { eventType = UIInputEventType::AXIS; } - - AxisEvent(int32_t id, float x, float y, float screenX, float screenY, double verticalAxis, double horizontalAxis, - double pinchAxisScale, double rotateAxisAngle, bool isRotationEvent, AxisAction action, TimeStamp timestamp, - int64_t deviceId, SourceType sourceType, SourceTool sourceTool, + AxisEvent(int32_t id, float x, float y, float screenX, float screenY, double globalDisplayX, double globalDisplayY, + double verticalAxis, double horizontalAxis, double pinchAxisScale, double rotateAxisAngle, bool isRotationEvent, + AxisAction action, TimeStamp timestamp, int64_t deviceId, SourceType sourceType, SourceTool sourceTool, std::shared_ptr pointerEvent, std::vector pressedCodes, int32_t targetDisplayId, int32_t originalId, bool isInjected, int32_t scrollStep) - : PointerEvent(x, y, screenX, screenY, timestamp), id(id), verticalAxis(verticalAxis), - horizontalAxis(horizontalAxis), pinchAxisScale(pinchAxisScale), rotateAxisAngle(rotateAxisAngle), - isRotationEvent(isRotationEvent), action(action), deviceId(deviceId), sourceType(sourceType), - sourceTool(sourceTool), pointerEvent(std::move(pointerEvent)), pressedCodes(pressedCodes), - targetDisplayId(targetDisplayId), originalId(originalId), isInjected(isInjected), scrollStep(scrollStep) + : PointerEvent(x, y, screenX, screenY, globalDisplayX, globalDisplayY, timestamp), id(id), + verticalAxis(verticalAxis), horizontalAxis(horizontalAxis), pinchAxisScale(pinchAxisScale), + rotateAxisAngle(rotateAxisAngle), isRotationEvent(isRotationEvent), action(action), deviceId(deviceId), + sourceType(sourceType), sourceTool(sourceTool), pointerEvent(std::move(pointerEvent)), + pressedCodes(pressedCodes), targetDisplayId(targetDisplayId), originalId(originalId), isInjected(isInjected), + scrollStep(scrollStep) { eventType = UIInputEventType::AXIS; } @@ -109,6 +111,7 @@ struct AxisEvent final : public PointerEvent { AxisEvent CreateScaleEvent(float scale) const; Offset GetOffset() const; Offset GetScreenOffset() const; + Offset GetGlobalDisplayOffset() const; int32_t GetTargetDisplayId() const; AxisDirection GetDirection() const; static bool IsDirectionUp(AxisDirection direction); @@ -144,6 +147,8 @@ public: AxisInfo& SetGlobalLocation(const Offset& globalLocation); AxisInfo& SetLocalLocation(const Offset& localLocation); AxisInfo& SetScreenLocation(const Offset& screenLocation); + AxisInfo& SetGlobalDisplayLocation(const Offset& globalDisplayLocation); + const Offset& GetGlobalDisplayLocation() const; const Offset& GetScreenLocation() const; const Offset& GetLocalLocation() const; const Offset& GetGlobalLocation() const; @@ -163,6 +168,8 @@ private: // current node which has the recognizer. Offset localLocation_; Offset screenLocation_; + // The location where the touch point touches the screen when there are multiple screens + Offset globalDisplayLocation_; }; using OnAxisEventFunc = std::function; diff --git a/frameworks/core/event/mouse_event.cpp b/frameworks/core/event/mouse_event.cpp index c9ed7aae488..63e886da784 100644 --- a/frameworks/core/event/mouse_event.cpp +++ b/frameworks/core/event/mouse_event.cpp @@ -80,6 +80,7 @@ bool HoverEventTarget::HandlePenHoverEvent(bool isHovered, const TouchEvent& eve hoverInfo.SetLocalLocation(Offset(localX, localY)); hoverInfo.SetGlobalLocation(Offset(event.x, event.y)); hoverInfo.SetScreenLocation(Offset(event.screenX, event.screenY)); + hoverInfo.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); hoverInfo.SetTarget(GetEventTarget().value_or(EventTarget())); // onPenHoverEventCallback_ may be overwritten in its invoke so we copy it first auto onPenHoverEventCallback = onPenHoverEventCallback_; @@ -114,6 +115,7 @@ bool HoverEventTarget::HandlePenHoverMoveEvent(const TouchEvent& event) hoverInfo.SetLocalLocation(Offset(localX, localY)); hoverInfo.SetGlobalLocation(Offset(event.x, event.y)); hoverInfo.SetScreenLocation(Offset(event.screenX, event.screenY)); + hoverInfo.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); hoverInfo.SetTarget(GetEventTarget().value_or(EventTarget())); // onPenHoverMoveEventCallback_ may be overwritten in its invoke so we copy it first auto onPenHoverMoveEventCallback = onPenHoverMoveEventCallback_; @@ -140,6 +142,7 @@ void HoverEventTarget::HandleAccessibilityHoverEvent(bool isHovered, const Touch hoverInfo.SetLocalLocation(Offset(localX, localY)); hoverInfo.SetGlobalLocation(Offset(event.x, event.y)); hoverInfo.SetScreenLocation(Offset(event.screenX, event.screenY)); + hoverInfo.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); hoverInfo.SetActionType(ConvertAccessibilityHoverAction(event.type)); hoverInfo.SetTarget(GetEventTarget().value_or(EventTarget())); // onAccessibilityHoverCallback_ may be overwritten in its invoke so we copy it first @@ -191,6 +194,7 @@ bool MouseEventTarget::HandleMouseEvent(const MouseEvent& event) auto localY = static_cast(localPoint.GetY()); info.SetLocalLocation(Offset(localX, localY)); info.SetScreenLocation(event.GetScreenOffset()); + info.SetGlobalDisplayLocation(event.GetGlobalDisplayOffset()); info.SetTimeStamp(event.time); info.SetDeviceId(event.deviceId); info.SetTargetDisplayId(event.targetDisplayId); @@ -226,6 +230,8 @@ MouseEvent MouseEvent::operator-(const Offset& offset) const mouseEvent.scrollZ = scrollZ; mouseEvent.screenX = screenX - offset.GetX(); mouseEvent.screenY = screenY - offset.GetY(); + mouseEvent.globalDisplayX = globalDisplayX - offset.GetX(); + mouseEvent.globalDisplayY = globalDisplayY - offset.GetY(); mouseEvent.action = action; mouseEvent.button = button; mouseEvent.pressedButtons = pressedButtons; diff --git a/frameworks/core/event/mouse_event.h b/frameworks/core/event/mouse_event.h index bc304488a7a..87fa6e51171 100644 --- a/frameworks/core/event/mouse_event.h +++ b/frameworks/core/event/mouse_event.h @@ -137,6 +137,11 @@ struct MouseEvent final : public PointerEvent { return Offset(screenX, screenY); } + Offset GetGlobalDisplayOffset() const + { + return Offset(globalDisplayX, globalDisplayY); + } + int32_t GetId() const { if (pressedButtons > 0) { @@ -177,6 +182,8 @@ struct MouseEvent final : public PointerEvent { mouseEvent.scrollZ = scrollZ / scale; mouseEvent.screenX = screenX / scale; mouseEvent.screenY = screenY / scale; + mouseEvent.globalDisplayX = globalDisplayX / scale; + mouseEvent.globalDisplayY = globalDisplayY / scale; mouseEvent.action = action; mouseEvent.pullAction = pullAction; mouseEvent.button = button; @@ -231,16 +238,16 @@ struct MouseEvent final : public PointerEvent { .y = y, .screenX = screenX, .screenY = screenY, + .globalDisplayX = globalDisplayX, + .globalDisplayY = globalDisplayY, .downTime = time, .size = 0.0, .isPressed = (type == TouchType::DOWN), .originalId = pointOriginalId }; TouchEvent event; event.SetId(pointId) - .SetX(x) - .SetY(y) - .SetScreenX(screenX) - .SetScreenY(screenY) + .SetX(x).SetY(y).SetScreenX(screenX).SetScreenY(screenY) + .SetGlobalDisplayX(globalDisplayX).SetGlobalDisplayY(globalDisplayY) .SetType(type) .SetTime(time) .SetSize(0.0) @@ -317,6 +324,17 @@ public: return *this; } + MouseInfo& SetGlobalDisplayLocation(const Offset& globalDisplayLocation) + { + globalDisplayLocation_ = globalDisplayLocation; + return *this; + } + + const Offset& GetGlobalDisplayLocation() const + { + return globalDisplayLocation_; + } + const Offset& GetScreenLocation() const { return screenLocation_; @@ -378,6 +396,8 @@ private: // current node which has the recognizer. Offset localLocation_; Offset screenLocation_; + // The location where the touch point touches the screen when there are multiple screens + Offset globalDisplayLocation_; float rawDeltaX_ = 0.0f; float rawDeltaY_ = 0.0f; std::vector pressedButtonsArray_; @@ -416,6 +436,17 @@ public: return *this; } + HoverInfo& SetGlobalDisplayLocation(const Offset& globalDisplayLocation) + { + globalDisplayLocation_ = globalDisplayLocation; + return *this; + } + + const Offset& GetGlobalDisplayLocation() const + { + return globalDisplayLocation_; + } + const Offset& GetScreenLocation() const { return screenLocation_; @@ -444,6 +475,7 @@ private: Offset localLocation_; Offset screenLocation_; + Offset globalDisplayLocation_; MouseAction mouseAction_ = MouseAction::NONE; }; @@ -471,6 +503,17 @@ public: return *this; } + AccessibilityHoverInfo& SetGlobalDisplayLocation(const Offset& globalDisplayLocation) + { + globalDisplayLocation_ = globalDisplayLocation; + return *this; + } + + const Offset& GetGlobalDisplayLocation() const + { + return globalDisplayLocation_; + } + const Offset& GetScreenLocation() const { return screenLocation_; @@ -505,6 +548,8 @@ private: Offset screenLocation_; + // The location where the touch point touches the screen when there are multiple screens + Offset globalDisplayLocation_; // touch type AccessibilityHoverAction actionType_ = AccessibilityHoverAction::UNKNOWN; }; diff --git a/frameworks/core/event/pointer_event.h b/frameworks/core/event/pointer_event.h index 490c1719e44..6058a2773ef 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; @@ -90,6 +92,16 @@ 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 { @@ -110,6 +122,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/event/touch_event.cpp b/frameworks/core/event/touch_event.cpp index e4f87b98245..181e3f639e2 100644 --- a/frameworks/core/event/touch_event.cpp +++ b/frameworks/core/event/touch_event.cpp @@ -73,6 +73,18 @@ TouchEvent& TouchEvent::SetScreenY(float screenY) return *this; } +TouchEvent& TouchEvent::SetGlobalDisplayX(double globalDisplayX) +{ + this->globalDisplayX = globalDisplayX; + return *this; +} + +TouchEvent& TouchEvent::SetGlobalDisplayY(double globalDisplayY) +{ + this->globalDisplayY = globalDisplayY; + return *this; +} + TouchEvent& TouchEvent::SetTime(TimeStamp time) { this->time = time; @@ -252,6 +264,8 @@ TouchEvent TouchEvent::CloneWith(float scale, float offsetX, float offsetY, std: event.y = (y - offsetY) / scale; event.screenX = (screenX - offsetX) / scale; event.screenY = (screenY - offsetY) / scale; + event.globalDisplayX = (globalDisplayX - offsetX) / scale; + event.globalDisplayY = (globalDisplayY - offsetY) / scale; event.type = type; event.pullType = pullType; event.time = time; @@ -357,6 +371,11 @@ Offset TouchEvent::GetScreenOffset() const return Offset(screenX, screenY); } +Offset TouchEvent::GetGlobalDisplayOffset() const +{ + return Offset(globalDisplayX, globalDisplayY); +} + void TouchEvent::CovertId() { if ((sourceType == SourceType::TOUCH) && (sourceTool == SourceTool::PEN)) { @@ -390,6 +409,8 @@ TouchEvent TouchEvent::CreateScalePoint(float scale) const point.y = point.y / scale; point.screenX = point.screenX / scale; point.screenY = point.screenY / scale; + point.globalDisplayX = point.globalDisplayX / scale; + point.globalDisplayY = point.globalDisplayY / scale; }); return CloneWith(scale); } @@ -403,6 +424,8 @@ TouchEvent TouchEvent::UpdateScalePoint(float scale, float offsetX, float offset point.y = point.y - offsetY; point.screenX = point.screenX - offsetX; point.screenY = point.screenY - offsetY; + point.globalDisplayX = point.globalDisplayX - offsetX; + point.globalDisplayY = point.globalDisplayY - offsetY; }); return CloneWith(1, offsetX, offsetY, pointId); } @@ -412,6 +435,8 @@ TouchEvent TouchEvent::UpdateScalePoint(float scale, float offsetX, float offset point.y = (point.y - offsetY) / scale; point.screenX = (point.screenX - offsetX) / scale; point.screenY = (point.screenY - offsetY) / scale; + point.globalDisplayX = (point.globalDisplayX - offsetX) / scale; + point.globalDisplayY = (point.globalDisplayY - offsetY) / scale; }); return CloneWith(scale, offsetX, offsetY, pointId); } @@ -423,6 +448,8 @@ TouchEvent TouchEvent::UpdatePointers() const .y = y, .screenX = screenX, .screenY = screenY, + .globalDisplayX = globalDisplayX, + .globalDisplayY = globalDisplayY, .downTime = time, .size = size, .force = force, @@ -434,6 +461,8 @@ TouchEvent TouchEvent::UpdatePointers() const .SetY(y) .SetScreenX(screenX) .SetScreenY(screenY) + .SetGlobalDisplayX(globalDisplayX) + .SetGlobalDisplayY(globalDisplayY) .SetType(type) .SetTime(time) .SetSize(size) @@ -489,6 +518,26 @@ float TouchCallBackInfo::GetScreenY() const return screenY_; } +void TouchCallBackInfo::SetGlobalDisplayX(double globalDisplayX) +{ + globalDisplayX_ = globalDisplayX; +} + +double TouchCallBackInfo::GetGlobalDisplayX() const +{ + return globalDisplayX_; +} + +void TouchCallBackInfo::SetGlobalDisplayY(double globalDisplayY) +{ + globalDisplayY_ = globalDisplayY; +} + +double TouchCallBackInfo::GetGlobalDisplayY() const +{ + return globalDisplayY_; +} + void TouchCallBackInfo::SetLocalX(float localX) { localX_ = localX; @@ -547,6 +596,12 @@ TouchLocationInfo& TouchLocationInfo::SetScreenLocation(const Offset& screenLoca return *this; } +TouchLocationInfo& TouchLocationInfo::SetGlobalDisplayLocation(const Offset& globalDisplayLocation) +{ + globalDisplayLocation_ = globalDisplayLocation; + return *this; +} + void TouchLocationInfo::SetSize(double size) { size_ = size; @@ -902,6 +957,8 @@ TouchEvent TouchEventInfo::ConvertToTouchEvent() const touchEvent.screenY = static_cast(changedTouches_.front().GetScreenLocation().GetY()); touchEvent.localX = static_cast(changedTouches_.front().GetLocalLocation().GetX()); touchEvent.localY = static_cast(changedTouches_.front().GetLocalLocation().GetY()); + touchEvent.globalDisplayX = static_cast(changedTouches_.front().GetGlobalDisplayLocation().GetX()); + touchEvent.globalDisplayY = static_cast(changedTouches_.front().GetGlobalDisplayLocation().GetY()); touchEvent.id = changedTouches_.front().GetFingerId(); touchEvent.force = changedTouches_.front().GetForce(); touchEvent.type = changedTouches_.front().GetTouchType(); diff --git a/frameworks/core/event/touch_event.h b/frameworks/core/event/touch_event.h index c936589c6bb..8b3b23a4c6b 100755 --- a/frameworks/core/event/touch_event.h +++ b/frameworks/core/event/touch_event.h @@ -42,6 +42,8 @@ struct TouchPoint final { float y = 0.0f; float screenX = 0.0f; float screenY = 0.0f; + double globalDisplayX = 0.0; + double globalDisplayY = 0.0; TimeStamp downTime; double size = 0.0; float force = 0.0f; @@ -121,6 +123,8 @@ struct TouchEvent final : public PointerEvent { TouchEvent& SetY(float y); TouchEvent& SetScreenX(float screenX); TouchEvent& SetScreenY(float screenY); + TouchEvent& SetGlobalDisplayX(double globalDisplayX); + TouchEvent& SetGlobalDisplayY(double globalDisplayY); TouchEvent& SetTime(TimeStamp time); TimeStamp GetTimeStamp() const; TouchEvent& SetType(TouchType type); @@ -154,6 +158,7 @@ struct TouchEvent final : public PointerEvent { void FromJson(const std::unique_ptr& json); Offset GetOffset() const; Offset GetScreenOffset() const; + Offset GetGlobalDisplayOffset() const; int32_t GetTargetDisplayId() const; void CovertId(); int32_t GetOriginalReCovertId() const; @@ -209,6 +214,10 @@ public: float GetScreenX() const; void SetScreenY(float screenY); float GetScreenY() const; + void SetGlobalDisplayX(double globalDisplayX); + double GetGlobalDisplayX() const; + void SetGlobalDisplayY(double globalDisplayY); + double GetGlobalDisplayY() const; void SetLocalX(float localX); float GetLocalX() const; void SetLocalY(float localY); @@ -219,6 +228,8 @@ public: TimeStamp GetTimeStamp() const; private: + double globalDisplayX_ = 0.0; + double globalDisplayY_ = 0.0; float screenX_ = 0.0f; float screenY_ = 0.0f; float localX_ = 0.0f; @@ -243,6 +254,11 @@ public: TouchLocationInfo& SetGlobalLocation(const Offset& globalLocation); TouchLocationInfo& SetLocalLocation(const Offset& localLocation); TouchLocationInfo& SetScreenLocation(const Offset& screenLocation); + TouchLocationInfo& SetGlobalDisplayLocation(const Offset& globalDisplayLocation); + const Offset& GetGlobalDisplayLocation() const + { + return globalDisplayLocation_; + } const Offset& GetScreenLocation() const { return screenLocation_; @@ -286,6 +302,8 @@ private: // current node which has the recognizer. Offset localLocation_; Offset screenLocation_; + // The location where the touch point touches the screen when there are multiple screens + Offset globalDisplayLocation_; // finger touch size double size_ = 0.0; // input device id diff --git a/frameworks/core/gestures/drag_event.h b/frameworks/core/gestures/drag_event.h index 0970c0864b4..9c9fe812be6 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; @@ -407,6 +427,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 156a1798b0c..c618f0b71a8 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_; @@ -375,6 +386,7 @@ private: // Will be used in drag. Offset screenLocation_; // Raw last touchPoint global location. + Offset globalDisplayLocation_; Offset rawGlobalLocation_; Offset pinchCenter_; Offset delta_; diff --git a/frameworks/core/gestures/gesture_info.h b/frameworks/core/gestures/gesture_info.h index 57529981eb1..982c51dc7ca 100644 --- a/frameworks/core/gestures/gesture_info.h +++ b/frameworks/core/gestures/gesture_info.h @@ -274,6 +274,7 @@ struct FingerInfo { //screen position at which the touch point contacts the screen. Offset screenLocation_; + Offset globalDisplayLocation_; SourceType sourceType_ = SourceType::NONE; SourceTool sourceTool_ = SourceTool::UNKNOWN; }; diff --git a/frameworks/core/gestures/long_press_recognizer.cpp b/frameworks/core/gestures/long_press_recognizer.cpp index 14c253a4728..45303e1eed8 100644 --- a/frameworks/core/gestures/long_press_recognizer.cpp +++ b/frameworks/core/gestures/long_press_recognizer.cpp @@ -31,6 +31,7 @@ void LongPressRecognizer::OnAccepted() LongPressInfo info(trackPoint.id); info.SetTimeStamp(time_); info.SetScreenLocation(trackPoint.GetScreenOffset()); + info.SetGlobalDisplayLocation(trackPoint.GetGlobalDisplayOffset()); info.SetGlobalLocation(trackPoint.GetOffset()).SetLocalLocation(trackPoint.GetOffset() - coordinateOffset_); info.SetTarget(GetEventTarget().value_or(EventTarget())); onLongPress_(info); @@ -244,6 +245,7 @@ void LongPressRecognizer::SendCallbackMsg(const std::unique_ptr t for (auto& point : touchPoints) { Offset localLocation = point.second.GetOffset() - coordinateOffset; FingerInfo fingerInfo = { point.first, point.second.operatingHand, point.second.GetOffset(), - localLocation, {} }; + localLocation, {}, point.second.GetGlobalDisplayOffset() }; fingerList.emplace_back(fingerInfo); } } diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index 1670ea77464..5fa845d037c 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -218,6 +218,8 @@ struct ArkUITouchPoint { ArkUI_Float32 screenY; ArkUI_Float32 windowX; ArkUI_Float32 windowY; + ArkUI_Float64 globalDisplayX; + ArkUI_Float64 globalDisplayY; ArkUI_Float32 nodeX; ArkUI_Float32 nodeY; ArkUI_Float64 pressure; @@ -385,6 +387,8 @@ struct ArkUIDragEvent { ArkUI_Float64 displayY; ArkUI_Float64 screenX; ArkUI_Float64 screenY; + ArkUI_Float64 globalDisplayX; + ArkUI_Float64 globalDisplayY; ArkUI_Uint64 modifierKeyState; ArkUI_Int32 dragBehavior; bool useCustomDropAnimation; @@ -1400,6 +1404,8 @@ struct ArkUIClickEvent { ArkUI_Float32 windowY; ArkUI_Float32 displayX; ArkUI_Float32 displayY; + ArkUI_Float64 globalDisplayX; + ArkUI_Float64 globalDisplayY; ArkUI_Float32 targetPositionX; ArkUI_Float32 targetPositionY; ArkUI_Float32 targetGlobalPositionX; diff --git a/frameworks/core/interfaces/native/node/node_common_modifier.cpp b/frameworks/core/interfaces/native/node/node_common_modifier.cpp index 8bbac834227..d62ca2115c4 100644 --- a/frameworks/core/interfaces/native/node/node_common_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_common_modifier.cpp @@ -7065,6 +7065,8 @@ ArkUI_Int32 PostTouchEvent(ArkUINodeHandle node, const ArkUITouchEvent* arkUITou point.y = touchPointes[index].nodeY; point.screenX = touchPointes[index].screenX * density; point.screenY = touchPointes[index].screenY * density; + point.globalDisplayX = touchPointes[index].globalDisplayX * density; + point.globalDisplayY = touchPointes[index].globalDisplayY * density; point.originalId = touchPointes[index].id; std::chrono::nanoseconds downNanoseconds(static_cast(touchPointes[index].pressedTime)); TimeStamp downTime(downNanoseconds); @@ -7077,6 +7079,8 @@ ArkUI_Int32 PostTouchEvent(ArkUINodeHandle node, const ArkUITouchEvent* arkUITou touchEvent.y = arkUITouchEvent->actionTouchPoint.nodeY; touchEvent.screenX = arkUITouchEvent->actionTouchPoint.screenX * density; touchEvent.screenY = arkUITouchEvent->actionTouchPoint.screenY * density; + touchEvent.globalDisplayX = arkUITouchEvent->actionTouchPoint.globalDisplayX * density; + touchEvent.globalDisplayY = arkUITouchEvent->actionTouchPoint.globalDisplayY * density; touchEvent.originalId = arkUITouchEvent->actionTouchPoint.id; MMI::PointerEvent* pointerEvent = reinterpret_cast(arkUITouchEvent->rawPointerEvent); NG::SetPostPointerEvent(pointerEvent, touchEvent); @@ -7098,6 +7102,10 @@ void SetHistoryTouchEvent(ArkUITouchEvent* arkUITouchEventCloned, const ArkUITou allHistoryEvents[i].actionTouchPoint.windowY = arkUITouchEvent->historyEvents[i].actionTouchPoint.windowY; allHistoryEvents[i].actionTouchPoint.screenX = arkUITouchEvent->historyEvents[i].actionTouchPoint.screenX; allHistoryEvents[i].actionTouchPoint.screenY = arkUITouchEvent->historyEvents[i].actionTouchPoint.screenY; + allHistoryEvents[i].actionTouchPoint.globalDisplayX = + arkUITouchEvent->historyEvents[i].actionTouchPoint.globalDisplayX; + allHistoryEvents[i].actionTouchPoint.globalDisplayY = + arkUITouchEvent->historyEvents[i].actionTouchPoint.globalDisplayY; allHistoryEvents[i].actionTouchPoint.pressure = arkUITouchEvent->historyEvents[i].actionTouchPoint.pressure; for (size_t j = 0; j < arkUITouchEvent->historyEvents[i].touchPointSize; j++) { @@ -7108,6 +7116,10 @@ void SetHistoryTouchEvent(ArkUITouchEvent* arkUITouchEventCloned, const ArkUITou allHistoryPoints[i][j].windowY = arkUITouchEvent->historyEvents[i].touchPointes[j].windowY; allHistoryPoints[i][j].screenX = arkUITouchEvent->historyEvents[i].touchPointes[j].screenX; allHistoryPoints[i][j].screenY = arkUITouchEvent->historyEvents[i].touchPointes[j].screenY; + allHistoryPoints[i][j].globalDisplayX = + arkUITouchEvent->historyEvents[i].touchPointes[j].globalDisplayX; + allHistoryPoints[i][j].globalDisplayY = + arkUITouchEvent->historyEvents[i].touchPointes[j].globalDisplayY; allHistoryPoints[i][j].contactAreaWidth = arkUITouchEvent->historyEvents[i].touchPointes[j].contactAreaWidth; allHistoryPoints[i][j].contactAreaHeight = @@ -8537,6 +8549,7 @@ void TriggerOnClickEvent(void* extraParam, int32_t nodeId, bool usePx, GestureEv Offset globalOffset = info.GetGlobalLocation(); Offset localOffset = info.GetLocalLocation(); Offset screenOffset = info.GetScreenLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); ArkUINodeEvent event; event.kind = ArkUIEventCategory::CLICK_EVENT; event.extraParam = reinterpret_cast(extraParam); @@ -8552,6 +8565,10 @@ void TriggerOnClickEvent(void* extraParam, int32_t nodeId, bool usePx, GestureEv usePx ? screenOffset.GetX() : PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX()); event.clickEvent.displayY = usePx ? screenOffset.GetY() : PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY()); + event.clickEvent.globalDisplayX = + usePx ? globalDisplayOffset.GetX() : PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX()); + event.clickEvent.globalDisplayY = + usePx ? globalDisplayOffset.GetY() : PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY()); SetOnClickInfo(event, info, usePx); SendArkUISyncEvent(&event); } @@ -8813,6 +8830,7 @@ void ConvertTouchLocationInfoToPoint(const TouchLocationInfo& locationInfo, ArkU const OHOS::Ace::Offset& globalLocation = locationInfo.GetGlobalLocation(); const OHOS::Ace::Offset& localLocation = locationInfo.GetLocalLocation(); const OHOS::Ace::Offset& screenLocation = locationInfo.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = locationInfo.GetGlobalDisplayLocation(); touchPoint.id = locationInfo.GetFingerId(); double density = usePx ? 1 : PipelineBase::GetCurrentDensity(); touchPoint.nodeX = localLocation.GetX() / density; @@ -8821,6 +8839,8 @@ void ConvertTouchLocationInfoToPoint(const TouchLocationInfo& locationInfo, ArkU touchPoint.windowY = globalLocation.GetY() / density; touchPoint.screenX = screenLocation.GetX() / density; touchPoint.screenY = screenLocation.GetY() / density; + touchPoint.globalDisplayX = globalDisplayLocation.GetX() / density; + touchPoint.globalDisplayY = globalDisplayLocation.GetY() / density; touchPoint.pressure = locationInfo.GetForce(); touchPoint.contactAreaWidth = locationInfo.GetSize(); touchPoint.contactAreaHeight = locationInfo.GetSize(); @@ -8857,6 +8877,10 @@ void ConvertTouchPointsToPoints(std::vector& touchPointes, historyLoaction.GetScreenLocation().GetX() / density; points[i].screenY = NearEqual(density, 0.0) ? 0.0f : historyLoaction.GetScreenLocation().GetY() / density; + points[i].globalDisplayX = NearEqual(density, 0.0) ? 0.0f : + historyLoaction.GetGlobalDisplayLocation().GetX() / density; + points[i].globalDisplayY = NearEqual(density, 0.0) ? 0.0f : + historyLoaction.GetGlobalDisplayLocation().GetY() / density; points[i].contactAreaWidth = touchPoint.size; points[i].contactAreaHeight = touchPoint.size; points[i].pressure = touchPoint.force; @@ -8974,6 +8998,8 @@ void SetOnTouch(ArkUINodeHandle node, void* extraParam) NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetGlobalLocation().GetY() / density; allHistoryEvents[i].actionTouchPoint.screenX = tempTouchEvent.screenX; allHistoryEvents[i].actionTouchPoint.screenY = tempTouchEvent.screenY; + allHistoryEvents[i].actionTouchPoint.globalDisplayX = tempTouchEvent.globalDisplayX; + allHistoryEvents[i].actionTouchPoint.globalDisplayY = tempTouchEvent.globalDisplayY; allHistoryEvents[i].actionTouchPoint.pressure = tempTouchEvent.force; ConvertTouchPointsToPoints( tempTouchEvent.pointers, allHistoryPoints[i], *historyLoacationIterator, usePx); @@ -9151,6 +9177,8 @@ void SetOnHoverMove(ArkUINodeHandle node, void* extraParam) event.touchEvent.actionTouchPoint.windowY = info.GetGlobalLocation().GetY(); event.touchEvent.actionTouchPoint.screenX = info.GetScreenLocation().GetX(); event.touchEvent.actionTouchPoint.screenY = info.GetScreenLocation().GetY(); + event.touchEvent.actionTouchPoint.globalDisplayX = info.GetGlobalDisplayLocation().GetX(); + event.touchEvent.actionTouchPoint.globalDisplayY = info.GetGlobalDisplayLocation().GetY(); event.touchEvent.actionTouchPoint.tiltX = info.GetTiltX().value_or(0.0f); event.touchEvent.actionTouchPoint.tiltY = info.GetTiltY().value_or(0.0f); event.touchEvent.actionTouchPoint.rollAngle = info.GetRollAngle().value_or(0.0f); @@ -9216,6 +9244,8 @@ void SetOnMouse(ArkUINodeHandle node, void* extraParam) event.mouseEvent.actionTouchPoint.windowY = info.GetGlobalLocation().GetY() / density; event.mouseEvent.actionTouchPoint.screenX = info.GetScreenLocation().GetX() / density; event.mouseEvent.actionTouchPoint.screenY = info.GetScreenLocation().GetY() / density; + event.mouseEvent.actionTouchPoint.globalDisplayX = info.GetGlobalDisplayLocation().GetX() / density; + event.mouseEvent.actionTouchPoint.globalDisplayY = info.GetGlobalDisplayLocation().GetY() / density; event.mouseEvent.rawDeltaX = info.GetRawDeltaX() / density; event.mouseEvent.rawDeltaY = info.GetRawDeltaY() / density; event.mouseEvent.targetDisplayId = info.GetTargetDisplayId(); @@ -9283,6 +9313,8 @@ void SetOnAxisEvent(ArkUINodeHandle node, void* extraParam) event.axisEvent.actionTouchPoint.windowY = info.GetGlobalLocation().GetY() / density; event.axisEvent.actionTouchPoint.screenX = info.GetScreenLocation().GetX() / density; event.axisEvent.actionTouchPoint.screenY = info.GetScreenLocation().GetY() / density; + event.axisEvent.actionTouchPoint.globalDisplayX = info.GetGlobalDisplayLocation().GetX() / density; + event.axisEvent.actionTouchPoint.globalDisplayY = info.GetGlobalDisplayLocation().GetY() / density; event.axisEvent.targetDisplayId = info.GetTargetDisplayId(); event.apiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion() % API_TARGET_VERSION_MASK; event.axisEvent.deviceId = info.GetDeviceId(); diff --git a/frameworks/core/interfaces/native/node/node_drag_modifier.cpp b/frameworks/core/interfaces/native/node/node_drag_modifier.cpp index a898576d65b..deede880f63 100644 --- a/frameworks/core/interfaces/native/node/node_drag_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_drag_modifier.cpp @@ -59,6 +59,8 @@ void SetDragEventProperty(const RefPtr& 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/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp b/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp index 901376c7d9e..47558d52ddd 100644 --- a/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp @@ -233,6 +233,8 @@ void ConvertTouchPointsToPoints(GestureEvent& info, std::vector& tou points[i].windowY = fingureIterator == fingureEnd ? 0.0f : fingureIterator->globalLocation_.GetY(); points[i].screenX = touchPoint.screenX; points[i].screenY = touchPoint.screenY; + points[i].globalDisplayX = touchPoint.globalDisplayX; + points[i].globalDisplayY = touchPoint.globalDisplayY; points[i].contactAreaWidth = touchPoint.size; points[i].contactAreaHeight = touchPoint.size; points[i].pressure = touchPoint.force; @@ -280,6 +282,8 @@ void ConvertIMMEventToTouchEvent(GestureEvent& info, ArkUITouchEvent& touchEvent touchEvent.actionTouchPoint.windowY = touchEvent.touchPointes[0].windowY; touchEvent.actionTouchPoint.screenX = touchEvent.touchPointes[0].screenX; touchEvent.actionTouchPoint.screenY = touchEvent.touchPointes[0].screenY; + touchEvent.actionTouchPoint.globalDisplayX = touchEvent.touchPointes[0].globalDisplayX; + touchEvent.actionTouchPoint.globalDisplayY = touchEvent.touchPointes[0].globalDisplayY; touchEvent.actionTouchPoint.toolType = touchEvent.touchPointes[0].toolType; touchEvent.actionTouchPoint.operatingHand = touchEvent.touchPointes[0].operatingHand; } @@ -471,6 +475,8 @@ void ConvertIMMEventToMouseEvent(GestureEvent& info, ArkUIMouseEvent& mouseEvent mouseEvent.actionTouchPoint.windowY = fingureBegin == fingureEnd ? 0.0f : fingureBegin->globalLocation_.GetY(); mouseEvent.actionTouchPoint.screenX = tempMouseEvent.screenX; mouseEvent.actionTouchPoint.screenY = tempMouseEvent.screenY; + mouseEvent.actionTouchPoint.globalDisplayX = tempMouseEvent.globalDisplayY; + mouseEvent.actionTouchPoint.globalDisplayY = tempMouseEvent.globalDisplayY; mouseEvent.actionTouchPoint.toolType = static_cast(tempMouseEvent.sourceTool); mouseEvent.targetDisplayId = info.GetTargetDisplayId(); } @@ -507,6 +513,10 @@ void ConvertIMMEventToAxisEvent(GestureEvent& info, ArkUIAxisEvent& axisEvent) axisEvent.actionTouchPoint.windowY = fingureBegin == fingureEnd ? 0.0f : fingureBegin->globalLocation_.GetY(); axisEvent.actionTouchPoint.screenX = fingureBegin == fingureEnd ? 0.0f : fingureBegin->screenLocation_.GetX(); axisEvent.actionTouchPoint.screenY = fingureBegin == fingureEnd ? 0.0f : fingureBegin->screenLocation_.GetY(); + axisEvent.actionTouchPoint.globalDisplayX = + fingureBegin == fingureEnd ? 0.0f : fingureBegin->globalDisplayLocation_.GetX(); + axisEvent.actionTouchPoint.globalDisplayY = + fingureBegin == fingureEnd ? 0.0f : fingureBegin->globalDisplayLocation_.GetY(); axisEvent.actionTouchPoint.toolType = static_cast(tempAxisEvent.sourceTool); axisEvent.targetDisplayId = info.GetTargetDisplayId(); } diff --git a/interfaces/inner_api/ace_kit/include/ui/base/geometry/point.h b/interfaces/inner_api/ace_kit/include/ui/base/geometry/point.h index 18788e924d7..8053196de33 100644 --- a/interfaces/inner_api/ace_kit/include/ui/base/geometry/point.h +++ b/interfaces/inner_api/ace_kit/include/ui/base/geometry/point.h @@ -35,6 +35,16 @@ public: : x_(x), y_(y), screenX_(screenX), screenY_(screenY), sourceType_(sourceType) {} + Point(double x, double y, double screenX, double screenY, double globalDisplayX, double globalDisplayY) + : x_(x), y_(y), screenX_(screenX), screenY_(screenY), globalDisplayX_(globalDisplayX), + globalDisplayY_(globalDisplayY) + {} + Point(double x, double y, double screenX, double screenY, double globalDisplayX, double globalDisplayY, + SourceType sourceType) + : x_(x), y_(y), screenX_(screenX), screenY_(screenY), globalDisplayX_(globalDisplayX), + globalDisplayY_(globalDisplayY), sourceType_(sourceType) + {} + double GetX() const { return x_; @@ -75,6 +85,26 @@ public: screenY_ = y; } + double GetGlobalDisplayX() const + { + return globalDisplayX_; + } + + double GetGlobalDisplayY() const + { + return globalDisplayY_; + } + + void SetGlobalDisplayX(double x) + { + globalDisplayX_ = x; + } + + void SetGlobalDisplayY(double y) + { + globalDisplayY_ = y; + } + void SetSourceType(SourceType sourceType) { sourceType_ = sourceType; @@ -123,6 +153,8 @@ private: double y_ = 0.0; double screenX_ = 0.0; double screenY_ = 0.0; + double globalDisplayX_ = 0.0; + double globalDisplayY_ = 0.0; SourceType sourceType_ = SourceType::NONE; }; diff --git a/interfaces/napi/kits/observer/ui_observer_listener.cpp b/interfaces/napi/kits/observer/ui_observer_listener.cpp index 0595e5bf4a4..143b77cc905 100644 --- a/interfaces/napi/kits/observer/ui_observer_listener.cpp +++ b/interfaces/napi/kits/observer/ui_observer_listener.cpp @@ -723,6 +723,16 @@ void UIObserverListener::AddGestureEventInfoTwo(napi_value objValueEvent, const napi_create_double(env_, gestureEventInfo.GetLocalLocation().GetY() / scale, &napiLocalY); napi_set_named_property(env_, objValueEvent, "localY", napiLocalY); } + napi_value napiGlobalDisplayX = GetNamedProperty(env_, objValueEvent, "globalDisplayX"); + if (GetValueType(env_, napiGlobalDisplayX) != napi_null) { + napi_create_double(env_, gestureEventInfo.GetGlobalDisplayLocation().GetX() / scale, &napiGlobalDisplayX); + napi_set_named_property(env_, objValueEvent, "globalDisplayX", napiGlobalDisplayX); + } + napi_value napiGlobalDisplayY = GetNamedProperty(env_, objValueEvent, "globalDisplayY"); + if (GetValueType(env_, napiGlobalDisplayY) != napi_null) { + napi_create_double(env_, gestureEventInfo.GetGlobalDisplayLocation().GetY() / scale, &napiGlobalDisplayY); + napi_set_named_property(env_, objValueEvent, "globalDisplayY", napiGlobalDisplayY); + } napi_value napiPinchCenterX = GetNamedProperty(env_, objValueEvent, "pinchCenterX"); if (GetValueType(env_, napiPinchCenterX) != napi_null) { napi_create_double(env_, gestureEventInfo.GetPinchCenter().GetX() / scale, &napiPinchCenterX); @@ -740,9 +750,7 @@ void UIObserverListener::AddGestureEventInfoThree(napi_value objValueEvent, cons { napi_handle_scope scope = nullptr; auto status = napi_open_handle_scope(env_, &scope); - if (status != napi_ok) { - return; - } + if (status != napi_ok) { return; } double scale = Dimension(1.0, DimensionUnit::VP).ConvertToPx(); if (NearZero(scale)) { scale = 1.0; @@ -805,6 +813,7 @@ void UIObserverListener::AddTapLocationInfo(napi_value objTapGestureEventInfo, c const OHOS::Ace::Offset& globalLocation = fingerInfo.globalLocation_; const OHOS::Ace::Offset& localLocation = fingerInfo.localLocation_; const OHOS::Ace::Offset& screenLocation = fingerInfo.screenLocation_; + const OHOS::Ace::Offset& globalDisplayLocation = fingerInfo.globalDisplayLocation_; napi_value napiGlobalX = nullptr; napi_create_double(env_, globalLocation.GetX() / scale, &napiGlobalX); napi_set_named_property(env_, tapLocation, "windowX", napiGlobalX); @@ -823,6 +832,12 @@ void UIObserverListener::AddTapLocationInfo(napi_value objTapGestureEventInfo, c napi_value napiScreenY = nullptr; napi_create_double(env_, screenLocation.GetY() / scale, &napiScreenY); napi_set_named_property(env_, tapLocation, "displayY", napiScreenY); + napi_value napiGlobalDisplayX = nullptr; + napi_create_double(env_, globalDisplayLocation.GetX() / scale, &napiGlobalDisplayX); + napi_set_named_property(env_, tapLocation, "globalDisplayX", napiGlobalDisplayX); + napi_value napiGlobalDisplayY = nullptr; + napi_create_double(env_, globalDisplayLocation.GetY() / scale, &napiGlobalDisplayY); + napi_set_named_property(env_, tapLocation, "globalDisplayY", napiGlobalDisplayY); napi_set_named_property(env_, objTapGestureEventInfo, "tapLocation", tapLocation); napi_close_handle_scope(env_, scope); } @@ -899,6 +914,7 @@ void UIObserverListener::AddFingerObjectInfo(napi_value napiFinger, const Finger const OHOS::Ace::Offset& globalLocation = finger.globalLocation_; const OHOS::Ace::Offset& localLocation = finger.localLocation_; const OHOS::Ace::Offset& screenLocaltion = finger.screenLocation_; + const OHOS::Ace::Offset& globalDisplayLocaltion = finger.globalDisplayLocation_; napi_value napiGlobalX = nullptr; napi_create_double(env_, globalLocation.GetX() / scale, &napiGlobalX); napi_set_named_property(env_, napiFinger, "globalX", napiGlobalX); @@ -917,6 +933,12 @@ void UIObserverListener::AddFingerObjectInfo(napi_value napiFinger, const Finger napi_value napiDisplayY = nullptr; napi_create_double(env_, screenLocaltion.GetY() / scale, &napiDisplayY); napi_set_named_property(env_, napiFinger, "displayY", napiDisplayY); + napi_value napiGlobalDisplayX = nullptr; + napi_create_double(env_, globalDisplayLocaltion.GetX() / scale, &napiGlobalDisplayX); + napi_set_named_property(env_, napiFinger, "globalDisplayX", napiGlobalDisplayX); + napi_value napiGlobalDisplayY = nullptr; + napi_create_double(env_, globalDisplayLocaltion.GetY() / scale, &napiGlobalDisplayY); + napi_set_named_property(env_, napiFinger, "globalDisplayY", napiGlobalDisplayY); } void UIObserverListener::AddClickEventInfoOne(napi_value objValueClickEvent, const ClickInfo& clickInfo) @@ -933,6 +955,7 @@ void UIObserverListener::AddClickEventInfoOne(napi_value objValueClickEvent, con } Offset globalOffset = clickInfo.GetGlobalLocation(); Offset screenOffset = clickInfo.GetScreenLocation(); + Offset globalDisplayOffset = clickInfo.GetGlobalDisplayLocation(); napi_value napiDisplayX = GetNamedProperty(env_, objValueClickEvent, "displayX"); if (GetValueType(env_, napiDisplayX) != napi_null) { napi_create_double(env_, screenOffset.GetX() / scale, &napiDisplayX); @@ -953,6 +976,16 @@ void UIObserverListener::AddClickEventInfoOne(napi_value objValueClickEvent, con napi_create_double(env_, globalOffset.GetY() / scale, &napiWindowY); napi_set_named_property(env_, objValueClickEvent, "windowY", napiWindowY); } + napi_value napiGlobalDisplayX = GetNamedProperty(env_, objValueClickEvent, "globalDisplayX"); + if (GetValueType(env_, napiGlobalDisplayX) != napi_null) { + napi_create_double(env_, globalDisplayOffset.GetX() / scale, &napiGlobalDisplayX); + napi_set_named_property(env_, objValueClickEvent, "globalDisplayX", napiGlobalDisplayX); + } + napi_value napiGlobalDisplayY = GetNamedProperty(env_, objValueClickEvent, "globalDisplayY"); + if (GetValueType(env_, napiGlobalDisplayY) != napi_null) { + napi_create_double(env_, globalDisplayOffset.GetY() / scale, &napiGlobalDisplayY); + napi_set_named_property(env_, objValueClickEvent, "globalDisplayY", napiGlobalDisplayY); + } napi_close_handle_scope(env_, scope); } diff --git a/interfaces/native/drag_and_drop.h b/interfaces/native/drag_and_drop.h index c82b6e1ea04..a7bf4b42360 100644 --- a/interfaces/native/drag_and_drop.h +++ b/interfaces/native/drag_and_drop.h @@ -439,6 +439,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 478615e9999..4fdb14c392a 100644 --- a/interfaces/native/event/drag_and_drop_impl.cpp +++ b/interfaces/native/event/drag_and_drop_impl.cpp @@ -690,6 +690,26 @@ float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event) return result; } +float OH_ArkUI_DragEvent_GetTouchPointXToGlobalDisplay(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) { diff --git a/interfaces/native/event/ui_input_event.cpp b/interfaces/native/event/ui_input_event.cpp index b30e3117aed..4af961ae2bd 100644 --- a/interfaces/native/event/ui_input_event.cpp +++ b/interfaces/native/event/ui_input_event.cpp @@ -1478,6 +1478,224 @@ float OH_ArkUI_PointerEvent_GetDisplayYByIndex(const ArkUI_UIInputEvent* event, RETURN_RET_WITH_STATUS_CHECK(0.0f, ARKUI_ERROR_INPUT_EVENT_TYPE_NOT_SUPPORT); } +float HandleCTouchEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (!touchEvent) { + return 0.0f; + } + return static_cast(touchEvent->actionTouchPoint.globalDisplayX); +} + +float HandleCClickEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* clickEvent = reinterpret_cast(event->inputEvent); + if (!clickEvent) { + return 0.0f; + } + return static_cast(clickEvent->globalDisplayX); +} + +float HandleCMouseEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return static_cast(mouseEvent->actionTouchPoint.globalDisplayX); +} + +float HandleCAxisEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent) { + return 0.0f; + } + return static_cast(axisEvent->actionTouchPoint.globalDisplayX); +} + +float HandleTouchEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (touchEvent) { + return static_cast(touchEvent->globalDisplayX); + } + return 0.0f; +} + +float HandleAxisEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (axisEvent) { + return static_cast(axisEvent->globalDisplayX); + } + return 0.0f; +} + +float OH_ArkUI_PointerEvent_GetGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + if (!event) { + return 0.0f; + } + std::map> eventHandlers = { + { C_TOUCH_EVENT_ID, HandleCTouchEventGlobalDisplayX }, + { TOUCH_EVENT_ID, HandleTouchEventGlobalDisplayX }, + { AXIS_EVENT_ID, HandleAxisEventGlobalDisplayX }, + { C_MOUSE_EVENT_ID, HandleCMouseEventGlobalDisplayX }, + { C_AXIS_EVENT_ID, HandleCAxisEventGlobalDisplayX }, + { C_CLICK_EVENT_ID, HandleCClickEventGlobalDisplayX }, + }; + auto it = eventHandlers.find(event->eventTypeId); + if (it != eventHandlers.end()) { + ArkUI_UIInputEvent* inputEvent = const_cast(event); + return it->second(inputEvent); + } + LOGE("The parameter of OH_ArkUI_PointerEvent_GetGlobalDisplayX is invalid"); + return 0.0f; +} + +float OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex) +{ + if (!event) { + return 0.0f; + } + switch (event->eventTypeId) { + case C_TOUCH_EVENT_ID: { + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (!isCurrentCTouchEventParamValid(touchEvent, pointerIndex)) { + return 0.0f; + } + return static_cast(touchEvent->touchPointes[pointerIndex].globalDisplayX); + } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent || pointerIndex != 0) { + return 0.0f; + } + return static_cast(mouseEvent->actionTouchPoint.globalDisplayX); + } + case C_AXIS_EVENT_ID: { + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent || pointerIndex != 0) { + return 0.0f; + } + return static_cast(axisEvent->actionTouchPoint.globalDisplayX); + } + default: + break; + } + return 0.0f; +} + +float HandleCTouchEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (!touchEvent) { + return 0.0f; + } + return static_cast(touchEvent->actionTouchPoint.globalDisplayY); +} + +float HandleCClickEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* clickEvent = reinterpret_cast(event->inputEvent); + if (!clickEvent) { + return 0.0f; + } + return static_cast(clickEvent->globalDisplayY); +} + +float HandleCMouseEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return static_cast(mouseEvent->actionTouchPoint.globalDisplayY); +} + +float HandleCAxisEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent) { + return 0.0f; + } + return static_cast(axisEvent->actionTouchPoint.globalDisplayY); +} + +float HandleTouchEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (touchEvent) { + return static_cast(touchEvent->globalDisplayY); + } + return 0.0f; +} + +float HandleAxisEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (axisEvent) { + return static_cast(axisEvent->globalDisplayY); + } + return 0.0f; +} + +float OH_ArkUI_PointerEvent_GetGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + if (!event) { + return 0.0f; + } + std::map> eventHandlers = { + { C_TOUCH_EVENT_ID, HandleCTouchEventGlobalDisplayY }, + { TOUCH_EVENT_ID, HandleTouchEventGlobalDisplayY }, + { AXIS_EVENT_ID, HandleAxisEventGlobalDisplayY }, + { C_MOUSE_EVENT_ID, HandleCMouseEventGlobalDisplayY }, + { C_AXIS_EVENT_ID, HandleCAxisEventGlobalDisplayY }, + { C_CLICK_EVENT_ID, HandleCClickEventGlobalDisplayY }, + }; + auto it = eventHandlers.find(event->eventTypeId); + if (it != eventHandlers.end()) { + ArkUI_UIInputEvent* inputEvent = const_cast(event); + return it->second(inputEvent); + } + LOGE("The parameter of OH_ArkUI_PointerEvent_GetGlobalDisplayX is invalid"); + return 0.0f; +} + +float OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex) +{ + if (!event) { + return 0.0f; + } + switch (event->eventTypeId) { + case C_TOUCH_EVENT_ID: { + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (!isCurrentCTouchEventParamValid(touchEvent, pointerIndex)) { + return 0.0f; + } + return static_cast(touchEvent->touchPointes[pointerIndex].globalDisplayY); + } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent || pointerIndex != 0) { + return 0.0f; + } + return static_cast(mouseEvent->actionTouchPoint.globalDisplayY); + } + case C_AXIS_EVENT_ID: { + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent || pointerIndex != 0) { + return 0.0f; + } + return static_cast(axisEvent->actionTouchPoint.globalDisplayY); + } + default: + break; + } + return 0.0f; +} + float OH_ArkUI_PointerEvent_GetPressure(const ArkUI_UIInputEvent* event, uint32_t pointerIndex) { CheckSupportedScenarioAndResetEventStatus(S_NODE_TOUCH_EVENT | S_NODE_ON_TOUCH_INTERCEPT | S_NODE_ON_MOUSE | @@ -1975,6 +2193,48 @@ float OH_ArkUI_PointerEvent_GetHistoryDisplayY( RETURN_RET_WITH_STATUS_CHECK(0.0f, ARKUI_ERROR_INPUT_EVENT_TYPE_NOT_SUPPORT); } +float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX( + const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex) +{ + if (!event) { + return 0.0f; + } + switch (event->eventTypeId) { + case C_TOUCH_EVENT_ID: { + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (!isHistoryCTouchEventParamValid(touchEvent, historyIndex, pointerIndex)) { + return 0.0f; + } + return static_cast( + touchEvent->historyEvents[historyIndex].touchPointes[pointerIndex].globalDisplayX); + } + default: + break; + } + return 0.0f; +} + +float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY( + const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex) +{ + if (!event) { + return 0.0f; + } + switch (event->eventTypeId) { + case C_TOUCH_EVENT_ID: { + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (!isHistoryCTouchEventParamValid(touchEvent, historyIndex, pointerIndex)) { + return 0.0f; + } + return static_cast( + touchEvent->historyEvents[historyIndex].touchPointes[pointerIndex].globalDisplayY); + } + default: + break; + } + return 0.0f; +} + float OH_ArkUI_PointerEvent_GetHistoryPressure( const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex) { diff --git a/interfaces/native/libace.ndk.json b/interfaces/native/libace.ndk.json index a3ac6b17469..6d6ced3e261 100644 --- a/interfaces/native/libace.ndk.json +++ b/interfaces/native/libace.ndk.json @@ -3435,6 +3435,38 @@ "first_introduced": "20", "name": "OH_ArkUI_SurfaceCallback_SetSurfaceHideEvent" }, + { + "first_introduced": "20", + "name": "OH_ArkUI_DragEvent_GetTouchPointXToGlobalDisplay" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_DragEvent_GetTouchPointYToGlobalDisplay" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PointerEvent_GetGlobalDisplayX" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PointerEvent_GetGlobalDisplayY" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX" + }, + { + "first_introduced": "20", + "name": "OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY" + }, { "first_introduced": "20", "name": "OH_ArkUI_PostAsyncUITask" diff --git a/interfaces/native/ui_input_event.h b/interfaces/native/ui_input_event.h index 37831a33e71..5e8152fed4b 100644 --- a/interfaces/native/ui_input_event.h +++ b/interfaces/native/ui_input_event.h @@ -463,6 +463,11 @@ float OH_ArkUI_PointerEvent_GetDisplayY(const ArkUI_UIInputEvent* event); */ float OH_ArkUI_PointerEvent_GetDisplayYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); +float OH_ArkUI_PointerEvent_GetGlobalDisplayX(const ArkUI_UIInputEvent* event); +float OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); +float OH_ArkUI_PointerEvent_GetGlobalDisplayY(const ArkUI_UIInputEvent* event); +float OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(const ArkUI_UIInputEvent* event, uint32_t pointerIndex); + /** * @brief Obtains the pressure applied to the touchscreen from a directional input event (for example, a touch event). * @@ -692,6 +697,11 @@ float OH_ArkUI_PointerEvent_GetHistoryDisplayX( float OH_ArkUI_PointerEvent_GetHistoryDisplayY( const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); +float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX( + const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); +float OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY( + const ArkUI_UIInputEvent* event, uint32_t pointerIndex, uint32_t historyIndex); + /** * @brief Obtains the pressure applied to the touchscreen in a specific historical event from a directional input event * (for example, a touch event).. diff --git a/test/unittest/interfaces/drag_and_drop_test.cpp b/test/unittest/interfaces/drag_and_drop_test.cpp index 12e6a9dabb2..19c85891713 100644 --- a/test/unittest/interfaces/drag_and_drop_test.cpp +++ b/test/unittest/interfaces/drag_and_drop_test.cpp @@ -41,6 +41,8 @@ const float PREVIEW_RECT_WIDTH = 1.0f; const float PREVIEW_RECT_HEIGHT = 1.0f; const float DISPLAY_X = 1.0f; const float DISPLAY_Y = 1.0f; +const float GLOBAL_DISPLAY_X = 1.0f; +const float GLOBAL_DISPLAY_Y = 1.0f; const float VELOCITY_X = 1.0f; const float VELOCITY_Y = 1.0f; const float VELOCITY = 1.0f; @@ -1287,4 +1289,74 @@ HWTEST_F(DragAndDropTest, DragAndDropTest0045, TestSize.Level1) EXPECT_EQ(ret3, ARKUI_ERROR_CODE_NO_ERROR); EXPECT_EQ(*isRemote, dragEvent.isRemoteDev); } + +/** + * @tc.name: DragAndDropTest0046 + * @tc.desc: test set DragEvent property function; + * @tc.type: FUNC + */ +HWTEST_F(DragAndDropTest, DragAndDropTest0046, TestSize.Level1) +{ + /** + *@tc.steps : step1.create and set property. + */ + ArkUIDragEvent dragEvent; + dragEvent.windowX = WINDOW_X; + dragEvent.windowY = WINDOW_Y; + dragEvent.displayX = DISPLAY_X; + dragEvent.displayY = DISPLAY_Y; + dragEvent.globalDisplayX = GLOBAL_DISPLAY_X; + dragEvent.globalDisplayY = GLOBAL_DISPLAY_Y; + dragEvent.touchPointX = TOUCH_POINT_X; + dragEvent.touchPointY = TOUCH_POINT_Y; + + dragEvent.previewRectWidth = PREVIEW_RECT_WIDTH; + dragEvent.previewRectHeight = PREVIEW_RECT_HEIGHT; + dragEvent.velocityX = VELOCITY_X; + dragEvent.velocityY = VELOCITY_Y; + dragEvent.velocity = VELOCITY; + auto* drag_Event = reinterpret_cast(&dragEvent); + + /** + * @tc.expected: Return expected results. + */ + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointXToWindow(drag_Event), WINDOW_X); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointYToWindow(drag_Event), WINDOW_Y); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewTouchPointX(drag_Event), TOUCH_POINT_X); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewTouchPointY(drag_Event), TOUCH_POINT_Y); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointXToDisplay(drag_Event), DISPLAY_X); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointYToDisplay(drag_Event), DISPLAY_Y); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointXToGlobalDisplay(drag_Event), GLOBAL_DISPLAY_X); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointYToGlobalDisplay(drag_Event), GLOBAL_DISPLAY_Y); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewRectWidth(drag_Event), PREVIEW_RECT_WIDTH); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewRectHeight(drag_Event), PREVIEW_RECT_HEIGHT); + EXPECT_EQ(OH_ArkUI_DragEvent_GetVelocityX(drag_Event), VELOCITY_X); + EXPECT_EQ(OH_ArkUI_DragEvent_GetVelocityY(drag_Event), VELOCITY_Y); + EXPECT_EQ(OH_ArkUI_DragEvent_GetVelocity(drag_Event), VELOCITY); +} + +/** + * @tc.name: DragAndDropTest0047 + * @tc.desc: test set DragEvent property function; + * @tc.type: FUNC + */ +HWTEST_F(DragAndDropTest, DragAndDropTest0047, TestSize.Level1) +{ + /** + * @tc.expected: Return expected results. + */ + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointXToWindow(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointYToWindow(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewTouchPointX(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewTouchPointY(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointXToDisplay(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointYToDisplay(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointXToGlobalDisplay(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetTouchPointYToGlobalDisplay(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewRectWidth(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetPreviewRectHeight(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetVelocityX(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetVelocityY(nullptr), 0.0f); + EXPECT_EQ(OH_ArkUI_DragEvent_GetVelocity(nullptr), 0.0f); +} } // namespace OHOS::Ace \ No newline at end of file diff --git a/test/unittest/interfaces/ui_input_event_test_one.cpp b/test/unittest/interfaces/ui_input_event_test_one.cpp index 240d627c776..a166adbbfc9 100644 --- a/test/unittest/interfaces/ui_input_event_test_one.cpp +++ b/test/unittest/interfaces/ui_input_event_test_one.cpp @@ -1582,4 +1582,326 @@ HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetRollAngle, TestSize.Level1) EXPECT_FLOAT_EQ(rollAngle, 2.2); EXPECT_EQ(ret, ARKUI_ERROR_CODE_NO_ERROR); } + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetGlobalDisplayX001 + * @tc.desc: Test OH_ArkUI_PointerEvent_GetGlobalDisplayX + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetGlobalDisplayX001, TestSize.Level1) +{ + ArkUI_UIInputEvent event; + auto ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(nullptr); + EXPECT_EQ(ret, 0.0f); + + event.eventTypeId = C_KEY_EVENT_ID; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 0.0f); + + event.eventTypeId = C_TOUCH_EVENT_ID; + ArkUITouchEvent touchEvent; + touchEvent.actionTouchPoint.globalDisplayX = 100.1f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &touchEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 100.1f); + + event.eventTypeId = C_MOUSE_EVENT_ID; + ArkUIMouseEvent mouseEvent; + mouseEvent.actionTouchPoint.globalDisplayX = 200.2f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &mouseEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 200.2f); +} + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetGlobalDisplayX002 + * @tc.desc: Test OH_ArkUI_PointerEvent_GetGlobalDisplayX + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetGlobalDisplayX002, TestSize.Level1) +{ + ArkUI_UIInputEvent event; + event.eventTypeId = C_AXIS_EVENT_ID; + ArkUIAxisEvent axisEvent; + axisEvent.actionTouchPoint.globalDisplayX = 300.3f; + event.inputEvent = nullptr; + auto ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &axisEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 300.3f); + + event.eventTypeId = TOUCH_EVENT_ID; + OHOS::Ace::TouchEvent aceTouchEvent; + aceTouchEvent.globalDisplayX = 400.4f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &aceTouchEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 400.4f); + + event.eventTypeId = AXIS_EVENT_ID; + OHOS::Ace::AxisEvent aceAxisEvent; + aceAxisEvent.globalDisplayX = 500.5f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &aceAxisEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayX(&event); + EXPECT_EQ(ret, 500.5f); +} + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetGlobalDisplayY001 + * @tc.desc: Test OH_ArkUI_PointerEvent_GetGlobalDisplayY + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetGlobalDisplayY001, TestSize.Level1) +{ + ArkUI_UIInputEvent event; + auto ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(nullptr); + EXPECT_EQ(ret, 0.0f); + + event.eventTypeId = C_KEY_EVENT_ID; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 0.0f); + + event.eventTypeId = C_TOUCH_EVENT_ID; + ArkUITouchEvent touchEvent; + touchEvent.actionTouchPoint.globalDisplayY = 100.1f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &touchEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 100.1f); + + event.eventTypeId = C_MOUSE_EVENT_ID; + ArkUIMouseEvent mouseEvent; + mouseEvent.actionTouchPoint.globalDisplayY = 200.2f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &mouseEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 200.2f); +} + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetGlobalDisplayY002 + * @tc.desc: Test OH_ArkUI_PointerEvent_GetGlobalDisplayY + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetGlobalDisplayY002, TestSize.Level1) +{ + ArkUI_UIInputEvent event; + event.eventTypeId = C_AXIS_EVENT_ID; + ArkUIAxisEvent axisEvent; + axisEvent.actionTouchPoint.globalDisplayY = 300.3f; + event.inputEvent = nullptr; + auto ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &axisEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 300.3f); + + event.eventTypeId = TOUCH_EVENT_ID; + OHOS::Ace::TouchEvent aceTouchEvent; + aceTouchEvent.globalDisplayY = 400.4f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &aceTouchEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 400.4f); + + event.eventTypeId = AXIS_EVENT_ID; + OHOS::Ace::AxisEvent aceAxisEvent; + aceAxisEvent.globalDisplayY = 500.5f; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 0.0f); + event.inputEvent = &aceAxisEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayY(&event); + EXPECT_EQ(ret, 500.5f); +} + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex + * @tc.desc: Test OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex, TestSize.Level1) +{ + ArkUI_UIInputEvent event; + auto ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(nullptr, 0); + EXPECT_EQ(ret, 0); + + event.eventTypeId = C_KEY_EVENT_ID; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 0); + EXPECT_EQ(ret, 0); + + event.eventTypeId = C_TOUCH_EVENT_ID; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 0); + EXPECT_EQ(ret, 0); + ArkUITouchEvent touchEvent; + ArkUITouchPoint touchPointes[3]; + touchPointes[2].globalDisplayX = 10; + touchEvent.touchPointSize = 3; + touchEvent.touchPointes = touchPointes; + event.inputEvent = &touchEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 2); + EXPECT_EQ(ret, 10); + + event.eventTypeId = C_MOUSE_EVENT_ID; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 1); + EXPECT_EQ(ret, 0); + ArkUIMouseEvent mouseEvent; + mouseEvent.actionTouchPoint.globalDisplayX = 20; + event.inputEvent = &mouseEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 1); + EXPECT_EQ(ret, 0); + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 0); + EXPECT_EQ(ret, 20); + + event.eventTypeId = C_AXIS_EVENT_ID; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 0); + EXPECT_EQ(ret, 0); + ArkUIAxisEvent axisEvent; + axisEvent.actionTouchPoint.globalDisplayX = 30; + event.inputEvent = &axisEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 1); + EXPECT_EQ(ret, 0); + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayXByIndex(&event, 0); + EXPECT_EQ(ret, 30); +} + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex + * @tc.desc: Test OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex, TestSize.Level1) +{ + ArkUI_UIInputEvent event; + auto ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(nullptr, 0); + EXPECT_EQ(ret, 0); + + event.eventTypeId = C_KEY_EVENT_ID; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 0); + EXPECT_EQ(ret, 0); + + event.eventTypeId = C_TOUCH_EVENT_ID; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 0); + EXPECT_EQ(ret, 0); + ArkUITouchEvent touchEvent; + ArkUITouchPoint touchPointes[3]; + touchPointes[2].globalDisplayY = 10; + touchEvent.touchPointSize = 3; + touchEvent.touchPointes = touchPointes; + event.inputEvent = &touchEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 2); + EXPECT_EQ(ret, 10); + + event.eventTypeId = C_MOUSE_EVENT_ID; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 1); + EXPECT_EQ(ret, 0); + ArkUIMouseEvent mouseEvent; + mouseEvent.actionTouchPoint.globalDisplayY = 20; + event.inputEvent = &mouseEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 1); + EXPECT_EQ(ret, 0); + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 0); + EXPECT_EQ(ret, 20); + + event.eventTypeId = C_AXIS_EVENT_ID; + event.inputEvent = nullptr; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 0); + EXPECT_EQ(ret, 0); + ArkUIAxisEvent axisEvent; + axisEvent.actionTouchPoint.globalDisplayY = 30; + event.inputEvent = &axisEvent; + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 1); + EXPECT_EQ(ret, 0); + ret = OH_ArkUI_PointerEvent_GetGlobalDisplayYByIndex(&event, 0); + EXPECT_EQ(ret, 30); +} + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX + * @tc.desc: test OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX, TestSize.Level1) +{ + auto uiInputEvent = std::make_unique(); + auto result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX(nullptr, 0, 0); + EXPECT_EQ(result, 0); + + uiInputEvent->eventTypeId = AXIS_EVENT_ID; + result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX(uiInputEvent.get(), 0, 0); + EXPECT_EQ(result, 0); + + uiInputEvent->eventTypeId = C_TOUCH_EVENT_ID; + auto touchEvent = std::make_unique(); + ArkUIHistoryTouchEvent events[2]; + ArkUITouchPoint pointes[2]; + events[1].touchPointSize = 2; + pointes[1].globalDisplayX = 30; + events[1].touchPointes = pointes; + touchEvent->historyEvents = events; + touchEvent->historySize = 2; + uiInputEvent->inputEvent = touchEvent.get(); + result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX(uiInputEvent.get(), 1, 1); + EXPECT_EQ(result, 30); + + uiInputEvent->inputEvent = nullptr; + result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayX(uiInputEvent.get(), 1, 1); + EXPECT_EQ(result, 0); +} + +/** + * @tc.name: OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY + * @tc.desc: test OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY + * @tc.type: FUNC + */ +HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY, TestSize.Level1) +{ + auto uiInputEvent = std::make_unique(); + auto result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY(nullptr, 0, 0); + EXPECT_EQ(result, 0); + + uiInputEvent->eventTypeId = AXIS_EVENT_ID; + result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY(uiInputEvent.get(), 0, 0); + EXPECT_EQ(result, 0); + + uiInputEvent->eventTypeId = C_TOUCH_EVENT_ID; + auto touchEvent = std::make_unique(); + ArkUIHistoryTouchEvent events[2]; + ArkUITouchPoint pointes[2]; + events[1].touchPointSize = 2; + pointes[1].globalDisplayY = 40; + events[1].touchPointes = pointes; + touchEvent->historyEvents = events; + touchEvent->historySize = 2; + uiInputEvent->inputEvent = touchEvent.get(); + result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY(uiInputEvent.get(), 1, 1); + EXPECT_EQ(result, 40); + + uiInputEvent->inputEvent = nullptr; + result = OH_ArkUI_PointerEvent_GetHistoryGlobalDisplayY(uiInputEvent.get(), 1, 1); + EXPECT_EQ(result, 0); +} } // namespace OHOS::Ace -- Gitee From a6d37c7f66c2f616009688c080ce8b92a46e0a0b Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Fri, 6 Jun 2025 17:06:17 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8Dcodecheck=E9=87=8D=E6=9E=84=E8=B6=85?= =?UTF-8?q?=E5=A4=A7=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 --- .../native/node/node_common_modifier.cpp | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/frameworks/core/interfaces/native/node/node_common_modifier.cpp b/frameworks/core/interfaces/native/node/node_common_modifier.cpp index d62ca2115c4..b38a5a358fc 100644 --- a/frameworks/core/interfaces/native/node/node_common_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_common_modifier.cpp @@ -7087,27 +7087,32 @@ ArkUI_Int32 PostTouchEvent(ArkUINodeHandle node, const ArkUITouchEvent* arkUITou return PostTouchEventToFrameNode(node, touchEvent); } +void SetSingleHistoryEvent(std::array& allHistoryEvents, + const ArkUITouchEvent* arkUITouchEvent, size_t index) +{ + allHistoryEvents[index].action = arkUITouchEvent->historyEvents[index].action; + allHistoryEvents[index].sourceType = arkUITouchEvent->historyEvents[index].sourceType; + allHistoryEvents[index].timeStamp = arkUITouchEvent->historyEvents[index].timeStamp; + allHistoryEvents[index].actionTouchPoint.nodeX = arkUITouchEvent->historyEvents[index].actionTouchPoint.nodeX; + allHistoryEvents[index].actionTouchPoint.nodeY = arkUITouchEvent->historyEvents[index].actionTouchPoint.nodeY; + allHistoryEvents[index].actionTouchPoint.windowX = arkUITouchEvent->historyEvents[index].actionTouchPoint.windowX; + allHistoryEvents[index].actionTouchPoint.windowY = arkUITouchEvent->historyEvents[index].actionTouchPoint.windowY; + allHistoryEvents[index].actionTouchPoint.screenX = arkUITouchEvent->historyEvents[index].actionTouchPoint.screenX; + allHistoryEvents[index].actionTouchPoint.screenY = arkUITouchEvent->historyEvents[index].actionTouchPoint.screenY; + allHistoryEvents[index].actionTouchPoint.globalDisplayX = + arkUITouchEvent->historyEvents[index].actionTouchPoint.globalDisplayX; + allHistoryEvents[index].actionTouchPoint.globalDisplayY = + arkUITouchEvent->historyEvents[index].actionTouchPoint.globalDisplayY; + allHistoryEvents[index].actionTouchPoint.pressure = arkUITouchEvent->historyEvents[index].actionTouchPoint.pressure; +} + void SetHistoryTouchEvent(ArkUITouchEvent* arkUITouchEventCloned, const ArkUITouchEvent* arkUITouchEvent) { std::array allHistoryEvents; std::array, MAX_HISTORY_EVENT_COUNT> allHistoryPoints; if (arkUITouchEvent->historySize > 0) { for (size_t i = 0; i < arkUITouchEvent->historySize; i++) { - allHistoryEvents[i].action = arkUITouchEvent->historyEvents[i].action; - allHistoryEvents[i].sourceType = arkUITouchEvent->historyEvents[i].sourceType; - allHistoryEvents[i].timeStamp = arkUITouchEvent->historyEvents[i].timeStamp; - allHistoryEvents[i].actionTouchPoint.nodeX = arkUITouchEvent->historyEvents[i].actionTouchPoint.nodeX; - allHistoryEvents[i].actionTouchPoint.nodeY = arkUITouchEvent->historyEvents[i].actionTouchPoint.nodeY; - allHistoryEvents[i].actionTouchPoint.windowX = arkUITouchEvent->historyEvents[i].actionTouchPoint.windowX; - allHistoryEvents[i].actionTouchPoint.windowY = arkUITouchEvent->historyEvents[i].actionTouchPoint.windowY; - allHistoryEvents[i].actionTouchPoint.screenX = arkUITouchEvent->historyEvents[i].actionTouchPoint.screenX; - allHistoryEvents[i].actionTouchPoint.screenY = arkUITouchEvent->historyEvents[i].actionTouchPoint.screenY; - allHistoryEvents[i].actionTouchPoint.globalDisplayX = - arkUITouchEvent->historyEvents[i].actionTouchPoint.globalDisplayX; - allHistoryEvents[i].actionTouchPoint.globalDisplayY = - arkUITouchEvent->historyEvents[i].actionTouchPoint.globalDisplayY; - allHistoryEvents[i].actionTouchPoint.pressure = - arkUITouchEvent->historyEvents[i].actionTouchPoint.pressure; + SetSingleHistoryEvent(allHistoryEvents, arkUITouchEvent, i); for (size_t j = 0; j < arkUITouchEvent->historyEvents[i].touchPointSize; j++) { allHistoryPoints[i][j].id = arkUITouchEvent->historyEvents[i].touchPointes[j].id; allHistoryPoints[i][j].nodeX = arkUITouchEvent->historyEvents[i].touchPointes[j].nodeX; -- Gitee From 9894fd7635c0b6161daa92359f8bee6d214c438d Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Fri, 6 Jun 2025 17:38:14 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcodecheck=E8=B6=85?= =?UTF-8?q?=E5=A4=A7=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 --- interfaces/napi/kits/observer/ui_observer_listener.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/napi/kits/observer/ui_observer_listener.cpp b/interfaces/napi/kits/observer/ui_observer_listener.cpp index 143b77cc905..82e2faf995f 100644 --- a/interfaces/napi/kits/observer/ui_observer_listener.cpp +++ b/interfaces/napi/kits/observer/ui_observer_listener.cpp @@ -696,9 +696,7 @@ void UIObserverListener::AddGestureEventInfoTwo(napi_value objValueEvent, const { napi_handle_scope scope = nullptr; auto status = napi_open_handle_scope(env_, &scope); - if (status != napi_ok) { - return; - } + if (status != napi_ok) { return; } double scale = Dimension(1.0, DimensionUnit::VP).ConvertToPx(); if (NearZero(scale)) { scale = 1.0; @@ -750,7 +748,9 @@ void UIObserverListener::AddGestureEventInfoThree(napi_value objValueEvent, cons { napi_handle_scope scope = nullptr; auto status = napi_open_handle_scope(env_, &scope); - if (status != napi_ok) { return; } + if (status != napi_ok) { + return; + } double scale = Dimension(1.0, DimensionUnit::VP).ConvertToPx(); if (NearZero(scale)) { scale = 1.0; -- Gitee From 39cf2e3568119282b2185100cea8d5625f26c00f Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Fri, 6 Jun 2025 19:57:10 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BF=AE=E6=94=B9TDD?= =?UTF-8?q?=E4=B8=AD=E6=9E=84=E9=80=A0FingerInfo=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 --- test/unittest/core/manager/json_report_test_ng.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unittest/core/manager/json_report_test_ng.cpp b/test/unittest/core/manager/json_report_test_ng.cpp index 1a49a71f79d..30e7b587f2b 100644 --- a/test/unittest/core/manager/json_report_test_ng.cpp +++ b/test/unittest/core/manager/json_report_test_ng.cpp @@ -35,7 +35,8 @@ const int32_t id = 1; const Offset offset(10, 10); const Offset offsetLocal(15, 15); const Offset offsetGlobal(20, 20); -const FingerInfo fingerInfo = { 0, 0, offset, offsetLocal, offsetGlobal, SourceType::TOUCH, SourceTool::FINGER }; +const Offset offsetGlobalDisplay(30, 30); +const FingerInfo fingerInfo = { 0, 0, offset, offsetLocal, offsetGlobal, offsetGlobalDisplay, SourceType::TOUCH, SourceTool::FINGER }; const std::list fingerList = { fingerInfo }; } // namespace -- Gitee From 73e960bc8656d89bd95d3685f323ddd8f66f7a85 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Fri, 6 Jun 2025 20:17:05 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcodecheck=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- test/unittest/core/manager/json_report_test_ng.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unittest/core/manager/json_report_test_ng.cpp b/test/unittest/core/manager/json_report_test_ng.cpp index 30e7b587f2b..3ea751ce2c8 100644 --- a/test/unittest/core/manager/json_report_test_ng.cpp +++ b/test/unittest/core/manager/json_report_test_ng.cpp @@ -36,7 +36,8 @@ const Offset offset(10, 10); const Offset offsetLocal(15, 15); const Offset offsetGlobal(20, 20); const Offset offsetGlobalDisplay(30, 30); -const FingerInfo fingerInfo = { 0, 0, offset, offsetLocal, offsetGlobal, offsetGlobalDisplay, SourceType::TOUCH, SourceTool::FINGER }; +const FingerInfo fingerInfo = { 0, 0, offset, offsetLocal, offsetGlobal, offsetGlobalDisplay, SourceType::TOUCH, + SourceTool::FINGER }; const std::list fingerList = { fingerInfo }; } // namespace -- Gitee From 72b79c18cb6611657782557862728861d38284f5 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Tue, 10 Jun 2025 19:27:13 +0800 Subject: [PATCH 6/8] =?UTF-8?q?mmi=E6=96=87=E4=BB=B6=E5=86=85=E5=AE=B9?= =?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 --- adapter/ohos/entrance/mmi_event_convertor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index f79654dbd9c..c3223aa1350 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -640,6 +640,8 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptr Date: Wed, 11 Jun 2025 17:59:10 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E8=87=AA=E6=9F=A5=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- .../engine/jsi/nativeModule/arkts_native_common_bridge.cpp | 6 ++++-- .../components/touch_listener/render_touch_listener.cpp | 2 +- .../components_ng/manager/drag_drop/drag_drop_manager.cpp | 2 +- frameworks/core/event/axis_event.cpp | 2 +- .../core/interfaces/native/node/node_gesture_modifier.cpp | 2 +- interfaces/native/event/ui_input_event.cpp | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp index ee5b4f142d2..f09cd5ec45e 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp @@ -10113,8 +10113,10 @@ Local CommonBridge::CreateAxisEventInfo(EcmaVM* vm, AxisInfo& panda::NumberRef::New(vm, static_cast(info.GetTiltX().value_or(0.0f))), panda::NumberRef::New(vm, static_cast(info.GetTiltY().value_or(0.0f))), panda::NumberRef::New(vm, static_cast(static_cast(info.GetSourceTool()))), - panda::NumberRef::New(vm, info.GetDeviceId()), panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), - panda::NumberRef::New(vm, info.GetVerticalAxis()), panda::NumberRef::New(vm, info.GetHorizontalAxis()), + panda::NumberRef::New(vm, info.GetDeviceId()), + panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), + panda::NumberRef::New(vm, info.GetVerticalAxis()), + panda::NumberRef::New(vm, info.GetHorizontalAxis()), panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); diff --git a/frameworks/core/components/touch_listener/render_touch_listener.cpp b/frameworks/core/components/touch_listener/render_touch_listener.cpp index 282fbda28b3..efd235edc5c 100644 --- a/frameworks/core/components/touch_listener/render_touch_listener.cpp +++ b/frameworks/core/components/touch_listener/render_touch_listener.cpp @@ -169,7 +169,7 @@ bool RenderTouchListener::TriggerTouchCallBack(const TouchEvent& changedPoint) float localX = pointPair.second.x - coordinateOffset_.GetX(); float localY = pointPair.second.y - coordinateOffset_.GetY(); double globalDisplayX = pointPair.second.globalDisplayX; - double globalDisplayY = pointPair.second.globalDisplayX; + double globalDisplayY = pointPair.second.globalDisplayY; TouchLocationInfo info("onTouch", pointPair.second.id); info.SetGlobalLocation(Offset(globalX, globalY)); info.SetLocalLocation(Offset(localX, localY)); 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 509d139bcb2..13b2fd81fc4 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 @@ -3288,7 +3288,7 @@ void DragDropManager::HandleTouchEvent(const TouchEvent& event) return; } auto pointerEvent = DragPointerEvent( - event.x, event.y, event.screenX, event.screenY, event.globalDisplayX, event.globalDisplayX); + event.x, event.y, event.screenX, event.screenY, event.globalDisplayX, event.globalDisplayY); SetDragAnimationPointerEvent(pointerEvent); } else if ((event.type == TouchType::UP) || (event.type == TouchType::CANCEL)) { ResetDraggingStatus(event); diff --git a/frameworks/core/event/axis_event.cpp b/frameworks/core/event/axis_event.cpp index b4d037dbdb1..b075941403c 100644 --- a/frameworks/core/event/axis_event.cpp +++ b/frameworks/core/event/axis_event.cpp @@ -329,7 +329,7 @@ bool AxisEventTarget::HandleAxisEvent(const AxisEvent& event) event.GetOffset().GetX() - coordinateOffset_.GetX(), event.GetOffset().GetY() - coordinateOffset_.GetY()); AxisInfo info = AxisInfo(event, localLocation, GetEventTarget().value_or(EventTarget())); info.SetScreenLocation(Offset(event.screenX, event.screenY)); - info.SetGlobalDisplayLocation(Offset(event.screenX, event.screenY)); + info.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); info.SetSourceTool(event.sourceTool); info.SetStopPropagation(true); onAxisCallback_(info); diff --git a/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp b/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp index 47558d52ddd..bf614a9b4ca 100644 --- a/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp @@ -475,7 +475,7 @@ void ConvertIMMEventToMouseEvent(GestureEvent& info, ArkUIMouseEvent& mouseEvent mouseEvent.actionTouchPoint.windowY = fingureBegin == fingureEnd ? 0.0f : fingureBegin->globalLocation_.GetY(); mouseEvent.actionTouchPoint.screenX = tempMouseEvent.screenX; mouseEvent.actionTouchPoint.screenY = tempMouseEvent.screenY; - mouseEvent.actionTouchPoint.globalDisplayX = tempMouseEvent.globalDisplayY; + mouseEvent.actionTouchPoint.globalDisplayX = tempMouseEvent.globalDisplayX; mouseEvent.actionTouchPoint.globalDisplayY = tempMouseEvent.globalDisplayY; mouseEvent.actionTouchPoint.toolType = static_cast(tempMouseEvent.sourceTool); mouseEvent.targetDisplayId = info.GetTargetDisplayId(); diff --git a/interfaces/native/event/ui_input_event.cpp b/interfaces/native/event/ui_input_event.cpp index 4af961ae2bd..1dc390df394 100644 --- a/interfaces/native/event/ui_input_event.cpp +++ b/interfaces/native/event/ui_input_event.cpp @@ -1659,7 +1659,7 @@ float OH_ArkUI_PointerEvent_GetGlobalDisplayY(const ArkUI_UIInputEvent* event) ArkUI_UIInputEvent* inputEvent = const_cast(event); return it->second(inputEvent); } - LOGE("The parameter of OH_ArkUI_PointerEvent_GetGlobalDisplayX is invalid"); + LOGE("The parameter of OH_ArkUI_PointerEvent_GetGlobalDisplayY is invalid"); return 0.0f; } -- Gitee From 74e2a943d1cf6972f8c6be9ec3f24bd67da6be78 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Thu, 12 Jun 2025 10:00:38 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=B6=85=E5=A4=A7=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- adapter/ohos/entrance/mmi_event_convertor.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index c3223aa1350..4e626e03322 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -595,6 +595,17 @@ static TouchType ConvertRawAxisActionToTouch(int32_t rawAxisAction) } } +void SetAxisEvent(PointerEvent& axisFakePntEvt, TouchPoint& touchPoint) +{ + axisFakePntEvt.x = touchPoint.x; + axisFakePntEvt.y = touchPoint.y; + axisFakePntEvt.screenX = touchPoint.screenX; + axisFakePntEvt.screenY = touchPoint.screenY; + axisFakePntEvt.globalDisplayX = touchPoint.globalDisplayX; + axisFakePntEvt.globalDisplayY = touchPoint.globalDisplayY; + touchPoint.downTime = axisFakePntEvt.time; +} + static void ConvertAxisEventToTouchPoint(const std::shared_ptr& pointerEvent, MMI::PointerEvent::PointerItem& pointerItem, TouchPoint& touchPoint, PointerEvent& axisFakePntEvt) { @@ -643,13 +654,7 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptr& pointerEvent, TouchEvent& touchEvt, -- Gitee