diff --git a/window_scene/session/screen/include/screen_property.h b/window_scene/session/screen/include/screen_property.h index abb35cf99cf2e316ae091755d18800cde074b679..ac829bb8c7e626669f4b216fbdb7ea76c8e9429e 100644 --- a/window_scene/session/screen/include/screen_property.h +++ b/window_scene/session/screen/include/screen_property.h @@ -42,6 +42,9 @@ public: void SetBounds(const RRect& bounds); RRect GetBounds() const; + void SetPhyBounds(const RRect& phyBounds); + RRect GetPhyBounds() const; + float GetDensity(); void SetPhyWidth(uint32_t phyWidth); @@ -92,6 +95,7 @@ private: } float rotation_ { 0.0f }; RRect bounds_; + RRect phyBounds_; uint32_t phyWidth_ { UINT32_MAX }; uint32_t phyHeight_ { UINT32_MAX }; diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index ce078a19219fd52c75c9d23a55d7e60ade17a7a6..ff4d2b006c58c9dad9429563db082bfd933b8a78 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -81,7 +81,6 @@ public: void SetScreenType(ScreenType type); ScreenId GetScreenId(); - void SetScreenProperty(ScreenProperty prop); ScreenProperty GetScreenProperty() const; void UpdatePropertyByActiveMode(); std::shared_ptr GetDisplayNode() const; @@ -106,6 +105,7 @@ public: void SetScreenRotationLockedFromJs(bool isLocked); bool IsScreenRotationLocked(); void UpdatePropertyAfterRotation(RRect bounds, int rotation); + void UpdatePropertyByFoldControl(RRect bounds, RRect phyBounds); std::string name_ { "UNKNOW" }; ScreenId screenId_ {}; @@ -135,7 +135,6 @@ private: ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; bool hasPrivateWindowForeground_ = false; std::recursive_mutex mutex_; - RRect physicalBounds_; }; class ScreenSessionGroup : public ScreenSession { diff --git a/window_scene/session/screen/src/screen_property.cpp b/window_scene/session/screen/src/screen_property.cpp index e8281ca502e0f8921c27d13f61da089e38736496..5547487c90bceceec14b4f77b347d55f7e0b096c 100644 --- a/window_scene/session/screen/src/screen_property.cpp +++ b/window_scene/session/screen/src/screen_property.cpp @@ -48,6 +48,16 @@ RRect ScreenProperty::GetBounds() const return bounds_; } +void ScreenProperty::SetPhyBounds(const RRect& phyBounds) +{ + phyBounds_ = phyBounds; +} + +RRect ScreenProperty::GetPhyBounds() const +{ + return phyBounds_; +} + float ScreenProperty::GetDensity() { return virtualPixelRatio_; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 1f1d2279d98bf5563462624dbf61061838272e2a..de3287a0625250f1d8106db7aa32cf8be9489691 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -109,8 +109,8 @@ sptr ScreenSession::ConvertToDisplayInfo() displayInfo->name_ = name_; displayInfo->SetWidth(property_.GetBounds().rect_.GetWidth()); displayInfo->SetHeight(property_.GetBounds().rect_.GetHeight()); - displayInfo->SetPhysicalWidth(physicalBounds_.rect_.GetWidth()); - displayInfo->SetPhysicalHeight(physicalBounds_.rect_.GetHeight()); + displayInfo->SetPhysicalWidth(property_.GetPhyBounds().rect_.GetWidth()); + displayInfo->SetPhysicalHeight(property_.GetPhyBounds().rect_.GetHeight()); displayInfo->SetScreenId(screenId_); displayInfo->SetDisplayId(screenId_); displayInfo->SetRefreshRate(property_.GetRefreshRate()); @@ -145,11 +145,6 @@ ScreenId ScreenSession::GetScreenId() return screenId_; } -void ScreenSession::SetScreenProperty(ScreenProperty prop) -{ - property_ = prop; -} - ScreenProperty ScreenSession::GetScreenProperty() const { return property_; @@ -166,6 +161,12 @@ void ScreenSession::UpdatePropertyByActiveMode() } } +void ScreenSession::UpdatePropertyByFoldControl(RRect bounds, RRect phyBounds) +{ + property_.SetBounds(bounds); + property_.SetPhyBounds(phyBounds); +} + std::shared_ptr ScreenSession::GetDisplayNode() const { return displayNode_; @@ -182,7 +183,6 @@ void ScreenSession::Connect() for (auto& listener : screenChangeListenerList_) { listener->OnConnect(); } - physicalBounds_ = property_.GetBounds(); } void ScreenSession::Disconnect() diff --git a/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp b/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp index fff563d9acb0e43fa361768c61ecd1521320dfca..36f4d0faaee4818487ce8bbc61866b4296ace4f1 100644 --- a/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp +++ b/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp @@ -60,8 +60,9 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod screenSession->SetDisplayNodeScreenId(screenIdMain); screenProperty_ = ScreenSessionManager::GetInstance().GetPhyScreenProperty(screenIdMain); - screenSession->SetScreenProperty(screenProperty_); - screenSession->PropertyChange(screenProperty_, ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND); + screenSession->UpdatePropertyByFoldControl(screenProperty_.GetBounds(), screenProperty_.GetPhyBounds()); + screenSession->PropertyChange(screenSession->GetScreenProperty(), + ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND); screenId_ = screenIdMain; break; } @@ -77,8 +78,9 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod screenSession->SetDisplayNodeScreenId(screenIdFull); screenProperty_ = ScreenSessionManager::GetInstance().GetPhyScreenProperty(screenIdFull); - screenSession->SetScreenProperty(screenProperty_); - screenSession->PropertyChange(screenProperty_, ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND); + screenSession->UpdatePropertyByFoldControl(screenProperty_.GetBounds(), screenProperty_.GetPhyBounds()); + screenSession->PropertyChange(screenSession->GetScreenProperty(), + ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND); screenId_ = screenIdFull; break; } diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index d19cd42c402f0c63a5350e362ab78a6ba18f3fbd..948df4e48813934a21b6328e6d74f4e19fc9c8d4 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -579,8 +579,8 @@ sptr ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre property.SetRotation(0.0f); property.SetPhyWidth(screenCapability.GetPhyWidth()); property.SetPhyHeight(screenCapability.GetPhyHeight()); + property.SetPhyBounds(screenBounds); property.SetBounds(screenBounds); - property.CalcDefaultDisplayOrientation(); if (isDensityDpiLoad_) { property.SetVirtualPixelRatio(densityDpi_); } else { @@ -588,6 +588,12 @@ sptr ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre } property.SetRefreshRate(screenRefreshRate); + if (foldScreenController_ != nullptr && screenId == 0) { + screenBounds = RRect({ 0, 0, screenMode.GetScreenHeight(), screenMode.GetScreenWidth() }, 0.0f, 0.0f); + property.SetBounds(screenBounds); + } + property.CalcDefaultDisplayOrientation(); + { std::lock_guard lock_phy(phyScreenPropMapMutex_); phyScreenPropMap_[screenId] = property;