1 /* 2 * Copyright (c) 2021-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_H 17 #define OHOS_ROSEN_WINDOW_LAYOUT_POLICY_H 18 19 #include <map> 20 #include <refbase.h> 21 #include <set> 22 23 #include "window_node.h" 24 #include "wm_common.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 class WindowLayoutPolicy : public RefBase { 29 public: 30 WindowLayoutPolicy() = delete; 31 WindowLayoutPolicy(const Rect& displayRect, const uint64_t& screenId, 32 sptr<WindowNode>& belowAppNode, sptr<WindowNode>& appNode, sptr<WindowNode>& aboveAppNode); 33 ~WindowLayoutPolicy() = default; 34 virtual void Launch(); 35 virtual void Clean(); 36 virtual void Reset(); 37 virtual void Reorder(); 38 virtual void UpdateDisplayInfo(); 39 virtual void AddWindowNode(sptr<WindowNode>& node); 40 virtual void LayoutWindowTree(); 41 virtual void RemoveWindowNode(sptr<WindowNode>& node); 42 virtual void UpdateWindowNode(sptr<WindowNode>& node, bool isAddWindow = false); 43 virtual void UpdateLayoutRect(sptr<WindowNode>& node) = 0; 44 void UpdateDefaultFoatingRect(); 45 float GetVirtualPixelRatio() const; 46 Rect GetDisplayLimitRect() const; 47 48 protected: 49 const Rect& displayRect_; 50 const uint64_t& screenId_; 51 sptr<WindowNode>& belowAppWindowNode_; 52 sptr<WindowNode>& appWindowNode_; 53 sptr<WindowNode>& aboveAppWindowNode_; 54 Rect limitRect_ = { 0, 0, 0, 0 }; 55 const std::set<WindowType> avoidTypes_ { 56 WindowType::WINDOW_TYPE_STATUS_BAR, 57 WindowType::WINDOW_TYPE_NAVIGATION_BAR, 58 }; 59 void UpdateFloatingLayoutRect(Rect& limitRect, Rect& winRect); 60 void UpdateLimitRect(const sptr<WindowNode>& node, Rect& limitRect); 61 virtual void LayoutWindowNode(sptr<WindowNode>& node); 62 AvoidPosType GetAvoidPosType(const Rect& rect); 63 void CalcAndSetNodeHotZone(Rect layoutOutRect, sptr<WindowNode>& node); 64 void LimitWindowSize(const sptr<WindowNode>& node, const Rect& displayRect, Rect& winRect); 65 void SetRectForFloating(const sptr<WindowNode>& node); 66 Rect ComputeDecoratedWindowRect(const Rect& winRect); 67 bool IsVertical() const; 68 bool IsFullScreenRecentWindowExist() const; 69 Rect defaultFloatingRect_ = { 0, 0, 0, 0 }; 70 }; 71 } 72 } 73 #endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_H 74