From b16e06dccb824fee5e7ff1c6526e9c124041d0eb Mon Sep 17 00:00:00 2001 From: chenkai008 Date: Tue, 2 Jul 2024 16:54:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=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?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenkai008 --- .../include/abstract_display_controller.h | 3 +- dmserver/include/abstract_screen.h | 4 +- dmserver/include/abstract_screen_controller.h | 1 + dmserver/src/abstract_display_controller.cpp | 55 +++++++++++++---- dmserver/src/abstract_screen.cpp | 52 ++++++++++------ dmserver/src/abstract_screen_controller.cpp | 59 ++++++++++++++++++- .../abstract_display_controller_test.cpp | 4 +- .../abstract_screen_controller_test.cpp | 14 ++--- .../test/unittest/abstract_screen_test.cpp | 28 ++++----- wmserver/include/window_layout_policy.h | 4 +- wmserver/src/display_group_controller.cpp | 6 ++ wmserver/src/input_window_monitor.cpp | 3 +- wmserver/src/window_layout_policy.cpp | 4 +- 13 files changed, 175 insertions(+), 62 deletions(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 51102b0beb..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); + bool UpdateDisplaySize(sptr absDisplay, sptr info, + Point offset = Point(0, 0)); 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/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 123595a7b0..fe91d36621 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,53 @@ 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..f8f91157fa 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,20 @@ 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_); + if (rsDisplayNode_ == nullptr) { + WLOGFD("rsDisplayNode_ is nullptr"); + return; + } + + startPoint_ = startPoint; + rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); + +} + ScreenId AbstractScreen::GetScreenGroupId() const { return groupDmsId_; @@ -486,7 +501,6 @@ AbstractScreenGroup::AbstractScreenGroup(sptr screenCo AbstractScreenGroup::~AbstractScreenGroup() { rsDisplayNode_ = nullptr; - abstractScreenMap_.clear(); } sptr AbstractScreenGroup::ConvertToScreenGroupInfo() const @@ -495,13 +509,14 @@ sptr AbstractScreenGroup::ConvertToScreenGroupInfo() const if (screenGroupInfo == nullptr) { return nullptr; } + 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 +571,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 +593,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 +621,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 +633,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 +660,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 +675,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 +684,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..e9b6389b7f 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,9 +770,58 @@ DMError AbstractScreenController::SetOrientation(ScreenId screenId, Orientation abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::UPDATE_ORIENTATION); } } + + auto screenGroup = screen->GetGroup(); + if (screenGroup) { + UpdateScreenGroupLayout(screenGroup); + } + return DMError::DM_OK; } +void AbstractScreenController::UpdateScreenGroupLayout(sptr screenGroup) +{ + if (screenGroup->combination_ != ScreenCombination::SCREEN_EXPAND) { + return; + } + + auto screens = screenGroup->GetChildren(); + if (screens.size() <= 1) { + return; + } + + // 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->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; + } +} + void AbstractScreenController::SetScreenRotateAnimation( sptr& screen, ScreenId screenId, Rotation rotationAfter, bool withAnimation) { diff --git a/dmserver/test/unittest/abstract_display_controller_test.cpp b/dmserver/test/unittest/abstract_display_controller_test.cpp index 5cc9e5710d..8a46a0b5a8 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); 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..20e6ef8973 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/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) { diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 38ce238ab7..c6a0fa1f39 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 c79107da81c8d1dfb37ebe219f52f40c66735200 Mon Sep 17 00:00:00 2001 From: chenkai008 Date: Tue, 2 Jul 2024 19:05:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenkai008 --- dmserver/src/abstract_screen.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index f8f91157fa..16fffeffdd 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -261,7 +261,6 @@ void AbstractScreen::UpdateRSDisplayNode(Point startPoint) startPoint_ = startPoint; rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); - } ScreenId AbstractScreen::GetScreenGroupId() const -- Gitee