From 3a8220616664a50e7073bf670d7d2620ca545d57 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 10:55:39 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=E9=80=82=E9=85=8Dmerge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- adapter/ohos/entrance/ace_container.cpp | 4 ++ adapter/ohos/entrance/mmi_event_convertor.cpp | 12 ++++ .../engine/functions/js_click_function.cpp | 18 ++++++ .../engine/functions/js_drag_function.cpp | 16 +++++ .../engine/functions/js_drag_function.h | 2 + .../engine/functions/js_hover_function.cpp | 9 +++ .../engine/functions/js_touch_function.cpp | 3 + .../declarative_frontend/engine/js_types.cpp | 5 ++ .../arkts_native_common_bridge.cpp | 13 ++++- .../arkts_native_frame_node_bridge.cpp | 24 +++++--- .../jsview/js_base_node.cpp | 2 + .../declarative_frontend/jsview/js_web.cpp | 3 + .../accessibility_manager_ng.cpp | 4 ++ frameworks/core/common/event_manager.cpp | 4 ++ 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 | 3 + .../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 + .../gestures/recognizers/pan_recognizer.cpp | 2 + .../drag_drop/drag_drop_func_wrapper.cpp | 2 + .../manager/drag_drop/drag_drop_manager.cpp | 2 + .../pattern/text/text_pattern.cpp | 1 + frameworks/core/event/axis_event.cpp | 24 +++++++- frameworks/core/event/axis_event.h | 15 +++-- frameworks/core/event/mouse_event.cpp | 3 + frameworks/core/event/mouse_event.h | 48 +++++++++++++++ frameworks/core/event/pointer_event.h | 12 ++++ frameworks/core/event/touch_event.cpp | 58 +++++++++++++++++++ frameworks/core/event/touch_event.h | 16 +++++ frameworks/core/gestures/drag_event.h | 22 +++++++ frameworks/core/gestures/gesture_event.h | 12 ++++ .../core/gestures/long_press_recognizer.cpp | 2 + .../core/interfaces/arkoala/arkoala_api.h | 2 + .../native/node/node_drag_modifier.cpp | 2 + interfaces/native/drag_and_drop.h | 3 + .../native/event/drag_and_drop_impl.cpp | 20 +++++++ 42 files changed, 372 insertions(+), 18 deletions(-) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 242381cd118..6ebfc0f23d6 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -3781,6 +3781,8 @@ bool AceContainer::GetCurPointerEventInfo(DragPointerEvent& dragPointerEvent, St dragPointerEvent.displayY = pointerItem.GetDisplayY(); dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); + dragPointerEvent.globalDisplayX = pointerItem.GetGlobalX(); + dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY(); dragPointerEvent.deviceId = pointerItem.GetDeviceId(); dragPointerEvent.sourceTool = static_cast(pointerItem.GetToolType()); dragPointerEvent.displayId = currentPointerEvent->GetTargetDisplayId(); @@ -3829,6 +3831,8 @@ bool AceContainer::GetLastMovingPointerPosition(DragPointerEvent& dragPointerEve dragPointerEvent.displayY = pointerItem.GetDisplayY(); dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); + dragPointerEvent.globalDisplayX = pointerItem.GetGlobalX(); + dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY() return true; } diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index 5fac041735d..fa0fb66053b 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -80,6 +80,8 @@ TouchPoint ConvertTouchPoint(const MMI::PointerEvent::PointerItem& pointerItem) touchPoint.y = pointerItem.GetWindowY(); touchPoint.screenX = pointerItem.GetDisplayX(); touchPoint.screenY = pointerItem.GetDisplayY(); + touchPoint.globalDisplayX = pointerItem.GetGlobalX(); + touchPoint.globalDisplayY = pointerItem.GetGlobalY(); touchPoint.isPressed = pointerItem.IsPressed(); touchPoint.force = static_cast(pointerItem.GetPressure()); touchPoint.tiltX = pointerItem.GetTiltX(); @@ -172,6 +174,8 @@ void UpdateMouseEventForPen(const MMI::PointerEvent::PointerItem& pointerItem, M mouseEvent.screenX = pointerItem.GetDisplayXPos(); mouseEvent.screenY = pointerItem.GetDisplayYPos(); mouseEvent.originalId = mouseEvent.id; + mouseEvent.globalDisplayX = pointerItem.GetGlobalX(); + mouseEvent.globalDisplayY = pointerItem.GetGlobalY(); } TouchEvent ConvertTouchEventFromTouchPoint(TouchPoint touchPoint) @@ -182,6 +186,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) @@ -246,6 +252,8 @@ TouchEvent ConvertTouchEvent(const std::shared_ptr& pointerEv event.y = item.GetWindowYPos(); event.screenX = item.GetDisplayXPos(); event.screenY = item.GetDisplayYPos(); + event.globalDisplayX = item.GetGlobalX(); + event.globalDisplayY = item.GetGlobalY(); } event.pressedKeyCodes_.clear(); for (const auto& curCode : pointerEvent->GetPressedKeys()) { @@ -493,6 +501,8 @@ void ConvertAxisEvent(const std::shared_ptr& pointerEvent, Ax event.y = static_cast(item.GetWindowY()); event.screenX = static_cast(item.GetDisplayX()); event.screenY = static_cast(item.GetDisplayY()); + event.globalDisplayX = static_cast(item.GetGlobalX()); + event.globalDisplayY = static_cast(item.GetGlobalY()); 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); @@ -780,6 +790,8 @@ void ConvertPointerEvent(const std::shared_ptr& pointerEvent, event.displayX = pointerItem.GetDisplayX(); event.displayY = pointerItem.GetDisplayY(); event.displayId = pointerEvent->GetTargetDisplayId(); + event.globalDisplayX = pointerItem.GetGlobalX(); + event.globalDisplayY = pointerItem.GetGlobalY(); event.size = std::max(pointerItem.GetWidth(), pointerItem.GetHeight()) / SIZE_DIVIDE; event.force = static_cast(pointerItem.GetPressure()); event.deviceId = pointerItem.GetDeviceId(); 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..73b0b27298a 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())); @@ -132,6 +138,9 @@ void JsClickFunction::Execute(MouseInfo& 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())); @@ -190,6 +199,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 +237,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())); @@ -261,6 +276,9 @@ void JsWeakClickFunction::Execute(MouseInfo& info) Offset localOffset = info.GetLocalLocation(); Offset globalOffset = info.GetGlobalLocation(); Offset screenOffset = info.GetScreenLocation(); + Offset globalDisplayOffset = info.GetGlobalDisplayLocation(); + obj->SetProperty("globalDisplayX", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetX())); + obj->SetProperty("globalDisplayY", PipelineBase::Px2VpWithCurrentDensity(globalDisplayOffset.GetY())); obj->SetProperty("button", static_cast(info.GetButton())); obj->SetProperty("action", static_cast(info.GetAction())); obj->SetProperty("displayX", PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX())); diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp index 2705e43c5e6..04a4385c1d9 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.cpp @@ -107,6 +107,8 @@ void JsDragEvent::JSBind(BindingTarget globalObj) JSClass::CustomMethod("getPasteData", &JsDragEvent::GetJsPasteData); JSClass::CustomMethod("getDisplayX", &JsDragEvent::GetScreenX); JSClass::CustomMethod("getDisplayY", &JsDragEvent::GetScreenY); + JSClass::CustomMethod("getGlobalDisplayX", &JsDragEvent::GetGlobalDisplayX); + JSClass::CustomMethod("getGlobalDisplayY", &JsDragEvent::GetGlobalDisplayY); JSClass::CustomMethod("getDragSource", &JsDragEvent::GetDragSource); JSClass::CustomMethod("isRemote", &JsDragEvent::IsRemote); JSClass::CustomMethod("getWindowX", &JsDragEvent::GetX); @@ -168,6 +170,20 @@ void JsDragEvent::GetScreenY(const JSCallbackInfo& args) args.SetReturnValue(yValueRef); } +void JsDragEvent::GetGlobalDisplayX(const JSCallbackInfo& args) +{ + auto xValue = JSVal(ToJSValue(PipelineBase::Px2VpWithCurrentDensity(dragEvent_->GetGlobalDisplayX()))); + auto xValueRef = JSRef::Make(xValue); + args.SetReturnValue(xValueRef); +} + +void JsDragEvent::GetGlobalDisplayY(const JSCallbackInfo& args) +{ + auto yValue = JSVal(ToJSValue(PipelineBase::Px2VpWithCurrentDensity(dragEvent_->GetGlobalDisplayY()))); + auto yValueRef = JSRef::Make(yValue); + args.SetReturnValue(yValueRef); +} + void JsDragEvent::GetDragSource(const JSCallbackInfo& args) { JSRef dragSource = JSRef::Make(ToJSValue(dragEvent_->GetDragSource())); diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h index 2693fede315..2dd55561fb1 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h @@ -54,6 +54,8 @@ public: void GetJsPasteData(const JSCallbackInfo& args); void GetScreenX(const JSCallbackInfo& args); void GetScreenY(const JSCallbackInfo& args); + void GetGlobalDisplayX(const JSCallbackInfo& args); + void GetGlobalDisplayY(const JSCallbackInfo& args); void GetDisplayId(const JSCallbackInfo& args); void GetX(const JSCallbackInfo& args); void GetY(const JSCallbackInfo& args); diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_hover_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_hover_function.cpp index 75edd2eba6a..f9b54737965 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,9 @@ 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 +83,9 @@ 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 +122,9 @@ 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 6a0ad721153..52ecc8799f3 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,8 @@ 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..7e0de289cbd 100644 --- a/frameworks/bridge/declarative_frontend/engine/js_types.cpp +++ b/frameworks/bridge/declarative_frontend/engine/js_types.cpp @@ -104,12 +104,15 @@ Local JsGetHistoricalPoints(panda::JsiRuntimeCallInfo *info) const OHOS::Ace::Offset& globalLocation = point.GetGlobalLocation(); const OHOS::Ace::Offset& localLocation = point.GetLocalLocation(); const OHOS::Ace::Offset& screenLocation = point.GetScreenLocation(); + const OHOS::Ace::Offset& globalDisplayLocation = point.GetGlobalDisplayLocation(); 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 globalDisplayX = PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.GetX()); + auto globalDisplayY = PipelineBase::Px2VpWithCurrentDensity(globalDisplayLocation.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 +123,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 ad8c55770be..e3406cc86d2 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 @@ -8762,7 +8762,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); } @@ -10111,9 +10113,11 @@ Local CommonBridge::CreateAxisEventInfo(EcmaVM* vm, AxisInfo& const Offset& localOffset = info.GetLocalLocation(); const Offset& screenOffset = info.GetScreenLocation(); double density = PipelineBase::GetCurrentDensity(); + const Offset& globalDisplayOffset = info.GetGlobalDisplayLocation(); 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), @@ -10134,7 +10138,10 @@ Local CommonBridge::CreateAxisEventInfo(EcmaVM* vm, AxisInfo& 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.GetHorizontalAxis()), + panda::NumberRef::New(vm, info.GetDeviceId()), panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), + 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 57f6d444114..00b6a259908 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,10 +222,12 @@ 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, touchInfo.GetFingerId()), + panda::NumberRef::New(vm, screenOffset.GetX() / density), panda::NumberRef::New(vm, screenOffset.GetY() / density), panda::NumberRef::New(vm, globalOffset.GetX() / density), panda::NumberRef::New(vm, globalOffset.GetY() / density), @@ -237,7 +239,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 +695,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 +710,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 +1064,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())), @@ -1163,10 +1170,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), diff --git a/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp b/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp index daacf548f0b..fdc361372a1 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp @@ -345,6 +345,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_web.cpp b/frameworks/bridge/declarative_frontend/jsview/js_web.cpp index 45e4b1b5b3f..2883e80bd61 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_web.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_web.cpp @@ -5054,6 +5054,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()); @@ -5064,6 +5065,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 f4621fd4534..ede2b193b32 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; + float globalDisplayX = item.globalDisplayX; + float 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 cecdbf37fa3..15e78e39b22 100644 --- a/frameworks/core/common/event_manager.cpp +++ b/frameworks/core/common/event_manager.cpp @@ -479,6 +479,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), @@ -489,6 +491,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..c6211b4790e 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(); + float globalDisplayX = pointPair.second.globalDisplayX; + float 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 1f11fe33c76..7c9205b9c52 100644 --- a/frameworks/core/components_ng/base/frame_node.cpp +++ b/frameworks/core/components_ng/base/frame_node.cpp @@ -5687,6 +5687,8 @@ void FrameNode::AddTouchEventAllFingersInfo(TouchEventInfo& event, const TouchEv float globalY = item.y; float screenX = item.screenX; float screenY = item.screenY; + float globalDisplayX = item.globalDisplayX; + float globalDisplayY = item.globalDisplayY; PointF localPoint(globalX, globalY); NGGestureRecognizer::Transform(localPoint, Claim(this), false, false); auto localX = static_cast(localPoint.GetX()); @@ -5695,6 +5697,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/gesture_event_hub_drag.cpp b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp index ca1126bb360..d805dd7ad07 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp @@ -1201,6 +1201,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, ""); @@ -1832,6 +1834,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..74f8aabb25e 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; + float globalDisplayX = pointItem.globalDisplayX; + float 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; + float globalDisplayX = eventItem.globalDisplayX; + float 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 83267fa9669..635aa770870 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 e4e198a8661..a0f120e8262 100644 --- a/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp @@ -410,6 +410,7 @@ void LongPressRecognizer::SendCallbackMsg( info.SetScreenLocation(lastTouchEvent_.GetScreenOffset()); info.SetGlobalLocation(lastTouchEvent_.GetOffset()) .SetLocalLocation(lastTouchEvent_.GetOffset() - coordinateOffset_); + info.SetGlobalDisplayLocation(lastTouchEvent_.GetGlobalDisplayOffset()); info.SetTarget(GetEventTarget().value_or(EventTarget())); info.SetForce(lastTouchEvent_.force); if (lastTouchEvent_.tiltX.has_value()) { diff --git a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp index 0d1641baebb..fabfd0a7d5f 100644 --- a/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp @@ -776,6 +776,7 @@ GestureEvent PanRecognizer::GetGestureEventInfo() info.SetMainDelta(mainDelta_ / static_cast(touchPoints_.size())); if (inputEventType_ == InputEventType::AXIS) { info.SetScreenLocation(lastAxisEvent_.GetScreenOffset()); + info.SetGlobalDisplayLocation(lastAxisEvent_.GetGlobalDisplayOffset()); info.SetSourceTool(lastAxisEvent_.sourceTool); info.SetVerticalAxis(lastAxisEvent_.verticalAxis); info.SetHorizontalAxis(lastAxisEvent_.horizontalAxis); @@ -784,6 +785,7 @@ GestureEvent PanRecognizer::GetGestureEventInfo() info.CopyConvertInfoFrom(lastAxisEvent_.convertInfo); } else { info.SetScreenLocation(lastTouchEvent_.GetScreenOffset()); + info.SetGlobalDisplayLocation(lastTouchEvent_.GetGlobalDisplayOffset()); info.SetSourceTool(lastTouchEvent_.sourceTool); info.SetPressedKeyCodes(lastTouchEvent_.pressedKeyCodes_); info.SetPointerEventId(lastTouchEvent_.touchEventId); diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp index 8336d9e53a7..81b06a59121 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp @@ -724,6 +724,8 @@ void DragDropFuncWrapper::ConvertPointerEvent(const TouchEvent& touchPoint, Drag event.windowY = touchPoint.y; event.displayX = touchPoint.screenX; event.displayY = touchPoint.screenY; + event.globalDisplayX = touchPoint.globalDisplayX; + event.globalDisplayY = touchPoint.globalDisplayY; event.deviceId = touchPoint.deviceId; event.displayId = touchPoint.targetDisplayId; event.x = event.windowX; diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp index d14515b7f7f..9cd539014ae 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 @@ -2086,6 +2086,8 @@ void DragDropManager::UpdateDragEvent( event->SetScreenY(point.GetScreenY()); event->SetDisplayX((double)pointerEvent.GetDisplayX()); event->SetDisplayY((double)pointerEvent.GetDisplayY()); + event->SetGlobalDisplayX(pointerEvent.GetGlobalDisplayX()); + event->SetGlobalDisplayY(pointerEvent.GetGlobalDisplayY()); event->SetVelocity(velocityTracker_.GetVelocity()); event->SetSummary(summaryMap_); event->SetPreviewRect(GetDragWindowRect(point)); diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index 3dc515bc4ce..042163d273a 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -1872,6 +1872,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/event/axis_event.cpp b/frameworks/core/event/axis_event.cpp index 4a335840190..5d81570cf8e 100644 --- a/frameworks/core/event/axis_event.cpp +++ b/frameworks/core/event/axis_event.cpp @@ -22,11 +22,11 @@ namespace OHOS::Ace { AxisEvent AxisEvent::CreateScaleEvent(float scale) const { if (NearZero(scale)) { - return { id, x, y, screenX, screenY, verticalAxis, horizontalAxis, pinchAxisScale, rotateAxisAngle, + 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, + 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 }; } @@ -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; @@ -234,6 +239,18 @@ const Offset& AxisInfo::GetGlobalLocation() const return globalLocation_; } +AxisInfo& AxisInfo::SetGlobalDisplayLocation(const Offset& globalDisplayLocation) +{ + LOGE("AxisInfo::SetGlobalDisplayLocation, globalDisplayLocation"); + globalDisplayLocation_ = globalDisplayLocation; + return *this; +} +const Offset& AxisInfo::GetGlobalDisplayLocation() const +{ + LOGE("Offset& AxisInfo::GetGlobalDisplayLocation."); + return globalDisplayLocation_; +} + AxisEvent AxisInfo::ConvertToAxisEvent() const { AxisEvent axisEvent; @@ -241,6 +258,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_; @@ -310,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..c27de5153c7 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 = {}, float globalDisplayX = {}, float 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 = {}; + float globalDisplayX = {}; + float globalDisplayY = {}; }; struct AxisEvent final : public PointerEvent { @@ -91,13 +93,12 @@ struct AxisEvent final : public PointerEvent { { eventType = UIInputEventType::AXIS; } - - AxisEvent(int32_t id, float x, float y, float screenX, float screenY, double verticalAxis, double horizontalAxis, + AxisEvent(int32_t id, float x, float y, float screenX, float screenY, float globalDisplayX, float 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), + : 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), @@ -144,6 +145,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 +166,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..8b89a7595b3 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 diff --git a/frameworks/core/event/mouse_event.h b/frameworks/core/event/mouse_event.h index bc304488a7a..03fa80daeea 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,6 +238,8 @@ struct MouseEvent final : public PointerEvent { .y = y, .screenX = screenX, .screenY = screenY, + .globalDisplayX = globalDisplayX, + .globalDisplayY = globalDisplayY, .downTime = time, .size = 0.0, .isPressed = (type == TouchType::DOWN), @@ -241,6 +250,8 @@ struct MouseEvent final : public PointerEvent { .SetY(y) .SetScreenX(screenX) .SetScreenY(screenY) + .SetGlobalDisplayX(globalDisplayX) + .SetGlobalDisplayY(globalDisplayY) .SetType(type) .SetTime(time) .SetSize(0.0) @@ -317,6 +328,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 +400,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 +440,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_; @@ -471,6 +506,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 +551,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..8e6dd01baea 100644 --- a/frameworks/core/event/pointer_event.h +++ b/frameworks/core/event/pointer_event.h @@ -66,6 +66,8 @@ struct DragPointerEvent final : public PointerEvent { int32_t windowY = 0; int32_t displayX = 0; int32_t displayY = 0; + double globalDisplayX = 0.0; + double globalDisplayY = 0.0; double size = 0.0; float force = 0.0f; int32_t deviceId = 0; @@ -110,6 +112,16 @@ struct DragPointerEvent final : public PointerEvent { return displayY; } + double GetGlobalDisplayX() const + { + return globalDisplayX; + } + + double GetGlobalDisplayY() const + { + return globalDisplayY; + } + int32_t GetDisplayId() const { return displayId; diff --git a/frameworks/core/event/touch_event.cpp b/frameworks/core/event/touch_event.cpp index 0f2b9b8153c..a9566ee07a7 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(float globalDisplayX) +{ + this->globalDisplayX = globalDisplayX; + return *this; +} + +TouchEvent& TouchEvent::SetGlobalDisplayY(float 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 / scale; + point.globalDisplayY = point.globalDisplayY / 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) @@ -447,6 +476,7 @@ TouchEvent TouchEvent::UpdatePointers() const .SetIsPassThroughMode(isPassThroughMode) .SetOperatingHand(operatingHand); event.pointers.emplace_back(std::move(point)); + LOGE("TouchEvent::UpdatePointers set globalDisplayX,Y"); return event; } @@ -481,6 +511,26 @@ float TouchCallBackInfo::GetScreenY() const return screenY_; } +void TouchCallBackInfo::SetGlobalDisplayX(float globalDisplayX) +{ + globalDisplayX_ = globalDisplayX; +} + +float TouchCallBackInfo::GetGlobalDisplayX() const +{ + return globalDisplayX_; +} + +void TouchCallBackInfo::SetGlobalDisplayY(float globalDisplayY) +{ + globalDisplayY_ = globalDisplayY; +} + +float TouchCallBackInfo::GetGlobalDisplayY() const +{ + return globalDisplayY_; +} + void TouchCallBackInfo::SetLocalX(float localX) { localX_ = localX; @@ -539,6 +589,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; @@ -894,6 +950,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 d1a5e3ea6f8..926e20d33ec 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; + float globalDisplayX = 0.0f; + float globalDisplayY = 0.0f; 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(float globalDisplayX); + TouchEvent& SetGlobalDisplayY(float globalDisplayY); TouchEvent& SetTime(TimeStamp time); TimeStamp GetTimeStamp() const; TouchEvent& SetType(TouchType type); @@ -208,6 +212,10 @@ public: float GetScreenX() const; void SetScreenY(float screenY); float GetScreenY() const; + void SetGlobalDisplayX(float globalDisplayX); + float GetGlobalDisplayX() const; + void SetGlobalDisplayY(float globalDisplayY); + float GetGlobalDisplayY() const; void SetLocalX(float localX); float GetLocalX() const; void SetLocalY(float localY); @@ -218,6 +226,8 @@ public: TimeStamp GetTimeStamp() const; private: + float globalDisplayX_ = 0.0f; + float globalDisplayY_ = 0.0f; float screenX_ = 0.0f; float screenY_ = 0.0f; float localX_ = 0.0f; @@ -242,6 +252,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_; @@ -285,6 +300,7 @@ private: // current node which has the recognizer. Offset localLocation_; Offset screenLocation_; + 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 303308c3867..a7ad9373f5e 100644 --- a/frameworks/core/gestures/drag_event.h +++ b/frameworks/core/gestures/drag_event.h @@ -173,6 +173,26 @@ public: displayY_ = y; } + double GetGlobalDisplayX() const + { + return globalDisplayX_; + } + + double GetGlobalDisplayY() const + { + return globalDisplayY_; + } + + void SetGlobalDisplayX(double x) + { + globalDisplayX_ = x; + } + + void SetGlobalDisplayY(double y) + { + globalDisplayY_ = y; + } + void SetDescription(const std::string& description) { description_ = description; @@ -397,6 +417,8 @@ private: double y_ = 0.0; double displayX_ = 0.0; double displayY_ = 0.0; + double globalDisplayX_ = 0.0; + double globalDisplayY_ = 0.0; std::string description_; RefPtr pixelMap_; std::map summary_; diff --git a/frameworks/core/gestures/gesture_event.h b/frameworks/core/gestures/gesture_event.h index cb6b9205623..154dd290fb1 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_; @@ -365,6 +376,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/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& info, ArkUINodeEve event.dragEvent.displayY = info->GetDisplayY(); event.dragEvent.screenX = info->GetScreenX(); event.dragEvent.screenY = info->GetScreenY(); + event.dragEvent.globalDisplayX = info->GetGlobalDisplayX(); + event.dragEvent.globalDisplayY = info->GetGlobalDisplayY(); event.dragEvent.previewRectWidth = info->GetPreviewRect().Width(); event.dragEvent.previewRectHeight = info->GetPreviewRect().Height(); diff --git a/interfaces/native/drag_and_drop.h b/interfaces/native/drag_and_drop.h index 8f172410019..7543724d4c4 100644 --- a/interfaces/native/drag_and_drop.h +++ b/interfaces/native/drag_and_drop.h @@ -414,6 +414,9 @@ float OH_ArkUI_DragEvent_GetTouchPointXToDisplay(ArkUI_DragEvent* event); */ float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event); +float OH_ArkUI_DragEvent_GetTouchPointXToGlobalDisplay(ArkUI_DragEvent* event); +float OH_ArkUI_DragEvent_GetTouchPointYToGlobalDisplay(ArkUI_DragEvent* event); + /** * @brief Obtains the dragging velocity along the x-axis. * diff --git a/interfaces/native/event/drag_and_drop_impl.cpp b/interfaces/native/event/drag_and_drop_impl.cpp index 5e8227e475e..978cf5ee04d 100644 --- a/interfaces/native/event/drag_and_drop_impl.cpp +++ b/interfaces/native/event/drag_and_drop_impl.cpp @@ -687,6 +687,26 @@ float OH_ArkUI_DragEvent_GetTouchPointYToDisplay(ArkUI_DragEvent* event) return result; } +float OH_ArkUI_DragEvent_GetTouchPointXToGllobalDisplay(ArkUI_DragEvent* event) +{ + if (!event) { + return 0.0f; + } + auto* dragEvent = reinterpret_cast(event); + auto result = static_cast(dragEvent->globalDisplayX); + return result; +} + +float OH_ArkUI_DragEvent_GetTouchPointYToGlobalDisplay(ArkUI_DragEvent* event) +{ + if (!event) { + return 0.0f; + } + auto* dragEvent = reinterpret_cast(event); + auto result = static_cast(dragEvent->globalDisplayY); + return result; +} + float OH_ArkUI_DragEvent_GetVelocityX(ArkUI_DragEvent* event) { if (!event) { -- Gitee From 0eba26a0dc4646ff02d2db80639b55c6cee30ea4 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 11:36:47 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- frameworks/core/event/mouse_event.h | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/core/event/mouse_event.h b/frameworks/core/event/mouse_event.h index 03fa80daeea..c69436ecb6f 100644 --- a/frameworks/core/event/mouse_event.h +++ b/frameworks/core/event/mouse_event.h @@ -479,6 +479,7 @@ private: Offset localLocation_; Offset screenLocation_; + Offset globalDisplayLocation_; MouseAction mouseAction_ = MouseAction::NONE; }; -- Gitee From 1eb1a80770dc991299e7f6c27fe226746939fa90 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 11:45:28 +0800 Subject: [PATCH 03/19] =?UTF-8?q?codecheck=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 --- frameworks/core/event/touch_event.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/core/event/touch_event.cpp b/frameworks/core/event/touch_event.cpp index a9566ee07a7..e59c82813c5 100644 --- a/frameworks/core/event/touch_event.cpp +++ b/frameworks/core/event/touch_event.cpp @@ -424,8 +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; + point.globalDisplayX = point.globalDisplayX - offsetX; + point.globalDisplayY = point.globalDisplayY - offsetY; }); return CloneWith(1, offsetX, offsetY, pointId); } -- Gitee From 32150f7dc6343acf0bd2383424670e76f2a1af53 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 12:24:35 +0800 Subject: [PATCH 04/19] =?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/ace_container.cpp | 2 +- adapter/ohos/entrance/mmi_event_convertor.cpp | 21 ++++++++++--------- .../arkts_native_common_bridge.cpp | 1 - .../arkts_native_frame_node_bridge.cpp | 11 ++++++---- frameworks/core/event/touch_event.cpp | 5 ++--- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 6ebfc0f23d6..a464d93344c 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -3832,7 +3832,7 @@ bool AceContainer::GetLastMovingPointerPosition(DragPointerEvent& dragPointerEve dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); dragPointerEvent.globalDisplayX = pointerItem.GetGlobalX(); - dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY() + dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY(); return true; } diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index fa0fb66053b..9078556dc12 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -80,8 +80,9 @@ TouchPoint ConvertTouchPoint(const MMI::PointerEvent::PointerItem& pointerItem) touchPoint.y = pointerItem.GetWindowY(); touchPoint.screenX = pointerItem.GetDisplayX(); touchPoint.screenY = pointerItem.GetDisplayY(); - touchPoint.globalDisplayX = pointerItem.GetGlobalX(); - touchPoint.globalDisplayY = pointerItem.GetGlobalY(); + // GetGlobalX()不是const,编译不过,先使用GetDisplayX()验证 + touchPoint.globalDisplayX = pointerItem.GetDisplayX(); + touchPoint.globalDisplayY = pointerItem.GetDisplayY(); touchPoint.isPressed = pointerItem.IsPressed(); touchPoint.force = static_cast(pointerItem.GetPressure()); touchPoint.tiltX = pointerItem.GetTiltX(); @@ -174,8 +175,8 @@ void UpdateMouseEventForPen(const MMI::PointerEvent::PointerItem& pointerItem, M mouseEvent.screenX = pointerItem.GetDisplayXPos(); mouseEvent.screenY = pointerItem.GetDisplayYPos(); mouseEvent.originalId = mouseEvent.id; - mouseEvent.globalDisplayX = pointerItem.GetGlobalX(); - mouseEvent.globalDisplayY = pointerItem.GetGlobalY(); + mouseEvent.globalDisplayX = pointerItem.GetDisplayXPos(); + mouseEvent.globalDisplayY = pointerItem.GetDisplayYPos(); } TouchEvent ConvertTouchEventFromTouchPoint(TouchPoint touchPoint) @@ -252,8 +253,8 @@ TouchEvent ConvertTouchEvent(const std::shared_ptr& pointerEv event.y = item.GetWindowYPos(); event.screenX = item.GetDisplayXPos(); event.screenY = item.GetDisplayYPos(); - event.globalDisplayX = item.GetGlobalX(); - event.globalDisplayY = item.GetGlobalY(); + event.globalDisplayX = item.GetDisplayXPos(); + event.globalDisplayY = item.GetDisplayYPos(); } event.pressedKeyCodes_.clear(); for (const auto& curCode : pointerEvent->GetPressedKeys()) { @@ -501,8 +502,8 @@ void ConvertAxisEvent(const std::shared_ptr& pointerEvent, Ax event.y = static_cast(item.GetWindowY()); event.screenX = static_cast(item.GetDisplayX()); event.screenY = static_cast(item.GetDisplayY()); - event.globalDisplayX = static_cast(item.GetGlobalX()); - event.globalDisplayY = static_cast(item.GetGlobalY()); + event.globalDisplayX = static_cast(item.GetDisplayX()); + event.globalDisplayY = static_cast(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); @@ -790,8 +791,8 @@ void ConvertPointerEvent(const std::shared_ptr& pointerEvent, event.displayX = pointerItem.GetDisplayX(); event.displayY = pointerItem.GetDisplayY(); event.displayId = pointerEvent->GetTargetDisplayId(); - event.globalDisplayX = pointerItem.GetGlobalX(); - event.globalDisplayY = pointerItem.GetGlobalY(); + event.globalDisplayX = pointerItem.GetDisplayX(); + event.globalDisplayY = pointerItem.GetDisplayY(); event.size = std::max(pointerItem.GetWidth(), pointerItem.GetHeight()) / SIZE_DIVIDE; event.force = static_cast(pointerItem.GetPressure()); event.deviceId = pointerItem.GetDeviceId(); 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 e3406cc86d2..e7cb4969e46 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 @@ -10139,7 +10139,6 @@ Local CommonBridge::CreateAxisEventInfo(EcmaVM* vm, AxisInfo& 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, globalDisplayOffset.GetX() / density), panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); 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 00b6a259908..ccc311bafbc 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 @@ -226,8 +226,7 @@ Local FrameNodeBridge::CreateTouchInfo( const char* keys[] = { "type", "id", "displayX", "displayY", "windowX", "windowY", "screenX", "screenY", "x", "y", "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, touchInfo.GetFingerId()), panda::NumberRef::New(vm, screenOffset.GetX() / density), panda::NumberRef::New(vm, screenOffset.GetY() / density), panda::NumberRef::New(vm, globalOffset.GetX() / density), panda::NumberRef::New(vm, globalOffset.GetY() / density), @@ -1081,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)))); @@ -1192,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/core/event/touch_event.cpp b/frameworks/core/event/touch_event.cpp index e59c82813c5..08ffb3e0d85 100644 --- a/frameworks/core/event/touch_event.cpp +++ b/frameworks/core/event/touch_event.cpp @@ -435,8 +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 / scale; - point.globalDisplayY = point.globalDisplayY / scale; + point.globalDisplayX = (point.globalDisplayX - offsetX) / scale; + point.globalDisplayY = (point.globalDisplayY - offsetY) / scale; }); return CloneWith(scale, offsetX, offsetY, pointId); } @@ -476,7 +476,6 @@ TouchEvent TouchEvent::UpdatePointers() const .SetIsPassThroughMode(isPassThroughMode) .SetOperatingHand(operatingHand); event.pointers.emplace_back(std::move(point)); - LOGE("TouchEvent::UpdatePointers set globalDisplayX,Y"); return event; } -- Gitee From 2568a2523e2a940c3b93b69981cc140b8460d5f6 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 13:35:40 +0800 Subject: [PATCH 05/19] =?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 --- .../engine/jsi/nativeModule/arkts_native_common_bridge.cpp | 1 + 1 file changed, 1 insertion(+) 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 e7cb4969e46..2b25286904b 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 @@ -8751,6 +8751,7 @@ Local CommonBridge::CreateHoverInfo(EcmaVM* vm, const HoverInf 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())), -- Gitee From 3f5135ae48a77876fc1393fb0f9fd3e86b815188 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 15:06:36 +0800 Subject: [PATCH 06/19] modifiy Signed-off-by: wangweiyuan --- frameworks/core/event/axis_event.cpp | 2 -- frameworks/core/event/axis_event.h | 1 + frameworks/core/event/mouse_event.cpp | 1 + frameworks/core/event/touch_event.h | 2 ++ 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frameworks/core/event/axis_event.cpp b/frameworks/core/event/axis_event.cpp index 5d81570cf8e..d7953eebc3e 100644 --- a/frameworks/core/event/axis_event.cpp +++ b/frameworks/core/event/axis_event.cpp @@ -241,13 +241,11 @@ const Offset& AxisInfo::GetGlobalLocation() const AxisInfo& AxisInfo::SetGlobalDisplayLocation(const Offset& globalDisplayLocation) { - LOGE("AxisInfo::SetGlobalDisplayLocation, globalDisplayLocation"); globalDisplayLocation_ = globalDisplayLocation; return *this; } const Offset& AxisInfo::GetGlobalDisplayLocation() const { - LOGE("Offset& AxisInfo::GetGlobalDisplayLocation."); return globalDisplayLocation_; } diff --git a/frameworks/core/event/axis_event.h b/frameworks/core/event/axis_event.h index c27de5153c7..48dea2675c9 100644 --- a/frameworks/core/event/axis_event.h +++ b/frameworks/core/event/axis_event.h @@ -110,6 +110,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); diff --git a/frameworks/core/event/mouse_event.cpp b/frameworks/core/event/mouse_event.cpp index 8b89a7595b3..23db6cb15f1 100644 --- a/frameworks/core/event/mouse_event.cpp +++ b/frameworks/core/event/mouse_event.cpp @@ -194,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); diff --git a/frameworks/core/event/touch_event.h b/frameworks/core/event/touch_event.h index 926e20d33ec..fd2ef577587 100755 --- a/frameworks/core/event/touch_event.h +++ b/frameworks/core/event/touch_event.h @@ -158,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; @@ -300,6 +301,7 @@ 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; -- Gitee From ef251d48209ab2743773cc6b510805a2ce61ae9e Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 15:41:10 +0800 Subject: [PATCH 07/19] modifiy Signed-off-by: wangweiyuan --- frameworks/core/event/axis_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/core/event/axis_event.h b/frameworks/core/event/axis_event.h index 48dea2675c9..ac680b247e0 100644 --- a/frameworks/core/event/axis_event.h +++ b/frameworks/core/event/axis_event.h @@ -110,7 +110,7 @@ struct AxisEvent final : public PointerEvent { AxisEvent CreateScaleEvent(float scale) const; Offset GetOffset() const; Offset GetScreenOffset() const; - Offset GetGlobalDisplayOffset() const + Offset GetGlobalDisplayOffset() const; int32_t GetTargetDisplayId() const; AxisDirection GetDirection() const; static bool IsDirectionUp(AxisDirection direction); -- Gitee From 5b5fbcbd5ab033e7b5592a9c0184ab9e301178d2 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 16:03:52 +0800 Subject: [PATCH 08/19] modifiy Signed-off-by: wangweiyuan --- frameworks/core/components_ng/event/gesture_event_hub_drag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d805dd7ad07..86030209517 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp @@ -1202,7 +1202,7 @@ 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->SetGlobalDisplayY(info.GetGlobalDisplayLocation().GetY()); event->SetPressedKeyCodes(info.GetPressedKeyCodes()); eventHub->FireCustomerOnDragFunc(DragFuncType::DRAG_DROP, event); eventHub->HandleInternalOnDrop(event, ""); -- Gitee From 013cdd6ab0bddb32bc543778f8d58de1312858e8 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sat, 31 May 2025 20:39:20 +0800 Subject: [PATCH 09/19] modifiy Signed-off-by: wangweiyuan --- frameworks/core/event/mouse_event.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frameworks/core/event/mouse_event.cpp b/frameworks/core/event/mouse_event.cpp index 23db6cb15f1..63e886da784 100644 --- a/frameworks/core/event/mouse_event.cpp +++ b/frameworks/core/event/mouse_event.cpp @@ -230,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; -- Gitee From 8b5736d83cdd0634a58394f7db40cc7fdee94a22 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 12:14:33 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E8=A1=A5=E5=85=85clickevent=E7=9A=84?= =?UTF-8?q?=E6=97=A0=E6=84=9F=E7=9B=91=E5=90=AC=E5=92=8C=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=8Cace=5Fcontainer=E4=B8=AD=E4=BB=8E?= =?UTF-8?q?=E5=A4=9A=E6=A8=A1=E6=8B=BFglobal=E6=95=B0=E6=8D=AE=E7=BB=99dra?= =?UTF-8?q?gpointerevent=E6=94=B9=E4=B8=BA=E6=8B=BFdisplay=E5=9D=90?= =?UTF-8?q?=E6=A0=87=E5=85=88=E7=94=A8=E4=BA=8E=E9=AA=8C=E8=AF=81?= 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 | 8 ++++---- .../jsview/js_location_button.cpp | 3 +++ .../declarative_frontend/jsview/js_paste_button.cpp | 3 +++ .../declarative_frontend/jsview/js_save_button.cpp | 3 +++ .../napi/kits/observer/ui_observer_listener.cpp | 11 +++++++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index a464d93344c..b1d5f2a94c1 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -3781,8 +3781,8 @@ bool AceContainer::GetCurPointerEventInfo(DragPointerEvent& dragPointerEvent, St dragPointerEvent.displayY = pointerItem.GetDisplayY(); dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); - dragPointerEvent.globalDisplayX = pointerItem.GetGlobalX(); - dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY(); + dragPointerEvent.globalDisplayX = pointerItem.GetDisplayX(); + dragPointerEvent.globalDisplayY = pointerItem.GetDisplayY(); dragPointerEvent.deviceId = pointerItem.GetDeviceId(); dragPointerEvent.sourceTool = static_cast(pointerItem.GetToolType()); dragPointerEvent.displayId = currentPointerEvent->GetTargetDisplayId(); @@ -3831,8 +3831,8 @@ bool AceContainer::GetLastMovingPointerPosition(DragPointerEvent& dragPointerEve dragPointerEvent.displayY = pointerItem.GetDisplayY(); dragPointerEvent.windowX = pointerItem.GetWindowX(); dragPointerEvent.windowY = pointerItem.GetWindowY(); - dragPointerEvent.globalDisplayX = pointerItem.GetGlobalX(); - dragPointerEvent.globalDisplayY = pointerItem.GetGlobalY(); + dragPointerEvent.globalDisplayX = pointerItem.GetDisplayX(); + dragPointerEvent.globalDisplayY = pointerItem.GetDisplayY(); return true; } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp index 92112d07549..44ac798d7a1 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp @@ -100,10 +100,13 @@ 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 fcf1353486f..156ea38ddf7 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_paste_button.cpp @@ -99,10 +99,13 @@ 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 2df5397d334..0b5246ce73e 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_save_button.cpp @@ -104,10 +104,13 @@ 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/interfaces/napi/kits/observer/ui_observer_listener.cpp b/interfaces/napi/kits/observer/ui_observer_listener.cpp index 190aaeb18fd..3390ae42474 100644 --- a/interfaces/napi/kits/observer/ui_observer_listener.cpp +++ b/interfaces/napi/kits/observer/ui_observer_listener.cpp @@ -1299,6 +1299,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); @@ -1319,6 +1320,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); } -- Gitee From 7a550362261df5f3782e743858c70a31ede7904a Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 14:12:53 +0800 Subject: [PATCH 11/19] modify Signed-off-by: wangweiyuan --- adapter/preview/entrance/event_dispatcher.cpp | 6 ++++ .../interfaces/cj_ffi/cj_common_ffi.h | 2 ++ .../pattern/model/model_touch_handler.cpp | 2 ++ .../ace_kit/include/ui/base/geometry/point.h | 28 +++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/adapter/preview/entrance/event_dispatcher.cpp b/adapter/preview/entrance/event_dispatcher.cpp index 1273da7a64c..925a7042445 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->globalX; + event.globalDisplayY = pointerEvent->globalY; 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->screenX; + mouseEvent.globalDisplayY = pointerEvent->screenY; GetMouseEventAction(pointerEvent->pointerAction_, mouseEvent); GetMouseEventButton(pointerEvent->buttonId_, mouseEvent); mouseEvent.sourceType = SourceType::MOUSE; 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/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/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..5f3cf0a0f72 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,12 @@ 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 +81,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 +149,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; }; -- Gitee From 0916cc68228738499f4ccc3e24b1a856adaca6af Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 16:09:56 +0800 Subject: [PATCH 12/19] modify Signed-off-by: wangweiyuan --- frameworks/core/components_ng/base/frame_node.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/core/components_ng/base/frame_node.cpp b/frameworks/core/components_ng/base/frame_node.cpp index 7c9205b9c52..89735c418a3 100644 --- a/frameworks/core/components_ng/base/frame_node.cpp +++ b/frameworks/core/components_ng/base/frame_node.cpp @@ -5624,6 +5624,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); -- Gitee From c9faed9119686c7084f4fa875077565b41529d55 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 17:55:20 +0800 Subject: [PATCH 13/19] modify Signed-off-by: wangweiyuan --- adapter/ohos/entrance/mmi_event_convertor.cpp | 6 ++++++ .../preview/external/multimodalinput/pointer_event.h | 4 ++++ .../declarative_frontend/jsview/js_base_node.cpp | 2 ++ .../core/components_ng/event/drag_drop_event.cpp | 2 ++ frameworks/core/components_ng/event/drag_event.cpp | 6 ++++-- .../manager/drag_drop/drag_drop_manager.cpp | 6 ++++-- .../manager/drag_drop/drag_drop_proxy.cpp | 11 +++++++---- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index 9078556dc12..d28c5bc73a8 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -379,6 +379,8 @@ void ConvertMouseEvent( events.y = item.GetWindowY(); events.screenX = item.GetDisplayX(); events.screenY = item.GetDisplayY(); + events.globalDisplayX = item.GetDisplayX(); + events.globalDisplayY = item.GetDisplayY(); events.rawDeltaX = item.GetRawDx(); events.rawDeltaY = item.GetRawDy(); GetMouseEventAction(pointerEvent->GetPointerAction(), events, isSceneBoardWindow); @@ -576,6 +578,8 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptrGetAxisValue(OHOS::MMI::PointerEvent::AxisType::AXIS_TYPE_SCROLL_HORIZONTAL); @@ -590,6 +594,8 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptrGetPropertyValue("windowY", 0.0f); point.screenX = itemObj->GetPropertyValue("displayX", 0.0f); point.screenY = itemObj->GetPropertyValue("displayY", 0.0f); + point.globalDisplayX = itemObj->GetPropertyValue("globalDisplayX", 0.0f); + point.globalDisplayY = itemObj->GetPropertyValue("globalDisplayY", 0.0f); point.originalId = itemObj->GetPropertyValue("id", 0); point.force = itemObj->GetPropertyValue("pressure", 0); auto pressedTimeJsVal = itemObj->GetProperty("pressedTime"); diff --git a/frameworks/core/components_ng/event/drag_drop_event.cpp b/frameworks/core/components_ng/event/drag_drop_event.cpp index dfe1d5fff06..529b5a48066 100644 --- a/frameworks/core/components_ng/event/drag_drop_event.cpp +++ b/frameworks/core/components_ng/event/drag_drop_event.cpp @@ -266,6 +266,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 304d7f3b653..67eec1d9f52 100644 --- a/frameworks/core/components_ng/event/drag_event.cpp +++ b/frameworks/core/components_ng/event/drag_event.cpp @@ -2013,14 +2013,16 @@ void DragEventActuator::HandleTouchEvent(const TouchEventInfo& info, bool isRest 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()); + 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/manager/drag_drop/drag_drop_manager.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp index 9cd539014ae..7d0c17e5f82 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 @@ -2464,11 +2464,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, 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..c68479d1c0f 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 @@ -61,9 +61,10 @@ 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 +85,8 @@ void DragDropProxy::OnDragMove(const GestureEvent& info) std::string extraInfo = manager->GetExtraInfo(); manager->OnDragMove(DragPointerEvent(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY(), - info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY()), extraInfo); + info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY(), + info.GetGlobalDisplayLocation().GetX(), info.GetGlobalDisplayLocation().GetY()), extraInfo); } void DragDropProxy::OnDragEnd(const GestureEvent& info, bool isTextDragEnd) @@ -100,7 +102,8 @@ void DragDropProxy::OnDragEnd(const GestureEvent& info, bool isTextDragEnd) static_cast(info.GetGlobalPoint().GetY()), extraInfo); } else { manager->OnDragEnd(DragPointerEvent(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY(), - info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY()), extraInfo); + info.GetScreenLocation().GetX(), info.GetScreenLocation().GetY(), + info.GetGlobalDisplayLocation().GetX(), info.GetGlobalDisplayLocation().GetY()), extraInfo); } } -- Gitee From a793a2aea477094a5b1960bddad32c26e73e07bc Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 18:26:01 +0800 Subject: [PATCH 14/19] modify Signed-off-by: wangweiyuan --- adapter/preview/entrance/event_dispatcher.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adapter/preview/entrance/event_dispatcher.cpp b/adapter/preview/entrance/event_dispatcher.cpp index 925a7042445..cec8f0b2dc9 100644 --- a/adapter/preview/entrance/event_dispatcher.cpp +++ b/adapter/preview/entrance/event_dispatcher.cpp @@ -76,8 +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->globalX; - event.globalDisplayY = pointerEvent->globalY; + 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; @@ -252,8 +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->screenX; - mouseEvent.globalDisplayY = pointerEvent->screenY; + mouseEvent.globalDisplayX = pointerEvent->globalDisplayX; + mouseEvent.globalDisplayY = pointerEvent->globalDisplayY; GetMouseEventAction(pointerEvent->pointerAction_, mouseEvent); GetMouseEventButton(pointerEvent->buttonId_, mouseEvent); mouseEvent.sourceType = SourceType::MOUSE; -- Gitee From a9e83b966233cfd0f939a62c23aeb50e6840171d Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 18:48:42 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E5=90=88=E5=85=A5capi=E4=BE=A7=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E4=BA=8B=E4=BB=B6pr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- .../core/interfaces/arkoala/arkoala_api.h | 4 + .../native/node/node_common_modifier.cpp | 28 ++ .../native/node/node_gesture_modifier.cpp | 8 + interfaces/native/event/ui_input_event.cpp | 258 ++++++++++++++++++ interfaces/native/ui_input_event.h | 10 + 5 files changed, 308 insertions(+) diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index b70b4d51425..7eaad07be4d 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -214,6 +214,8 @@ struct ArkUITouchPoint { ArkUI_Float32 screenY; ArkUI_Float32 windowX; ArkUI_Float32 windowY; + ArkUI_Float32 globalDisplayX; + ArkUI_Float32 globalDisplayY; ArkUI_Float32 nodeX; ArkUI_Float32 nodeY; ArkUI_Float64 pressure; @@ -1397,6 +1399,8 @@ struct ArkUIClickEvent { ArkUI_Float32 windowY; ArkUI_Float32 displayX; ArkUI_Float32 displayY; + ArkUI_Float32 globalDisplayX; + ArkUI_Float32 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 50ee32af74c..2dda1e6a75d 100644 --- a/frameworks/core/interfaces/native/node/node_common_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_common_modifier.cpp @@ -7058,6 +7058,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); @@ -7070,6 +7072,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); @@ -7091,6 +7095,8 @@ 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++) { @@ -7101,6 +7107,8 @@ 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 = @@ -8494,6 +8502,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); @@ -8509,6 +8518,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); } @@ -8770,6 +8783,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; @@ -8778,6 +8792,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(); @@ -8814,6 +8830,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; @@ -8931,6 +8951,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); @@ -9108,6 +9130,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.rollAngle = info.GetRollAngle().value_or(0.0f); event.touchEvent.deviceId = info.GetDeviceId(); event.apiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion() % API_TARGET_VERSION_MASK; @@ -9171,6 +9195,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(); @@ -9238,6 +9264,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_gesture_modifier.cpp b/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp index 2ee6fccbe5b..295746750fe 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; } @@ -451,6 +455,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(); } @@ -487,6 +493,8 @@ 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/native/event/ui_input_event.cpp b/interfaces/native/event/ui_input_event.cpp index 8d8d2a7f4f3..9cf4af45255 100644 --- a/interfaces/native/event/ui_input_event.cpp +++ b/interfaces/native/event/ui_input_event.cpp @@ -1314,6 +1314,224 @@ float OH_ArkUI_PointerEvent_GetDisplayYByIndex(const ArkUI_UIInputEvent* event, return 0.0f; } +float HandleCTouchEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (!touchEvent) { + return 0.0f; + } + return touchEvent->actionTouchPoint.globalDisplayX; +} + +float HandleCClickEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* clickEvent = reinterpret_cast(event->inputEvent); + if (!clickEvent) { + return 0.0f; + } + return clickEvent->globalDisplayX; +} + +float HandleCMouseEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.globalDisplayX; +} + +float HandleCAxisEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent) { + return 0.0f; + } + return axisEvent->actionTouchPoint.globalDisplayX; +} + +float HandleTouchEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (touchEvent) { + return touchEvent->globalDisplayX; + } + return 0.0f; +} + +float HandleAxisEventGlobalDisplayX(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (axisEvent) { + return 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 touchEvent->touchPointes[pointerIndex].globalDisplayX; + } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent || pointerIndex != 0) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.globalDisplayX; + } + case C_AXIS_EVENT_ID: { + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent || pointerIndex != 0) { + return 0.0f; + } + return 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 touchEvent->actionTouchPoint.globalDisplayY; +} + +float HandleCClickEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* clickEvent = reinterpret_cast(event->inputEvent); + if (!clickEvent) { + return 0.0f; + } + return clickEvent->globalDisplayY; +} + +float HandleCMouseEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.globalDisplayY; +} + +float HandleCAxisEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent) { + return 0.0f; + } + return axisEvent->actionTouchPoint.globalDisplayY; +} + +float HandleTouchEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* touchEvent = reinterpret_cast(event->inputEvent); + if (touchEvent) { + return touchEvent->globalDisplayY; + } + return 0.0f; +} + +float HandleAxisEventGlobalDisplayY(const ArkUI_UIInputEvent* event) +{ + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (axisEvent) { + return 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 touchEvent->touchPointes[pointerIndex].globalDisplayY; + } + case C_MOUSE_EVENT_ID: { + const auto* mouseEvent = reinterpret_cast(event->inputEvent); + if (!mouseEvent || pointerIndex != 0) { + return 0.0f; + } + return mouseEvent->actionTouchPoint.globalDisplayY; + } + case C_AXIS_EVENT_ID: { + const auto* axisEvent = reinterpret_cast(event->inputEvent); + if (!axisEvent || pointerIndex != 0) { + return 0.0f; + } + return axisEvent->actionTouchPoint.globalDisplayY; + } + default: + break; + } + return 0.0f; +} + float OH_ArkUI_PointerEvent_GetPressure(const ArkUI_UIInputEvent* event, uint32_t pointerIndex) { if (!event) { @@ -1751,6 +1969,46 @@ float OH_ArkUI_PointerEvent_GetHistoryDisplayY( return 0.0f; } +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 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 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/ui_input_event.h b/interfaces/native/ui_input_event.h index aa0c30c76f1..315d0b9c758 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_GetHistoryGllobalDisplayY( + 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).. -- Gitee From 7f66c746cd026b6eb39cf5e603a1c292016a678b Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 19:05:49 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=89=8B=E5=8A=BF?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6js=E3=80=81=E6=97=A0=E6=84=9F=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E3=80=81modifier=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- .../engine/functions/js_gesture_function.cpp | 3 +++ .../arkts_native_common_bridge.cpp | 18 +++++++++++++++--- .../recognizers/multi_fingers_recognizer.cpp | 2 +- frameworks/core/gestures/gesture_info.h | 1 + .../core/gestures/multi_fingers_recognizer.cpp | 2 +- .../kits/observer/ui_observer_listener.cpp | 10 ++++++++++ 6 files changed, 31 insertions(+), 5 deletions(-) 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..b1621a64525 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,8 @@ 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/jsi/nativeModule/arkts_native_common_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_common_bridge.cpp index 2b25286904b..e10b527e3f7 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 @@ -7378,7 +7378,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())), @@ -7386,6 +7388,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); } @@ -7469,8 +7473,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), @@ -7478,6 +7484,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); } @@ -9051,8 +9059,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())), @@ -9061,6 +9071,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); } 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..3afc8c615ee 100644 --- a/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp +++ b/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp @@ -73,7 +73,7 @@ void MultiFingersRecognizer::UpdateFingerListInfo() 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.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/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/multi_fingers_recognizer.cpp b/frameworks/core/gestures/multi_fingers_recognizer.cpp index 61b04afd8e5..51bcbc35c6a 100644 --- a/frameworks/core/gestures/multi_fingers_recognizer.cpp +++ b/frameworks/core/gestures/multi_fingers_recognizer.cpp @@ -78,7 +78,7 @@ void MultiFingersRecognizer::SetFingerList(const std::map 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/interfaces/napi/kits/observer/ui_observer_listener.cpp b/interfaces/napi/kits/observer/ui_observer_listener.cpp index 3390ae42474..2e09393a722 100644 --- a/interfaces/napi/kits/observer/ui_observer_listener.cpp +++ b/interfaces/napi/kits/observer/ui_observer_listener.cpp @@ -1089,6 +1089,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); -- Gitee From a89277cfbb9718cab9209c523afcabd975ae89e8 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 20:34:18 +0800 Subject: [PATCH 17/19] modify Signed-off-by: wangweiyuan --- adapter/preview/entrance/event_dispatcher.cpp | 6 ------ adapter/preview/external/multimodalinput/pointer_event.h | 4 ---- .../bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h | 2 -- .../bridge/declarative_frontend/jsview/js_base_node.cpp | 2 -- .../components_ng/pattern/model/model_touch_handler.cpp | 2 -- 5 files changed, 16 deletions(-) diff --git a/adapter/preview/entrance/event_dispatcher.cpp b/adapter/preview/entrance/event_dispatcher.cpp index cec8f0b2dc9..1273da7a64c 100644 --- a/adapter/preview/entrance/event_dispatcher.cpp +++ b/adapter/preview/entrance/event_dispatcher.cpp @@ -76,8 +76,6 @@ 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; @@ -94,8 +92,6 @@ 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, @@ -252,8 +248,6 @@ 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 baba0f05a88..9dd88541cea 100644 --- a/adapter/preview/external/multimodalinput/pointer_event.h +++ b/adapter/preview/external/multimodalinput/pointer_event.h @@ -48,8 +48,6 @@ struct TouchPoint final { float y = 0.0f; float screenX = 0.0f; float screenY = 0.0f; - float globalDisplayX = 0.0f; - float globalDisplayY = 0.0f; TimeStamp downTime; double size = 0.0; float force = 0.0f; @@ -70,8 +68,6 @@ public: float y = 0.0f; float screenX = 0.0f; float screenY = 0.0f; - float globalDisplayX = 0.0f; - float globalDisplayY = 0.0f; TouchType type = TouchType::UNKNOWN; TouchType pullType = TouchType::UNKNOWN; TimeStamp time; 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 8d94738ebda..2745cf03dd1 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,8 +249,6 @@ struct CJClickInfo { double windowY; double displayX; double displayY; - double globalDisplayX; - double globalDisplayY; std::string ToString() const; }; diff --git a/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp b/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp index 5f37e318d31..fdc361372a1 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp @@ -432,8 +432,6 @@ bool JSBaseNode::GetInputTouches(const JSCallbackInfo& info, TouchEvent& touchEv point.y = itemObj->GetPropertyValue("windowY", 0.0f); point.screenX = itemObj->GetPropertyValue("displayX", 0.0f); point.screenY = itemObj->GetPropertyValue("displayY", 0.0f); - point.globalDisplayX = itemObj->GetPropertyValue("globalDisplayX", 0.0f); - point.globalDisplayY = itemObj->GetPropertyValue("globalDisplayY", 0.0f); point.originalId = itemObj->GetPropertyValue("id", 0); point.force = itemObj->GetPropertyValue("pressure", 0); auto pressedTimeJsVal = itemObj->GetProperty("pressedTime"); 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 52041289047..7beaca09b36 100644 --- a/frameworks/core/components_ng/pattern/model/model_touch_handler.cpp +++ b/frameworks/core/components_ng/pattern/model/model_touch_handler.cpp @@ -70,8 +70,6 @@ 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()); } -- Gitee From f80b8c372f125eb611a3406bff749d78a4c90478 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 21:27:54 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E8=A1=A5=E5=85=85DragPointerEvent?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E5=87=BD=E6=95=B0=E4=BB=A5=E5=8F=8A=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=9E=84=E9=80=A0=E5=87=BD=E6=95=B0=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E6=96=B9=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=A2=9E=E7=9A=84=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangweiyuan --- .../manager/drag_drop/drag_drop_manager.cpp | 4 +++- .../components_ng/manager/drag_drop/drag_drop_proxy.cpp | 2 +- frameworks/core/event/pointer_event.h | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp index 7d0c17e5f82..ad039df6e56 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 @@ -2067,6 +2067,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()); @@ -3259,7 +3261,7 @@ void DragDropManager::HandleTouchEvent(const TouchEvent& event) if (!IsDragging() || !IsSameDraggingPointer(event.id)) { return; } - auto pointerEvent = DragPointerEvent(event.x, event.y, event.screenX, event.screenY); + auto pointerEvent = DragPointerEvent(event.x, event.y, event.screenX, event.screenY, event.globalDisplayX, event.globalDisplayX); SetDragAnimationPointerEvent(pointerEvent); } else if ((event.type == TouchType::UP) || (event.type == TouchType::CANCEL)) { ResetDraggingStatus(event); diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp index c68479d1c0f..0e68a0ea4eb 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); } diff --git a/frameworks/core/event/pointer_event.h b/frameworks/core/event/pointer_event.h index 8e6dd01baea..591feb2871c 100644 --- a/frameworks/core/event/pointer_event.h +++ b/frameworks/core/event/pointer_event.h @@ -92,7 +92,14 @@ 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 { if (!x && !y) { -- Gitee From 8ba222c4578fe887934f38fe6149410ac51be584 Mon Sep 17 00:00:00 2001 From: wangweiyuan Date: Sun, 1 Jun 2025 23:18:48 +0800 Subject: [PATCH 19/19] modify fingers make error Signed-off-by: wangweiyuan --- frameworks/core/common/event_manager.cpp | 4 ++-- frameworks/core/gestures/multi_fingers_recognizer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/core/common/event_manager.cpp b/frameworks/core/common/event_manager.cpp index 15e78e39b22..3ab543837cd 100644 --- a/frameworks/core/common/event_manager.cpp +++ b/frameworks/core/common/event_manager.cpp @@ -441,8 +441,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); diff --git a/frameworks/core/gestures/multi_fingers_recognizer.cpp b/frameworks/core/gestures/multi_fingers_recognizer.cpp index 51bcbc35c6a..b54c2f5a947 100644 --- a/frameworks/core/gestures/multi_fingers_recognizer.cpp +++ b/frameworks/core/gestures/multi_fingers_recognizer.cpp @@ -78,7 +78,7 @@ void MultiFingersRecognizer::SetFingerList(const std::map t for (auto& point : touchPoints) { Offset localLocation = point.second.GetOffset() - coordinateOffset; FingerInfo fingerInfo = { point.first, point.second.operatingHand, point.second.GetOffset(), - localLocation, {}, point.second.getGlobalDisplayOffset() }; + localLocation, {}, point.second.GetGlobalDisplayOffset() }; fingerList.emplace_back(fingerInfo); } } -- Gitee