diff --git a/wmserver/src/window_layout_policy_cascade.cpp b/wmserver/src/window_layout_policy_cascade.cpp index e9464b73..ffd756ac 100644 --- a/wmserver/src/window_layout_policy_cascade.cpp +++ b/wmserver/src/window_layout_policy_cascade.cpp @@ -444,19 +444,26 @@ Rect WindowLayoutPolicyCascade::GetCurCascadeRect(const sptr& node) const DisplayId& displayId = node->GetDisplayId(); const auto& appWindowNodeVec = *(const_cast(this)-> windowNodeMaps_[displayId][WindowRootNodeType::APP_WINDOW_NODE]); - for (auto iter = appWindowNodeVec.rbegin(); iter != appWindowNodeVec.rend(); iter++) { - WLOGFI("GetCurCascadeRect id: %{public}d,", (*iter)->GetWindowId()); - if ((*iter)->GetWindowType() != WindowType::WINDOW_TYPE_DOCK_SLICE && - (*iter)->GetWindowId() != node->GetWindowId()) { - auto property = (*iter)->GetWindowProperty(); - if (property != nullptr) { - cascadeRect = property->GetRequestRect(); + const auto& aboveAppWindowNodeVec = *(const_cast(this)-> + windowNodeMaps_[displayId][WindowRootNodeType::ABOVE_WINDOW_NODE]); + + std::vector>> roots = { aboveAppWindowNodeVec, appWindowNodeVec }; + for (auto& root : roots) { + for (auto iter = root.rbegin(); iter != root.rend(); iter++) { + if ((*iter)->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && + (*iter)->GetWindowId() != node->GetWindowId()) { + auto property = (*iter)->GetWindowProperty(); + if (property != nullptr) { + cascadeRect = property->GetRequestRect(); + } + WLOGFI("Get current cascadeRect: %{public}u [%{public}d, %{public}d, %{public}u, %{public}u]", + (*iter)->GetWindowId(), cascadeRect.posX_, cascadeRect.posY_, + cascadeRect.width_, cascadeRect.height_); + break; } - WLOGFI("get current cascadeRect :[%{public}d, %{public}d, %{public}d, %{public}d]", - cascadeRect.posX_, cascadeRect.posY_, cascadeRect.width_, cascadeRect.height_); - break; } } + if (WindowHelper::IsEmptyRect(cascadeRect)) { WLOGFI("cascade rect is empty use first cascade rect"); return cascadeRectsMap_[displayId].firstCascadeRect_; @@ -502,13 +509,13 @@ void WindowLayoutPolicyCascade::SetCascadeRect(const sptr& node) isFirstAppWindow = false; } else if (WindowHelper::IsAppWindow(property->GetWindowType()) && !isFirstAppWindow) { WLOGFI("set other app window cascade rect"); - rect= GetCurCascadeRect(node); + rect = GetCurCascadeRect(node); } else { // system window WLOGFI("set system window cascade rect"); rect = cascadeRectsMap_[node->GetDisplayId()].firstCascadeRect_; } - WLOGFI("set cascadeRect :[%{public}d, %{public}d, %{public}d, %{public}d]", + WLOGFI("set cascadeRect :[%{public}d, %{public}d, %{public}u, %{public}u]", rect.posX_, rect.posY_, rect.width_, rect.height_); node->SetRequestRect(rect); node->SetDecoStatus(true); diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 13b49c65..ac22c0e4 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -195,7 +195,9 @@ WMError WindowNodeContainer::AddWindowNodeOnWindowTree(sptr& node, s } node->requestedVisibility_ = true; if (parentNode != nullptr) { // subwindow - if (parentNode->parent_ != root) { + if (parentNode->parent_ != root && + !((node->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED)) && + (node->parent_ == aboveAppWindowNode_))) { WLOGFE("window type and parent window not match or try to add subwindow to subwindow, which is forbidden"); return WMError::WM_ERROR_INVALID_PARAM; } @@ -350,9 +352,6 @@ bool WindowNodeContainer::UpdateRSTree(sptr& node, bool isAdd, bool // add or remove window without animation updateRSTreeFunc(); } - - UpdateWindowNodeMaps(); - return true; } @@ -423,6 +422,7 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr& node) } } UpdateRSTree(node, false, node->isPlayAnimationHide_); + UpdateWindowNodeMaps(); layoutPolicy_->RemoveWindowNode(node); windowPair_->HandleRemoveWindow(node); if (WindowHelper::IsAvoidAreaWindow(node->GetWindowType())) { @@ -576,6 +576,7 @@ void WindowNodeContainer::AssignZOrder() return false; }; TraverseWindowTree(func, false); + UpdateWindowNodeMaps(); } WMError WindowNodeContainer::SetFocusWindow(uint32_t windowId)