diff --git a/dmserver/include/abstract_display.h b/dmserver/include/abstract_display.h index 3e4391d8..84cc240c 100644 --- a/dmserver/include/abstract_display.h +++ b/dmserver/include/abstract_display.h @@ -46,7 +46,6 @@ public: uint32_t GetRefreshRate() const; float GetVirtualPixelRatio() const; ScreenId GetAbstractScreenId() const; - bool BindAbstractScreen(ScreenId dmsScreenId); bool BindAbstractScreen(sptr abstractDisplay); sptr ConvertToDisplayInfo() const; Rotation GetRotation() const; diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 1d4595ef..19cd57b8 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -25,13 +25,15 @@ #include "screen.h" #include "abstract_display.h" +#include "display_change_listener.h" #include "transaction/rs_interfaces.h" #include "future.h" namespace OHOS::Rosen { class AbstractDisplayController : public RefBase { +using DisplayStateChangeListener = std::function; public: - AbstractDisplayController(std::recursive_mutex& mutex); + AbstractDisplayController(std::recursive_mutex& mutex, DisplayStateChangeListener); ~AbstractDisplayController(); WM_DISALLOW_COPY_AND_MOVE(AbstractDisplayController); @@ -66,6 +68,7 @@ private: sptr abstractScreenController_; sptr abstractScreenCallback_; OHOS::Rosen::RSInterfaces& rsInterface_; + DisplayStateChangeListener displayStateChangeListener_; class ScreenshotCallback : public SurfaceCaptureCallback, public Future> { public: diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index 49a01983..eb270b0e 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -35,11 +35,6 @@ namespace OHOS::Rosen { class DisplayManagerService : public SystemAbility, public DisplayManagerStub { -friend class DisplayManagerServiceInner; -friend class DisplayPowerController; -friend class AbstractDisplay; -friend class AbstractDisplayController; -friend class AbstractScreen; DECLARE_SYSTEM_ABILITY(DisplayManagerService); WM_DECLARE_SINGLE_INSTANCE_BASE(DisplayManagerService); @@ -82,10 +77,6 @@ public: void NotifyDisplayEvent(DisplayEvent event) override; bool SetFreeze(std::vector displayIds, bool isFreeze) override; - sptr GetAbstractDisplay(DisplayId displayId); - sptr GetAbstractScreenController(); - sptr GetDisplayByDisplayId(DisplayId displayId) const; - sptr GetDisplayByScreen(ScreenId screenId) const; ScreenId MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId) override; ScreenId MakeExpand(std::vector screenId, std::vector startPoint) override; void RemoveVirtualScreenFromGroup(std::vector screens) override; @@ -96,11 +87,11 @@ public: std::vector GetAllDisplayIds() override; bool SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override; + void RegisterDisplayChangeListener(sptr listener); private: DisplayManagerService(); ~DisplayManagerService() = default; bool Init(); - void RegisterDisplayChangeListener(sptr listener); void NotifyDisplayStateChange(DisplayId id, DisplayStateChangeType type); void SetShotScreen(ScreenId mainScreenId, std::vector shotScreenIds); ScreenId GetScreenIdByDisplayId(DisplayId displayId) const; diff --git a/dmserver/include/display_manager_service_inner.h b/dmserver/include/display_manager_service_inner.h index 1e67bcb2..dc893703 100644 --- a/dmserver/include/display_manager_service_inner.h +++ b/dmserver/include/display_manager_service_inner.h @@ -31,15 +31,15 @@ class DisplayManagerServiceInner { WM_DECLARE_SINGLE_INSTANCE(DisplayManagerServiceInner); public: - std::vector> GetAllDisplays(); - DisplayId GetDefaultDisplayId(); - const sptr GetDefaultDisplay(); - const sptr GetDisplayById(DisplayId displayId); - std::vector GetAllDisplayIds(); + std::vector> GetAllDisplays() const; + DisplayId GetDefaultDisplayId() const; + sptr GetDefaultDisplay() const; + sptr GetDisplayById(DisplayId displayId) const; + std::vector GetAllDisplayIds() const; ScreenId GetRSScreenId(DisplayId displayId) const; - const sptr GetScreenInfoByDisplayId(DisplayId displayId) const; - const sptr GetScreenModesByDisplayId(DisplayId displayId); - std::shared_ptr GetDisplaySnapshot(DisplayId); + sptr GetScreenInfoByDisplayId(DisplayId displayId) const; + sptr GetScreenModesByDisplayId(DisplayId displayId) const; + std::shared_ptr GetDisplaySnapshot(DisplayId) const; void UpdateRSTree(DisplayId displayId, std::shared_ptr& surfaceNode, bool isAdd); void RegisterDisplayChangeListener(sptr listener); }; diff --git a/dmserver/include/display_power_controller.h b/dmserver/include/display_power_controller.h index 429d6c24..d3516316 100644 --- a/dmserver/include/display_power_controller.h +++ b/dmserver/include/display_power_controller.h @@ -20,13 +20,18 @@ #include #include #include "display.h" +#include "display_change_listener.h" #include "dm_common.h" namespace OHOS { namespace Rosen { class DisplayPowerController : public RefBase { +using DisplayStateChangeListener = std::function; public: - DisplayPowerController(std::recursive_mutex& mutex) : mutex_(mutex) {} + DisplayPowerController(std::recursive_mutex& mutex, DisplayStateChangeListener listener) + : mutex_(mutex), displayStateChangeListener_(listener) + { + } virtual ~DisplayPowerController() = default; bool SuspendBegin(PowerStateChangeReason reason); @@ -38,6 +43,7 @@ private: DisplayState displayState_ { DisplayState::UNKNOWN }; bool isKeyguardDrawn_ { false }; std::recursive_mutex& mutex_; + DisplayStateChangeListener displayStateChangeListener_; }; } } diff --git a/dmserver/src/abstract_display.cpp b/dmserver/src/abstract_display.cpp index 730f9ddb..218fb9fe 100644 --- a/dmserver/src/abstract_display.cpp +++ b/dmserver/src/abstract_display.cpp @@ -123,13 +123,6 @@ FreezeFlag AbstractDisplay::GetFreezeFlag() const return freezeFlag_; } -bool AbstractDisplay::BindAbstractScreen(ScreenId dmsScreenId) -{ - sptr screenController - = DisplayManagerService::GetInstance().GetAbstractScreenController(); - return BindAbstractScreen(screenController->GetAbstractScreen(dmsScreenId)); -} - bool AbstractDisplay::BindAbstractScreen(sptr abstractScreen) { if (abstractScreen == nullptr) { diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index cfd64680..2902a6bf 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -29,8 +29,8 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "AbstractDisplayController"}; } -AbstractDisplayController::AbstractDisplayController(std::recursive_mutex& mutex) - : mutex_(mutex), rsInterface_(RSInterfaces::GetInstance()) +AbstractDisplayController::AbstractDisplayController(std::recursive_mutex& mutex, DisplayStateChangeListener listener) + : mutex_(mutex), rsInterface_(RSInterfaces::GetInstance()), displayStateChangeListener_(listener) { } @@ -185,8 +185,7 @@ void AbstractDisplayController::OnAbstractScreenDisconnect(sptr DisplayManagerAgentController::GetInstance().OnDisplayDestroy(absDisplayId); } } else if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { - DisplayManagerService::GetInstance().NotifyDisplayStateChange( - absDisplayId, DisplayStateChangeType::DESTROY); + displayStateChangeListener_(absDisplayId, DisplayStateChangeType::DESTROY); DisplayManagerAgentController::GetInstance().OnDisplayDestroy(absDisplayId); abstractDisplayMap_.erase(absDisplayId); } else { @@ -291,8 +290,7 @@ void AbstractDisplayController::ProcessDisplayUpdateOrientation(sptrSetOrientation(absScreen->orientation_); if (abstractDisplay->RequestRotation(absScreen->rotation_)) { // Notify rotation event to WMS - DisplayManagerService::GetInstance().NotifyDisplayStateChange(abstractDisplay->GetId(), - DisplayStateChangeType::UPDATE_ROTATION); + displayStateChangeListener_(abstractDisplay->GetId(), DisplayStateChangeType::UPDATE_ROTATION); } // Notify orientation event to DisplayManager sptr displayInfo = abstractDisplay->ConvertToDisplayInfo(); @@ -326,8 +324,7 @@ void AbstractDisplayController::ProcessDisplaySizeChange(sptr ab WLOGFI("Size of matchedDisplays %{public}zu", matchedDisplays.size()); for (auto iter = matchedDisplays.begin(); iter != matchedDisplays.end(); ++iter) { WLOGFI("Notify display size change. Id %{public}" PRIu64"", iter->first); - DisplayManagerService::GetInstance().NotifyDisplayStateChange( - iter->first, DisplayStateChangeType::SIZE_CHANGE); + displayStateChangeListener_(iter->first, DisplayStateChangeType::SIZE_CHANGE); DisplayManagerAgentController::GetInstance().OnDisplayChange( iter->second->ConvertToDisplayInfo(), DisplayChangeEvent::DISPLAY_SIZE_CHANGED); } @@ -375,7 +372,7 @@ void AbstractDisplayController::BindAloneScreenLocked(sptr realA WLOGI("bind display for new screen. screen:%{public}" PRIu64", display:%{public}" PRIu64"", realAbsScreen->dmsId_, dummyDisplay_->GetId()); bool updateFlag = dummyDisplay_->GetHeight() == info->height_ && dummyDisplay_->GetWidth() == info->width_; - dummyDisplay_->BindAbstractScreen(realAbsScreen->dmsId_); + dummyDisplay_->BindAbstractScreen(abstractScreenController_->GetAbstractScreen(realAbsScreen->dmsId_)); if (updateFlag) { DisplayManagerAgentController::GetInstance().OnDisplayCreate(dummyDisplay_->ConvertToDisplayInfo()); } @@ -466,7 +463,7 @@ void AbstractDisplayController::SetFreeze(std::vector displayIds, boo } // Notify freeze event to WMS - DisplayManagerService::GetInstance().NotifyDisplayStateChange(displayId, type); + displayStateChangeListener_(displayId, type); // Notify freeze event to DisplayManager sptr displayInfo = abstractDisplay->ConvertToDisplayInfo(); DisplayManagerAgentController::GetInstance().OnDisplayChange(displayInfo, event); diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 3914453d..d1d2156f 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -40,9 +40,11 @@ const bool REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(&SingletonCon } while (false) DisplayManagerService::DisplayManagerService() : SystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID, true), - abstractDisplayController_(new AbstractDisplayController(mutex_)), + abstractDisplayController_(new AbstractDisplayController(mutex_, + std::bind(&DisplayManagerService::NotifyDisplayStateChange, this, std::placeholders::_1, std::placeholders::_2))), abstractScreenController_(new AbstractScreenController(mutex_)), - displayPowerController_(new DisplayPowerController(mutex_)) + displayPowerController_(new DisplayPowerController(mutex_, + std::bind(&DisplayManagerService::NotifyDisplayStateChange, this, std::placeholders::_1, std::placeholders::_2))) { } @@ -77,6 +79,7 @@ void DisplayManagerService::RegisterDisplayChangeListener(sptrOnDisplayStateChange(id, type); } @@ -86,7 +89,7 @@ DisplayId DisplayManagerService::GetDefaultDisplayId() { ScreenId dmsScreenId = abstractScreenController_->GetDefaultAbstractScreenId(); WLOGFI("GetDefaultDisplayId %{public}" PRIu64"", dmsScreenId); - sptr display = GetDisplayByScreen(dmsScreenId); + sptr display = abstractDisplayController_->GetAbstractDisplayByScreen(dmsScreenId); if (display == nullptr) { WLOGFE("fail to get displayInfo by id: invalid display"); return DISPLAY_ID_INVALID; @@ -96,7 +99,7 @@ DisplayId DisplayManagerService::GetDefaultDisplayId() sptr DisplayManagerService::GetDisplayInfoById(DisplayId displayId) { - sptr display = GetDisplayByDisplayId(displayId); + sptr display = abstractDisplayController_->GetAbstractDisplay(displayId); if (display == nullptr) { WLOGFE("fail to get displayInfo by id: invalid display"); return nullptr; @@ -106,7 +109,7 @@ sptr DisplayManagerService::GetDisplayInfoById(DisplayId displayId) sptr DisplayManagerService::GetDisplayInfoByScreen(ScreenId screenId) { - sptr display = GetDisplayByScreen(screenId); + sptr display = abstractDisplayController_->GetAbstractDisplayByScreen(screenId); if (display == nullptr) { WLOGFE("fail to get displayInfo by screenId: invalid display"); return nullptr; @@ -114,11 +117,6 @@ sptr DisplayManagerService::GetDisplayInfoByScreen(ScreenId screenI return display->ConvertToDisplayInfo(); } -sptr DisplayManagerService::GetAbstractDisplay(DisplayId displayId) -{ - return abstractDisplayController_->GetAbstractDisplay(displayId); -} - ScreenId DisplayManagerService::CreateVirtualScreen(VirtualScreenOption option) { WM_SCOPED_TRACE("dms:CreateVirtualScreen(%s)", option.name_.c_str()); @@ -322,21 +320,6 @@ ScreenId DisplayManagerService::GetScreenIdByDisplayId(DisplayId displayId) cons return abstractDisplay->GetAbstractScreenId(); } -sptr DisplayManagerService::GetDisplayByDisplayId(DisplayId displayId) const -{ - return abstractDisplayController_->GetAbstractDisplay(displayId); -} - -sptr DisplayManagerService::GetDisplayByScreen(ScreenId screenId) const -{ - return abstractDisplayController_->GetAbstractDisplayByScreen(screenId); -} - -sptr DisplayManagerService::GetAbstractScreenController() -{ - return abstractScreenController_; -} - DisplayState DisplayManagerService::GetDisplayState(DisplayId displayId) { std::lock_guard lock(mutex_); diff --git a/dmserver/src/display_manager_service_inner.cpp b/dmserver/src/display_manager_service_inner.cpp index 21dc9e72..011accad 100644 --- a/dmserver/src/display_manager_service_inner.cpp +++ b/dmserver/src/display_manager_service_inner.cpp @@ -16,13 +16,8 @@ #include "display_manager_service_inner.h" #include -#include - -#include #include -#include -#include "abstract_display_controller.h" #include "display_manager_service.h" #include "window_manager_hilog.h" @@ -32,43 +27,43 @@ namespace { } WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerServiceInner) -DisplayId DisplayManagerServiceInner::GetDefaultDisplayId() +DisplayId DisplayManagerServiceInner::GetDefaultDisplayId() const { return DisplayManagerService::GetInstance().GetDefaultDisplayId(); } -const sptr DisplayManagerServiceInner::GetDisplayById(DisplayId displayId) +sptr DisplayManagerServiceInner::GetDisplayById(DisplayId displayId) const { - sptr display = DisplayManagerService::GetInstance().GetAbstractDisplay(displayId); + sptr display = DisplayManagerService::GetInstance().GetDisplayInfoById(displayId); if (display == nullptr) { WLOGFE("GetDisplayById can not find corresponding display!\n"); } return display; } -const sptr DisplayManagerServiceInner::GetDefaultDisplay() +sptr DisplayManagerServiceInner::GetDefaultDisplay() const { DisplayId defaultDisplayId = GetDefaultDisplayId(); if (defaultDisplayId == DISPLAY_ID_INVALID) { WLOGFE("Fail to get default displayId"); return nullptr; } - return GetDisplayById(GetDefaultDisplayId()); + return DisplayManagerService::GetInstance().GetDisplayInfoById(defaultDisplayId); } -std::vector DisplayManagerServiceInner::GetAllDisplayIds() +std::vector DisplayManagerServiceInner::GetAllDisplayIds() const { return DisplayManagerService::GetInstance().GetAllDisplayIds(); } -std::vector> DisplayManagerServiceInner::GetAllDisplays() +std::vector> DisplayManagerServiceInner::GetAllDisplays() const { - std::vector> res; + std::vector> res; auto displayIds = GetAllDisplayIds(); for (auto displayId: displayIds) { - const sptr display = GetDisplayById(displayId); + sptr display = DisplayManagerService::GetInstance().GetDisplayInfoById(displayId); if (display != nullptr) { - res.push_back(display); + res.emplace_back(display); } else { WLOGFE("GetAllDisplays display %" PRIu64" nullptr!", displayId); } @@ -87,32 +82,35 @@ ScreenId DisplayManagerServiceInner::GetRSScreenId(DisplayId displayId) const return DisplayManagerService::GetInstance().GetRSScreenId(displayId); } -const sptr DisplayManagerServiceInner::GetScreenInfoByDisplayId(DisplayId displayId) const +sptr DisplayManagerServiceInner::GetScreenInfoByDisplayId(DisplayId displayId) const { - return DisplayManagerService::GetInstance().GetScreenInfoById( - DisplayManagerService::GetInstance().GetScreenIdByDisplayId(displayId)); -} - -const sptr DisplayManagerServiceInner::GetScreenModesByDisplayId(DisplayId displayId) -{ - const sptr display = GetDisplayById(displayId); - if (display == nullptr) { + auto displayInfo = DisplayManagerService::GetInstance().GetDisplayInfoById(displayId); + if (displayInfo == nullptr) { WLOGFE("can not get display."); return nullptr; } - ScreenId dmsScreenId = display->GetAbstractScreenId(); - sptr abstractScreen = - DisplayManagerService::GetInstance().abstractScreenController_->GetAbstractScreen(dmsScreenId); - if (abstractScreen == nullptr) { + return DisplayManagerService::GetInstance().GetScreenInfoById(displayInfo->GetScreenId()); +} + +sptr DisplayManagerServiceInner::GetScreenModesByDisplayId(DisplayId displayId) const +{ + const sptr screenInfo = GetScreenInfoByDisplayId(displayId); + if (screenInfo == nullptr) { + WLOGFE("can not get display."); + return nullptr; + } + auto modes = screenInfo->GetModes(); + auto id = screenInfo->GetModeId(); + if (id >= modes.size()) { WLOGFE("can not get screenMode."); return nullptr; } - return abstractScreen->GetActiveScreenMode(); + return modes[id]; } -std::shared_ptr DisplayManagerServiceInner::GetDisplaySnapshot(DisplayId displayId) +std::shared_ptr DisplayManagerServiceInner::GetDisplaySnapshot(DisplayId displayId) const { - return DisplayManagerService::GetInstance().abstractDisplayController_->GetScreenSnapshot(displayId); + return DisplayManagerService::GetInstance().GetDisplaySnapshot(displayId); } void DisplayManagerServiceInner::RegisterDisplayChangeListener(sptr listener) diff --git a/dmserver/src/display_power_controller.cpp b/dmserver/src/display_power_controller.cpp index 9383a64b..a98fb06d 100644 --- a/dmserver/src/display_power_controller.cpp +++ b/dmserver/src/display_power_controller.cpp @@ -27,8 +27,7 @@ namespace { bool DisplayPowerController::SuspendBegin(PowerStateChangeReason reason) { WLOGFI("reason:%{public}u", reason); - DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALID, - DisplayStateChangeType::BEFORE_SUSPEND); + displayStateChangeListener_(DISPLAY_ID_INVALID, DisplayStateChangeType::BEFORE_SUSPEND); return true; } @@ -51,8 +50,7 @@ bool DisplayPowerController::SetDisplayState(DisplayState state) isKeyguardDrawn = isKeyguardDrawn_; } if (!isKeyguardDrawn) { - DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALID, - DisplayStateChangeType::BEFORE_UNLOCK); + displayStateChangeListener_(DISPLAY_ID_INVALID, DisplayStateChangeType::BEFORE_UNLOCK); } DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::DISPLAY_ON, EventStatus::BEGIN); @@ -85,8 +83,7 @@ void DisplayPowerController::NotifyDisplayEvent(DisplayEvent event) { WLOGFI("DisplayEvent:%{public}u", event); if (event == DisplayEvent::UNLOCK) { - DisplayManagerService::GetInstance().NotifyDisplayStateChange(DISPLAY_ID_INVALID, - DisplayStateChangeType::BEFORE_UNLOCK); + displayStateChangeListener_(DISPLAY_ID_INVALID, DisplayStateChangeType::BEFORE_UNLOCK); DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::DESKTOP_READY, EventStatus::BEGIN); std::lock_guard lock(mutex_); diff --git a/wmserver/include/window_root.h b/wmserver/include/window_root.h index 31160674..7dcb99ec 100644 --- a/wmserver/include/window_root.h +++ b/wmserver/include/window_root.h @@ -59,7 +59,7 @@ public: WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode); void NotifyWindowStateChange(WindowState state, WindowStateChangeReason reason); - void NotifyDisplayChange(sptr abstractDisplay); + void NotifyDisplayChange(sptr abstractDisplay); void NotifyDisplayDestroy(DisplayId displayId); void NotifySystemBarTints(); WMError RaiseZOrderForAppWindow(sptr& node); @@ -74,7 +74,7 @@ private: void UpdateFocusWindowWithWindowRemoved(const sptr& node, const sptr& container) const; std::string GenAllWindowsLogInfo() const; - bool CheckDisplayInfo(const sptr& display); + bool CheckDisplayInfo(const sptr& display); std::recursive_mutex& mutex_; std::map> windowNodeContainerMap_; diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 846750e5..48409912 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -287,8 +287,8 @@ void WindowController::NotifyDisplayStateChange(DisplayId displayId, DisplayStat void WindowController::ProcessDisplayChange(DisplayId displayId, DisplayStateChangeType type) { - const sptr abstractDisplay = DisplayManagerServiceInner::GetInstance().GetDisplayById(displayId); - if (abstractDisplay == nullptr) { + const sptr displayInfo = DisplayManagerServiceInner::GetInstance().GetDisplayById(displayId); + if (displayInfo == nullptr) { WLOGFE("get display failed displayId:%{public}" PRId64 "", displayId); return; } @@ -296,14 +296,14 @@ void WindowController::ProcessDisplayChange(DisplayId displayId, DisplayStateCha switch (type) { case DisplayStateChangeType::SIZE_CHANGE: case DisplayStateChangeType::UPDATE_ROTATION: { - windowRoot_->NotifyDisplayChange(abstractDisplay); + windowRoot_->NotifyDisplayChange(displayInfo); // Remove 'sysBarWinId_' after SystemUI resize 'systembar' - uint32_t width = static_cast(abstractDisplay->GetWidth()); - uint32_t height = abstractDisplay->GetHeight() * SYSTEM_BAR_HEIGHT_RATIO; + uint32_t width = static_cast(displayInfo->GetWidth()); + uint32_t height = displayInfo->GetHeight() * SYSTEM_BAR_HEIGHT_RATIO; Rect newRect = { 0, 0, width, height }; ResizeRect(sysBarWinId_[WindowType::WINDOW_TYPE_STATUS_BAR], newRect, WindowSizeChangeReason::DRAG); - newRect = { 0, abstractDisplay->GetHeight() - height, width, height }; + newRect = { 0, displayInfo->GetHeight() - height, width, height }; ResizeRect(sysBarWinId_[WindowType::WINDOW_TYPE_NAVIGATION_BAR], newRect, WindowSizeChangeReason::DRAG); break; } diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index f9e872e7..dbf0d178 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -33,26 +33,26 @@ sptr WindowRoot::GetOrCreateWindowNodeContainer(DisplayId d if (iter != windowNodeContainerMap_.end()) { return iter->second; } - const sptr abstractDisplay = DisplayManagerServiceInner::GetInstance().GetDisplayById(displayId); - if (abstractDisplay == nullptr) { + const sptr displayInfo = DisplayManagerServiceInner::GetInstance().GetDisplayById(displayId); + if (displayInfo == nullptr) { WLOGFE("get display failed displayId:%{public}" PRId64 "", displayId); return nullptr; } - if (!CheckDisplayInfo(abstractDisplay)) { + if (!CheckDisplayInfo(displayInfo)) { WLOGFE("get display invailed infp:%{public}" PRId64 "", displayId); return nullptr; } WLOGFI("create new window node container display width:%{public}d, height:%{public}d, screenId:%{public}" PRIu64"", - abstractDisplay->GetWidth(), abstractDisplay->GetHeight(), abstractDisplay->GetId()); - sptr container = new WindowNodeContainer(abstractDisplay->GetId(), - static_cast(abstractDisplay->GetWidth()), static_cast(abstractDisplay->GetHeight())); + displayInfo->GetWidth(), displayInfo->GetHeight(), displayInfo->GetDisplayId()); + sptr container = new WindowNodeContainer(displayInfo->GetDisplayId(), + static_cast(displayInfo->GetWidth()), static_cast(displayInfo->GetHeight())); windowNodeContainerMap_.insert(std::make_pair(displayId, container)); return container; } -bool WindowRoot::CheckDisplayInfo(const sptr& display) +bool WindowRoot::CheckDisplayInfo(const sptr& display) { const int32_t minWidth = 50; const int32_t minHeight = 50; @@ -402,15 +402,15 @@ void WindowRoot::NotifyWindowStateChange(WindowState state, WindowStateChangeRea } } -void WindowRoot::NotifyDisplayChange(sptr abstractDisplay) +void WindowRoot::NotifyDisplayChange(sptr displayInfo) { WLOGFD("window should be updated for display changed"); - auto container = GetOrCreateWindowNodeContainer(abstractDisplay->GetId()); + auto container = GetOrCreateWindowNodeContainer(displayInfo->GetDisplayId()); if (container == nullptr) { WLOGFE("can't find window node container, failed!"); return; } - container->UpdateDisplayRect(abstractDisplay->GetWidth(), abstractDisplay->GetHeight()); + container->UpdateDisplayRect(displayInfo->GetWidth(), displayInfo->GetHeight()); } void WindowRoot::NotifySystemBarTints()