1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ROSEN_WINDOW_LAYOUT_POLICY_CASCADE_H 17 #define OHOS_ROSEN_WINDOW_LAYOUT_POLICY_CASCADE_H 18 19 #include <map> 20 #include <refbase.h> 21 #include <set> 22 23 #include "window_layout_policy.h" 24 #include "window_node.h" 25 #include "wm_common.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 class WindowLayoutPolicyCascade : public WindowLayoutPolicy { 30 public: 31 WindowLayoutPolicyCascade() = delete; 32 WindowLayoutPolicyCascade(const sptr<DisplayGroupInfo>& displayGroupInfo, 33 DisplayGroupWindowTree& displayGroupWindowTree); 34 ~WindowLayoutPolicyCascade() = default; 35 void Launch() override; 36 void Clean() override; 37 void Reset() override; 38 void Reorder() override; 39 void AddWindowNode(const sptr<WindowNode>& node) override; 40 void UpdateWindowNode(const sptr<WindowNode>& node, bool isAddWindow = false) override; 41 void UpdateLayoutRect(const sptr<WindowNode>& node) override; 42 void SetSplitDividerWindowRects(std::map<DisplayId, Rect> dividerWindowRects) override; 43 void RemoveWindowNode(const sptr<WindowNode>& node) override; 44 Rect GetDividerRect(DisplayId displayId) const override; 45 std::vector<int32_t> GetExitSplitPoints(DisplayId displayId) const override; 46 47 private: 48 void InitAllRects(); 49 void InitSplitRects(DisplayId displayId); 50 int32_t GetSplitRatioPoint(float ratio, DisplayId displayId); 51 void SetSplitRect(const Rect& rect, DisplayId displayId); 52 void UpdateSplitLimitRect(const Rect& limitRect, Rect& limitSplitRect); 53 void UpdateSplitRatioPoints(DisplayId displayId); 54 void UpdateDockSlicePosition(DisplayId displayId, int32_t& origin) const; 55 void LayoutWindowNode(const sptr<WindowNode>& node) override; 56 void LayoutWindowTree(DisplayId displayId) override; 57 void InitLimitRects(DisplayId displayId); 58 void LimitDividerMoveBounds(Rect& rect, DisplayId displayId) const; 59 void InitCascadeRect(DisplayId displayId); 60 void SetCascadeRect(const sptr<WindowNode>& node); 61 void ApplyWindowRectConstraints(const sptr<WindowNode>& node, Rect& winRect) const; 62 void UpdateWindowNodeRectOffset(const sptr<WindowNode>& node) const; 63 bool SpecialReasonProcess(const sptr<WindowNode>& node, bool isAddWindow) const; 64 65 Rect GetRectByWindowMode(const WindowMode& mode) const; 66 Rect GetLimitRect(const WindowMode mode, DisplayId displayId) const; 67 Rect GetDisplayRect(const WindowMode mode, DisplayId displayId) const; 68 Rect GetCurCascadeRect(const sptr<WindowNode>& node) const; 69 Rect StepCascadeRect(Rect rect, DisplayId displayId) const; 70 71 struct CascadeRects { 72 Rect primaryRect_; 73 Rect secondaryRect_; 74 Rect primaryLimitRect_; 75 Rect secondaryLimitRect_; 76 Rect dividerRect_; 77 Rect firstCascadeRect_; 78 }; 79 mutable std::map<DisplayId, LayoutRects> cascadeRectsMap_; 80 std::map<DisplayId, Rect> restoringDividerWindowRects_; 81 }; 82 } 83 } 84 #endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_CASCADE_H 85