diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 242381cd11808be9e20ca1e02815ee8edf789f82..b1d5f2a94c1b3c6ce1e6550633723037aee94528 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.GetDisplayX(); + dragPointerEvent.globalDisplayY = pointerItem.GetDisplayY(); 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.GetDisplayX(); + dragPointerEvent.globalDisplayY = pointerItem.GetDisplayY(); return true; } diff --git a/adapter/ohos/entrance/mmi_event_convertor.cpp b/adapter/ohos/entrance/mmi_event_convertor.cpp index 5fac041735d1c3f5b854d35ca31002b62ef386de..d28c5bc73a8b6f50fe36175dd6018600a1f5786e 100644 --- a/adapter/ohos/entrance/mmi_event_convertor.cpp +++ b/adapter/ohos/entrance/mmi_event_convertor.cpp @@ -80,6 +80,9 @@ TouchPoint ConvertTouchPoint(const MMI::PointerEvent::PointerItem& pointerItem) touchPoint.y = pointerItem.GetWindowY(); touchPoint.screenX = pointerItem.GetDisplayX(); touchPoint.screenY = pointerItem.GetDisplayY(); + // 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(); @@ -172,6 +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.GetDisplayXPos(); + mouseEvent.globalDisplayY = pointerItem.GetDisplayYPos(); } TouchEvent ConvertTouchEventFromTouchPoint(TouchPoint touchPoint) @@ -182,6 +187,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 +253,8 @@ TouchEvent ConvertTouchEvent(const std::shared_ptr& pointerEv event.y = item.GetWindowYPos(); event.screenX = item.GetDisplayXPos(); event.screenY = item.GetDisplayYPos(); + event.globalDisplayX = item.GetDisplayXPos(); + event.globalDisplayY = item.GetDisplayYPos(); } event.pressedKeyCodes_.clear(); for (const auto& curCode : pointerEvent->GetPressedKeys()) { @@ -370,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); @@ -493,6 +504,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.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); @@ -565,6 +578,8 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptrGetAxisValue(OHOS::MMI::PointerEvent::AxisType::AXIS_TYPE_SCROLL_HORIZONTAL); @@ -579,6 +594,8 @@ static void ConvertAxisEventToTouchPoint(const std::shared_ptr& pointerEvent, event.displayX = pointerItem.GetDisplayX(); event.displayY = pointerItem.GetDisplayY(); event.displayId = pointerEvent->GetTargetDisplayId(); + 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/functions/js_click_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_click_function.cpp index 4d0724caa1d6f28c26864b397385738825b752f2..73b0b27298a3e3f498eb9d5495c113663134e631 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 2705e43c5e65129226d4592dd82dc4e98946d128..04a4385c1d90c22248684ffdaaf12efafff90a2c 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 2693fede315e456dd88252b27c33496901814bc8..2dd55561fb1e096d107f552a95adbbb8ade31b71 100644 --- a/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h +++ b/frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h @@ -54,6 +54,8 @@ public: void GetJsPasteData(const JSCallbackInfo& args); void GetScreenX(const JSCallbackInfo& args); void GetScreenY(const JSCallbackInfo& args); + void GetGlobalDisplayX(const JSCallbackInfo& args); + void GetGlobalDisplayY(const JSCallbackInfo& args); void GetDisplayId(const JSCallbackInfo& args); void GetX(const JSCallbackInfo& args); void GetY(const JSCallbackInfo& args); diff --git a/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_gesture_function.cpp index 4e6b827827cbdc0cbac71809b1deb7bfd7144c70..b1621a64525d516e3e3fcbd606751776efe8f95d 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/functions/js_hover_function.cpp b/frameworks/bridge/declarative_frontend/engine/functions/js_hover_function.cpp index 75edd2eba6a1eb08afa1d65bf657f7387455b8af..f9b54737965d8713d4d3cea8b1e56d20c9a3db18 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 6a0ad7211532eac47ea32365757a7086186a7fef..52ecc8799f318691b680b00ac84cc241eb126f72 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 c14d8791f3ec3b35eaf078bd65857c6c5bd241ba..7e0de289cbd6321a5f967c29275acf85fbd29b46 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 ad8c55770be61e3f53531c5c3d56082b52851709..e10b527e3f74d209d831b2853ba1a326ac989fff 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); } @@ -8751,6 +8759,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())), @@ -8762,7 +8771,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); } @@ -9048,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())), @@ -9058,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); } @@ -10111,9 +10126,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 +10151,9 @@ 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, 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 57f6d4441148ef5b66e79c7beea5f3558f630f58..ccc311bafbc1f1645d9cb0995113b4162ce4950b 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_frame_node_bridge.cpp @@ -222,8 +222,9 @@ Local FrameNodeBridge::CreateTouchInfo( const Offset& globalOffset = touchInfo.GetGlobalLocation(); const Offset& localOffset = touchInfo.GetLocalLocation(); const Offset& screenOffset = touchInfo.GetScreenLocation(); + const Offset& globalDisplayOffset = touchInfo.GetGlobalDisplayLocation(); const char* keys[] = { "type", "id", "displayX", "displayY", "windowX", "windowY", "screenX", "screenY", "x", "y", - "pressedTime", "pressure", "width", "height", "hand" }; + "pressedTime", "pressure", "width", "height", "hand" ,"globalDisplayX", "globalDisplayY"}; Local values[] = { panda::NumberRef::New(vm, static_cast(touchInfo.GetTouchType())), panda::NumberRef::New(vm, touchInfo.GetFingerId()), panda::NumberRef::New(vm, screenOffset.GetX() / density), panda::NumberRef::New(vm, screenOffset.GetY() / density), @@ -237,7 +238,9 @@ Local FrameNodeBridge::CreateTouchInfo( panda::NumberRef::New(vm, touchInfo.GetForce()), panda::NumberRef::New(vm, touchInfo.GetWidth() / density), panda::NumberRef::New(vm, touchInfo.GetHeight() / density), - panda::NumberRef::New(vm, touchInfo.GetOperatingHand()) }; + panda::NumberRef::New(vm, touchInfo.GetOperatingHand()), + panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), + panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; auto touchInfoObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); touchInfoObj->SetNativePointerFieldCount(vm, 1); touchInfoObj->SetNativePointerField(vm, 0, static_cast(&info)); @@ -691,9 +694,9 @@ Local FrameNodeBridge::CreateGestureEventInfo(EcmaVM* vm, Gest const Offset& localOffset = info.GetLocalLocation(); const Offset& screenOffset = info.GetScreenLocation(); double density = PipelineBase::GetCurrentDensity(); - + const Offset& globalDisplayOffset = info.GetGlobalDisplayLocation(); const char* keys[] = { "displayX", "displayY", "windowX", "windowY", "screenX", "screenY", "x", "y", "timestamp", - "source", "pressure", "deviceId", "hand" }; + "source", "pressure", "deviceId", "hand" , "globalDisplayX", "globalDisplayY"}; Local values[] = { panda::NumberRef::New(vm, screenOffset.GetX() / density), panda::NumberRef::New(vm, screenOffset.GetY() / density), panda::NumberRef::New(vm, globalOffset.GetX() / density), @@ -706,7 +709,9 @@ Local FrameNodeBridge::CreateGestureEventInfo(EcmaVM* vm, Gest panda::NumberRef::New(vm, static_cast(info.GetSourceDevice())), panda::NumberRef::New(vm, info.GetForce()), panda::NumberRef::New(vm, info.GetDeviceId()), - panda::NumberRef::New(vm, GetOperatingHand(info)) }; + panda::NumberRef::New(vm, GetOperatingHand(info)), + panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), + panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; auto obj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); obj->Set( vm, panda::StringRef::NewFromUtf8(vm, "targetDisplayId"), panda::NumberRef::New(vm, info.GetTargetDisplayId())); @@ -1058,11 +1063,12 @@ ArkUINativeModuleValue FrameNodeBridge::SetOnBlur(ArkUIRuntimeCallInfo* runtimeC Local FrameNodeBridge::CreateHoverInfo(EcmaVM* vm, HoverInfo& hoverInfo) { const char* keys[] = { "stopPropagation", "getModifierKeyState", "timestamp", "source", "target", "deviceId", - "displayX", "displayY", "windowX", "windowY", "x", "y", }; + "displayX", "displayY", "windowX", "windowY", "x", "y", "globalDisplayX", "globalDisplayY", }; double density = PipelineBase::GetCurrentDensity(); const Offset& globalOffset = hoverInfo.GetGlobalLocation(); const Offset& localOffset = hoverInfo.GetLocalLocation(); const Offset& screenOffset = hoverInfo.GetScreenLocation(); + const Offset& globalDisplayOffset = hoverInfo.GetGlobalDisplayLocation(); Local values[] = { panda::FunctionRef::New(vm, Framework::JsStopPropagation), panda::FunctionRef::New(vm, ArkTSUtils::JsGetModifierKeyState), panda::NumberRef::New(vm, static_cast(hoverInfo.GetTimeStamp().time_since_epoch().count())), @@ -1074,7 +1080,9 @@ Local FrameNodeBridge::CreateHoverInfo(EcmaVM* vm, HoverInfo& panda::NumberRef::New(vm, density != 0 ? globalOffset.GetX() / density : 0), panda::NumberRef::New(vm, density != 0 ? globalOffset.GetY() / density : 0), panda::NumberRef::New(vm, density != 0 ? localOffset.GetX() / density : 0), - panda::NumberRef::New(vm, density != 0 ? localOffset.GetY() / density : 0) }; + panda::NumberRef::New(vm, density != 0 ? localOffset.GetY() / density : 0), + panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetX() / density : 0), + panda::NumberRef::New(vm, density != 0 ? globalDisplayOffset.GetY() / density : 0) }; auto eventObj = panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); eventObj->Set(vm, panda::StringRef::NewFromUtf8(vm, "rollAngle"), panda::NumberRef::New(vm, static_cast(hoverInfo.GetRollAngle().value_or(0.0f)))); @@ -1163,10 +1171,11 @@ Local FrameNodeBridge::CreateMouseInfoObj(EcmaVM* vm, MouseInf const Offset& globalOffset = info.GetGlobalLocation(); const Offset& localOffset = info.GetLocalLocation(); const Offset& screenOffset = info.GetScreenLocation(); + const Offset& globalDisplayOffset = info.GetGlobalDisplayLocation(); double density = PipelineBase::GetCurrentDensity(); const char* keys[] = { "button", "action", "displayX", "displayY", "windowX", "windowY", "screenX", "screenY", "x", "y", "timestamp", "stopPropagation", "getModifierKeyState", "source", "pressure", "deviceId", "rawDeltaX", - "rawDeltaY", "targetDisplayId" }; + "rawDeltaY", "targetDisplayId", "globalDisplayX", "globalDisplayY" }; Local values[] = { panda::NumberRef::New(vm, static_cast(info.GetButton())), panda::NumberRef::New(vm, static_cast(info.GetAction())), panda::NumberRef::New(vm, screenOffset.GetX() / density), @@ -1184,7 +1193,9 @@ Local FrameNodeBridge::CreateMouseInfoObj(EcmaVM* vm, MouseInf panda::NumberRef::New(vm, info.GetForce()), panda::NumberRef::New(vm, info.GetDeviceId()), panda::NumberRef::New(vm, info.GetRawDeltaX() / density), panda::NumberRef::New(vm, info.GetRawDeltaY() / density), - panda::NumberRef::New(vm, info.GetTargetDisplayId()) }; + panda::NumberRef::New(vm, info.GetTargetDisplayId()), + panda::NumberRef::New(vm, globalDisplayOffset.GetX() / density), + panda::NumberRef::New(vm, globalDisplayOffset.GetY() / density) }; return panda::ObjectRef::NewWithNamedProperties(vm, ArraySize(keys), keys, values); } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp b/frameworks/bridge/declarative_frontend/jsview/js_base_node.cpp index daacf548f0bbe0f984099c788990d0885a301979..fdc361372a17f387d8d187474ddb4b68352af75c 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_location_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_location_button.cpp index 92112d07549deb93dacee1ddd97f5b394c1730fd..44ac798d7a1629cafefd150a1929c54b47331c45 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 fcf1353486f635354371e7c8a8b67e1684f3f69e..156ea38ddf755ab5003e2e0df28bbe16480c956a 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 2df5397d3342ce8b46cc1f7bb19ae3faa0e92e03..0b5246ce73ea92c1ab93d70b849f8230365798f3 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/frameworks/bridge/declarative_frontend/jsview/js_web.cpp b/frameworks/bridge/declarative_frontend/jsview/js_web.cpp index 45e4b1b5b3fbd6da7228fd35475ce22a42879316..2883e80bd61968fd07a5fe1b3ce8edc1d1649641 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 f4621fd45341c87071a552f54433ae2f4309546b..ede2b193b329a364015a3480a8eb8cf5c1775734 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 cecdbf37fa313916f14706b253cc8e6b8e6ffe21..3ab543837cd237ab2d7ffcf36c3e31b188b8533d 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); @@ -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 d5db2e3f558dae74871a40e0b3ef50939449d1e9..ca330c59bab4ad5d624434bc53b01d6d48a78800 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 5dc0bed26c53325559ee0cb08ded79944843a70a..b6c315a7f49b44fe9082506c88cf5e2558accc42 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 635619a640b97815d7022b7d326498e8c5a0440c..c1975435d6460ca4186c9ac0524dcf6784bd7f97 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 45058057f703164d3bed094fdaaf3169bb842627..c6211b4790ee68ccf6a86dada3d51e61ec43fec5 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 b538ffad94db5db260bc2d4cbf201f346946a906..14c9079c207e574adb60de7f9b9f3e98199e8961 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 1f11fe33c76f36ed54b84c5d4d84d6b72342dc0f..89735c418a3e53c412a8e19e4329c9b5099f475c 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); @@ -5687,6 +5688,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 +5698,7 @@ void FrameNode::AddTouchEventAllFingersInfo(TouchEventInfo& event, const TouchEv info.SetGlobalLocation(Offset(globalX, globalY)); info.SetLocalLocation(Offset(localX, localY)); info.SetScreenLocation(Offset(screenX, screenY)); + info.SetGlobalDisplayLocation(Offset(globalDisplayX, globalDisplayY)); info.SetTouchType(touchEvent.type); info.SetForce(item.force); info.SetPressedTime(item.downTime); diff --git a/frameworks/core/components_ng/event/drag_drop_event.cpp b/frameworks/core/components_ng/event/drag_drop_event.cpp index dfe1d5fff06f8429034d872e787ebfd47568c28b..529b5a480662d52af2cfbd68c2e4112635f362ab 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 304d7f3b65323ebc657ec630037807344ca56235..67eec1d9f5266d9d57bf580c8c798065d227e29a 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/event/gesture_event_hub_drag.cpp b/frameworks/core/components_ng/event/gesture_event_hub_drag.cpp index ca1126bb36013ce1aa3b08285d0483c6c6b1092f..86030209517d8848bb4ff70157fed014410dae98 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 d85242117d6dc11f8cbd2911f5cd5609fc27b3b0..74f8aabb25e61052d0a2d77e190aa9876b32bc78 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 83267fa966917480082d5991df3f9abe14c556c3..635aa7708700900c2cb3c89e679c7bed136d5e2d 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 e4e198a86616c900427cc46e9e0f7ca38573cc99..a0f120e82623e7363e9d6f29f4f2fed77a9605dc 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/multi_fingers_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp index 56b5ea4178ca0785a7ca05ef55013ba1e556a32b..3afc8c615eea8fe4a605555827fce8d8c868df45 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/components_ng/gestures/recognizers/pan_recognizer.cpp b/frameworks/core/components_ng/gestures/recognizers/pan_recognizer.cpp index 0d1641baebbee1e87e0218a0d307e0fd2756cba1..fabfd0a7d5f946d9a1ecf960c98b2702497e6d47 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 8336d9e53a7d0dfb6ddd925a1aaae28dd18b0e6b..81b06a591219e1f2de23bb4ecd46a3061e8574ea 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 d14515b7f7f17fbde2213cbc608e2d7b27cdcd7d..ad039df6e56a4e98556126a1162bbed82715c224 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()); @@ -2086,6 +2088,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)); @@ -2462,11 +2466,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, @@ -3255,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 fc48d5ab1897b63a79d608d0e0a43e7e6f6a5014..0e68a0ea4ebaabc72eff0880ab3871b13e1cec8f 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp @@ -47,7 +47,7 @@ void HandleExtraDragMoveReporting(const RefPtr& frameNode, const std: CHECK_NULL_VOID(dragDropManager); auto touchDownPoint = actuator->GetTouchDownPoint(); auto pointerEvent = DragPointerEvent(touchDownPoint.x, touchDownPoint.y, - touchDownPoint.screenX, touchDownPoint.screenY); + touchDownPoint.screenX, touchDownPoint.screenY, touchDownPoint.globalDisplayX, touchDownPoint.globalDisplayY); dragDropManager->OnDragMove(pointerEvent, extraInfo); } @@ -61,9 +61,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); } } diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index 3dc515bc4ce5f24fd43296ddbfc45dfe6dd6beaf..042163d273acbf9badd12a1c00aba3d15607abcc 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 4a3358401905613a2053e610d2eb055f62a4b687..d7953eebc3ea1745028a2c4b34962312f66438a1 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,16 @@ const Offset& AxisInfo::GetGlobalLocation() const return globalLocation_; } +AxisInfo& AxisInfo::SetGlobalDisplayLocation(const Offset& globalDisplayLocation) +{ + globalDisplayLocation_ = globalDisplayLocation; + return *this; +} +const Offset& AxisInfo::GetGlobalDisplayLocation() const +{ + return globalDisplayLocation_; +} + AxisEvent AxisInfo::ConvertToAxisEvent() const { AxisEvent axisEvent; @@ -241,6 +256,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 +327,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 e0242153bba4fcbc07bcd0970e923930e629d08b..ac680b247e0a1b845ce1b1ff0aad5353b3db42a7 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), @@ -109,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); @@ -144,6 +146,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 +167,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 c9ed7aae48818c1d436ce501118f21e0b02ea13a..63e886da7843357db4d792309add7b13b24aebd8 100644 --- a/frameworks/core/event/mouse_event.cpp +++ b/frameworks/core/event/mouse_event.cpp @@ -80,6 +80,7 @@ bool HoverEventTarget::HandlePenHoverEvent(bool isHovered, const TouchEvent& eve hoverInfo.SetLocalLocation(Offset(localX, localY)); hoverInfo.SetGlobalLocation(Offset(event.x, event.y)); hoverInfo.SetScreenLocation(Offset(event.screenX, event.screenY)); + hoverInfo.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); hoverInfo.SetTarget(GetEventTarget().value_or(EventTarget())); // onPenHoverEventCallback_ may be overwritten in its invoke so we copy it first auto onPenHoverEventCallback = onPenHoverEventCallback_; @@ -114,6 +115,7 @@ bool HoverEventTarget::HandlePenHoverMoveEvent(const TouchEvent& event) hoverInfo.SetLocalLocation(Offset(localX, localY)); hoverInfo.SetGlobalLocation(Offset(event.x, event.y)); hoverInfo.SetScreenLocation(Offset(event.screenX, event.screenY)); + hoverInfo.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); hoverInfo.SetTarget(GetEventTarget().value_or(EventTarget())); // onPenHoverMoveEventCallback_ may be overwritten in its invoke so we copy it first auto onPenHoverMoveEventCallback = onPenHoverMoveEventCallback_; @@ -140,6 +142,7 @@ void HoverEventTarget::HandleAccessibilityHoverEvent(bool isHovered, const Touch hoverInfo.SetLocalLocation(Offset(localX, localY)); hoverInfo.SetGlobalLocation(Offset(event.x, event.y)); hoverInfo.SetScreenLocation(Offset(event.screenX, event.screenY)); + hoverInfo.SetGlobalDisplayLocation(Offset(event.globalDisplayX, event.globalDisplayY)); hoverInfo.SetActionType(ConvertAccessibilityHoverAction(event.type)); hoverInfo.SetTarget(GetEventTarget().value_or(EventTarget())); // onAccessibilityHoverCallback_ may be overwritten in its invoke so we copy it first @@ -191,6 +194,7 @@ bool MouseEventTarget::HandleMouseEvent(const MouseEvent& event) auto localY = static_cast(localPoint.GetY()); info.SetLocalLocation(Offset(localX, localY)); info.SetScreenLocation(event.GetScreenOffset()); + info.SetGlobalDisplayLocation(event.GetGlobalDisplayOffset()); info.SetTimeStamp(event.time); info.SetDeviceId(event.deviceId); info.SetTargetDisplayId(event.targetDisplayId); @@ -226,6 +230,8 @@ MouseEvent MouseEvent::operator-(const Offset& offset) const mouseEvent.scrollZ = scrollZ; mouseEvent.screenX = screenX - offset.GetX(); mouseEvent.screenY = screenY - offset.GetY(); + mouseEvent.globalDisplayX = globalDisplayX - offset.GetX(); + mouseEvent.globalDisplayY = globalDisplayY - offset.GetY(); mouseEvent.action = action; mouseEvent.button = button; mouseEvent.pressedButtons = pressedButtons; diff --git a/frameworks/core/event/mouse_event.h b/frameworks/core/event/mouse_event.h index bc304488a7a2dec8aad6d5f27a0b50cceda1dea7..c69436ecb6f75ccc0706ab7b9f2258c65ae0c4d9 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_; @@ -444,6 +479,7 @@ private: Offset localLocation_; Offset screenLocation_; + Offset globalDisplayLocation_; MouseAction mouseAction_ = MouseAction::NONE; }; @@ -471,6 +507,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 +552,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 490c1719e4459eb0543feeed2f0e197bda7d5c5a..591feb2871cb8f2f24b0796d91dcf070cde96686 100644 --- a/frameworks/core/event/pointer_event.h +++ b/frameworks/core/event/pointer_event.h @@ -66,6 +66,8 @@ struct DragPointerEvent final : public PointerEvent { int32_t windowY = 0; int32_t displayX = 0; int32_t displayY = 0; + double globalDisplayX = 0.0; + double globalDisplayY = 0.0; double size = 0.0; float force = 0.0f; int32_t deviceId = 0; @@ -90,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) { @@ -110,6 +119,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 0f2b9b8153c2248ee0f49402bcffbaa596bb4832..08ffb3e0d85ca5293007d3ea1e4041f7bf936afb 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 - offsetX) / scale; + point.globalDisplayY = (point.globalDisplayY - offsetY) / scale; }); return CloneWith(scale, offsetX, offsetY, pointId); } @@ -423,6 +448,8 @@ TouchEvent TouchEvent::UpdatePointers() const .y = y, .screenX = screenX, .screenY = screenY, + .globalDisplayX = globalDisplayX, + .globalDisplayY = globalDisplayY, .downTime = time, .size = size, .force = force, @@ -434,6 +461,8 @@ TouchEvent TouchEvent::UpdatePointers() const .SetY(y) .SetScreenX(screenX) .SetScreenY(screenY) + .SetGlobalDisplayX(globalDisplayX) + .SetGlobalDisplayY(globalDisplayY) .SetType(type) .SetTime(time) .SetSize(size) @@ -481,6 +510,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 +588,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 +949,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 d1a5e3ea6f8ec479357917a8ea2ab992a697e451..fd2ef5775873c0d13d823bf73dbf4d2529107923 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); @@ -154,6 +158,7 @@ struct TouchEvent final : public PointerEvent { void FromJson(const std::unique_ptr& json); Offset GetOffset() const; Offset GetScreenOffset() const; + Offset GetGlobalDisplayOffset() const; int32_t GetTargetDisplayId() const; void CovertId(); int32_t GetOriginalReCovertId() const; @@ -208,6 +213,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 +227,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 +253,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 +301,8 @@ private: // current node which has the recognizer. Offset localLocation_; Offset screenLocation_; + // The location where the touch point touches the screen when there are multiple screens + Offset globalDisplayLocation_; // finger touch size double size_ = 0.0; // input device id diff --git a/frameworks/core/gestures/drag_event.h b/frameworks/core/gestures/drag_event.h index 303308c38674c0e904d230b5579bc1feb9239223..a7ad9373f5ec33f213e4a75522c3b50eede78ca1 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 cb6b9205623af8ee7b8ce509396b77d4b204a3f6..154dd290fb1dd1d0e1c867069ede8ec3fdee2a4a 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/gesture_info.h b/frameworks/core/gestures/gesture_info.h index 57529981eb10c68d59b9f2eb4bc422aec65a35c9..982c51dc7caa4eb32445b2e6c553127b857c137b 100644 --- a/frameworks/core/gestures/gesture_info.h +++ b/frameworks/core/gestures/gesture_info.h @@ -274,6 +274,7 @@ struct FingerInfo { //screen position at which the touch point contacts the screen. Offset screenLocation_; + Offset globalDisplayLocation_; SourceType sourceType_ = SourceType::NONE; SourceTool sourceTool_ = SourceTool::UNKNOWN; }; diff --git a/frameworks/core/gestures/long_press_recognizer.cpp b/frameworks/core/gestures/long_press_recognizer.cpp index 14c253a47288cf40d906302179b4bf56a284f20e..45303e1eed8680664230cf5269f9b518b463f246 100644 --- a/frameworks/core/gestures/long_press_recognizer.cpp +++ b/frameworks/core/gestures/long_press_recognizer.cpp @@ -31,6 +31,7 @@ void LongPressRecognizer::OnAccepted() LongPressInfo info(trackPoint.id); info.SetTimeStamp(time_); info.SetScreenLocation(trackPoint.GetScreenOffset()); + info.SetGlobalDisplayLocation(trackPoint.GetGlobalDisplayOffset()); info.SetGlobalLocation(trackPoint.GetOffset()).SetLocalLocation(trackPoint.GetOffset() - coordinateOffset_); info.SetTarget(GetEventTarget().value_or(EventTarget())); onLongPress_(info); @@ -244,6 +245,7 @@ void LongPressRecognizer::SendCallbackMsg(const std::unique_ptr t for (auto& point : touchPoints) { Offset localLocation = point.second.GetOffset() - coordinateOffset; FingerInfo fingerInfo = { point.first, point.second.operatingHand, point.second.GetOffset(), - localLocation, {} }; + localLocation, {}, point.second.GetGlobalDisplayOffset() }; fingerList.emplace_back(fingerInfo); } } diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index 33882acc74f6823d541e70a9fe6885957fdec203..7eaad07be4d9644e9e17aac50e2e6f9cf77b9995 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; @@ -381,6 +383,8 @@ struct ArkUIDragEvent { ArkUI_Float64 displayY; ArkUI_Float64 screenX; ArkUI_Float64 screenY; + ArkUI_Float64 globalDisplayX; + ArkUI_Float64 globalDisplayY; ArkUI_Uint64 modifierKeyState; ArkUI_Int32 dragBehavior; bool useCustomDropAnimation; @@ -1395,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 50ee32af74c49fef82d21c1d75349fac5c86789b..2dda1e6a75dbe1eb8409e9d6d672da5fea0d02e0 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_drag_modifier.cpp b/frameworks/core/interfaces/native/node/node_drag_modifier.cpp index 87a124d2308e6508c0de634a501155677c69455d..636d2dead57af0842223def61edd9cfba6edb33d 100644 --- a/frameworks/core/interfaces/native/node/node_drag_modifier.cpp +++ b/frameworks/core/interfaces/native/node/node_drag_modifier.cpp @@ -59,6 +59,8 @@ void SetDragEventProperty(const RefPtr& info, ArkUINodeEve event.dragEvent.displayY = info->GetDisplayY(); event.dragEvent.screenX = info->GetScreenX(); event.dragEvent.screenY = info->GetScreenY(); + event.dragEvent.globalDisplayX = info->GetGlobalDisplayX(); + event.dragEvent.globalDisplayY = info->GetGlobalDisplayY(); event.dragEvent.previewRectWidth = info->GetPreviewRect().Width(); event.dragEvent.previewRectHeight = info->GetPreviewRect().Height(); diff --git a/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp b/frameworks/core/interfaces/native/node/node_gesture_modifier.cpp index 2ee6fccbe5bd71d05fc7467826051f278924ea12..295746750fe0beb78c8c6776cf195a80825ab3dd 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/inner_api/ace_kit/include/ui/base/geometry/point.h b/interfaces/inner_api/ace_kit/include/ui/base/geometry/point.h index 18788e924d72649f03e249ce4cd7352667a8fe02..5f3cf0a0f72b029f01115f7ae70ade94a546e6fa 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; }; diff --git a/interfaces/napi/kits/observer/ui_observer_listener.cpp b/interfaces/napi/kits/observer/ui_observer_listener.cpp index 190aaeb18fd24247b825e65f7b9c7eafd22e8f3d..2e09393a7225cd853be94e32f07e1ab481096056 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); @@ -1299,6 +1309,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 +1330,16 @@ void UIObserverListener::AddClickEventInfoOne(napi_value objValueClickEvent, con napi_create_double(env_, globalOffset.GetY() / scale, &napiWindowY); napi_set_named_property(env_, objValueClickEvent, "windowY", napiWindowY); } + napi_value napiGlobalDisplayX = GetNamedProperty(env_, objValueClickEvent, "globalDisplayX"); + if (GetValueType(env_, napiGlobalDisplayX) != napi_null) { + napi_create_double(env_, globalDisplayOffset.GetX() / scale, &napiGlobalDisplayX); + napi_set_named_property(env_, objValueClickEvent, "globalDisplayX", napiGlobalDisplayX); + } + napi_value napiGlobalDisplayY = GetNamedProperty(env_, objValueClickEvent, "globalDisplayY"); + if (GetValueType(env_, napiGlobalDisplayY) != napi_null) { + napi_create_double(env_, globalDisplayOffset.GetY() / scale, &napiGlobalDisplayY); + napi_set_named_property(env_, objValueClickEvent, "globalDisplayY", napiGlobalDisplayY); + } napi_close_handle_scope(env_, scope); } diff --git a/interfaces/native/drag_and_drop.h b/interfaces/native/drag_and_drop.h index 8f1724100191ae0ae49b88378e626b864c70835b..7543724d4c491ca9188e905f5898f682d0a28edd 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 5e8227e475e0f8eed8c95d6afe3464f7c3b6662d..978cf5ee04d519e525cea024763cac7d5dfbbc43 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) { diff --git a/interfaces/native/event/ui_input_event.cpp b/interfaces/native/event/ui_input_event.cpp index 8d8d2a7f4f38a374866d6af33232d10d3ecfa141..9cf4af4525567aaa00f28ea241e64873a20209dd 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 aa0c30c76f12d3150fb1dbcf03bf226a0e3fb355..315d0b9c758248b553333cf3f597b085dfa2e403 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)..