1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License. 5e0dac50fSopenharmony_ci * You may obtain a copy of the License at 6e0dac50fSopenharmony_ci * 7e0dac50fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e0dac50fSopenharmony_ci * 9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and 13e0dac50fSopenharmony_ci * limitations under the License. 14e0dac50fSopenharmony_ci */ 15e0dac50fSopenharmony_ci 16e0dac50fSopenharmony_ci#ifndef OHOS_ROSEN_WINDOW_LAYOUT_POLICY_H 17e0dac50fSopenharmony_ci#define OHOS_ROSEN_WINDOW_LAYOUT_POLICY_H 18e0dac50fSopenharmony_ci 19e0dac50fSopenharmony_ci#include <map> 20e0dac50fSopenharmony_ci#include <refbase.h> 21e0dac50fSopenharmony_ci#include <set> 22e0dac50fSopenharmony_ci 23e0dac50fSopenharmony_ci#include "display_group_info.h" 24e0dac50fSopenharmony_ci#include "display_info.h" 25e0dac50fSopenharmony_ci#include "window_node.h" 26e0dac50fSopenharmony_ci#include "wm_common.h" 27e0dac50fSopenharmony_ci 28e0dac50fSopenharmony_ci 29e0dac50fSopenharmony_cinamespace OHOS { 30e0dac50fSopenharmony_cinamespace Rosen { 31e0dac50fSopenharmony_ciusing DisplayGroupWindowTree = std::map<DisplayId, 32e0dac50fSopenharmony_ci std::map<WindowRootNodeType, std::unique_ptr<std::vector<sptr<WindowNode>>>>>; 33e0dac50fSopenharmony_cienum class DockWindowShowState : uint32_t { 34e0dac50fSopenharmony_ci NOT_SHOWN = 0, 35e0dac50fSopenharmony_ci SHOWN_IN_BOTTOM = 1, 36e0dac50fSopenharmony_ci SHOWN_IN_LEFT = 2, 37e0dac50fSopenharmony_ci SHOWN_IN_RIGHT = 3, 38e0dac50fSopenharmony_ci SHOWN_IN_TOP = 4, 39e0dac50fSopenharmony_ci}; 40e0dac50fSopenharmony_ciclass WindowLayoutPolicy : public RefBase { 41e0dac50fSopenharmony_cipublic: 42e0dac50fSopenharmony_ci WindowLayoutPolicy() = delete; 43e0dac50fSopenharmony_ci WindowLayoutPolicy(DisplayGroupWindowTree& displayGroupWindowTree); 44e0dac50fSopenharmony_ci ~WindowLayoutPolicy() = default; 45e0dac50fSopenharmony_ci virtual void Launch(); 46e0dac50fSopenharmony_ci virtual void Reorder(); 47e0dac50fSopenharmony_ci virtual void PerformWindowLayout(const sptr<WindowNode>& node, WindowUpdateType type) = 0; 48e0dac50fSopenharmony_ci void ProcessDisplayCreate(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap); 49e0dac50fSopenharmony_ci void ProcessDisplayDestroy(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap); 50e0dac50fSopenharmony_ci void ProcessDisplaySizeChangeOrRotation(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap); 51e0dac50fSopenharmony_ci void ProcessDisplayVprChange(DisplayId displayId); 52e0dac50fSopenharmony_ci 53e0dac50fSopenharmony_ci virtual void SetSplitDividerWindowRects(std::map<DisplayId, Rect> dividerWindowRects) {}; 54e0dac50fSopenharmony_ci virtual Rect GetDividerRect(DisplayId displayId) const; 55e0dac50fSopenharmony_ci virtual bool IsTileRectSatisfiedWithSizeLimits(const sptr<WindowNode>& node); 56e0dac50fSopenharmony_ci bool IsMultiDisplay(); 57e0dac50fSopenharmony_ci Rect GetDisplayGroupRect() const; 58e0dac50fSopenharmony_ci void SetSplitRatioPoints(DisplayId displayId, const std::vector<int32_t>& splitRatioPoints); 59e0dac50fSopenharmony_ci void NotifyClientAndAnimation(const sptr<WindowNode>& node, const Rect& winRect, WindowSizeChangeReason reason); 60e0dac50fSopenharmony_ci // methods for setting bottom posY limit for cascade rect on pc 61e0dac50fSopenharmony_ci static void SetCascadeRectBottomPosYLimit(uint32_t floatingBottomPosY); 62e0dac50fSopenharmony_ci static void SetMaxFloatingWindowSize(uint32_t maxSize); 63e0dac50fSopenharmony_ci static void CalcAndSetNodeHotZone(const Rect& winRect, const sptr<WindowNode>& node); 64e0dac50fSopenharmony_ci virtual void GetMaximizeRect(const sptr<WindowNode>& node, Rect& maxRect); 65e0dac50fSopenharmony_ci 66e0dac50fSopenharmony_ciprotected: 67e0dac50fSopenharmony_ci /* 68e0dac50fSopenharmony_ci * methods for calculate window rect 69e0dac50fSopenharmony_ci */ 70e0dac50fSopenharmony_ci virtual void UpdateLayoutRect(const sptr<WindowNode>& node) = 0; 71e0dac50fSopenharmony_ci void LayoutWindowTree(DisplayId displayId); 72e0dac50fSopenharmony_ci void LayoutWindowNode(const sptr<WindowNode>& node); 73e0dac50fSopenharmony_ci void LayoutWindowNodesByRootType(const std::vector<sptr<WindowNode>>& nodeVec); 74e0dac50fSopenharmony_ci void FixWindowRectWithinDisplay(const sptr<WindowNode>& node) const; 75e0dac50fSopenharmony_ci 76e0dac50fSopenharmony_ci /* 77e0dac50fSopenharmony_ci * methods for get/update display information or limit information 78e0dac50fSopenharmony_ci */ 79e0dac50fSopenharmony_ci AvoidPosType GetAvoidPosType(const Rect& rect, DisplayId displayId) const; 80e0dac50fSopenharmony_ci void UpdateDisplayLimitRect(const sptr<WindowNode>& node, Rect& limitRect); 81e0dac50fSopenharmony_ci bool IsVerticalDisplay(DisplayId displayId) const; 82e0dac50fSopenharmony_ci bool IsFullScreenRecentWindowExist(const std::vector<sptr<WindowNode>>& nodeVec) const; 83e0dac50fSopenharmony_ci void UpdateWindowSizeLimits(const sptr<WindowNode>& node); 84e0dac50fSopenharmony_ci WindowLimits GetSystemSizeLimits(const sptr<WindowNode>& node, const Rect& displayRect, float vpr); 85e0dac50fSopenharmony_ci 86e0dac50fSopenharmony_ci /* 87e0dac50fSopenharmony_ci * methods for multiDisplay 88e0dac50fSopenharmony_ci */ 89e0dac50fSopenharmony_ci void UpdateMultiDisplayFlag(); 90e0dac50fSopenharmony_ci void UpdateDisplayGroupRect(); 91e0dac50fSopenharmony_ci void UpdateDisplayGroupLimitRect(); 92e0dac50fSopenharmony_ci void PostProcessWhenDisplayChange(); 93e0dac50fSopenharmony_ci void LimitWindowToBottomRightCorner(const sptr<WindowNode>& node); 94e0dac50fSopenharmony_ci void UpdateRectInDisplayGroupForAllNodes(DisplayId displayId, const Rect& oriDisplayRect, 95e0dac50fSopenharmony_ci const Rect& newDisplayRect); 96e0dac50fSopenharmony_ci void UpdateRectInDisplayGroup(const sptr<WindowNode>& node, const Rect& oriDisplayRect, 97e0dac50fSopenharmony_ci const Rect& newDisplayRect); 98e0dac50fSopenharmony_ci void UpdateDisplayRectAndDisplayGroupInfo(const std::map<DisplayId, Rect>& displayRectMap); 99e0dac50fSopenharmony_ci 100e0dac50fSopenharmony_ci /* 101e0dac50fSopenharmony_ci * methods for update node latest information, include: 102e0dac50fSopenharmony_ci * 1. notify client and animation 103e0dac50fSopenharmony_ci * 2. update hot zone 104e0dac50fSopenharmony_ci * 3. update surface bounds 105e0dac50fSopenharmony_ci */ 106e0dac50fSopenharmony_ci void NotifyAnimationSizeChangeIfNeeded(); 107e0dac50fSopenharmony_ci static Rect CalcEntireWindowHotZone(const sptr<WindowNode>& node, const Rect& winRect, uint32_t hotZone, 108e0dac50fSopenharmony_ci float vpr, TransformHelper::Vector2 hotZoneScale); 109e0dac50fSopenharmony_ci void UpdateSurfaceBounds(const sptr<WindowNode>& node, const Rect& winRect, const Rect& preRect); 110e0dac50fSopenharmony_ci 111e0dac50fSopenharmony_ci void GetStoragedAspectRatio(const sptr<WindowNode>& node); 112e0dac50fSopenharmony_ci bool IsNeedAnimationSync(WindowType type); 113e0dac50fSopenharmony_ci 114e0dac50fSopenharmony_ci Rect displayGroupRect_{}; 115e0dac50fSopenharmony_ci Rect displayGroupLimitRect_{}; 116e0dac50fSopenharmony_ci bool isMultiDisplay_ = false; 117e0dac50fSopenharmony_ci mutable std::map<DisplayId, Rect> limitRectMap_; 118e0dac50fSopenharmony_ci DisplayGroupWindowTree& displayGroupWindowTree_; 119e0dac50fSopenharmony_ci std::map<DisplayId, Rect> restoringDividerWindowRects_; 120e0dac50fSopenharmony_ci mutable std::map<DisplayId, std::vector<int32_t>> splitRatioPointsMap_; 121e0dac50fSopenharmony_ci // bottom posY limit for cascade rect on pc 122e0dac50fSopenharmony_ci static uint32_t floatingBottomPosY_; 123e0dac50fSopenharmony_ci // max size of floating window in config 124e0dac50fSopenharmony_ci static uint32_t maxFloatingWindowSize_; 125e0dac50fSopenharmony_ci}; 126e0dac50fSopenharmony_ci} 127e0dac50fSopenharmony_ci} 128e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_H 129