From 1156cb661058fea0d9f21e2fc1d0ecbf68e85a40 Mon Sep 17 00:00:00 2001 From: majian Date: Fri, 22 Nov 2024 17:06:28 +0800 Subject: [PATCH 1/5] compatible mode drag Change-Id: I1cce0e1b5a09ec76c9de2a2e3feb1981fc51d95a Signed-off-by: majian --- window_scene/session/host/src/scene_session.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 7a80341e1f..3bc6e68c93 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2575,7 +2575,9 @@ void SceneSession::HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reaso const int32_t compatibleInPcLandscapeWidth = sessionProperty->GetCompatibleInPcLandscapeWidth(); const int32_t compatibleInPcLandscapeHeight = sessionProperty->GetCompatibleInPcLandscapeHeight(); const int32_t compatibleInPcDragLimit = compatibleInPcLandscapeWidth - compatibleInPcPortraitWidth; - WSRect windowRect = GetSessionRect(); + WSRect windowRect = moveDragController_->GetTargetRect(reason == SizeChangeReason::DRAG_END ? + MoveDragController::TargetRectCoordinate::RELATED_TO_END_DISPLAY : + MoveDragController::TargetRectCoordinate::GLOBAL); auto windowWidth = windowRect.width_; auto windowHeight = windowRect.height_; @@ -2794,7 +2796,11 @@ void SceneSession::OnMoveDragCallback(SizeChangeReason reason) HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::OnMoveDragCallback [%d, %d, %u, %u]", rect.posX_, rect.posY_, rect.width_, rect.height_); if (isCompatibleModeInPc && !IsFreeMultiWindowMode()) { - HandleCompatibleModeMoveDrag(globalRect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush); + if (reason == SizeChangeReason::DRAG_END) { + HandleCompatibleModeMoveDrag(rect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush); + } else { + HandleCompatibleModeMoveDrag(globalRect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush); + } } else if (reason == SizeChangeReason::DRAG && IsFreeMultiWindowMode() && isMainWindow) { OnSessionEvent(SessionEvent::EVENT_DRAG); return; From 254d85e49ac9708f4f73e6ed71ca75590c62511f Mon Sep 17 00:00:00 2001 From: majian Date: Fri, 22 Nov 2024 17:56:15 +0800 Subject: [PATCH 2/5] update Change-Id: I350bb18128d4c2419f4a5a46f522f7e131d04033 Signed-off-by: majian --- window_scene/session/host/src/scene_session.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 3bc6e68c93..62709df453 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2580,7 +2580,6 @@ void SceneSession::HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reaso MoveDragController::TargetRectCoordinate::GLOBAL); auto windowWidth = windowRect.width_; auto windowHeight = windowRect.height_; - if (isSupportDragInPcCompatibleMode && windowWidth > windowHeight && (rect.width_ < compatibleInPcLandscapeWidth - compatibleInPcDragLimit || rect.width_ == static_cast(windowLimits.minWidth_))) { @@ -2785,7 +2784,6 @@ void SceneSession::OnMoveDragCallback(SizeChangeReason reason) MoveDragController::TargetRectCoordinate::GLOBAL); bool isGlobal = (reason != SizeChangeReason::DRAG_END); bool needFlush = (reason != SizeChangeReason::DRAG_END); - TLOGD(WmsLogTag::WMS_LAYOUT, "Rect: [%{public}d, %{public}d, %{public}u, %{public}u], reason: %{public}d, " "isCompatibleMode: %{public}d, isSupportDragInPcCompatibleMode: %{public}d", rect.posX_, rect.posY_, rect.width_, rect.height_, reason, isCompatibleModeInPc, isSupportDragInPcCompatibleMode); From c32132e12e4c3441bc56b2f8bb3cabf408e7e44e Mon Sep 17 00:00:00 2001 From: majian Date: Fri, 22 Nov 2024 18:22:31 +0800 Subject: [PATCH 3/5] update Change-Id: I9aa8bb3cabb6b242a7503df09dbbc4700c57f799 Signed-off-by: majian --- window_scene/session/host/src/scene_session.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 62709df453..915525ed97 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2596,13 +2596,8 @@ void SceneSession::HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reaso UpdateSizeChangeReason(reason); UpdateRect(rect, reason, "compatibleInPcLandscape"); } else if (isSupportDragInPcCompatibleMode) { - if (windowWidth < windowHeight) { - rect.width_ = compatibleInPcPortraitWidth; - rect.height_ = compatibleInPcPortraitHeight; - } else { - rect.width_ = compatibleInPcLandscapeWidth; - rect.height_ = compatibleInPcLandscapeHeight; - } + rect.width_ = (windowWidth < windowHeight) ? compatibleInPcPortraitWidth : compatibleInPcLandscapeWidth; + rect.height_ = (windowWidth < windowHeight) ? compatibleInPcPortraitHeight : compatibleInPcLandscapeHeight; rect.posX_ = windowRect.posX_; rect.posY_ = windowRect.posY_; SetSurfaceBounds(rect, isGlobal, needFlush); From 4536ea786c9e1869c8b2d6e06e0ddfc491c8b619 Mon Sep 17 00:00:00 2001 From: majian Date: Fri, 22 Nov 2024 18:36:41 +0800 Subject: [PATCH 4/5] update Change-Id: I40d290b83d2926e006018d334cfbbd015b6dc665 Signed-off-by: majian --- window_scene/session/host/src/scene_session.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 915525ed97..18f7653a9f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2788,12 +2788,10 @@ void SceneSession::OnMoveDragCallback(SizeChangeReason reason) } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::OnMoveDragCallback [%d, %d, %u, %u]", rect.posX_, rect.posY_, rect.width_, rect.height_); - if (isCompatibleModeInPc && !IsFreeMultiWindowMode()) { - if (reason == SizeChangeReason::DRAG_END) { - HandleCompatibleModeMoveDrag(rect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush); - } else { - HandleCompatibleModeMoveDrag(globalRect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush); - } + if (isCompatibleModeInPc && !IsFreeMultiWindowMode() && reason == SizeChangeReason::DRAG_END) { + HandleCompatibleModeMoveDrag(rect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush); + } else if (isCompatibleModeInPc && !IsFreeMultiWindowMode() && reason != SizeChangeReason::DRAG_END) { + HandleCompatibleModeMoveDrag(globalRect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush); } else if (reason == SizeChangeReason::DRAG && IsFreeMultiWindowMode() && isMainWindow) { OnSessionEvent(SessionEvent::EVENT_DRAG); return; From c6a34dffd5387c422323e7997bb578b45c195448 Mon Sep 17 00:00:00 2001 From: majian Date: Fri, 22 Nov 2024 19:47:46 +0800 Subject: [PATCH 5/5] update tdd Change-Id: Ie88c73269c8245e30e5aa374ea504cca90f147a9 Signed-off-by: majian --- window_scene/test/unittest/scene_session_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index a0e692b845..e3ac9f3ddf 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -1912,6 +1912,7 @@ HWTEST_F(SceneSessionTest, HandleCompatibleModeMoveDrag, Function | SmallTest | info.bundleName_ = "HandleCompatibleModeMoveDrag"; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); + sceneSession->moveDragController_ = sptr::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT); WSRect rect = {1, 1, 1, 1}; WSRect rect2 = {1, 1, 2, 1}; @@ -1967,6 +1968,7 @@ HWTEST_F(SceneSessionTest, HandleCompatibleModeDrag, Function | SmallTest | Leve info.bundleName_ = "HandleCompatibleModeDrag"; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); + sceneSession->moveDragController_ = sptr::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT); WSRect rect = {1, 1, 1, 1}; WSRect rect2 = {2, 1, 1, 1};