From 343a7a620f44455b5c0904a73d0151f336083b54 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 6 Feb 2025 14:42:50 +0800 Subject: [PATCH 01/14] add code Signed-off-by: ZihaoWU --- .../host/include/pc_fold_screen_manager.h | 1 + .../session/host/include/scene_session.h | 2 +- window_scene/session/host/include/session.h | 8 ++- .../host/src/pc_fold_screen_manager.cpp | 8 +++ .../session/host/src/scene_session.cpp | 37 +++++++++--- window_scene/session/host/src/session.cpp | 58 +++++++++++++++---- .../src/scene_session_manager.cpp | 9 ++- .../test/unittest/scene_session_test.cpp | 12 ++-- window_scene/test/unittest/session_test.cpp | 10 ++-- wm/src/window_session_impl.cpp | 6 +- 10 files changed, 115 insertions(+), 36 deletions(-) diff --git a/window_scene/session/host/include/pc_fold_screen_manager.h b/window_scene/session/host/include/pc_fold_screen_manager.h index 54b2a83594..eea01796fa 100644 --- a/window_scene/session/host/include/pc_fold_screen_manager.h +++ b/window_scene/session/host/include/pc_fold_screen_manager.h @@ -45,6 +45,7 @@ public: SuperFoldStatus GetScreenFoldStatus() const; bool IsHalfFolded(DisplayId displayId) const; bool IsHalfFoldedOnMainDisplay(DisplayId displayId) const; + bool IsHalfFoldedDisplayId(DisplayId displayId) const; void UpdateSystemKeyboardStatus(bool hasSystemKeyboard); bool HasSystemKeyboard() const; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index c2c2124658..67b1955001 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -934,7 +934,7 @@ private: bool AdjustRectByAspectRatio(WSRect& rect); bool SaveAspectRatio(float ratio); WSError UpdateRectForDrag(const WSRect& rect); - void UpdateSessionRectPosYFromClient(WSRect& rect); + void UpdateSessionRectPosYFromClient(SizeChangeReason reason, DisplayId configDisplayId, WSRect& rect); /* * Window Decor diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 0aeacf4ccb..6a55485c32 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -577,11 +577,14 @@ public: std::optional GetClientDragEnable() const; std::shared_ptr GetEventHandler() const; WSError UpdateClientDisplayId(DisplayId displayId); - DisplayId TransformGlobalRectToRelativeRect(WSRect& rect) const; + DisplayId TransformGlobalRectToRelativeRect(WSRect& rect, DisplayId clientDisplayId = 0) const; void UpdateClientRectPosYAndDisplayId(WSRect& rect); bool IsDragAccessible() const; void SetSingleHandTransform(const SingleHandTransform& transform); SingleHandTransform GetSingleHandTransform() const; + void SetClientDisplayId(DisplayId displayId) const; + DisplayId GetClientDisplayId() const; + DisplayId GetParentClientDisplayId(); /* * Screen Lock @@ -754,7 +757,8 @@ protected: float clientScaleY_ = 1.0f; float clientPivotX_ = 0.0f; float clientPivotY_ = 0.0f; - DisplayId lastUpdatedDisplayId_ = 0; + DisplayId clientDisplayId_ = 0; + DisplayId configDisplayId_ = 0; SuperFoldStatus lastScreenFoldStatus_ = SuperFoldStatus::UNKNOWN; /* diff --git a/window_scene/session/host/src/pc_fold_screen_manager.cpp b/window_scene/session/host/src/pc_fold_screen_manager.cpp index 6f103f4d3c..1ca133b676 100644 --- a/window_scene/session/host/src/pc_fold_screen_manager.cpp +++ b/window_scene/session/host/src/pc_fold_screen_manager.cpp @@ -44,7 +44,10 @@ const RSAnimationTimingCurve THROW_SLIP_CURVE = constexpr int32_t RULE_TRANS_X = 48; // dp constexpr int32_t MIN_DECOR_HEIGHT = 37; constexpr WSRect RECT_ZERO = { 0, 0, 0, 0 }; + +// all displayId constexpr DisplayId DEFAULT_DISPLAY_ID = 0; +constexpr DisplayId VIRTUAL_DISPLAY_ID = 999; } // namespace WM_IMPLEMENT_SINGLE_INSTANCE(PcFoldScreenManager); @@ -108,6 +111,11 @@ bool PcFoldScreenManager::IsHalfFoldedOnMainDisplay(DisplayId displayId) const return screenFoldStatus_ == SuperFoldStatus::HALF_FOLDED && displayId == DEFAULT_DISPLAY_ID; } +bool PcFoldScreenManager::IsHalfFoldedDisplayId(DisplayId displayId) const +{ + return displayId == DEFAULT_DISPLAY_ID || displayId == VIRTUAL_DISPLAY_ID; +} + void PcFoldScreenManager::UpdateSystemKeyboardStatus(bool hasSystemKeyboard) { TLOGI(WmsLogTag::WMS_KEYBOARD, "status: %{public}d", hasSystemKeyboard); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 01c2c31ddb..4b6f1afa9e 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -66,6 +66,7 @@ const std::string DLP_INDEX = "ohos.dlp.params.index"; constexpr const char* APP_CLONE_INDEX = "ohos.extra.param.key.appCloneIndex"; constexpr float MINI_FLOAT_SCALE = 0.3f; constexpr float MOVE_DRAG_POSITION_Z = 100.5f; +constexpr DisplayId DEFAULT_DISPLAY_ID = 0; constexpr DisplayId VIRTUAL_DISPLAY_ID = 999; constexpr int32_t SUPER_FOLD_DIVIDE_FACTOR = 2; @@ -1550,7 +1551,14 @@ void SceneSession::UpdateSessionRectInner(const WSRect& rect, SizeChangeReason r DisplayId displayId = GetSessionProperty() != nullptr ? GetSessionProperty()->GetDisplayId() : DISPLAY_ID_INVALID; TLOGI(WmsLogTag::WMS_LAYOUT, "Get displayId: %{public}" PRIu64, displayId); - NotifySessionRectChange(newRequestRect, newReason, displayId, rectAnimationConfig); + auto notifyRect = newRequestRect; + if (PcFoldScreenManager::GetInstance().IsHalfFolded(GetScreenId())) { + if (clientDisplayId_ == VIRTUAL_DISPLAY_ID) { + newReason == SizeChangeReason::UNDEFINED; + } + notifyRect = rect; + } + NotifySessionRectChange(notifyRect, newReason, displayId, rectAnimationConfig); } else { if (!Session::IsScbCoreEnabled()) { SetSessionRect(rect); @@ -1563,14 +1571,29 @@ void SceneSession::UpdateSessionRectInner(const WSRect& rect, SizeChangeReason r newWinRect.ToString().c_str()); } -void SceneSession::UpdateSessionRectPosYFromClient(WSRect& rect) +void SceneSession::UpdateSessionRectPosYFromClient(SizeChangeReason reason, DisplayId configDisplayId, WSRect& rect) { if (!PcFoldScreenManager::GetInstance().IsHalfFolded(GetScreenId())) { + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, displayId: %{public}" PRIu64, + GetPersistentId(), GetScreenId()); return; } - TLOGD(WmsLogTag::WMS_LAYOUT, "windowId: %{public}d, lastUpdatedDisplayId_: %{public}" PRIu64, - GetPersistentId(), lastUpdatedDisplayId_); - if (lastUpdatedDisplayId_ != VIRTUAL_DISPLAY_ID) { + if (reason != SizeChangeReason::RESIZE) { + configDisplayId_ = configDisplayId; + } + if (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(configDisplayId_)) { + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, configDisplayId: %{public}" PRIu64, + GetPersistentId(), configDisplayId_); + return; + } + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, input: %{public}s, screenId: %{public}" PRIu64, + ", clientDisplayId: %{public}" PRIu64 ", configDisplayId: %{public}" PRIu64, + GetPersistentId(), rect.ToString().c_str(), GetScreenId(), clientDisplayId_, configDisplayId_); + if (configDisplayId == DISPLAY_ID_INVALID) { + if (clientDisplayId_ != VIRTUAL_DISPLAY_ID) { + return; + } + } else if (configDisplayId != VIRTUAL_DISPLAY_ID) { return; } const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = @@ -1578,7 +1601,7 @@ void SceneSession::UpdateSessionRectPosYFromClient(WSRect& rect) auto lowerScreenPosY = defaultDisplayRect.height_ - foldCreaseRect.height_ / SUPER_FOLD_DIVIDE_FACTOR + foldCreaseRect.height_; rect.posY_ += lowerScreenPosY; - TLOGI(WmsLogTag::WMS_LAYOUT, "windowId: %{public}d, lowerScreenPosY: %{public}d, output: %{public}s", + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, lowerScreenPosY: %{public}d, output: %{public}s", GetPersistentId(), lowerScreenPosY, rect.ToString().c_str()); } @@ -1594,7 +1617,7 @@ WSError SceneSession::UpdateSessionRect( } WSRect newRect = rect; UpdateCrossAxisOfLayout(rect); - UpdateSessionRectPosYFromClient(newRect); + UpdateSessionRectPosYFromClient(reason, moveConfiguration.displayId, newRect); if (isGlobal && WindowHelper::IsSubWindow(Session::GetWindowType()) && (systemConfig_.IsPhoneWindow() || (systemConfig_.IsPadWindow() && !IsFreeMultiWindowMode()))) { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index d029fcec12..3448850867 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -968,7 +968,7 @@ WSError Session::UpdateSizeChangeReason(SizeChangeReason reason) WSError Session::UpdateClientDisplayId(DisplayId displayId) { - if (displayId == lastUpdatedDisplayId_) { + if (displayId == clientDisplayId_) { return WSError::WS_DO_NOTHING; } if (sessionStage_ == nullptr) { @@ -976,22 +976,22 @@ WSError Session::UpdateClientDisplayId(DisplayId displayId) return WSError::WS_ERROR_NULLPTR; } TLOGI(WmsLogTag::WMS_LAYOUT, "windowId: %{public}d move display %{public}" PRIu64 " from %{public}" PRIu64, - GetPersistentId(), displayId, lastUpdatedDisplayId_); - lastUpdatedDisplayId_ = displayId; + GetPersistentId(), displayId, clientDisplayId_); + clientDisplayId_ = displayId; sessionStage_->UpdateDisplayId(displayId); return WSError::WS_OK; } -DisplayId Session::TransformGlobalRectToRelativeRect(WSRect& rect) const + +DisplayId Session::TransformGlobalRectToRelativeRect(WSRect& rect, DisplayId clientDisplayId) const { const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = PcFoldScreenManager::GetInstance().GetDisplayRects(); int32_t lowerScreenPosY = defaultDisplayRect.height_ - foldCreaseRect.height_ / SUPER_FOLD_DIVIDE_FACTOR + foldCreaseRect.height_; TLOGD(WmsLogTag::WMS_LAYOUT, "lowerScreenPosY: %{public}d", lowerScreenPosY); - DisplayId updatedDisplayId = GetScreenId(); if (rect.posY_ >= lowerScreenPosY) { - updatedDisplayId = VIRTUAL_DISPLAY_ID; + clientDisplayId = VIRTUAL_DISPLAY_ID; rect.posY_ -= lowerScreenPosY; } return updatedDisplayId; @@ -1008,21 +1008,31 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) TLOGD(WmsLogTag::WMS_LAYOUT, "Error status"); return; } + if (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(GetScreenId())) { + TLOGD(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, displayId: %{public}" PRIu64 "not need", + GetPersistentId(), GetScreenId()); + return; + } TLOGI(WmsLogTag::WMS_LAYOUT, "lastStatus: %{public}d, curStatus: %{public}d", lastScreenFoldStatus_, currScreenFoldStatus); if (currScreenFoldStatus == SuperFoldStatus::EXPANDED) { lastScreenFoldStatus_ = currScreenFoldStatus; auto ret = UpdateClientDisplayId(DEFAULT_DISPLAY_ID); - TLOGI(WmsLogTag::WMS_LAYOUT, "JustUpdateId: windowId: %{public}d, result: %{public}d", + TLOGI(WmsLogTag::WMS_LAYOUT, "JustUpdateId: winId: %{public}d, result: %{public}d", GetPersistentId(), ret); return; } + auto clientDisplayId = DEFAULT_DISPLAY_ID; + if (WindowHelper::IsSubWindow(GetWindowType()) || WindowHelper::IsSystemWindow(GetWindowType())) { + GetParentClientDisplayId(); + } WSRect lastRect = rect; - auto updatedDisplayId = TransformGlobalRectToRelativeRect(rect); + auto updatedDisplayId = TransformGlobalRectToRelativeRect(rect, clientDisplayId); auto ret = UpdateClientDisplayId(updatedDisplayId); lastScreenFoldStatus_ = currScreenFoldStatus; - TLOGI(WmsLogTag::WMS_LAYOUT, "CalculatedRect: windowId: %{public}d, input: %{public}s, output: %{public}s," - " result: %{public}d", GetPersistentId(), lastRect.ToString().c_str(), rect.ToString().c_str(), ret); + TLOGI(WmsLogTag::WMS_LAYOUT,"CalculatedRect: winId: %{public}d, input: %{public}s, output: %{public}s," + " result: %{public}d, clientDisplayId: %{public}" PRIu64, GetPersistentId(), lastRect.ToString().c_str(), + rect.ToString().c_str(), ret, updatedDisplayId); } void Session::SetSingleHandTransform(const SingleHandTransform& transform) @@ -1128,6 +1138,9 @@ __attribute__((no_sanitize("cfi"))) WSError Session::ConnectInner(const sptrSetDisplayId(clientDisplayId_); + } return WSError::WS_OK; } @@ -3908,4 +3921,29 @@ WindowMetaInfo Session::GetWindowMetaInfoForWindowInfo() const windowMetaInfo.abilityName = GetSessionInfo().abilityName_; return windowMetaInfo; } + +DisplayId Session::GetClientDisplayId() const +{ + return clientDisplayId_; +} + +DisplayId Session::SetClientDisplayId(DisplayId displayid) const +{ + clientDisplayId_ = displayid; +} + +DisplayId Session::GetParentClientDisplayId() +{ + DisplayId updatedDisplayId = DEFAULT_DISPLAY_ID; + if (auto parentSession = GetParentSession()) { + TLOGI(WmsLogTag::WMS_MAIN, "winId: %{public}d, parentWinId: %{public}d, parentClientDisplay: %{public}" PRIu64, + GetPersistentId(), parentSession->GetPersistentId(), parentSession->GetClientDisplayId()); + updatedDisplayId = parentSession->GetClientDisplayId(); + } else if (GetClientDisplayId() == VIRTUAL_DISPLAY_ID) { + TLOGI(WmsLogTag::WMS_MAIN, "winId: %{public}d, no parentSession, but init virtual display", GetPersistentId()); + clientDisplayId_ = DEFAULT_DISPLAY_ID; + updatedDisplayId = VIRTUAL_DISPLAY_ID; + } + return updatedDisplayId; +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 8c55db1bdd..27f615808e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -66,6 +66,7 @@ #include "anomaly_detection.h" #include "session/host/include/ability_info_manager.h" #include "session/host/include/multi_instance_manager.h" +#include "session/host/include/pc_fold_screen_manager.h" #include "common/include/fold_screen_state_internel.h" #include "hidump_controller.h" @@ -2874,6 +2875,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetParentPersistentId()); if (parentSession) { auto parentProperty = parentSession->GetSessionProperty(); @@ -2882,6 +2884,8 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetSubWindowLevel(parentProperty->GetSubWindowLevel() + 1); + property->SetDisplayId(parentProperty->GetDisplayId()); + parentSessionClientDisplayId = parentSession->GetClientDisplayId(); } TLOGI(WmsLogTag::WMS_LIFE, "The corner radius is %{public}f", appWindowSceneConfig_.floatCornerRadius_); @@ -2921,8 +2925,8 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetClientDisplayId(parentSessionClientDisplayId); newSession->GetSessionProperty()->SetWindowCornerRadius(property->GetWindowCornerRadius()); property->SetSystemCalling(isSystemCalling); auto errCode = newSession->ConnectInner( diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index b9be04c074..8dfeca9743 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -1538,26 +1538,26 @@ HWTEST_F(SceneSessionTest, UpdateSessionRectPosYFromClient01, Function | SmallTe PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::EXPANDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); WSRect rect = {0, 0, 0, 0}; - sceneSession->UpdateSessionRectPosYFromClient(rect); + sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, 0, rect); EXPECT_EQ(rect.posY_, 0); PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::KEYBOARD, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); rect = {0, 100, 0, 0}; - sceneSession->UpdateSessionRectPosYFromClient(rect); + sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, 0, rect); EXPECT_EQ(rect.posY_, 100); PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = PcFoldScreenManager::GetInstance().GetDisplayRects(); - sceneSession->lastUpdatedDisplayId_ = 0; + sceneSession->clientDisplayId_ = 0; rect = {0, 100, 100, 100}; - sceneSession->UpdateSessionRectPosYFromClient(rect); + sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, 0, rect); EXPECT_EQ(rect.posY_, 100); - sceneSession->lastUpdatedDisplayId_ = 999; + sceneSession->clientDisplayId_ = 999; rect = {0, 100, 100, 100}; auto rect2 = rect; - sceneSession->UpdateSessionRectPosYFromClient(rect); + sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, 0, rect); EXPECT_EQ(rect.posY_, rect2.posY_ + defaultDisplayRect.height_ + foldCreaseRect.height_ / 2); } diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 6a15b5e247..dde00cc665 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -206,22 +206,22 @@ HWTEST_F(WindowSessionTest, UpdateClientDisplayId01, Function | SmallTest | Leve { ASSERT_NE(session_, nullptr); session_->sessionStage_ = nullptr; - session_->lastUpdatedDisplayId_ = 0; + session_->clientDisplayId_ = 0; DisplayId updatedDisplayId = 0; EXPECT_EQ(session_->UpdateClientDisplayId(updatedDisplayId), WSError::WS_DO_NOTHING); - EXPECT_EQ(updatedDisplayId, session_->lastUpdatedDisplayId_); + EXPECT_EQ(updatedDisplayId, session_->clientDisplayId_); updatedDisplayId = 10; EXPECT_EQ(session_->UpdateClientDisplayId(updatedDisplayId), WSError::WS_ERROR_NULLPTR); - EXPECT_NE(updatedDisplayId, session_->lastUpdatedDisplayId_); + EXPECT_NE(updatedDisplayId, session_->clientDisplayId_); ASSERT_NE(mockSessionStage_, nullptr); session_->sessionStage_ = mockSessionStage_; updatedDisplayId = 0; EXPECT_EQ(session_->UpdateClientDisplayId(updatedDisplayId), WSError::WS_DO_NOTHING); - EXPECT_EQ(updatedDisplayId, session_->lastUpdatedDisplayId_); + EXPECT_EQ(updatedDisplayId, session_->clientDisplayId_); updatedDisplayId = 100; EXPECT_EQ(session_->UpdateClientDisplayId(updatedDisplayId), WSError::WS_OK); - EXPECT_EQ(updatedDisplayId, session_->lastUpdatedDisplayId_); + EXPECT_EQ(updatedDisplayId, session_->clientDisplayId_); } /** diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 46d74504ae..0303a09514 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -726,9 +726,9 @@ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reaso property_->SetRequestRect(wmRect); TLOGI(WmsLogTag::WMS_LAYOUT, "%{public}s, preRect:%{public}s, reason:%{public}u, hasRSTransaction:%{public}d" - ", duration:%{public}d, [name:%{public}s, id:%{public}d]", rect.ToString().c_str(), preRect.ToString().c_str(), - wmReason, config.rsTransaction_ != nullptr, config.animationDuration_, - GetWindowName().c_str(), GetPersistentId()); + ", duration:%{public}d, [name:%{public}s, id:%{public}d], clientDisplayId: %{public}" PRIu64, + rect.ToString().c_str(), preRect.ToString().c_str(), wmReason, config.rsTransaction_ != nullptr, + config.animationDuration_, GetWindowName().c_str(), GetPersistentId(), property_->GetDisplayId()); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "WindowSessionImpl::UpdateRect id: %d [%d, %d, %u, %u] reason: %u hasRSTransaction: %u", GetPersistentId(), wmRect.posX_, wmRect.posY_, wmRect.width_, wmRect.height_, wmReason, config.rsTransaction_ != nullptr); -- Gitee From 62a126b363f79ccc47fdd7119b193eea0997e156 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 6 Feb 2025 16:11:13 +0800 Subject: [PATCH 02/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 11 ++++------- window_scene/session/host/src/session.cpp | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 6a55485c32..ebd26909d9 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -582,7 +582,7 @@ public: bool IsDragAccessible() const; void SetSingleHandTransform(const SingleHandTransform& transform); SingleHandTransform GetSingleHandTransform() const; - void SetClientDisplayId(DisplayId displayId) const; + void SetClientDisplayId(DisplayId displayId); DisplayId GetClientDisplayId() const; DisplayId GetParentClientDisplayId(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 4b6f1afa9e..857da286ef 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -66,7 +66,6 @@ const std::string DLP_INDEX = "ohos.dlp.params.index"; constexpr const char* APP_CLONE_INDEX = "ohos.extra.param.key.appCloneIndex"; constexpr float MINI_FLOAT_SCALE = 0.3f; constexpr float MOVE_DRAG_POSITION_Z = 100.5f; -constexpr DisplayId DEFAULT_DISPLAY_ID = 0; constexpr DisplayId VIRTUAL_DISPLAY_ID = 999; constexpr int32_t SUPER_FOLD_DIVIDE_FACTOR = 2; @@ -1553,9 +1552,7 @@ void SceneSession::UpdateSessionRectInner(const WSRect& rect, SizeChangeReason r TLOGI(WmsLogTag::WMS_LAYOUT, "Get displayId: %{public}" PRIu64, displayId); auto notifyRect = newRequestRect; if (PcFoldScreenManager::GetInstance().IsHalfFolded(GetScreenId())) { - if (clientDisplayId_ == VIRTUAL_DISPLAY_ID) { - newReason == SizeChangeReason::UNDEFINED; - } + newReason = SizeChangeReason::UNDEFINED; notifyRect = rect; } NotifySessionRectChange(notifyRect, newReason, displayId, rectAnimationConfig); @@ -1586,14 +1583,14 @@ void SceneSession::UpdateSessionRectPosYFromClient(SizeChangeReason reason, Disp GetPersistentId(), configDisplayId_); return; } - TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, input: %{public}s, screenId: %{public}" PRIu64, + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, input: %{public}s, screenId: %{public}" PRIu64 ", clientDisplayId: %{public}" PRIu64 ", configDisplayId: %{public}" PRIu64, GetPersistentId(), rect.ToString().c_str(), GetScreenId(), clientDisplayId_, configDisplayId_); - if (configDisplayId == DISPLAY_ID_INVALID) { + if (configDisplayId_ == DISPLAY_ID_INVALID) { if (clientDisplayId_ != VIRTUAL_DISPLAY_ID) { return; } - } else if (configDisplayId != VIRTUAL_DISPLAY_ID) { + } else if (configDisplayId_ != VIRTUAL_DISPLAY_ID) { return; } const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 3448850867..4ab1504d2b 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1138,7 +1138,7 @@ __attribute__((no_sanitize("cfi"))) WSError Session::ConnectInner(const sptrSetDisplayId(clientDisplayId_); } return WSError::WS_OK; @@ -3927,7 +3927,7 @@ DisplayId Session::GetClientDisplayId() const return clientDisplayId_; } -DisplayId Session::SetClientDisplayId(DisplayId displayid) const +DisplayId Session::SetClientDisplayId(DisplayId displayid) { clientDisplayId_ = displayid; } -- Gitee From 01e50c0a691789c71b534082f774d96b01a43818 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 6 Feb 2025 16:41:41 +0800 Subject: [PATCH 03/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/src/session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 4ab1504d2b..1b83efad64 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1024,7 +1024,7 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) } auto clientDisplayId = DEFAULT_DISPLAY_ID; if (WindowHelper::IsSubWindow(GetWindowType()) || WindowHelper::IsSystemWindow(GetWindowType())) { - GetParentClientDisplayId(); + clientDisplayId = GetParentClientDisplayId(); } WSRect lastRect = rect; auto updatedDisplayId = TransformGlobalRectToRelativeRect(rect, clientDisplayId); -- Gitee From e7a07b34e32017e77236ab6213cee44b0ae50cf3 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 6 Feb 2025 17:11:52 +0800 Subject: [PATCH 04/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/src/session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 1b83efad64..7a8d6789bf 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -994,7 +994,7 @@ DisplayId Session::TransformGlobalRectToRelativeRect(WSRect& rect, DisplayId cli clientDisplayId = VIRTUAL_DISPLAY_ID; rect.posY_ -= lowerScreenPosY; } - return updatedDisplayId; + return clientDisplayId; } void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) -- Gitee From a75067a173151a27e8554042164e790720955a7f Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Thu, 6 Feb 2025 17:18:25 +0800 Subject: [PATCH 05/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/src/session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 7a8d6789bf..6b01f5c572 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3927,7 +3927,7 @@ DisplayId Session::GetClientDisplayId() const return clientDisplayId_; } -DisplayId Session::SetClientDisplayId(DisplayId displayid) +void Session::SetClientDisplayId(DisplayId displayid) { clientDisplayId_ = displayid; } -- Gitee From 084c61c3f5d01da3eb549643b21c8b84dab7e7e1 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 7 Feb 2025 13:06:34 +0800 Subject: [PATCH 06/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/session.cpp | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index ebd26909d9..186b4e1510 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -577,7 +577,7 @@ public: std::optional GetClientDragEnable() const; std::shared_ptr GetEventHandler() const; WSError UpdateClientDisplayId(DisplayId displayId); - DisplayId TransformGlobalRectToRelativeRect(WSRect& rect, DisplayId clientDisplayId = 0) const; + DisplayId TransformGlobalRectToRelativeRect(WSRect& rect) const; void UpdateClientRectPosYAndDisplayId(WSRect& rect); bool IsDragAccessible() const; void SetSingleHandTransform(const SingleHandTransform& transform); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 6b01f5c572..bfdda3d828 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -983,18 +983,21 @@ WSError Session::UpdateClientDisplayId(DisplayId displayId) } -DisplayId Session::TransformGlobalRectToRelativeRect(WSRect& rect, DisplayId clientDisplayId) const +DisplayId Session::TransformGlobalRectToRelativeRect(WSRect& rect) const { const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = PcFoldScreenManager::GetInstance().GetDisplayRects(); int32_t lowerScreenPosY = defaultDisplayRect.height_ - foldCreaseRect.height_ / SUPER_FOLD_DIVIDE_FACTOR + foldCreaseRect.height_; TLOGD(WmsLogTag::WMS_LAYOUT, "lowerScreenPosY: %{public}d", lowerScreenPosY); + DisplayId updatedDisplayId = DEFAULT_DISPLAY_ID; if (rect.posY_ >= lowerScreenPosY) { - clientDisplayId = VIRTUAL_DISPLAY_ID; + if (WindowHelper::IsMainWindow(GetWindowType())) { + updatedDisplayId = VIRTUAL_DISPLAY_ID; + } rect.posY_ -= lowerScreenPosY; } - return clientDisplayId; + return updatedDisplayId; } void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) @@ -1008,8 +1011,9 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) TLOGD(WmsLogTag::WMS_LAYOUT, "Error status"); return; } - if (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(GetScreenId())) { - TLOGD(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, displayId: %{public}" PRIu64 "not need", + if ((GetScreenId() != DISPLAY_ID_INVALID) && + (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(GetScreenId()))) { + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, displayId: %{public}" PRIu64 "not need", GetPersistentId(), GetScreenId()); return; } @@ -1022,12 +1026,11 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) GetPersistentId(), ret); return; } - auto clientDisplayId = DEFAULT_DISPLAY_ID; + WSRect lastRect = rect; + auto updatedDisplayId = TransformGlobalRectToRelativeRect(rect); if (WindowHelper::IsSubWindow(GetWindowType()) || WindowHelper::IsSystemWindow(GetWindowType())) { - clientDisplayId = GetParentClientDisplayId(); + updatedDisplayId = GetParentClientDisplayId(); } - WSRect lastRect = rect; - auto updatedDisplayId = TransformGlobalRectToRelativeRect(rect, clientDisplayId); auto ret = UpdateClientDisplayId(updatedDisplayId); lastScreenFoldStatus_ = currScreenFoldStatus; TLOGI(WmsLogTag::WMS_LAYOUT,"CalculatedRect: winId: %{public}d, input: %{public}s, output: %{public}s," -- Gitee From 58db4aee4f497e31141adbff51ecedbb46209437 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 7 Feb 2025 17:28:53 +0800 Subject: [PATCH 07/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 15 ++++++++------- window_scene/session/host/src/session.cpp | 9 +++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 186b4e1510..35b901fe1c 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -584,7 +584,7 @@ public: SingleHandTransform GetSingleHandTransform() const; void SetClientDisplayId(DisplayId displayId); DisplayId GetClientDisplayId() const; - DisplayId GetParentClientDisplayId(); + void UpdateDisplayIdByParentSession(DisplayId& updatedDisplayId); /* * Screen Lock diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 857da286ef..8b27ff3ea7 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1578,19 +1578,20 @@ void SceneSession::UpdateSessionRectPosYFromClient(SizeChangeReason reason, Disp if (reason != SizeChangeReason::RESIZE) { configDisplayId_ = configDisplayId; } - if (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(configDisplayId_)) { + if ((configDisplayId_ != DISPLAY_ID_INVALID) && + (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(configDisplayId_))) { TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, configDisplayId: %{public}" PRIu64, GetPersistentId(), configDisplayId_); return; } + auto clientDisplayId = clientDisplayId_; + if (WindowHelper::IsSubWindow(GetWindowType()) || WindowHelper::IsSystemWindow(GetWindowType())) { + updateDisplayIdByParentSession(clientDisplayId); + } TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, input: %{public}s, screenId: %{public}" PRIu64 ", clientDisplayId: %{public}" PRIu64 ", configDisplayId: %{public}" PRIu64, - GetPersistentId(), rect.ToString().c_str(), GetScreenId(), clientDisplayId_, configDisplayId_); - if (configDisplayId_ == DISPLAY_ID_INVALID) { - if (clientDisplayId_ != VIRTUAL_DISPLAY_ID) { - return; - } - } else if (configDisplayId_ != VIRTUAL_DISPLAY_ID) { + GetPersistentId(), rect.ToString().c_str(), GetScreenId(), clientDisplayId, configDisplayId_); + if (configDisplayId_ != VIRTUAL_DISPLAY_ID && clientDisplayId != VIRTUAL_DISPLAY_ID) { return; } const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index bfdda3d828..427e05aa2b 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -982,7 +982,6 @@ WSError Session::UpdateClientDisplayId(DisplayId displayId) return WSError::WS_OK; } - DisplayId Session::TransformGlobalRectToRelativeRect(WSRect& rect) const { const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = @@ -1013,7 +1012,7 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) } if ((GetScreenId() != DISPLAY_ID_INVALID) && (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(GetScreenId()))) { - TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, displayId: %{public}" PRIu64 "not need", + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, displayId: %{public}" PRIu64 " not need", GetPersistentId(), GetScreenId()); return; } @@ -1029,7 +1028,7 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) WSRect lastRect = rect; auto updatedDisplayId = TransformGlobalRectToRelativeRect(rect); if (WindowHelper::IsSubWindow(GetWindowType()) || WindowHelper::IsSystemWindow(GetWindowType())) { - updatedDisplayId = GetParentClientDisplayId(); + updateDisplayIdByParentSession(updatedDisplayId); } auto ret = UpdateClientDisplayId(updatedDisplayId); lastScreenFoldStatus_ = currScreenFoldStatus; @@ -3935,9 +3934,8 @@ void Session::SetClientDisplayId(DisplayId displayid) clientDisplayId_ = displayid; } -DisplayId Session::GetParentClientDisplayId() +void Session::UpdateDisplayIdByParentSession(DisplayId& updatedDisplayId) { - DisplayId updatedDisplayId = DEFAULT_DISPLAY_ID; if (auto parentSession = GetParentSession()) { TLOGI(WmsLogTag::WMS_MAIN, "winId: %{public}d, parentWinId: %{public}d, parentClientDisplay: %{public}" PRIu64, GetPersistentId(), parentSession->GetPersistentId(), parentSession->GetClientDisplayId()); @@ -3947,6 +3945,5 @@ DisplayId Session::GetParentClientDisplayId() clientDisplayId_ = DEFAULT_DISPLAY_ID; updatedDisplayId = VIRTUAL_DISPLAY_ID; } - return updatedDisplayId; } } // namespace OHOS::Rosen \ No newline at end of file -- Gitee From 5d7624021266e9438470b45aca45e4043f405443 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 7 Feb 2025 17:52:03 +0800 Subject: [PATCH 08/14] add code Signed-off-by: ZihaoWU --- .../src/scene_session_manager.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 27f615808e..175c0c19c9 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2874,8 +2874,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetParentPersistentId()); if (parentSession) { auto parentProperty = parentSession->GetSessionProperty(); @@ -2884,10 +2883,15 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetSubWindowLevel(parentProperty->GetSubWindowLevel() + 1); - property->SetDisplayId(parentProperty->GetDisplayId()); - parentSessionClientDisplayId = parentSession->GetClientDisplayId(); + if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { + property->SetDisplayId(DEFAULT_DISPLAY_ID); + InitClientDisplayId = parentSession->GetClientDisplayId(); + } + } + if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { + property->SetDisplayId(DEFAULT_DISPLAY_ID); + InitClientDisplayId = VIRTUAL_DISPLAY_ID; } - TLOGI(WmsLogTag::WMS_LIFE, "The corner radius is %{public}f", appWindowSceneConfig_.floatCornerRadius_); property->SetWindowCornerRadius(appWindowSceneConfig_.floatCornerRadius_); bool shouldBlock = (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT && @@ -2926,7 +2930,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetClientDisplayId(parentSessionClientDisplayId); + newSession->SetClientDisplayId(InitClientDisplayId); newSession->GetSessionProperty()->SetWindowCornerRadius(property->GetWindowCornerRadius()); property->SetSystemCalling(isSystemCalling); auto errCode = newSession->ConnectInner( -- Gitee From 3163d2519fcadecbf078257df35a425d6b8bc9e2 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 7 Feb 2025 18:25:15 +0800 Subject: [PATCH 09/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/src/scene_session.cpp | 4 ++-- window_scene/session/host/src/session.cpp | 5 ++--- window_scene/test/unittest/scene_session_test.cpp | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 8b27ff3ea7..55e62fcdf4 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1578,8 +1578,8 @@ void SceneSession::UpdateSessionRectPosYFromClient(SizeChangeReason reason, Disp if (reason != SizeChangeReason::RESIZE) { configDisplayId_ = configDisplayId; } - if ((configDisplayId_ != DISPLAY_ID_INVALID) && - (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(configDisplayId_))) { + if (configDisplayId_ != DISPLAY_ID_INVALID && + !PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(configDisplayId_)) { TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, configDisplayId: %{public}" PRIu64, GetPersistentId(), configDisplayId_); return; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 427e05aa2b..eb4a93c654 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1010,8 +1010,8 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) TLOGD(WmsLogTag::WMS_LAYOUT, "Error status"); return; } - if ((GetScreenId() != DISPLAY_ID_INVALID) && - (!PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(GetScreenId()))) { + if (GetScreenId() != DISPLAY_ID_INVALID && + !PcFoldScreenManager::GetInstance().IsHalfFoldedDisplayId(GetScreenId())) { TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, displayId: %{public}" PRIu64 " not need", GetPersistentId(), GetScreenId()); return; @@ -3942,7 +3942,6 @@ void Session::UpdateDisplayIdByParentSession(DisplayId& updatedDisplayId) updatedDisplayId = parentSession->GetClientDisplayId(); } else if (GetClientDisplayId() == VIRTUAL_DISPLAY_ID) { TLOGI(WmsLogTag::WMS_MAIN, "winId: %{public}d, no parentSession, but init virtual display", GetPersistentId()); - clientDisplayId_ = DEFAULT_DISPLAY_ID; updatedDisplayId = VIRTUAL_DISPLAY_ID; } } diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 8dfeca9743..efd24a3e28 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -1548,8 +1548,6 @@ HWTEST_F(SceneSessionTest, UpdateSessionRectPosYFromClient01, Function | SmallTe PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); - const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = - PcFoldScreenManager::GetInstance().GetDisplayRects(); sceneSession->clientDisplayId_ = 0; rect = {0, 100, 100, 100}; sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, 0, rect); @@ -1558,7 +1556,7 @@ HWTEST_F(SceneSessionTest, UpdateSessionRectPosYFromClient01, Function | SmallTe rect = {0, 100, 100, 100}; auto rect2 = rect; sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, 0, rect); - EXPECT_EQ(rect.posY_, rect2.posY_ + defaultDisplayRect.height_ + foldCreaseRect.height_ / 2); + EXPECT_EQ(rect.posY_, rect2.posY_); } /** -- Gitee From 215e421f9985d66e5b13149d0f0cbdcbffd35af1 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 7 Feb 2025 19:42:37 +0800 Subject: [PATCH 10/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/src/pc_fold_screen_manager.cpp | 4 +++- window_scene/session/host/src/scene_session.cpp | 2 +- window_scene/session/host/src/session.cpp | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/pc_fold_screen_manager.cpp b/window_scene/session/host/src/pc_fold_screen_manager.cpp index 1ca133b676..3eedc101a3 100644 --- a/window_scene/session/host/src/pc_fold_screen_manager.cpp +++ b/window_scene/session/host/src/pc_fold_screen_manager.cpp @@ -113,7 +113,9 @@ bool PcFoldScreenManager::IsHalfFoldedOnMainDisplay(DisplayId displayId) const bool PcFoldScreenManager::IsHalfFoldedDisplayId(DisplayId displayId) const { - return displayId == DEFAULT_DISPLAY_ID || displayId == VIRTUAL_DISPLAY_ID; + std::shared_lock lock(displayInfoMutex_); + return screenFoldStatus_ == SuperFoldStatus::HALF_FOLDED && + (displayId == DEFAULT_DISPLAY_ID || displayId == VIRTUAL_DISPLAY_ID); } void PcFoldScreenManager::UpdateSystemKeyboardStatus(bool hasSystemKeyboard) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 55e62fcdf4..e7f9bc209e 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1586,7 +1586,7 @@ void SceneSession::UpdateSessionRectPosYFromClient(SizeChangeReason reason, Disp } auto clientDisplayId = clientDisplayId_; if (WindowHelper::IsSubWindow(GetWindowType()) || WindowHelper::IsSystemWindow(GetWindowType())) { - updateDisplayIdByParentSession(clientDisplayId); + UpdateDisplayIdByParentSession(clientDisplayId); } TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}d, input: %{public}s, screenId: %{public}" PRIu64 ", clientDisplayId: %{public}" PRIu64 ", configDisplayId: %{public}" PRIu64, diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index eb4a93c654..31ce4ac925 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1028,7 +1028,7 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) WSRect lastRect = rect; auto updatedDisplayId = TransformGlobalRectToRelativeRect(rect); if (WindowHelper::IsSubWindow(GetWindowType()) || WindowHelper::IsSystemWindow(GetWindowType())) { - updateDisplayIdByParentSession(updatedDisplayId); + UpdateDisplayIdByParentSession(updatedDisplayId); } auto ret = UpdateClientDisplayId(updatedDisplayId); lastScreenFoldStatus_ = currScreenFoldStatus; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 175c0c19c9..a1b4221f4e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -66,7 +66,6 @@ #include "anomaly_detection.h" #include "session/host/include/ability_info_manager.h" #include "session/host/include/multi_instance_manager.h" -#include "session/host/include/pc_fold_screen_manager.h" #include "common/include/fold_screen_state_internel.h" #include "hidump_controller.h" -- Gitee From 6d5559b6647b1f7937c2259a9be3355dfa0ee1a2 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Fri, 7 Feb 2025 20:02:16 +0800 Subject: [PATCH 11/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/src/session.cpp | 2 +- .../session_manager/src/scene_session_manager.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 31ce4ac925..e40ca39f67 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1032,7 +1032,7 @@ void Session::UpdateClientRectPosYAndDisplayId(WSRect& rect) } auto ret = UpdateClientDisplayId(updatedDisplayId); lastScreenFoldStatus_ = currScreenFoldStatus; - TLOGI(WmsLogTag::WMS_LAYOUT,"CalculatedRect: winId: %{public}d, input: %{public}s, output: %{public}s," + TLOGI(WmsLogTag::WMS_LAYOUT, "CalculatedRect: winId: %{public}d, input: %{public}s, output: %{public}s," " result: %{public}d, clientDisplayId: %{public}" PRIu64, GetPersistentId(), lastRect.ToString().c_str(), rect.ToString().c_str(), ret, updatedDisplayId); } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index a1b4221f4e..9a3c7fe4eb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2873,7 +2873,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetParentPersistentId()); if (parentSession) { auto parentProperty = parentSession->GetSessionProperty(); @@ -2884,12 +2884,12 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetSubWindowLevel(parentProperty->GetSubWindowLevel() + 1); if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { property->SetDisplayId(DEFAULT_DISPLAY_ID); - InitClientDisplayId = parentSession->GetClientDisplayId(); + initClientDisplayId = parentSession->GetClientDisplayId(); } } if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { property->SetDisplayId(DEFAULT_DISPLAY_ID); - InitClientDisplayId = VIRTUAL_DISPLAY_ID; + initClientDisplayId = VIRTUAL_DISPLAY_ID; } TLOGI(WmsLogTag::WMS_LIFE, "The corner radius is %{public}f", appWindowSceneConfig_.floatCornerRadius_); property->SetWindowCornerRadius(appWindowSceneConfig_.floatCornerRadius_); @@ -2929,7 +2929,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetClientDisplayId(InitClientDisplayId); + newSession->SetClientDisplayId(initClientDisplayId); newSession->GetSessionProperty()->SetWindowCornerRadius(property->GetWindowCornerRadius()); property->SetSystemCalling(isSystemCalling); auto errCode = newSession->ConnectInner( -- Gitee From 81cc75c440faadc2ab9ac8917a59eaed8463140d Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Sat, 8 Feb 2025 10:51:28 +0800 Subject: [PATCH 12/14] add code Signed-off-by: ZihaoWU --- window_scene/session/host/include/session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 35b901fe1c..206bf3a0ae 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -757,7 +757,7 @@ protected: float clientScaleY_ = 1.0f; float clientPivotX_ = 0.0f; float clientPivotY_ = 0.0f; - DisplayId clientDisplayId_ = 0; + DisplayId clientDisplayId_ = 0; // Window displayId on the client DisplayId configDisplayId_ = 0; SuperFoldStatus lastScreenFoldStatus_ = SuperFoldStatus::UNKNOWN; -- Gitee From 2a377909657f8569a969a2fa86ecdb6045763ae3 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Sat, 8 Feb 2025 14:52:04 +0800 Subject: [PATCH 13/14] add code Signed-off-by: ZihaoWU --- .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 7b4ba55332..e7d2c5dbb1 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -841,6 +841,7 @@ private: std::vector>& filteredSessions); bool IsGetWindowLayoutInfoNeeded(const sptr& session) const; int32_t GetFoldLowerScreenPosY() const; + DisplayId updateSubWindowAndSystemWindowDisplayId(const sptr& property); /* * Window Rotate Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 9a3c7fe4eb..7d80f2399e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2873,7 +2873,6 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetParentPersistentId()); if (parentSession) { auto parentProperty = parentSession->GetSessionProperty(); @@ -2882,15 +2881,8 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetSubWindowLevel(parentProperty->GetSubWindowLevel() + 1); - if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { - property->SetDisplayId(DEFAULT_DISPLAY_ID); - initClientDisplayId = parentSession->GetClientDisplayId(); - } - } - if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { - property->SetDisplayId(DEFAULT_DISPLAY_ID); - initClientDisplayId = VIRTUAL_DISPLAY_ID; } + auto initClientDisplayId = updateSubWindowAndSystemWindowDisplayId(property); TLOGI(WmsLogTag::WMS_LIFE, "The corner radius is %{public}f", appWindowSceneConfig_.floatCornerRadius_); property->SetWindowCornerRadius(appWindowSceneConfig_.floatCornerRadius_); bool shouldBlock = (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT && @@ -13053,4 +13045,22 @@ WSError SceneSessionManager::CloneWindow(int32_t fromPersistentId, int32_t toPer return WSError::WS_OK; }, __func__); } + +DisplayId SceneSessionManager::updateSubWindowAndSystemWindowDisplayId(const sptr& property) +{ + auto initClientDisplayId = DEFAULT_DISPLAY_ID; + // SubWindow + if (auto parentSession = GetSceneSession(property->GetParentPersistentId())) { + if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { + property->SetDisplayId(DEFAULT_DISPLAY_ID); + initClientDisplayId = parentSession->GetClientDisplayId(); + } + } + // SystemWindow + if (property->GetDisplayId() == VIRTUAL_DISPLAY_ID) { + property->SetDisplayId(DEFAULT_DISPLAY_ID); + initClientDisplayId = VIRTUAL_DISPLAY_ID; + } + return initClientDisplayId; +} } // namespace OHOS::Rosen -- Gitee From 5d1b933b45e96acff9cf43f32d2ee13445273cd5 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Sat, 8 Feb 2025 15:55:38 +0800 Subject: [PATCH 14/14] add code Signed-off-by: ZihaoWU --- window_scene/session_manager/include/scene_session_manager.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index e7d2c5dbb1..8747131d68 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -841,7 +841,7 @@ private: std::vector>& filteredSessions); bool IsGetWindowLayoutInfoNeeded(const sptr& session) const; int32_t GetFoldLowerScreenPosY() const; - DisplayId updateSubWindowAndSystemWindowDisplayId(const sptr& property); + DisplayId UpdateSpecificSessionClientDisplayId(const sptr& property); /* * Window Rotate Animation diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7d80f2399e..99af0afb0b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2882,7 +2882,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrSetSubWindowLevel(parentProperty->GetSubWindowLevel() + 1); } - auto initClientDisplayId = updateSubWindowAndSystemWindowDisplayId(property); + auto initClientDisplayId = UpdateSpecificSessionClientDisplayId(property); TLOGI(WmsLogTag::WMS_LIFE, "The corner radius is %{public}f", appWindowSceneConfig_.floatCornerRadius_); property->SetWindowCornerRadius(appWindowSceneConfig_.floatCornerRadius_); bool shouldBlock = (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT && @@ -13046,7 +13046,7 @@ WSError SceneSessionManager::CloneWindow(int32_t fromPersistentId, int32_t toPer }, __func__); } -DisplayId SceneSessionManager::updateSubWindowAndSystemWindowDisplayId(const sptr& property) +DisplayId SceneSessionManager::UpdateSpecificSessionClientDisplayId(const sptr& property) { auto initClientDisplayId = DEFAULT_DISPLAY_ID; // SubWindow -- Gitee