From c5bd4fd5096f17e3e1345eccb1b3ddcb960c1544 Mon Sep 17 00:00:00 2001 From: z-hf Date: Mon, 18 Aug 2025 11:13:20 +0800 Subject: [PATCH] fix drag Signed-off-by: z-hf --- .../src/input_windows_manager.cpp | 2 +- .../test/input_windows_manager_test.cpp | 46 ++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index a629994654..3a7e29f6c1 100644 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -6365,7 +6365,7 @@ int32_t InputWindowsManager::AppendExtraData(const ExtraData& extraData) extraData_.pullId = extraData.pullId; extraData_.eventId = extraData.eventId; extraData_.drawCursor = extraData.drawCursor; - if ((extraData.sourceType == PointerEvent::SOURCE_TYPE_MOUSE) && + if ((extraData_.eventId > 0) && (extraData.sourceType == PointerEvent::SOURCE_TYPE_MOUSE) && (mouseDownEventId_ < 0 || extraData.eventId < mouseDownEventId_)) { MMI_HILOGE("Mouse drag failed, PI:%{public}d, EI:%{public}d, DEI:%{public}d", extraData.pointerId, extraData.eventId, mouseDownEventId_); diff --git a/service/window_manager/test/input_windows_manager_test.cpp b/service/window_manager/test/input_windows_manager_test.cpp index 3f00bfc237..ed54e49d0b 100644 --- a/service/window_manager/test/input_windows_manager_test.cpp +++ b/service/window_manager/test/input_windows_manager_test.cpp @@ -4430,12 +4430,12 @@ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FoldScreenRotation, Te } /** - * @tc.name: InputWindowsManagerTest_PrintChangedWindowBySync + * @tc.name: InputWindowsManagerTest_PrintChangedWindowBySync_001 * @tc.desc: Test PrintChangedWindowBySync * @tc.type: FUNC * @tc.require: */ -HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowBySync, TestSize.Level1) +HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowBySync_001, TestSize.Level1) { CALL_TEST_DEBUG; InputWindowsManager inputWindowsMgr; @@ -4454,6 +4454,48 @@ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowBySy EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayInfo)); } +/** + * @tc.name: InputWindowsManagerTest_PrintChangedWindowBySync_002 + * @tc.desc: Test PrintChangedWindowBySync + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowBySync_002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + OLD::DisplayGroupInfo newDisplayGroupInfo; + OLD::DisplayInfo newDisplayInfo; + newDisplayInfo.direction = DIRECTION0; + newDisplayInfo.displayDirection = DIRECTION0; + newDisplayInfo.width = 200; + newDisplayInfo.height = 300; + newDisplayGroupInfo.displaysInfo.push_back(newDisplayInfo); + OLD::DisplayInfo displayInfo; + displayInfo.direction = DIRECTION0; + displayInfo.displayDirection = DIRECTION0; + displayInfo.width = 200; + displayInfo.height = 300; + auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsMgr.displayGroupInfoMap_.end()) { + it->second.displaysInfo.push_back(displayInfo); + } + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayGroupInfo)); + + newDisplayInfo.direction = DIRECTION90; + newDisplayGroupInfo.displaysInfo.clear(); + newDisplayGroupInfo.displaysInfo.push_back(newDisplayInfo); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayGroupInfo)); + + displayInfo.direction = DIRECTION90; + auto iter = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (iter != inputWindowsMgr.displayGroupInfoMap_.end()) { + iter->second.displaysInfo.clear(); + iter->second.displaysInfo.push_back(displayInfo); + } + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayGroupInfo)); +} + /** * @tc.name: InputWindowsManagerTest_GetClientFd_003 * @tc.desc: Test the funcation GetClientFd -- Gitee