diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index 33882acc74f6823d541e70a9fe6885957fdec203..fef4d9734e05b1d404a937d4b397bf445b689aae 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; @@ -379,6 +381,8 @@ struct ArkUIDragEvent { ArkUI_Float64 windowY; ArkUI_Float64 displayX; ArkUI_Float64 displayY; + ArkUI_Float64 globalDisplayX; + ArkUI_Float64 globalDisplayY; ArkUI_Float64 screenX; ArkUI_Float64 screenY; ArkUI_Uint64 modifierKeyState; @@ -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_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/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)..