diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index d967fcad..fda04fe8 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -35,6 +35,15 @@ enum class WindowStateChangeReason : uint32_t { NORMAL, KEYGUARD, }; + +enum class WindowUpdateReason : uint32_t { + UPDATE_ALL, + UPDATE_MODE, + UPDATE_RECT, + UPDATE_FLAGS, + UPDATE_TYPE, + UPDATE_OTHER_PROPS, +}; } } #endif // OHOS_ROSEN_WM_COMMON_INNER_H \ No newline at end of file diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 298f3cff..a9f487e9 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -33,7 +33,7 @@ public: ~WindowNodeContainer(); WMError AddWindowNode(sptr& node, sptr& parentNode); WMError RemoveWindowNode(sptr& node); - WMError UpdateWindowNode(sptr& node); + WMError UpdateWindowNode(sptr& node, WindowUpdateReason reason); WMError DestroyWindowNode(sptr& node, std::vector& windowIds); const std::vector& Destroy(); void AssignZOrder(); diff --git a/wmserver/include/window_root.h b/wmserver/include/window_root.h index b784adf3..ac5777b0 100644 --- a/wmserver/include/window_root.h +++ b/wmserver/include/window_root.h @@ -44,7 +44,7 @@ public: WMError AddWindowNode(uint32_t parentId, sptr& node); WMError RemoveWindowNode(uint32_t windowId); WMError DestroyWindow(uint32_t windowId, bool onlySelf); - WMError UpdateWindowNode(uint32_t windowId); + WMError UpdateWindowNode(uint32_t windowId, WindowUpdateReason reason); bool isVerticalDisplay(sptr& node) const; WMError RequestFocus(uint32_t windowId); diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 54b2994f..7e91d7c1 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -148,7 +148,7 @@ WMError WindowController::ResizeRect(uint32_t windowId, const Rect& rect, Window } property->SetWindowRect(newRect); - WMError res = windowRoot_->UpdateWindowNode(windowId); + WMError res = windowRoot_->UpdateWindowNode(windowId, WindowUpdateReason::UPDATE_RECT); if (res != WMError::WM_OK) { return res; } @@ -202,7 +202,7 @@ WMError WindowController::SetWindowMode(uint32_t windowId, WindowMode dstMode) return res; } } - res = windowRoot_->UpdateWindowNode(windowId); + res = windowRoot_->UpdateWindowNode(windowId, WindowUpdateReason::UPDATE_MODE); if (res != WMError::WM_OK) { WLOGFE("Set window mode failed, update node failed"); return res; @@ -315,7 +315,7 @@ WMError WindowController::SetWindowType(uint32_t windowId, WindowType type) auto property = node->GetWindowProperty(); property->SetWindowType(type); UpdateWindowAnimation(node); - WMError res = windowRoot_->UpdateWindowNode(windowId); + WMError res = windowRoot_->UpdateWindowNode(windowId, WindowUpdateReason::UPDATE_TYPE); if (res != WMError::WM_OK) { return res; } @@ -333,7 +333,7 @@ WMError WindowController::SetWindowFlags(uint32_t windowId, uint32_t flags) } auto property = node->GetWindowProperty(); property->SetWindowFlags(flags); - WMError res = windowRoot_->UpdateWindowNode(windowId); + WMError res = windowRoot_->UpdateWindowNode(windowId, WindowUpdateReason::UPDATE_FLAGS); if (res != WMError::WM_OK) { return res; } @@ -350,7 +350,7 @@ WMError WindowController::SetSystemBarProperty(uint32_t windowId, WindowType typ return WMError::WM_ERROR_NULLPTR; } node->SetSystemBarProperty(type, property); - WMError res = windowRoot_->UpdateWindowNode(windowId); + WMError res = windowRoot_->UpdateWindowNode(windowId, WindowUpdateReason::UPDATE_OTHER_PROPS); if (res != WMError::WM_OK) { return res; } diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 3ed3ef63..4c965e7b 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -137,13 +137,17 @@ WMError WindowNodeContainer::AddWindowNode(sptr& node, sptr& node) +WMError WindowNodeContainer::UpdateWindowNode(sptr& node, WindowUpdateReason reason) { if (!node->surfaceNode_) { WLOGFE("surface node is nullptr!"); return WMError::WM_ERROR_NULLPTR; } - SwitchLayoutPolicy(WindowLayoutMode::CASCADE); + if (layoutMode_ == WindowLayoutMode::TILE) { + if (WindowHelper::IsMainWindow(node->GetWindowType()) && reason != WindowUpdateReason::UPDATE_OTHER_PROPS) { + SwitchLayoutPolicy(WindowLayoutMode::CASCADE); + } + } layoutPolicy_->UpdateWindowNode(node); if (avoidController_->IsAvoidAreaNode(node)) { avoidController_->UpdateAvoidAreaNode(node); @@ -906,7 +910,7 @@ WMError WindowNodeContainer::UpdateWindowPairInfo(sptr& triggerNode, WindowMode::WINDOW_MODE_SPLIT_SECONDARY : WindowMode::WINDOW_MODE_SPLIT_PRIMARY; pairNode->SetWindowMode(pairDstMode); pairNode->GetWindowToken()->UpdateWindowMode(pairDstMode); - WMError ret = UpdateWindowNode(pairNode); + WMError ret = UpdateWindowNode(pairNode, WindowUpdateReason::UPDATE_MODE); if (ret != WMError::WM_OK) { WLOGFE("Update window pair info failed"); return ret; diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index 0f385109..0edede25 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -191,7 +191,7 @@ WMError WindowRoot::RemoveWindowNode(uint32_t windowId) return container->RemoveWindowNode(node); } -WMError WindowRoot::UpdateWindowNode(uint32_t windowId) +WMError WindowRoot::UpdateWindowNode(uint32_t windowId, WindowUpdateReason reason) { auto node = GetWindowNode(windowId); if (node == nullptr) { @@ -203,7 +203,7 @@ WMError WindowRoot::UpdateWindowNode(uint32_t windowId) WLOGFE("add window failed, window container could not be found"); return WMError::WM_ERROR_NULLPTR; } - return container->UpdateWindowNode(node); + return container->UpdateWindowNode(node, reason); } WMError WindowRoot::EnterSplitWindowMode(sptr& node)