From 6ea7258ee6dbd8b7a8f3bb11af1bc87689cb7e2b Mon Sep 17 00:00:00 2001 From: xiahaiqin Date: Thu, 14 Jul 2022 19:10:02 +0800 Subject: [PATCH] check visibility for change focus and active window Signed-off-by: xiahaiqin Change-Id: I1eb6f29258e75fde11d1075e084accb85a78fdfc --- wmserver/src/window_node_container.cpp | 9 +++++++-- wmserver/src/window_root.cpp | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 2cfcd930..c7861787 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -415,6 +415,10 @@ bool WindowNodeContainer::UpdateRSTree(sptr& node, DisplayId display WLOGFI("UpdateRSTree windowId: %{public}d, displayId: %{public}" PRIu64", isAdd: %{public}d", node->GetWindowId(), displayId, isAdd); if (isAdd) { + if (!node->currentVisibility_) { + WLOGFI("window: %{public}d is invisible, do not need update RS tree", node->GetWindowId()); + return; + } auto& surfaceNode = node->leashWinSurfaceNode_ != nullptr ? node->leashWinSurfaceNode_ : node->surfaceNode_; dms.UpdateRSTree(displayId, surfaceNode, true); for (auto& child : node->children_) { @@ -1283,7 +1287,7 @@ sptr WindowNodeContainer::GetNextFocusableWindow(uint32_t windowId) bool previousFocusedWindowFound = false; WindowNodeOperationFunc func = [windowId, &nextFocusableWindow, &previousFocusedWindowFound]( sptr node) { - if (previousFocusedWindowFound && node->GetWindowProperty()->GetFocusable()) { + if (previousFocusedWindowFound && node->GetWindowProperty()->GetFocusable() && node->currentVisibility_) { nextFocusableWindow = node; return true; } @@ -1328,7 +1332,8 @@ sptr WindowNodeContainer::GetNextActiveWindow(uint32_t windowId) con } int index = std::distance(windowNodes.begin(), iter); for (size_t i = static_cast(index) + 1; i < windowNodes.size(); i++) { - if (windowNodes[i]->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) { + if (windowNodes[i]->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE + || !windowNodes[i]->currentVisibility_) { continue; } return windowNodes[i]; diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index f00799a0..1df3e7dd 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -419,6 +419,10 @@ void WindowRoot::DestroyLeakStartingWindow() WMError WindowRoot::PostProcessAddWindowNode(sptr& node, sptr& parentNode, sptr& container) { + if (!node->currentVisibility_) { + WLOGFI("window is isVisible, do not need process"); + return WMError::WM_DO_NOTHING; + } if (WindowHelper::IsSubWindow(node->GetWindowType())) { if (parentNode == nullptr) { WLOGFE("window type is invalid"); @@ -880,7 +884,7 @@ WMError WindowRoot::RequestActiveWindow(uint32_t windowId) WLOGFE("window container could not be found"); return WMError::WM_ERROR_NULLPTR; } - auto res = container->SetActiveWindow(windowId, false); + auto res = container->SetActiveWindow(windowId, false); WLOGFI("windowId:%{public}u, name:%{public}s, orientation:%{public}u, type:%{public}u, isMainWindow:%{public}d", windowId, node->GetWindowName().c_str(), static_cast(node->GetRequestedOrientation()), node->GetWindowType(), WindowHelper::IsMainWindow(node->GetWindowType()));