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 8482139e9278d12434809dbce8194a20cf9da093..1aedc2e0d169c2c272d40d42e093bfb7b96c1210 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 8e53c5eb08b9cc25cb8225508e16815e7fe110ac..fa0f5aa257d4d0eee6b0461a4683bf52f64ca1e5 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();