From e079360449f01a43cb09d31f260a25549dfbd4b7 Mon Sep 17 00:00:00 2001 From: xueyuanzhao Date: Mon, 14 Jul 2025 14:55:11 +0800 Subject: [PATCH] Signed-off-by:xueyuanzhao Signed-off-by: xueyuanzhao Change-Id: I73d890462578e863733422893f2b1a7c16a4498a --- .../napi/input_event_client/src/js_register_module.cpp | 5 +++++ frameworks/native/input/oh_input_manager.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frameworks/napi/input_event_client/src/js_register_module.cpp b/frameworks/napi/input_event_client/src/js_register_module.cpp index 8482139e92..1aedc2e0d1 100644 --- a/frameworks/napi/input_event_client/src/js_register_module.cpp +++ b/frameworks/napi/input_event_client/src/js_register_module.cpp @@ -371,6 +371,10 @@ static void HandleMousePropertyInt32(napi_env env, napi_value mouseHandle, MMI_HILOGE("toolType:%{public}d is less 0, can not process", toolType); THROWERR_CUSTOM(env, COMMON_PARAMETER_ERROR, "toolType must be greater than or equal to 0"); } + int32_t screenId = -1; + if (GetNamedPropertyInt32(env, mouseHandle, "screenId", screenId, false) != RET_OK) { + MMI_HILOGW("Get screenId failed"); + } int32_t globalX = INT_MAX; if (GetNamedPropertyInt32(env, mouseHandle, "globalX", globalX, false) != RET_OK) { MMI_HILOGD("No globaX"); @@ -380,6 +384,7 @@ static void HandleMousePropertyInt32(napi_env env, napi_value mouseHandle, MMI_HILOGD("No globaY"); } pointerEvent->SetSourceType(toolType); + pointerEvent->SetTargetDisplayId(screenId); item.SetPointerId(0); item.SetDisplayX(screenX); item.SetDisplayY(screenY); diff --git a/frameworks/native/input/oh_input_manager.cpp b/frameworks/native/input/oh_input_manager.cpp index 8e53c5eb08..fa0f5aa257 100644 --- a/frameworks/native/input/oh_input_manager.cpp +++ b/frameworks/native/input/oh_input_manager.cpp @@ -526,7 +526,12 @@ int32_t OH_Input_InjectMouseEvent(const struct Input_MouseEvent* mouseEvent) CHKPR(g_mouseEvent, INPUT_PARAMETER_ERROR); g_mouseEvent->ClearFlag(); g_mouseEvent->ClearAxisValue(); - g_mouseEvent->SetTargetDisplayId(0); + if (mouseEvent->displayId <= 0) { + g_mouseEvent->SetTargetDisplayId(0); + } else { + MMI_HILOGI("{%{public}d}", mouseEvent->displayId); + g_mouseEvent->SetTargetDisplayId(mouseEvent->displayId); + } int64_t time = mouseEvent->actionTime; if (time < 0) { time = OHOS::MMI::GetSysClockTime(); -- Gitee