From f0d3401521ea6bc8857b5804516b01a7d37032bf Mon Sep 17 00:00:00 2001 From: z-hf Date: Thu, 11 Sep 2025 21:55:42 +0800 Subject: [PATCH 1/3] Consider the case where displayid is less than 1 Signed-off-by: z-hf --- .../proxy/events/include/event_log_helper.h | 6 +++--- .../message_handle/src/server_msg_handler.cpp | 18 ++++++++++-------- .../include/i_input_windows_manager.h | 1 + .../mock/include/input_windows_manager_mock.h | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/frameworks/proxy/events/include/event_log_helper.h b/frameworks/proxy/events/include/event_log_helper.h index 4b82240547..d67acb3151 100644 --- a/frameworks/proxy/events/include/event_log_helper.h +++ b/frameworks/proxy/events/include/event_log_helper.h @@ -276,9 +276,9 @@ private: item.GetFixedDisplayXPos(), item.GetFixedDisplayYPos(), item.GetWindowXPos(), item.GetWindowYPos(), item.IsPressed(), item.GetPressure(), item.GetMoveFlag(), item.GetLongAxis(), item.GetShortAxis(), isSimulate.c_str()); - MMI_HILOG_HEADER(LOG_INFO, lh, "%{public}d|%{public}d|%{public}d|%{public}d|%{public}" PRId64, - item.GetPointerId(), item.GetTargetWindowId(), item.GetOriginPointerId(), - item.GetTwist(), item.GetDownTime()); + MMI_HILOG_HEADER(LOG_INFO, lh, "%{public}d|%{public}d|%{public}d|%{public}d|%{public}d“ + ”|%{public}" PRId64, item.GetPointerId(), item.GetTargetWindowId(), item.GetOriginPointerId(), + event->GetTargetDisplayId(), item.GetTwist(), item.GetDownTime()); } } std::vector pressedKeys = event->GetPressedKeys(); diff --git a/service/message_handle/src/server_msg_handler.cpp b/service/message_handle/src/server_msg_handler.cpp index 945623d4e0..1d82182ff8 100644 --- a/service/message_handle/src/server_msg_handler.cpp +++ b/service/message_handle/src/server_msg_handler.cpp @@ -624,12 +624,6 @@ int32_t ServerMsgHandler::SaveTargetWindowId(std::shared_ptr point if ((pointerEvent->GetSourceType() == PointerEvent::SOURCE_TYPE_TOUCHSCREEN) && (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_DOWN || pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_HOVER_ENTER)) { - int32_t pointerId = pointerEvent->GetPointerId(); - PointerEvent::PointerItem pointerItem; - if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) { - MMI_HILOGE("Can't find pointer item, pointer:%{public}d", pointerId); - return RET_ERR; - } int32_t targetWindowId = pointerEvent->GetTargetWindowId(); if (isShell) { shellTargetWindowIds_[touch] = targetWindowId; @@ -640,11 +634,12 @@ int32_t ServerMsgHandler::SaveTargetWindowId(std::shared_ptr point } else { nativeTargetWindowIds_[touch] = targetWindowId; } + MMI_HILOGD("Update displayId:%{public}d, pointerId:%{public}d, targetWindowId:%{public}d", + touch.displayId_, touch.pointerId_, targetWindowId); } if ((pointerEvent->GetSourceType() == PointerEvent::SOURCE_TYPE_TOUCHSCREEN) && (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_UP || pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_HOVER_EXIT)) { - int32_t pointerId = pointerEvent->GetPointerId(); if (isShell) { shellTargetWindowIds_.erase(touch); } else if (IsCastInject(pointerEvent->GetDeviceId()) && (pointerEvent->GetZOrder() > 0)) { @@ -654,6 +649,8 @@ int32_t ServerMsgHandler::SaveTargetWindowId(std::shared_ptr point } else { nativeTargetWindowIds_.erase(touch); } + MMI_HILOGD("Erase displayId:%{public}d, pointerId:%{public}d", + touch.displayId_, touch.pointerId_); } return RET_OK; } @@ -698,8 +695,13 @@ int32_t ServerMsgHandler::FixTargetWindowId(std::shared_ptr pointe pointerEvent->SetPointerId(pointerEvent->GetPointerId() + diffPointerId); } } + auto displayId = pointerEvent->GetTargetDisplayId(); + if (displayId < 0 && !UpdateDisplayId(displayId)) { + MMI_HILOG_DISPATCHE("This display is not existent"); + return RET_ERR; + } InjectionTouch touch{ - .displayId_ = pointerEvent->GetTargetDisplayId(), .pointerId_ = pointerEvent->GetPointerId()}; + .displayId_ = displayId, .pointerId_ = pointerEvent->GetPointerId()}; auto iter = targetWindowIdMap.find(touch); if (iter != targetWindowIdMap.end()) { return iter->second; diff --git a/service/window_manager/include/i_input_windows_manager.h b/service/window_manager/include/i_input_windows_manager.h index 84d9f7bad7..db9791b0b7 100644 --- a/service/window_manager/include/i_input_windows_manager.h +++ b/service/window_manager/include/i_input_windows_manager.h @@ -151,6 +151,7 @@ public: #endif // OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) + virtual bool UpdateDisplayId(int32_t& displayId) = 0; virtual void DrawTouchGraphic(std::shared_ptr pointerEvent) = 0; virtual int32_t UpdateTargetPointer(std::shared_ptr pointerEvent) = 0; virtual const OLD::DisplayInfo *GetPhysicalDisplay(int32_t id) const = 0; diff --git a/test/facility/mock/include/input_windows_manager_mock.h b/test/facility/mock/include/input_windows_manager_mock.h index c5cc3e01d3..db193636f0 100644 --- a/test/facility/mock/include/input_windows_manager_mock.h +++ b/test/facility/mock/include/input_windows_manager_mock.h @@ -113,6 +113,7 @@ public: #endif // OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) + MOCK_METHOD(bool, UpdateDisplayId, (int32_t&)); void DrawTouchGraphic(std::shared_ptr) override {} MOCK_METHOD(int32_t, UpdateTargetPointer, (std::shared_ptr)); MOCK_METHOD(const OLD::DisplayInfo *, GetPhysicalDisplay, (int32_t), (const)); -- Gitee From 671e200faba9fb9d110f18ef42900b0b2ea2dade Mon Sep 17 00:00:00 2001 From: z-hf Date: Thu, 11 Sep 2025 22:41:04 +0800 Subject: [PATCH 2/3] Consider the case where displayid is less than 1 Signed-off-by: z-hf --- frameworks/proxy/events/include/event_log_helper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/proxy/events/include/event_log_helper.h b/frameworks/proxy/events/include/event_log_helper.h index d67acb3151..211904c5c1 100644 --- a/frameworks/proxy/events/include/event_log_helper.h +++ b/frameworks/proxy/events/include/event_log_helper.h @@ -276,8 +276,8 @@ private: item.GetFixedDisplayXPos(), item.GetFixedDisplayYPos(), item.GetWindowXPos(), item.GetWindowYPos(), item.IsPressed(), item.GetPressure(), item.GetMoveFlag(), item.GetLongAxis(), item.GetShortAxis(), isSimulate.c_str()); - MMI_HILOG_HEADER(LOG_INFO, lh, "%{public}d|%{public}d|%{public}d|%{public}d|%{public}d“ - ”|%{public}" PRId64, item.GetPointerId(), item.GetTargetWindowId(), item.GetOriginPointerId(), + MMI_HILOG_HEADER(LOG_INFO, lh, "%{public}d|%{public}d|%{public}d|%{public}d|%{public}d" + "|%{public}" PRId64, item.GetPointerId(), item.GetTargetWindowId(), item.GetOriginPointerId(), event->GetTargetDisplayId(), item.GetTwist(), item.GetDownTime()); } } -- Gitee From 261c70733022f4bea5d2a867ee3d69d94bb603f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B5=B7=E5=B3=B0?= Date: Fri, 12 Sep 2025 01:15:46 +0000 Subject: [PATCH 3/3] update service/message_handle/src/server_msg_handler.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张海峰 --- service/message_handle/src/server_msg_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/message_handle/src/server_msg_handler.cpp b/service/message_handle/src/server_msg_handler.cpp index 1d82182ff8..fe9a950e48 100644 --- a/service/message_handle/src/server_msg_handler.cpp +++ b/service/message_handle/src/server_msg_handler.cpp @@ -696,7 +696,7 @@ int32_t ServerMsgHandler::FixTargetWindowId(std::shared_ptr pointe } } auto displayId = pointerEvent->GetTargetDisplayId(); - if (displayId < 0 && !UpdateDisplayId(displayId)) { + if (displayId < 0 && !WIN_MGR->UpdateDisplayId(displayId)) { MMI_HILOG_DISPATCHE("This display is not existent"); return RET_ERR; } -- Gitee