From 9edd17c373c333dd92bcf92288c9de1b669e9ac7 Mon Sep 17 00:00:00 2001 From: huatong Date: Tue, 10 Oct 2023 20:05:54 +0800 Subject: [PATCH] adjust foldscreen initial size and physical size Signed-off-by: huatong --- .../session/screen/include/screen_property.h | 4 ++++ .../session/screen/include/screen_session.h | 3 +-- .../session/screen/src/screen_property.cpp | 10 ++++++++++ .../session/screen/src/screen_session.cpp | 16 ++++++++-------- .../dual_display_device_policy.cpp | 10 ++++++---- .../src/screen_session_manager.cpp | 8 +++++++- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/window_scene/session/screen/include/screen_property.h b/window_scene/session/screen/include/screen_property.h index abb35cf99c..ac829bb8c7 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 ce078a1921..ff4d2b006c 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 e8281ca502..5547487c90 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 1f1d2279d9..de3287a062 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 fff563d9ac..36f4d0faae 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 d19cd42c40..948df4e488 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; -- Gitee