diff --git a/frameworks/native/input/oh_input_manager.cpp b/frameworks/native/input/oh_input_manager.cpp index 45e989733ed7908bd3cf0bdac3357306dbe5ae85..91c7b2596d30391be392cd3b72442e72c75d99a4 100644 --- a/frameworks/native/input/oh_input_manager.cpp +++ b/frameworks/native/input/oh_input_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -49,6 +49,8 @@ struct Input_MouseEvent { int32_t action; int32_t displayX; int32_t displayY; + int32_t globalX; + int32_t globalY; int32_t button { -1 }; int32_t axisType { -1 }; float axisValue { 0.0f }; @@ -62,6 +64,8 @@ struct Input_TouchEvent { int32_t id; int32_t displayX; int32_t displayY; + int32_t globalX; + int32_t globalY; int64_t actionTime { -1 }; int32_t windowId { -1 }; int32_t displayId { -1 }; @@ -71,6 +75,8 @@ struct Input_AxisEvent { int32_t axisAction; float displayX; float displayY; + int32_t globalX; + int32_t globalY; std::map axisValues; int64_t actionTime { -1 }; int32_t sourceType; @@ -681,6 +687,34 @@ int32_t OH_Input_GetMouseEventDisplayId(const struct Input_MouseEvent* mouseEven return mouseEvent->displayId; } +void OH_Input_SetMouseEventGlobalX(struct Input_MouseEvent* mouseEvent, int32_t globalX) +{ + CALL_DEBUG_ENTER; + CHKPV(mouseEvent); + mouseEvent->globalX = globalX; +} + +int32_t OH_Input_GetMouseEventGlobalX(const struct Input_MouseEvent* mouseEvent) +{ + CALL_DEBUG_ENTER; + CHKPR(mouseEvent, RET_ERR); + return mouseEvent->globalX; +} + +void OH_Input_SetMouseEventGlobalY(struct Input_MouseEvent* mouseEvent, int32_t globalY) +{ + CALL_DEBUG_ENTER; + CHKPV(mouseEvent); + mouseEvent->globalY = globalY; +} + +int32_t OH_Input_GetMouseEventGlobalY(const struct Input_MouseEvent* mouseEvent) +{ + CALL_DEBUG_ENTER; + CHKPR(mouseEvent, RET_ERR); + return mouseEvent->globalY; +} + static void HandleTouchActionDown(OHOS::MMI::PointerEvent::PointerItem &item, int64_t time) { auto pointIds = g_touchEvent->GetPointerIds(); @@ -910,6 +944,34 @@ int32_t OH_Input_GetTouchEventDisplayId(const struct Input_TouchEvent* touchEven return touchEvent->displayId; } +void OH_Input_SetTouchEventGlobalX(struct Input_TouchEvent* touchEvent, int32_t globalX) +{ + CALL_DEBUG_ENTER; + CHKPV(touchEvent); + touchEvent->globalX = globalX; +} + +int32_t OH_Input_GetTouchEventGlobalX(const struct Input_TouchEvent* touchEvent) +{ + CALL_DEBUG_ENTER; + CHKPR(touchEvent, RET_ERR); + return touchEvent->globalX; +} + +void OH_Input_SetTouchEventGlobalY(struct Input_TouchEvent* touchEvent, int32_t globalY) +{ + CALL_DEBUG_ENTER; + CHKPV(touchEvent); + touchEvent->globalY = globalY; +} + +int32_t OH_Input_GetTouchEventGlobalY(const struct Input_TouchEvent* touchEvent) +{ + CALL_DEBUG_ENTER; + CHKPR(touchEvent, RET_ERR); + return touchEvent->globalY; +} + void OH_Input_CancelInjection() { CALL_DEBUG_ENTER; @@ -1109,6 +1171,36 @@ Input_Result OH_Input_GetAxisEventDisplayId(const Input_AxisEvent* axisEvent, in return INPUT_SUCCESS; } +Input_Result OH_Input_SetAxisEventGlobalX(struct Input_AxisEvent* axisEvent, int32_t globalX) +{ + CHKPR(axisEvent, INPUT_PARAMETER_ERROR); + axisEvent->globalX = globalX; + return INPUT_SUCCESS; +} + +Input_Result OH_Input_GetAxisEventGlobalX(const Input_AxisEvent* axisEvent, int32_t* globalX) +{ + CHKPR(axisEvent, INPUT_PARAMETER_ERROR); + CHKPR(globalX, INPUT_PARAMETER_ERROR); + *globalX = axisEvent->globalX; + return INPUT_SUCCESS; +} + +Input_Result OH_Input_SetAxisEventGlobalY(struct Input_AxisEvent* axisEvent, int32_t globalY) +{ + CHKPR(axisEvent, INPUT_PARAMETER_ERROR); + axisEvent->globalY = globalY; + return INPUT_SUCCESS; +} + +Input_Result OH_Input_GetAxisEventGlobalY(const Input_AxisEvent* axisEvent, int32_t* globalY) +{ + CHKPR(axisEvent, INPUT_PARAMETER_ERROR); + CHKPR(globalY, INPUT_PARAMETER_ERROR); + *globalY = axisEvent->globalY; + return INPUT_SUCCESS; +} + static Input_Result NormalizeResult(int32_t result) { if (result < RET_OK) { @@ -1242,6 +1334,8 @@ static void TouchEventMonitorCallback(std::shared_ptr e touchEvent->id = event->GetPointerId(); touchEvent->displayX = item.GetDisplayX(); touchEvent->displayY = item.GetDisplayY(); + touchEvent->globalX = item.GetGlobalX(); + touchEvent->globalY = item.GetGlobalY(); touchEvent->actionTime = event->GetActionTime(); touchEvent->windowId = event->GetTargetWindowId(); touchEvent->displayId = event->GetTargetDisplayId(); @@ -1325,6 +1419,8 @@ static void MouseEventMonitorCallback(std::shared_ptr e } mouseEvent->displayX = item.GetDisplayX(); mouseEvent->displayY = item.GetDisplayY(); + mouseEvent->globalX = item.GetGlobalX(); + mouseEvent->globalY = item.GetGlobalY(); mouseEvent->actionTime = event->GetActionTime(); mouseEvent->windowId = event->GetTargetWindowId(); mouseEvent->displayId = event->GetTargetDisplayId(); @@ -1371,6 +1467,8 @@ static void AxisEventMonitorCallback(std::shared_ptr ev SetAxisEventAction(axisEvent, event->GetPointerAction()); axisEvent->displayX = item.GetDisplayX(); axisEvent->displayY = item.GetDisplayY(); + axisEvent->globalX = item.GetGlobalX(); + axisEvent->globalY = item.GetGlobalY(); axisEvent->actionTime = event->GetActionTime(); axisEvent->sourceType = event->GetSourceType(); axisEvent->windowId = event->GetTargetWindowId(); @@ -1677,6 +1775,8 @@ static void TouchEventInterceptorCallback(std::shared_ptrid = event->GetPointerId(); touchEvent->displayX = item.GetDisplayX(); touchEvent->displayY = item.GetDisplayY(); + touchEvent->globalX = item.GetGlobalX(); + touchEvent->globalY = item.GetGlobalY(); touchEvent->actionTime = event->GetActionTime(); touchEvent->windowId = event->GetTargetWindowId(); touchEvent->displayId = event->GetTargetDisplayId(); @@ -1711,6 +1811,8 @@ static void MouseEventInterceptorCallback(std::shared_ptrdisplayX = item.GetDisplayX(); mouseEvent->displayY = item.GetDisplayY(); + mouseEvent->globalX = item.GetGlobalX(); + mouseEvent->globalY = item.GetGlobalY(); mouseEvent->actionTime = event->GetActionTime(); mouseEvent->windowId = event->GetTargetWindowId(); mouseEvent->displayId = event->GetTargetDisplayId(); @@ -1743,6 +1845,8 @@ static void AxisEventInterceptorCallback(std::shared_ptrGetPointerAction()); axisEvent->displayX = item.GetDisplayX(); axisEvent->displayY = item.GetDisplayY(); + axisEvent->globalX = item.GetGlobalX(); + axisEvent->globalY = item.GetGlobalY(); axisEvent->actionTime = event->GetActionTime(); axisEvent->sourceType = event->GetSourceType(); axisEvent->windowId = event->GetTargetWindowId(); @@ -2681,7 +2785,6 @@ static int32_t TransformTouchProperty(const struct Input_TouchEvent *touchEvent, CALL_INFO_TRACE; CHKPR(touchEvent, INPUT_PARAMETER_ERROR); CHKPR(pointerEvent, INPUT_PARAMETER_ERROR); - int32_t id = touchEvent->id; int32_t screenX = touchEvent->displayX; int32_t screenY = touchEvent->displayY; if (screenX < 0 || screenY < 0) { @@ -2690,6 +2793,13 @@ static int32_t TransformTouchProperty(const struct Input_TouchEvent *touchEvent, } item.SetDisplayX(screenX); item.SetDisplayY(screenY); + + int32_t globalX = touchEvent->globalX; + int32_t globalY = touchEvent->globalY; + item.SetGlobalX(globalX); + item.SetGlobalY(globalY); + + int32_t id = touchEvent->id; item.SetOriginPointerId(id); if (id < SIMULATE_POINTER_EVENT_START_ID) { item.SetPointerId(id + SIMULATE_POINTER_EVENT_START_ID); diff --git a/frameworks/native/input/test/oh_input_manager_test.cpp b/frameworks/native/input/test/oh_input_manager_test.cpp index 21a41e33f4ebbe45631f8559ddf49b8407bf6cc4..74e5d262f731a12655e60da90114452ae7c94fe5 100644 --- a/frameworks/native/input/test/oh_input_manager_test.cpp +++ b/frameworks/native/input/test/oh_input_manager_test.cpp @@ -82,6 +82,8 @@ using namespace testing::ext; constexpr int32_t MIN_MULTI_TOUCH_POINT_NUM { 0 }; constexpr int32_t MAX_MULTI_TOUCH_POINT_NUM { 10 }; constexpr int32_t UNKNOWN_MULTI_TOUCH_POINT_NUM { -1 }; +constexpr int32_t DEFAULT_GLOBAL_X { -1 }; +constexpr int32_t DEFAULT_GLOBAL_Y { -1 }; } // namespace class OHInputManagerTest : public testing::Test { @@ -1958,5 +1960,58 @@ HWTEST_F(OHInputManagerTest, OHInputManagerTest_QueryMaxTouchPoints_002, TestSiz EXPECT_TRUE((pointNum == UNKNOWN_MULTI_TOUCH_POINT_NUM) || ((pointNum >= MIN_MULTI_TOUCH_POINT_NUM) && (pointNum <= MAX_MULTI_TOUCH_POINT_NUM))); } + +/* + * @tc.name: OHInputManagerTest_TouchMouseGlobalCoordinates + * @tc.desc: OH_Input_SetTouchMouseGlobalX OH_Input_SetTouchMouseGlobalY + * OH_Input_GetTouchMouseGlobalX OH_Input_GetMouseEventGlobalY + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(OHInputManagerTest, OHInputManagerTest_MouseEventGlobalCoordinates, TestSize.Level1) +{ + Input_MouseEvent mouseEvent; + OH_Input_SetMouseEventGlobalX(&mouseEvent, DEFAULT_GLOBAL_X); + OH_Input_SetMouseEventGlobalY(&mouseEvent, DEFAULT_GLOBAL_Y); + int32_t globalX = OH_Input_GetMouseEventGlobalX(&mouseEvent); + int32_t globalY = OH_Input_GetMouseEventGlobalY(&mouseEvent); + EXPECT_TRUE((globalX == DEFAULT_GLOBAL_X) && (globalY == DEFAULT_GLOBAL_Y)); +} + +/* + * @tc.name: OHInputManagerTest_TouchEventGlobalCoordinates + * @tc.desc: OH_Input_SetTouchEventGlobalX OH_Input_SetTouchEventGlobalY + * OH_Input_GetTouchEventGlobalX OH_Input_GetTouchEventGlobalY + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(OHInputManagerTest, OHInputManagerTest_TouchEventGlobalCoordinates, TestSize.Level1) +{ + Input_TouchEvent touchEvent; + OH_Input_SetTouchEventGlobalX(&touchEvent, DEFAULT_GLOBAL_X); + OH_Input_SetTouchEventGlobalY(&touchEvent, DEFAULT_GLOBAL_Y); + int32_t globalX = OH_Input_GetTouchEventGlobalX(&touchEvent); + int32_t globalY = OH_Input_GetTouchEventGlobalY(&touchEvent); + EXPECT_TRUE((globalX == DEFAULT_GLOBAL_X) && (globalY == DEFAULT_GLOBAL_Y)); +} + +/* + * @tc.name: OHInputManagerTest_AxisEventGlobalCoordinates + * @tc.desc: OH_Input_SetAxisEventGlobalX OH_Input_SetAxisEventGlobalY + * OH_Input_GetAxisEventGlobalX OH_Input_GetAxisEventGlobalY + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(OHInputManagerTest, OHInputManagerTest_AxisEventGlobalCoordinates, TestSize.Level1) +{ + Input_AxisEvent axisEvent; + OH_Input_SetAxisEventGlobalX(&axisEvent, DEFAULT_GLOBAL_X); + OH_Input_SetAxisEventGlobalY(&axisEvent, DEFAULT_GLOBAL_Y); + int32_t globalX { 0 }; + int32_t globalY { 0 }; + ASSERT_EQ(OH_Input_GetAxisEventGlobalX(&axisEvent, &globalX), INPUT_SUCCESS); + ASSERT_EQ(OH_Input_GetAxisEventGlobalY(&axisEvent, &globalY), INPUT_SUCCESS); + EXPECT_TRUE((globalX == DEFAULT_GLOBAL_X) && (globalY == DEFAULT_GLOBAL_Y)); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/frameworks/proxy/events/src/pointer_event.cpp b/frameworks/proxy/events/src/pointer_event.cpp index fbc6f487256516653359107db4ee3def21c348cf..9c937386112447549f9eb875c3778b6be72e957a 100644 --- a/frameworks/proxy/events/src/pointer_event.cpp +++ b/frameworks/proxy/events/src/pointer_event.cpp @@ -254,6 +254,26 @@ void PointerEvent::PointerItem::SetToolWindowY(int32_t y) toolWindowY_ = y; } +void PointerEvent::PointerItem::SetGlobalX(double globalX) +{ + globalX_ = globalX; +} + +double PointerEvent::PointerItem::GetGlobalX() +{ + return globalX_; +} + +void PointerEvent::PointerItem::SetGlobalY(double globalY) +{ + globalY_ = globalY; +} + +double PointerEvent::PointerItem::GetGlobalY() +{ + return globalY_; +} + int32_t PointerEvent::PointerItem::GetToolWidth() const { return toolWidth_; @@ -476,7 +496,9 @@ bool PointerEvent::PointerItem::WriteToParcel(Parcel &out) const out.WriteInt32(blobId_) && out.WriteInt32(twist_) && out.WriteInt32(fixedDisplayX_) && - out.WriteInt32(fixedDisplayY_) + out.WriteInt32(fixedDisplayY_) && + out.WriteDouble(globalX_) && + out.WriteDouble(globalY_) ); } @@ -518,7 +540,9 @@ bool PointerEvent::PointerItem::ReadFromParcel(Parcel &in) in.ReadInt32(blobId_) && in.ReadInt32(twist_) && in.ReadInt32(fixedDisplayX_) && - in.ReadInt32(fixedDisplayY_) + in.ReadInt32(fixedDisplayY_) && + in.ReadDouble(globalX_) && + in.ReadDouble(globalY_) ); } diff --git a/frameworks/proxy/events/test/pointer_event_test.cpp b/frameworks/proxy/events/test/pointer_event_test.cpp index 127f26640490cc09c259ae73000cbf4fa9d57c8f..dd73845f5f37e1ab426646f3f6d4b125e3ecd26d 100644 --- a/frameworks/proxy/events/test/pointer_event_test.cpp +++ b/frameworks/proxy/events/test/pointer_event_test.cpp @@ -58,6 +58,8 @@ std::shared_ptr PointerEventTest::CreatePointEvent() item.SetDisplayX(623); item.SetDisplayY(823); + item.SetGlobalX(0); + item.SetGlobalY(0); item.SetWindowX(600); item.SetWindowY(800); @@ -2300,5 +2302,23 @@ HWTEST_F(PointerEventTest, PointerEventTest_PointerItem_SetOrientation, TestSize ASSERT_NO_FATAL_FAILURE(item.SetOrientation(orientation)); ASSERT_EQ(item.GetOrientation(), orientation); } + +/** + * @tc.name: PointerEventTest_PointerItem_GlobalCoordinates + * @tc.desc: Test + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PointerEventTest, PointerEventTest_PointerItem_GlobalCoordinates, TestSize.Level2) +{ + CALL_TEST_DEBUG; + double globalX { -1.0 }; + double globalY { -1.0 }; + PointerEvent::PointerItem item; + ASSERT_NO_FATAL_FAILURE(item.SetGlobalX(globalX)); + ASSERT_NO_FATAL_FAILURE(item.SetGlobalY(globalY)); + ASSERT_EQ(static_cast(item.GetGlobalX()), globalX); + ASSERT_EQ(static_cast(item.GetGlobalY()), globalY); +} } // namespace MMI } // namespace OHOS diff --git a/interfaces/kits/c/input/oh_input_manager.h b/interfaces/kits/c/input/oh_input_manager.h index acdfd98d0d32f41f1d503a8233c684564300726f..dd61420e1ddffe523df6876eed168a97dd027c79 100644 --- a/interfaces/kits/c/input/oh_input_manager.h +++ b/interfaces/kits/c/input/oh_input_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -785,6 +785,46 @@ void OH_Input_SetMouseEventDisplayId(struct Input_MouseEvent* mouseEvent, int32_ */ int32_t OH_Input_GetMouseEventDisplayId(const struct Input_MouseEvent* mouseEvent); +/** + * @brief Set the global X coordinate of the mouse event. + * + * @param mouseEvent Mouse event object. + * @param globalX Global X coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +void OH_Input_SetMouseEventGlobalX(struct Input_MouseEvent* mouseEvent, int32_t globalX); + +/** + * @brief Queries the global X coordinate of the mouse event. + * + * @param mouseEvent Mouse event object. + * @return Global X coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +int32_t OH_Input_GetMouseEventGlobalX(const struct Input_MouseEvent* mouseEvent); + +/** + * @brief Set the global Y coordinate of the mouse event. + * + * @param mouseEvent Mouse event object. + * @param globalY Global Y coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +void OH_Input_SetMouseEventGlobalY(struct Input_MouseEvent* mouseEvent, int32_t globalY); + +/** + * @brief Queries the global Y coordinate of the mouse event. + * + * @param mouseEvent Mouse event object. + * @return Global Y coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +int32_t OH_Input_GetMouseEventGlobalY(const struct Input_MouseEvent* mouseEvent); + /** * @brief Inject touch event. * @@ -956,6 +996,46 @@ void OH_Input_SetTouchEventDisplayId(struct Input_TouchEvent* touchEvent, int32_ */ int32_t OH_Input_GetTouchEventDisplayId(const struct Input_TouchEvent* touchEvent); +/** + * @brief Set the global X coordinate of the touch event. + * + * @param touchEvent Touch event object. + * @param globalX Global X coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +void OH_Input_SetTouchEventGlobalX(struct Input_TouchEvent* touchEvent, int32_t globalX); + +/** + * @brief Queries the global X coordinate of the touch event. + * + * @param touchEvent Touch event object. + * @return Global X coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +int32_t OH_Input_GetTouchEventGlobalX(const struct Input_TouchEvent* touchEvent); + +/** + * @brief Set the global Y coordinate of the touch event. + * + * @param touchEvent Touch event object. + * @param globalY Global Y coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +void OH_Input_SetTouchEventGlobalY(struct Input_TouchEvent* touchEvent, int32_t globalY); + +/** + * @brief Queries the global Y coordinate of the touch event. + * + * @param touchEvent Touch event object. + * @return Global Y coordinate. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +int32_t OH_Input_GetTouchEventGlobalY(const struct Input_TouchEvent* touchEvent); + /** * @brief Cancels event injection and revokes authorization. * @@ -1225,6 +1305,58 @@ Input_Result OH_Input_SetAxisEventDisplayId(Input_AxisEvent* axisEvent, int32_t */ Input_Result OH_Input_GetAxisEventDisplayId(const Input_AxisEvent* axisEvent, int32_t* displayId); +/** + * @brief Set the global X coordinate of the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param globalX Global X coordinate. + * @return OH_Input_SetAxisEventGlobalX function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +Input_Result OH_Input_SetAxisEventGlobalX(struct Input_AxisEvent* axisEvent, int32_t globalX); + +/** + * @brief Queries the global X coordinate of the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param globalX Global X coordinate. + * @return OH_Input_GetAxisEventGlobalX function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the globalX is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +Input_Result OH_Input_GetAxisEventGlobalX(const Input_AxisEvent* axisEvent, int32_t* globalX); + +/** + * @brief Set the global Y coordinate of the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param globalY Global Y coordinate. + * @return OH_Input_SetAxisEventGlobalY function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +Input_Result OH_Input_SetAxisEventGlobalY(struct Input_AxisEvent* axisEvent, int32_t globalY); + +/** + * @brief Queries the global Y coordinate of the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param globalY Global Y coordinate. + * @return OH_Input_GetAxisEventGlobalY function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the globalY is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +Input_Result OH_Input_GetAxisEventGlobalY(const Input_AxisEvent* axisEvent, int32_t* globalY); + /** * @brief Adds a listener of key events. * diff --git a/interfaces/native/innerkits/event/include/pointer_event.h b/interfaces/native/innerkits/event/include/pointer_event.h index 94a1a71c95c4427fc50136472c07a64d7ec8cffc..c9a3bc504230fb340dbf9a14dcaa847ac7c3bf0b 100644 --- a/interfaces/native/innerkits/event/include/pointer_event.h +++ b/interfaces/native/innerkits/event/include/pointer_event.h @@ -860,6 +860,35 @@ public: void SetWindowY(int32_t y); void SetWindowYPos(double y); + /** + * @brief Set global X coordinate. + * @param globalX Indicates the global X coordinate to set. + * @return void + * @since 20 + */ + void SetGlobalX(double globalX); + + /** + * @brief Get global X coordinate. + * @return double + * @since 20 + */ + double GetGlobalX(); + + /** + * @brief Set global Y coordinate. + * @param globalY Indicates the global Y coordinate to set. + * @return void + * @since 20 + */ + void SetGlobalY(double globalY); + + /** + * @brief Get global X coordinate. + * @return double + * @since 20 + */ + double GetGlobalY(); /** * @brief Obtains the width of the pressed area. * @return Returns the width. @@ -1287,6 +1316,8 @@ public: bool pressed_ { false }; int32_t displayX_ {}; int32_t displayY_ {}; + double globalX_ { 0.0f }; + double globalY_ { 0.0f }; int32_t fixedDisplayX_ {}; int32_t fixedDisplayY_ {}; int32_t windowX_ {};