From 10b02d76b69abdab6722c8b2ab5a426d873784ec Mon Sep 17 00:00:00 2001 From: chenhao Date: Wed, 31 Jan 2024 11:03:05 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E5=B1=8F?= =?UTF-8?q?=E5=90=8C=E6=98=BE=E5=92=8C=E5=A4=9A=E5=B1=8F=E5=BC=82=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic6a397c1c6deffffacd8e54a6a907e5ba780ac2a Signed-off-by: chenhao --- .../include/abstract_display_controller.h | 2 +- dmserver/include/abstract_screen.h | 4 +- dmserver/src/abstract_display_controller.cpp | 54 ++++++++++++++---- dmserver/src/abstract_screen.cpp | 44 +++++++++------ dmserver/src/abstract_screen_controller.cpp | 55 ++++++++++++++++++- wmserver/include/window_layout_policy.h | 4 +- wmserver/src/display_group_controller.cpp | 6 ++ wmserver/src/window_layout_policy.cpp | 4 +- 8 files changed, 137 insertions(+), 36 deletions(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 51102b0beb..351d9eb1b6 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -65,7 +65,7 @@ private: sptr absScreen, sptr screenGroup, sptr& absDisplay); DisplayId ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); - bool UpdateDisplaySize(sptr absDisplay, sptr info); + bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset); void SetDisplayStateChangeListener(sptr abstractDisplay, DisplayStateChangeType type); DisplayId GetDefaultDisplayId(); diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index f82d87ed26..a9e2ddf1a6 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -56,6 +56,7 @@ public: void UpdateDisplayGroupRSTree(std::shared_ptr& surfaceNode, NodeId parentNodeId, bool isAdd); void InitRSDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); void InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); + void UpdateRSDisplayNode(Point startPoint); ScreenId GetScreenGroupId() const; // colorspace, gamut @@ -76,6 +77,7 @@ public: bool isScreenGroup_ { false }; std::shared_ptr rsDisplayNode_; RSDisplayNodeConfig rSDisplayNodeConfig_; + Point startPoint_{}; ScreenId groupDmsId_ { SCREEN_ID_INVALID }; ScreenId lastGroupDmsId_ { SCREEN_ID_INVALID }; ScreenType type_ { ScreenType::REAL }; @@ -130,7 +132,7 @@ public: private: bool GetRSDisplayNodeConfig(sptr& dmsScreen, struct RSDisplayNodeConfig& config); - std::map, Point>> abstractScreenMap_; + std::map> screenMap_; }; } // namespace OHOS::Rosen #endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H \ No newline at end of file diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index 123595a7b0..0a80fc3bdb 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -450,7 +450,7 @@ void AbstractDisplayController::ProcessDisplaySizeChange(sptr ab if (absDisplay == nullptr || absDisplay->GetAbstractScreenId() != absScreen->dmsId_) { continue; } - if (UpdateDisplaySize(absDisplay, info)) { + if (UpdateDisplaySize(absDisplay, info, absScreen->startPoint_)) { matchedDisplays.insert(std::make_pair(iter->first, iter->second)); } } @@ -466,22 +466,52 @@ void AbstractDisplayController::ProcessDisplaySizeChange(sptr ab } } -bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info) +bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info, Point offset) { - if (absDisplay == nullptr || info == nullptr) { + if (absDisplay == nullptr) { WLOGFE("invalid params."); return false; } - if (info->height_ == static_cast(absDisplay->GetHeight()) && - info->width_ == static_cast(absDisplay->GetWidth())) { - WLOGFI("keep display size. display:%{public}" PRIu64"", absDisplay->GetId()); - return false; + + bool changed = false; + if (info) { + auto rotation = absDisplay->GetRotation(); + int32_t width = 0; + int32_t height = 0; + if (rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270) { + width = absDisplay->GetHeight(); + height = absDisplay->GetWidth(); + } else { + width = absDisplay->GetWidth(); + height = absDisplay->GetHeight(); + } + + if (info->width_ == static_cast(width) && + info->height_ == static_cast(height)) { + WLOGFD("keep display size. display:%{public}" PRIu64"", absDisplay->GetId()); + } else { + WLOGFD("Reset H&W. id %{public}" PRIu64", size: %{public}d %{public}d", + absDisplay->GetId(), info->width_, info->height_); + absDisplay->SetWidth(info->width_); + absDisplay->SetHeight(info->height_); + changed = true; + } + } else { + WLOGFE("mode info is null"); } - absDisplay->SetHeight(info->height_); - absDisplay->SetWidth(info->width_); - WLOGFI("Reset H&W. id %{public}" PRIu64", size: %{public}d %{public}d", - absDisplay->GetId(), absDisplay->GetWidth(), absDisplay->GetHeight()); - return true; + + if (offset.posX_ == absDisplay->GetOffsetX() && + offset.posY_ == absDisplay->GetOffsetY()) { + WLOGFD("keep display offset. display:%{public}" PRIu64"", absDisplay->GetId()); + } else { + WLOGFD("Reset offset. id %{public}" PRIu64", size: %{public}d %{public}d", + absDisplay->GetId(), offset.posX_, offset.posY_); + absDisplay->SetOffsetX(offset.posX_); + absDisplay->SetOffsetY(offset.posY_); + changed = true; + } + + return changed; } void AbstractDisplayController::ProcessVirtualPixelRatioChange(sptr absScreen) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 5ea59e9514..e16c275454 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -173,6 +173,7 @@ void AbstractScreen::SetPropertyForDisplayNode(const std::shared_ptrSetDisplayOffset(startPoint.posX_, startPoint.posY_); uint32_t width = 0; @@ -249,6 +250,14 @@ void AbstractScreen::InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, WLOGFD("InitRSDefaultDisplayNode success"); } +void AbstractScreen::UpdateRSDisplayNode(Point startPoint) +{ + WLOGD("update display offset from [%{public}d %{public}d] to [%{public}d %{public}d]", + startPoint_.posX_, startPoint_.posY_, startPoint.posX_, startPoint.posY_); + startPoint_ = startPoint; + rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); +} + ScreenId AbstractScreen::GetScreenGroupId() const { return groupDmsId_; @@ -486,7 +495,6 @@ AbstractScreenGroup::AbstractScreenGroup(sptr screenCo AbstractScreenGroup::~AbstractScreenGroup() { rsDisplayNode_ = nullptr; - abstractScreenMap_.clear(); } sptr AbstractScreenGroup::ConvertToScreenGroupInfo() const @@ -497,11 +505,10 @@ sptr AbstractScreenGroup::ConvertToScreenGroupInfo() const } FillScreenInfo(screenGroupInfo); screenGroupInfo->combination_ = combination_; - for (auto iter = abstractScreenMap_.begin(); iter != abstractScreenMap_.end(); iter++) { + for (auto iter = screenMap_.begin(); iter != screenMap_.end(); iter++) { screenGroupInfo->children_.push_back(iter->first); + screenGroupInfo->position_.push_back(iter->second->startPoint_); } - auto positions = GetChildrenPosition(); - screenGroupInfo->position_.insert(screenGroupInfo->position_.end(), positions.begin(), positions.end()); return screenGroupInfo; } @@ -556,13 +563,13 @@ bool AbstractScreenGroup::AddChild(sptr& dmsScreen, Point& start } ScreenId screenId = dmsScreen->dmsId_; WLOGFD("AbstractScreenGroup AddChild dmsScreenId: %{public}" PRIu64"", screenId); - auto iter = abstractScreenMap_.find(screenId); - if (iter != abstractScreenMap_.end()) { + auto iter = screenMap_.find(screenId); + if (iter != screenMap_.end()) { if (dmsScreen->rsDisplayNode_ != nullptr && dmsScreen->type_ == ScreenType::REAL && defaultScreenId_ == screenId) { WLOGFD("Add default screen, id: %{public}" PRIu64"", screenId); } else { - WLOGE("AddChild, abstractScreenMap_ has dmsScreen:%{public}" PRIu64"", screenId); + WLOGE("AddChild, screenMap_ has dmsScreen:%{public}" PRIu64"", screenId); return false; } } @@ -578,7 +585,7 @@ bool AbstractScreenGroup::AddChild(sptr& dmsScreen, Point& start dmsScreen->InitRSDisplayNode(config, startPoint); dmsScreen->lastGroupDmsId_ = dmsScreen->groupDmsId_; dmsScreen->groupDmsId_ = dmsId_; - abstractScreenMap_.insert(std::make_pair(screenId, std::make_pair(dmsScreen, startPoint))); + screenMap_.insert(std::make_pair(screenId, dmsScreen)); } return true; } @@ -606,6 +613,7 @@ bool AbstractScreenGroup::RemoveChild(sptr& dmsScreen) ScreenId screenId = dmsScreen->dmsId_; dmsScreen->lastGroupDmsId_ = dmsScreen->groupDmsId_; dmsScreen->groupDmsId_ = SCREEN_ID_INVALID; + dmsScreen->startPoint_ = Point(); if (dmsScreen->rsDisplayNode_ != nullptr) { dmsScreen->rsDisplayNode_->SetDisplayOffset(0, 0); dmsScreen->rsDisplayNode_->RemoveFromTree(); @@ -617,7 +625,7 @@ bool AbstractScreenGroup::RemoveChild(sptr& dmsScreen) } WLOGFD("groupDmsId:%{public}" PRIu64", screenId:%{public}" PRIu64"", dmsScreen->groupDmsId_, screenId); - return abstractScreenMap_.erase(screenId); + return screenMap_.erase(screenId); } bool AbstractScreenGroup::RemoveDefaultScreen(const sptr& dmsScreen) @@ -644,14 +652,14 @@ bool AbstractScreenGroup::RemoveDefaultScreen(const sptr& dmsScr bool AbstractScreenGroup::HasChild(ScreenId childScreen) const { - return abstractScreenMap_.find(childScreen) != abstractScreenMap_.end(); + return screenMap_.find(childScreen) != screenMap_.end(); } std::vector> AbstractScreenGroup::GetChildren() const { std::vector> res; - for (auto iter = abstractScreenMap_.begin(); iter != abstractScreenMap_.end(); iter++) { - res.push_back(iter->second.first); + for (auto iter = screenMap_.begin(); iter != screenMap_.end(); iter++) { + res.push_back(iter->second); } return res; } @@ -659,8 +667,8 @@ std::vector> AbstractScreenGroup::GetChildren() const std::vector AbstractScreenGroup::GetChildrenPosition() const { std::vector res; - for (auto iter = abstractScreenMap_.begin(); iter != abstractScreenMap_.end(); iter++) { - res.push_back(iter->second.second); + for (auto iter = screenMap_.begin(); iter != screenMap_.end(); iter++) { + res.push_back(iter->second->startPoint_); } return res; } @@ -668,16 +676,16 @@ std::vector AbstractScreenGroup::GetChildrenPosition() const Point AbstractScreenGroup::GetChildPosition(ScreenId screenId) const { Point point; - auto iter = abstractScreenMap_.find(screenId); - if (iter != abstractScreenMap_.end()) { - point = iter->second.second; + auto iter = screenMap_.find(screenId); + if (iter != screenMap_.end()) { + point = iter->second->startPoint_; } return point; } size_t AbstractScreenGroup::GetChildCount() const { - return abstractScreenMap_.size(); + return screenMap_.size(); } ScreenCombination AbstractScreenGroup::GetScreenCombination() const diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index bc134c8d2a..23705d86c4 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -588,7 +588,15 @@ sptr AbstractScreenController::AddAsSuccedentScreenLocked(s auto screenGroup = screenGroupIter->second; Point point; if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { - point = {screen->GetActiveScreenMode()->width_, 0}; + for (auto& child : screenGroup->GetChildren()) { + WLOGD("AddAsSuccedentScreenLocked. defaultScreen rotation:%d", child->rotation_); + if (child->rotation_ == Rotation::ROTATION_90 || child->rotation_ == Rotation::ROTATION_270) { + point.posX_ += child->GetActiveScreenMode()->height_; + } else { + point.posX_ += child->GetActiveScreenMode()->width_; + } + } + WLOGD("AddAsSuccedentScreenLocked. point:[%d %d]", point.posX_, point.posY_); } screenGroup->AddChild(newScreen, point); return screenGroup; @@ -762,6 +770,51 @@ DMError AbstractScreenController::SetOrientation(ScreenId screenId, Orientation abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::UPDATE_ORIENTATION); } } + + auto screenGroup = screen->GetGroup(); + if (!screenGroup) { + WLOGE("no screen group"); + return DMError::DM_ERROR_NULLPTR; + } + + if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { + // update display start point + auto screens = screenGroup->GetChildren(); + if (screens.size() > 1) { + // from left to right + std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { + return a->startPoint_.posX_ < b->startPoint_.posX_; + }); + + Point point; + int width = 0; + for (auto& screen : screens) { + WLOGD("screen: %{public}llu", screen->dmsId_); + auto mode = screen->GetActiveScreenMode(); + if (!mode) { + WLOGE("no active screen mode"); + continue; + } + + if (screen->startPoint_.posX_ != point.posX_) { + screen->UpdateRSDisplayNode(point); + if (abstractScreenCallback_ != nullptr) { + abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); + } + } + + if (screen->rotation_ == Rotation::ROTATION_90 || + screen->rotation_ == Rotation::ROTATION_270) { + width = mode->height_; + } else { + width = mode->width_; + } + + point.posX_ += width; + } + } + } + return DMError::DM_OK; } diff --git a/wmserver/include/window_layout_policy.h b/wmserver/include/window_layout_policy.h index 8a549503d8..12da59bc2e 100644 --- a/wmserver/include/window_layout_policy.h +++ b/wmserver/include/window_layout_policy.h @@ -111,8 +111,8 @@ protected: void GetStoragedAspectRatio(const sptr& node); bool IsNeedAnimationSync(WindowType type); - Rect displayGroupRect_; - Rect displayGroupLimitRect_; + Rect displayGroupRect_{}; + Rect displayGroupLimitRect_{}; bool isMultiDisplay_ = false; mutable std::map limitRectMap_; DisplayGroupWindowTree& displayGroupWindowTree_; diff --git a/wmserver/src/display_group_controller.cpp b/wmserver/src/display_group_controller.cpp index b356c51109..d641fe0df5 100644 --- a/wmserver/src/display_group_controller.cpp +++ b/wmserver/src/display_group_controller.cpp @@ -228,6 +228,12 @@ void DisplayGroupController::UpdateWindowDisplayIdIfNeeded(const sptr& node, DisplayId displayId) { + auto displays = node->GetShowingDisplays(); + if (std::find(displays.begin(), displays.end(), displayId) != displays.end()) { + WLOGFD("Alreedy show in display %{public}" PRIu64 "", displayId); + return; + } + Rect requestRect = node->GetRequestRect(); const Rect& displayRect = DisplayGroupInfo::GetInstance().GetDisplayRect(displayId); requestRect.posX_ += displayRect.posX_; diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 38ce238ab7..4aca5d323e 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -87,7 +87,9 @@ void WindowLayoutPolicy::UpdateDisplayGroupRect() for (auto& elem : DisplayGroupInfo::GetInstance().GetAllDisplayRects()) { newDisplayGroupRect.posX_ = std::min(displayGroupRect_.posX_, elem.second.posX_); newDisplayGroupRect.posY_ = std::min(displayGroupRect_.posY_, elem.second.posY_); - newDisplayGroupRect.width_ += elem.second.width_; + int32_t right = std::max(newDisplayGroupRect.posX_ + static_cast(newDisplayGroupRect.width_), + elem.second.posX_+ static_cast(elem.second.width_)); + newDisplayGroupRect.width_ = right - newDisplayGroupRect.posX_; int32_t maxHeight = std::max(newDisplayGroupRect.posY_ + static_cast(newDisplayGroupRect.height_), elem.second.posY_+ static_cast(elem.second.height_)); newDisplayGroupRect.height_ = maxHeight - newDisplayGroupRect.posY_; -- Gitee From ce4d9cbf9156c1927d08607fd5442175d972d8de Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 19:57:39 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6f05ee163f52b55231a98872e257d12627375eb8 Signed-off-by: chenhao --- dmserver/include/abstract_screen_controller.h | 1 + dmserver/src/abstract_display_controller.cpp | 3 +- dmserver/src/abstract_screen_controller.cpp | 73 ++++++++++--------- wmserver/src/window_layout_policy.cpp | 2 +- 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/dmserver/include/abstract_screen_controller.h b/dmserver/include/abstract_screen_controller.h index 274252bd7a..347dcfb5eb 100644 --- a/dmserver/include/abstract_screen_controller.h +++ b/dmserver/include/abstract_screen_controller.h @@ -120,6 +120,7 @@ private: void NotifyScreenGroupChanged(const std::vector>& screenInfo, ScreenGroupChangeEvent event) const; void OpenRotationSyncTransaction(); void CloseRotationSyncTransaction(); + void UpdateScreenGroupLayout(sptr screenGroup); class ScreenIdManager { public: diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index 0a80fc3bdb..9b8371c6f2 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -466,7 +466,8 @@ void AbstractDisplayController::ProcessDisplaySizeChange(sptr ab } } -bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info, Point offset) +bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info, + Point offset) { if (absDisplay == nullptr) { WLOGFE("invalid params."); diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index 23705d86c4..ce2e0923e2 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -772,50 +772,53 @@ DMError AbstractScreenController::SetOrientation(ScreenId screenId, Orientation } auto screenGroup = screen->GetGroup(); - if (!screenGroup) { - WLOGE("no screen group"); - return DMError::DM_ERROR_NULLPTR; + if (screenGroup) { + UpdateScreenGroupLayout(screenGroup); } - if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { - // update display start point - auto screens = screenGroup->GetChildren(); - if (screens.size() > 1) { - // from left to right - std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { - return a->startPoint_.posX_ < b->startPoint_.posX_; - }); - - Point point; - int width = 0; - for (auto& screen : screens) { - WLOGD("screen: %{public}llu", screen->dmsId_); - auto mode = screen->GetActiveScreenMode(); - if (!mode) { - WLOGE("no active screen mode"); - continue; - } + return DMError::DM_OK; +} - if (screen->startPoint_.posX_ != point.posX_) { - screen->UpdateRSDisplayNode(point); - if (abstractScreenCallback_ != nullptr) { - abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); - } - } +void AbstractScreenController::UpdateScreenGroupLayout(sptr screenGroup) +{ + if (screenGroup->combination_ != ScreenCombination::SCREEN_EXPAND) { + return; + } - if (screen->rotation_ == Rotation::ROTATION_90 || - screen->rotation_ == Rotation::ROTATION_270) { - width = mode->height_; - } else { - width = mode->width_; + // update display start point + auto screens = screenGroup->GetChildren(); + if (screens.size() > 1) { + // from left to right + std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { + return a->startPoint_.posX_ < b->startPoint_.posX_; + }); + + Point point; + int width = 0; + for (auto& screen : screens) { + auto mode = screen->GetActiveScreenMode(); + if (!mode) { + WLOGE("no active screen mode"); + continue; + } + + if (screen->startPoint_.posX_ != point.posX_) { + screen->UpdateRSDisplayNode(point); + if (abstractScreenCallback_ != nullptr) { + abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); } + } - point.posX_ += width; + if (screen->rotation_ == Rotation::ROTATION_90 || + screen->rotation_ == Rotation::ROTATION_270) { + width = mode->height_; + } else { + width = mode->width_; } + + point.posX_ += width; } } - - return DMError::DM_OK; } void AbstractScreenController::SetScreenRotateAnimation( diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 4aca5d323e..c6a0fa1f39 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -88,7 +88,7 @@ void WindowLayoutPolicy::UpdateDisplayGroupRect() newDisplayGroupRect.posX_ = std::min(displayGroupRect_.posX_, elem.second.posX_); newDisplayGroupRect.posY_ = std::min(displayGroupRect_.posY_, elem.second.posY_); int32_t right = std::max(newDisplayGroupRect.posX_ + static_cast(newDisplayGroupRect.width_), - elem.second.posX_+ static_cast(elem.second.width_)); + elem.second.posX_+ static_cast(elem.second.width_)); newDisplayGroupRect.width_ = right - newDisplayGroupRect.posX_; int32_t maxHeight = std::max(newDisplayGroupRect.posY_ + static_cast(newDisplayGroupRect.height_), elem.second.posY_+ static_cast(elem.second.height_)); -- Gitee From e6914f7b8ea0ec8395b8cdb81964f32b389ae03b Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 21:33:46 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenhao Change-Id: Iec10cf620afbcdc08f63ba737662c9391c0016c4 --- dmserver/src/abstract_screen_controller.cpp | 55 +++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index ce2e0923e2..d58eb4d4b4 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -785,39 +785,40 @@ void AbstractScreenController::UpdateScreenGroupLayout(sptr return; } - // update display start point auto screens = screenGroup->GetChildren(); - if (screens.size() > 1) { - // from left to right - std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { - return a->startPoint_.posX_ < b->startPoint_.posX_; - }); - - Point point; - int width = 0; - for (auto& screen : screens) { - auto mode = screen->GetActiveScreenMode(); - if (!mode) { - WLOGE("no active screen mode"); - continue; - } + if (screens.size() <= 1) { + return; + } - if (screen->startPoint_.posX_ != point.posX_) { - screen->UpdateRSDisplayNode(point); - if (abstractScreenCallback_ != nullptr) { - abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); - } - } + // update display node's start point from left to right. + std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { + return a->startPoint_.posX_ < b->startPoint_.posX_; + }); + + Point point; + int width = 0; + for (auto& screen : screens) { + auto mode = screen->GetActiveScreenMode(); + if (!mode) { + WLOGE("no active screen mode"); + continue; + } - if (screen->rotation_ == Rotation::ROTATION_90 || - screen->rotation_ == Rotation::ROTATION_270) { - width = mode->height_; - } else { - width = mode->width_; + if (screen->startPoint_.posX_ != point.posX_) { + screen->UpdateRSDisplayNode(point); + if (abstractScreenCallback_ != nullptr) { + abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); } + } - point.posX_ += width; + if (screen->rotation_ == Rotation::ROTATION_90 || + screen->rotation_ == Rotation::ROTATION_270) { + width = mode->height_; + } else { + width = mode->width_; } + + point.posX_ += width; } } -- Gitee From 35c927d6ca8a51afe7c563788c5e98a1b044d313 Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 22:17:26 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenhao Change-Id: I6d6fe17cd46ebcdfa40c1f45c76a8874c32921db --- .../include/abstract_display_controller.h | 2 +- .../abstract_display_controller_test.cpp | 4 +-- .../abstract_screen_controller_test.cpp | 14 ++++------ .../test/unittest/abstract_screen_test.cpp | 28 +++++++++---------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 351d9eb1b6..67a6eb956f 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -65,7 +65,7 @@ private: sptr absScreen, sptr screenGroup, sptr& absDisplay); DisplayId ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); - bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset); + bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset = Point(0, 0)); void SetDisplayStateChangeListener(sptr abstractDisplay, DisplayStateChangeType type); DisplayId GetDefaultDisplayId(); diff --git a/dmserver/test/unittest/abstract_display_controller_test.cpp b/dmserver/test/unittest/abstract_display_controller_test.cpp index e48c879a4f..1f85c86864 100644 --- a/dmserver/test/unittest/abstract_display_controller_test.cpp +++ b/dmserver/test/unittest/abstract_display_controller_test.cpp @@ -121,7 +121,7 @@ HWTEST_F(AbstractDisplayControllerTest, OnAbstractScreenConnectAndDisConnect02, { auto group = absScreen_->GetGroup(); EXPECT_NE(nullptr, group); - group->abstractScreenMap_.insert(std::make_pair(100, std::make_pair(absScreen_, Point(0, 0)))); // 100 is test data + group->screenMap_.insert(std::make_pair(100, absScreen_)); // 100 is test data group->combination_ = ScreenCombination::SCREEN_MIRROR; absDisplayController_->OnAbstractScreenConnect(absScreen_); absDisplayController_->OnAbstractScreenDisconnect(absScreen_); @@ -136,7 +136,7 @@ HWTEST_F(AbstractDisplayControllerTest, OnAbstractScreenConnectAndDisConnect03, { auto group = absScreen_->GetGroup(); EXPECT_NE(nullptr, group); - group->abstractScreenMap_.insert(std::make_pair(100, std::make_pair(absScreen_, Point(0, 0)))); // 100 is test data + group->screenMap_.insert(std::make_pair(100, absScreen_)); // 100 is test data group->combination_ = ScreenCombination::SCREEN_EXPAND; absDisplayController_->OnAbstractScreenConnect(absScreen_); absDisplayController_->OnAbstractScreenDisconnect(absScreen_); diff --git a/dmserver/test/unittest/abstract_screen_controller_test.cpp b/dmserver/test/unittest/abstract_screen_controller_test.cpp index dceb59e4a4..35cb1046f4 100644 --- a/dmserver/test/unittest/abstract_screen_controller_test.cpp +++ b/dmserver/test/unittest/abstract_screen_controller_test.cpp @@ -423,10 +423,8 @@ HWTEST_F(AbstractScreenControllerTest, RemoveChildFromGroup01, Function | SmallT { sptr screen = screenVec[0]; ScreenId dmsId = screen->dmsId_; - Point point; - auto p = std::make_pair(screen, point); sptr screenGroup = absController_->dmsScreenGroupMap_[0]; - screenGroup->abstractScreenMap_.insert(std::make_pair(dmsId, p)); + screenGroup->screenMap_.insert(std::make_pair(dmsId, screen)); ASSERT_EQ(true, absController_->RemoveChildFromGroup(screen, screenGroup)); } /** @@ -652,9 +650,8 @@ HWTEST_F(AbstractScreenControllerTest, ChangeScreenGroup01, Function | SmallTest { sptr group = screenGroupVec[0]; Point point; - auto abs2pointPair = std::make_pair(screenVec[0], point); - group->abstractScreenMap_.insert(std::make_pair(0, abs2pointPair)); - group->abstractScreenMap_.insert(std::make_pair(1, abs2pointPair)); + group->screenMap_.insert(std::make_pair(0, screenVec[0])); + group->screenMap_.insert(std::make_pair(1, screenVec[0])); std::vector startPoints; std::vector screens; for (ScreenId i = 0; i < 7; ++i) { @@ -676,9 +673,8 @@ HWTEST_F(AbstractScreenControllerTest, ChangeScreenGroup02, Function | SmallTest { sptr group = screenGroupVec[0]; Point point; - auto abs2pointPair = std::make_pair(screenVec[0], point); - group->abstractScreenMap_.insert(std::make_pair(0, abs2pointPair)); - group->abstractScreenMap_.insert(std::make_pair(1, abs2pointPair)); + group->screenMap_.insert(std::make_pair(0, screenVec[0])); + group->screenMap_.insert(std::make_pair(1, screenVec[0])); std::vector startPoints; std::vector screens; for (ScreenId i = 0; i < 7; ++i) { diff --git a/dmserver/test/unittest/abstract_screen_test.cpp b/dmserver/test/unittest/abstract_screen_test.cpp index aa41be2eb6..c37ce01f38 100644 --- a/dmserver/test/unittest/abstract_screen_test.cpp +++ b/dmserver/test/unittest/abstract_screen_test.cpp @@ -273,8 +273,8 @@ HWTEST_F(AbstractScreenTest, GetSourceMode, Function | SmallTest | Level3) HWTEST_F(AbstractScreenTest, ConvertToScreenGroupInfo, Function | SmallTest | Level3) { Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); sptr result = absScreenGroup_->ConvertToScreenGroupInfo(); EXPECT_EQ(result->children_[0], 10086); } @@ -300,8 +300,8 @@ HWTEST_F(AbstractScreenTest, GetRSDisplayNodeConfig, Function | SmallTest | Leve result = absScreenGroup_->GetRSDisplayNodeConfig(absTest, config_); EXPECT_FALSE(result); Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); absScreenGroup_->mirrorScreenId_ = 10086; EXPECT_FALSE(result); } @@ -313,7 +313,7 @@ HWTEST_F(AbstractScreenTest, GetRSDisplayNodeConfig, Function | SmallTest | Leve */ HWTEST_F(AbstractScreenTest, AddChild01, Function | SmallTest | Level3) { - absScreenGroup_->abstractScreenMap_.clear(); + absScreenGroup_->screenMap_.clear(); sptr absTest = nullptr; Point point_(159, 357); bool result = absScreenGroup_->AddChild(absTest, point_); @@ -343,12 +343,12 @@ HWTEST_F(AbstractScreenTest, AddChild01, Function | SmallTest | Level3) */ HWTEST_F(AbstractScreenTest, AddChild02, Function | SmallTest | Level3) { - absScreenGroup_->abstractScreenMap_.clear(); + absScreenGroup_->screenMap_.clear(); Point point_(159, 357); absScreenGroup_->mirrorScreenId_ = 10086; absScreenGroup_->combination_ = ScreenCombination::SCREEN_MIRROR; - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({0, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({0, absScreen_}); absScreen_->rsDisplayNode_ = nullptr; bool result = absScreenGroup_->AddChild(absScreen_, point_); EXPECT_FALSE(result); @@ -406,8 +406,8 @@ HWTEST_F(AbstractScreenTest, RemoveChild02, Function | SmallTest | Level3) Point point_(159, 357); struct RSDisplayNodeConfig config; absScreen_->rsDisplayNode_ = std::make_shared(config); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({0, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({0, absScreen_}); bool result = absScreenGroup_->RemoveChild(absScreen_); ASSERT_TRUE(result); } @@ -441,8 +441,8 @@ HWTEST_F(AbstractScreenTest, RemoveDefaultScreen, Function | SmallTest | Level3) HWTEST_F(AbstractScreenTest, GetChildren, Function | SmallTest | Level3) { Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); std::vector> result = absScreenGroup_->GetChildren(); ASSERT_EQ(result[0], absScreen_); } @@ -455,8 +455,8 @@ HWTEST_F(AbstractScreenTest, GetChildren, Function | SmallTest | Level3) HWTEST_F(AbstractScreenTest, GetChildrenPosition, Function | SmallTest | Level3) { Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); std::vector result = absScreenGroup_->GetChildrenPosition(); EXPECT_EQ(result[0].posX_, 159); EXPECT_EQ(result[0].posY_, 357); -- Gitee From b783e428e1178a6d55066676076d5cf6345b44eb Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 22:30:31 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenhao Change-Id: I2e1a7069d06ecb4b6e129dc8b854ef701aeb8dc9 --- dmserver/include/abstract_display_controller.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 67a6eb956f..33ff7eea8e 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -65,7 +65,8 @@ private: sptr absScreen, sptr screenGroup, sptr& absDisplay); DisplayId ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); - bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset = Point(0, 0)); + bool UpdateDisplaySize(sptr absDisplay, sptr info, + Point offset = Point(0, 0)); void SetDisplayStateChangeListener(sptr abstractDisplay, DisplayStateChangeType type); DisplayId GetDefaultDisplayId(); -- Gitee From 615002c26e67744f5d214306e3c4bc314bddb39b Mon Sep 17 00:00:00 2001 From: ludao Date: Tue, 6 Feb 2024 16:26:48 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ludao Change-Id: I5912ed6ae9866a4f15cf36a0295ef8fa8263ab72 --- dmserver/src/abstract_screen.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index e16c275454..472a86bda7 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -254,6 +254,11 @@ void AbstractScreen::UpdateRSDisplayNode(Point startPoint) { WLOGD("update display offset from [%{public}d %{public}d] to [%{public}d %{public}d]", startPoint_.posX_, startPoint_.posY_, startPoint.posX_, startPoint.posY_); + if (rsDisplayNode_ == nullptr) { + WLOGFD("rsDisplayNode_ is nullptr"); + return; + } + startPoint_ = startPoint; rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); } -- Gitee From eba697ea79fcf1f9f6f787be2fa3c78002f90220 Mon Sep 17 00:00:00 2001 From: ludao Date: Wed, 7 Feb 2024 14:34:36 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=A4=9A=E6=A8=A1?= =?UTF-8?q?=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ludao Change-Id: I8d9e38cbe0bba88ec93a91a8efa33401f73e55ee --- wmserver/src/input_window_monitor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wmserver/src/input_window_monitor.cpp b/wmserver/src/input_window_monitor.cpp index fe20f45693..dca2e3d584 100644 --- a/wmserver/src/input_window_monitor.cpp +++ b/wmserver/src/input_window_monitor.cpp @@ -124,9 +124,10 @@ void InputWindowMonitor::UpdateDisplayInfo(const std::vector>& .width = static_cast(displayWidth), .height = static_cast(displayHeight), .dpi = displayInfo->GetDpi(), - .name = (std::stringstream("display ")<GetDisplayId()).str(), + .name = "display " + std::to_string(displayInfo->GetDisplayId()), .uniq = "default" + std::to_string(displayInfo->GetDisplayId()), .direction = GetDisplayDirectionForMmi(displayInfo->GetRotation()), + .displayDirection = GetDisplayDirectionForMmi(displayInfo->GetRotation()), }; auto displayIter = std::find_if(displayInfoVector.begin(), displayInfoVector.end(), [&display](MMI::DisplayInfo& displayInfoTmp) { -- Gitee