diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 6e4313deaa23691dee8f332273b3fe56a2039417..23a401be5e9a431a7b38587a1c927d1555b5618d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8497,10 +8497,6 @@ bool SceneSessionManager::FillWindowInfo(std::vectorwid_ = static_cast(sceneSession->GetPersistentId()); } info->uiNodeId_ = sceneSession->GetUINodeId(); - WSRect wsRect = sceneSession->GetSessionGlobalRectWithSingleHandScale(); // only accessability and mmi need global - info->windowRect_ = { wsRect.posX_, wsRect.posY_, wsRect.width_, wsRect.height_ }; - auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); - info->focused_ = sceneSession->GetPersistentId() == GetFocusedSessionId(displayId); info->type_ = sceneSession->GetWindowType(); info->mode_ = sceneSession->GetWindowMode(); info->layer_ = sceneSession->GetZOrder(); @@ -8509,11 +8505,20 @@ bool SceneSessionManager::FillWindowInfo(std::vectorscaleY_ = sceneSession->GetScaleY(); info->bundleName_ = sceneSession->GetSessionInfo().bundleName_; info->touchHotAreas_ = sceneSession->GetTouchHotAreas(); - info->displayId_ = sceneSession->GetSessionProperty()->GetDisplayId(); info->isDecorEnable_ = sceneSession->GetSessionProperty()->IsDecorEnable(); + WSRect wsRect = sceneSession->GetSessionGlobalRectWithSingleHandScale(); // only accessability and mmi need global + DisplayId displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + if (PcFoldScreenManager::GetInstance().IsHalfFoldedOnMainDisplay(displayId)) { + displayId = sceneSession->TransformGlobalRectToRelativeRect(wsRect); + } + info->displayId_ = displayId; + info->focused_ = sceneSession->GetPersistentId() == GetFocusedSessionId(displayId); + info->windowRect_ = { wsRect.posX_, wsRect.posY_, wsRect.width_, wsRect.height_ }; infos.emplace_back(info); - TLOGD(WmsLogTag::WMS_ATTRIBUTE, "wid=%{public}d, inWid=%{public}d, uiNId=%{public}d, bundleName=%{public}s", - info->wid_, info->innerWid_, info->uiNodeId_, info->bundleName_.c_str()); + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "wid: %{public}d, innerWid: %{public}d, nodeId: %{public}d" + ", bundleName: %{public}s, displayId: %{public}" PRIu64 ", rect: %{public}s", + info->wid_, info->innerWid_, info->uiNodeId_, info->bundleName_.c_str(), + info->displayId_, info->windowRect_.ToString().c_str()); return true; } @@ -11709,7 +11714,12 @@ std::shared_ptr SceneSessionManager::GetDisplayRegion(DisplayId displa TLOGE(WmsLogTag::WMS_MAIN, "invalid display size of display: %{public}" PRIu64, displayId); return nullptr; } - + if (PcFoldScreenManager::GetInstance().IsHalfFolded(displayId)) { + const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = + PcFoldScreenManager::GetInstance().GetDisplayRects(); + displayHeight = virtualDisplayRect.posY_ + virtualDisplayRect.height_; + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "update display height in pc fold"); + } SkIRect rect {.fLeft = 0, .fTop = 0, .fRight = displayWidth, .fBottom = displayHeight}; auto region = std::make_shared(rect); displayRegionMap_[displayId] = region; @@ -11720,20 +11730,27 @@ std::shared_ptr SceneSessionManager::GetDisplayRegion(DisplayId displa void SceneSessionManager::UpdateDisplayRegion(const sptr& displayInfo) { if (displayInfo == nullptr) { - TLOGE(WmsLogTag::WMS_MAIN, "update display region failed, displayInfo is nullptr."); + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "update display region failed, displayInfo is nullptr."); return; } auto displayId = displayInfo->GetDisplayId(); int32_t displayWidth = displayInfo->GetWidth(); int32_t displayHeight = displayInfo->GetHeight(); if (displayWidth == 0 || displayHeight == 0) { - TLOGE(WmsLogTag::WMS_MAIN, "invalid display size of display: %{public}" PRIu64, displayId); + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "invalid display size of display: %{public}" PRIu64, displayId); return; } + if (PcFoldScreenManager::GetInstance().IsHalfFolded(displayId)) { + const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = + PcFoldScreenManager::GetInstance().GetDisplayRects(); + displayHeight = virtualDisplayRect.posY_ + virtualDisplayRect.height_; + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "update display height in pc fold"); + } SkIRect rect {.fLeft = 0, .fTop = 0, .fRight = displayWidth, .fBottom = displayHeight}; auto region = std::make_shared(rect); displayRegionMap_[displayId] = region; - TLOGI(WmsLogTag::WMS_MAIN, "update display region to w=%{public}d, h=%{public}d", displayWidth, displayHeight); + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "update display region to w: %{public}d, h: %{public}d", + displayWidth, displayHeight); } bool SceneSessionManager::GetDisplaySizeById(DisplayId displayId, int32_t& displayWidth, int32_t& displayHeight) diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 29b5a3d1a447e15384095477b8d7f70153968f29..679741159c07ec1786a4c875a13e2a8dcca0d4ae 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ -#include -#include #include #include #include +#include +#include #include "context.h" #include "interfaces/include/ws_common.h" @@ -27,8 +27,9 @@ #include "session_info.h" #include "session_manager.h" #include "session_manager/include/scene_session_manager.h" -#include "session/host/include/scene_session.h" #include "session/host/include/main_session.h" +#include "session/host/include/pc_fold_screen_controller.h" +#include "session/host/include/scene_session.h" #include "window_manager_agent.h" #include "zidl/window_manager_agent_interface.h" @@ -381,16 +382,58 @@ HWTEST_F(SceneSessionManagerTest4, UpdateDisplayRegion, Function | SmallTest | L ssm_->UpdateDisplayRegion(nullptr); sptr displayInfo = sptr::MakeSptr(); ASSERT_NE(displayInfo, nullptr); - displayInfo->SetWidth(0); + + constexpr DisplayId displayId = 0; + constexpr int32_t width = 100; + displayInfo->SetDisplayId(displayId); + displayInfo->SetWidth(width); ssm_->UpdateDisplayRegion(displayInfo); - displayInfo->SetWidth(1); - displayInfo->SetHeight(0); + constexpr int32_t height = 200; + displayInfo->SetWidth(width); + displayInfo->SetHeight(height); ssm_->UpdateDisplayRegion(displayInfo); - displayInfo->SetHeight(1); + displayInfo->SetHeight(height); + PcFoldScreenManager::GetInstance().SetDisplayInfo(displayId, SuperFoldStatus::HALF_FOLDED); + PcFoldScreenManager::GetInstance().SetDisplayRects( + WSRect::EMPTY_RECT, { 0, 0, width, height }, WSRect::EMPTY_RECT); ssm_->UpdateDisplayRegion(displayInfo); - EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr)); + ASSERT_NE(ssm_->displayRegionMap_.count(displayId), 0); + auto region = ssm_->displayRegionMap_[displayId]; + ASSERT_NE(region, nullptr); + const SkIRect& rect = region->getBounds(); + EXPECT_EQ(rect.fLeft, 0); + EXPECT_EQ(rect.fTop, 0); + EXPECT_EQ(rect.fRight, width); + EXPECT_EQ(rect.fBottom, height); +} + +/** + * @tc.name: GetDisplayRegion + * @tc.desc: GetDisplayRegion + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest4, GetDisplayRegion, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + constexpr DisplayId displayId = 0; + auto region = ssm_->GetDisplayRegion(displayId); + EXPECT_NE(region, nullptr); + + constexpr int32_t left = 0; + constexpr int32_t top = 0; + constexpr int32_t right = 100; + constexpr int32_t bottom = 200; + SkIRect rect { .fLeft = left, .fTop = top, .fRight = right, .fBottom = bottom }; + ssm_->displayRegionMap_[displayId] = std::make_shared(rect); + auto region1 = ssm_->GetDisplayRegion(displayId); + ASSERT_NE(region1, nullptr); + const SkIRect& rect1 = region1->getBounds(); + EXPECT_EQ(rect1.fLeft, 0); + EXPECT_EQ(rect1.fTop, 0); + EXPECT_EQ(rect1.fRight, right); + EXPECT_EQ(rect1.fBottom, bottom); } /**