fix showWhenLocked bug

Signed-off-by: qianlf <qianliangfang@huawei.com>
Change-Id: I2ef302b356d7f63244e935c12f445af482c63a7c
This commit is contained in:
qianlf
2022-04-26 10:33:13 +08:00
parent 39b8e3fff2
commit 0acf472b25
2 changed files with 24 additions and 16 deletions
+19 -12
View File
@@ -444,19 +444,26 @@ Rect WindowLayoutPolicyCascade::GetCurCascadeRect(const sptr<WindowNode>& node)
const DisplayId& displayId = node->GetDisplayId();
const auto& appWindowNodeVec = *(const_cast<WindowLayoutPolicyCascade*>(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<WindowLayoutPolicyCascade*>(this)->
windowNodeMaps_[displayId][WindowRootNodeType::ABOVE_WINDOW_NODE]);
std::vector<std::vector<sptr<WindowNode>>> 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<WindowNode>& 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);
+5 -4
View File
@@ -195,7 +195,9 @@ WMError WindowNodeContainer::AddWindowNodeOnWindowTree(sptr<WindowNode>& node, s
}
node->requestedVisibility_ = true;
if (parentNode != nullptr) { // subwindow
if (parentNode->parent_ != root) {
if (parentNode->parent_ != root &&
!((node->GetWindowFlags() & static_cast<uint32_t>(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<WindowNode>& node, bool isAdd, bool
// add or remove window without animation
updateRSTreeFunc();
}
UpdateWindowNodeMaps();
return true;
}
@@ -423,6 +422,7 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& 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)