/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ROSEN_WINDOW_NODE_CONTAINER_H #define OHOS_ROSEN_WINDOW_NODE_CONTAINER_H #include #include "avoid_area_controller.h" #include "display_info.h" #include "minimize_app.h" #include "display_group_controller.h" #include "display_group_info.h" #include "window_layout_policy.h" #include "window_manager.h" #include "window_node.h" #include "window_zorder_policy.h" #include "wm_common.h" #include "wm_common_inner.h" #include "window_pair.h" namespace OHOS { namespace Rosen { using WindowNodeOperationFunc = std::function)>; // return true indicates to stop traverse class WindowNodeContainer : public RefBase { public: WindowNodeContainer(const sptr& displayInfo, ScreenId displayGroupId); ~WindowNodeContainer(); WMError ShowStartingWindow(sptr& node); WMError AddWindowNode(sptr& node, sptr& parentNode); WMError RemoveWindowNode(sptr& node); WMError HandleRemoveWindow(sptr& node); WMError UpdateWindowNode(sptr& node, WindowUpdateReason reason); WMError DestroyWindowNode(sptr& node, std::vector& windowIds); const std::vector& Destroy(); void AssignZOrder(); WMError SetFocusWindow(uint32_t windowId); uint32_t GetFocusWindow() const; WMError SetActiveWindow(uint32_t windowId, bool byRemoved); uint32_t GetActiveWindow() const; void SetDisplayBrightness(float brightness); float GetDisplayBrightness() const; void SetBrightnessWindow(uint32_t windowId); uint32_t GetBrightnessWindow() const; uint32_t ToOverrideBrightness(float brightness); void UpdateBrightness(uint32_t id, bool byRemoved); void HandleKeepScreenOn(const sptr& node, bool requireLock); std::vector GetAvoidAreaByType(AvoidAreaType avoidAreaType, DisplayId displayId); WMError MinimizeStructuredAppWindowsExceptSelf(const sptr& node); void TraverseContainer(std::vector>& windowNodes) const; uint64_t GetScreenId(DisplayId displayId) const; Rect GetDisplayRect(DisplayId displayId) const; std::unordered_map GetExpectImmersiveProperty() const; void NotifyAccessibilityWindowInfo(const sptr& windowId, WindowUpdateType type) const; int GetWindowCountByType(WindowType windowType); bool IsForbidDockSliceMove(DisplayId displayId) const; void OnAvoidAreaChange(const std::vector& avoidAreas, DisplayId displayId); bool isVerticalDisplay(DisplayId displayId) const; WMError RaiseZOrderForAppWindow(sptr& node, sptr& parentNode); sptr GetNextFocusableWindow(uint32_t windowId) const; sptr GetNextActiveWindow(uint32_t windowId) const; void MinimizeAllAppWindows(DisplayId displayId); void MinimizeOldestAppWindow(); WMError ToggleShownStateForAllAppWindows(std::function restoreFunc, bool restore); void RestoreAllAppWindows(std::function restoreFunc); bool IsAppWindowsEmpty() const; void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason); void NotifySystemBarTints(std::vector displayIdVec); void NotifySystemBarDismiss(sptr& node); WMError MinimizeAppNodeExceptOptions(MinimizeReason reason, const std::vector &exceptionalIds = {}, const std::vector &exceptionalModes = {}); WMError SetWindowMode(sptr& node, WindowMode dstMode); WMError SwitchLayoutPolicy(WindowLayoutMode mode, DisplayId displayId, bool reorder = false); void RaiseSplitRelatedWindowToTop(sptr& node); float GetVirtualPixelRatio(DisplayId displayId) const; Rect GetDisplayGroupRect() const; void TraverseWindowTree(const WindowNodeOperationFunc& func, bool isFromTopToBottom = true) const; void UpdateSizeChangeReason(sptr& node, WindowSizeChangeReason reason); void GetWindowList(std::vector>& windowList) const; void DropShowWhenLockedWindowIfNeeded(const sptr& node); void SetMinimizedByOther(bool isMinimizedByOther); void GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config); sptr GetDisplayInfo(DisplayId displayId); float GetDisplayVirtualPixelRatio(DisplayId displayId) const; bool UpdateRSTree(sptr& node, DisplayId displayId, bool isAdd, bool animationPlayed = false); sptr GetLayoutPolicy() const; sptr GetAvoidController() const; sptr GetMutiDisplayController() const; sptr GetRootNode(WindowRootNodeType type) const; void NotifyDockWindowStateChanged(sptr& node, bool isEnable); private: void TraverseWindowNode(sptr& root, std::vector>& windowNodes) const; sptr FindRoot(WindowType type) const; sptr FindWindowNodeById(uint32_t id) const; void UpdateFocusStatus(uint32_t id, bool focused) const; void UpdateActiveStatus(uint32_t id, bool isActive) const; void NotifyIfSystemBarTintChanged(DisplayId displayId); void NotifyIfSystemBarRegionChanged(DisplayId displayId); void TraverseAndUpdateWindowState(WindowState state, int32_t topPriority); void UpdateWindowTree(sptr& node); void UpdateWindowState(sptr node, int32_t topPriority, WindowState state); void HandleKeepScreenOn(const sptr& node, WindowState state); bool IsTopWindow(uint32_t windowId, sptr& rootNode) const; sptr FindDividerNode() const; void RaiseWindowToTop(uint32_t windowId, std::vector>& windowNodes); void ResetLayoutPolicy(); bool IsAboveSystemBarNode(sptr node) const; bool IsSplitImmersiveNode(sptr node) const; bool TraverseFromTopToBottom(sptr node, const WindowNodeOperationFunc& func) const; bool TraverseFromBottomToTop(sptr node, const WindowNodeOperationFunc& func) const; void RcoveryScreenDefaultOrientationIfNeed(DisplayId displayId); // cannot determine in case of a window covered by union of several windows or with transparent value void UpdateWindowVisibilityInfos(std::vector>& infos); void RaiseOrderedWindowToTop(std::vector>& orderedNodes, std::vector>& windowNodes); static bool ReadIsWindowAnimationEnabledProperty(); void DumpScreenWindowTree(); void RaiseInputMethodWindowPriorityIfNeeded(const sptr& node) const; void ReZOrderShowWhenLockedWindowIfNeeded(const sptr& node); void RaiseShowWhenLockedWindowIfNeeded(const sptr& node); void ReZOrderShowWhenLockedWindows(bool up); WMError AddWindowNodeOnWindowTree(sptr& node, const sptr& parentNode); void RemoveWindowNodeFromWindowTree(sptr& node); void UpdateRSTreeWhenShowingDisplaysChange(sptr& node, const std::vector& lastShowingDisplays, const std::vector& curShowingDisplays); void FillWindowInfo(sptr& windowInfo, const sptr& node) const; float displayBrightness_ = UNDEFINED_BRIGHTNESS; uint32_t brightnessWindow_ = INVALID_WINDOW_ID; uint32_t zOrder_ { 0 }; uint32_t focusedWindow_ { INVALID_WINDOW_ID }; uint32_t activeWindow_ = INVALID_WINDOW_ID; bool isScreenLocked_ = false; std::vector backupWindowIds_; std::map backupWindowMode_; std::map backupDividerWindowRect_; sptr zorderPolicy_ = new WindowZorderPolicy(); std::unordered_map> layoutPolicys_; WindowLayoutMode layoutMode_ = WindowLayoutMode::CASCADE; std::vector currentCoveredArea_; std::vector removedIds_; sptr belowAppWindowNode_ = new WindowNode(); sptr appWindowNode_ = new WindowNode(); sptr aboveAppWindowNode_ = new WindowNode(); sptr layoutPolicy_; sptr avoidController_; sptr displayGroupController_; sptr displayGroupInfo_; }; } // namespace Rosen } // namespace OHOS #endif // OHOS_ROSEN_WINDOW_NODE_CONTAINER_H