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_TILE_H 17 #define OHOS_ROSEN_WINDOW_LAYOUT_POLICY_TILE_H 18 19 #include <map> 20 #include <queue> 21 #include <refbase.h> 22 #include <set> 23 24 #include "window_layout_policy.h" 25 #include "window_node.h" 26 #include "wm_common.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 class WindowLayoutPolicyTile : public WindowLayoutPolicy { 31 public: 32 WindowLayoutPolicyTile() = delete; 33 WindowLayoutPolicyTile(const sptr<DisplayGroupInfo>& displayGroupInfo, 34 DisplayGroupWindowTree& displayGroupWindowTree); 35 ~WindowLayoutPolicyTile() = default; 36 void Launch() override; 37 void AddWindowNode(const sptr<WindowNode>& node) override; 38 void UpdateWindowNode(const sptr<WindowNode>& node, bool isAddWindow = false) override; 39 void RemoveWindowNode(const sptr<WindowNode>& node) override; 40 void UpdateLayoutRect(const sptr<WindowNode>& node) override; 41 bool IsTileRectSatisfiedWithSizeLimits(const sptr<WindowNode>& node) override; 42 43 private: 44 std::map<DisplayId, uint32_t> maxTileWinNumMap_; 45 std::map<DisplayId, std::vector<std::vector<Rect>>> presetRectsMap_; 46 std::map<DisplayId, std::deque<sptr<WindowNode>>> foregroundNodesMap_; 47 void InitAllRects(); 48 uint32_t GetMaxTileWinNum(DisplayId displayId) const; 49 void InitTileWindowRects(DisplayId displayId); 50 void AssignNodePropertyForTileWindows(DisplayId displayId); 51 void LayoutForegroundNodeQueue(DisplayId displayId); 52 void InitForegroundNodeQueue(); 53 void ForegroundNodeQueuePushBack(const sptr<WindowNode>& node, DisplayId displayId); 54 void ForegroundNodeQueueRemove(const sptr<WindowNode>& node); 55 }; 56 } 57 } 58 #endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_TILE_H 59