1 /* 2 * Copyright (c) 2022-2023 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(DisplayGroupWindowTree& displayGroupWindowTree); 34 ~WindowLayoutPolicyTile() = default; 35 void Launch() override; 36 bool IsTileRectSatisfiedWithSizeLimits(const sptr<WindowNode>& node) override; 37 void PerformWindowLayout(const sptr<WindowNode>& node, WindowUpdateType type) override; 38 39 private: 40 /* 41 * methods for calculate maxTileNum and preset tileRects 42 */ 43 void InitTileRects(DisplayId displayId); 44 uint32_t GetMaxTileWinNum(DisplayId displayId) const; 45 46 /* 47 * methods for update tile queue 48 */ 49 void InitTileQueue(DisplayId displayId); 50 void LayoutTileQueue(DisplayId displayId); 51 void RefreshTileQueue(DisplayId displayId, std::vector<sptr<WindowNode>>& needMinimizeNodes, 52 std::vector<sptr<WindowNode>>& needRecoverNodes); 53 void PushBackNodeInTileQueue(const sptr<WindowNode>& node, DisplayId displayId); 54 void RemoveNodeFromTileQueue(const sptr<WindowNode>& node); 55 56 /* 57 * methods for calculate tile window rect 58 */ 59 void ApplyPresetRectForTileWindows(DisplayId displayId); 60 void UpdateLayoutRect(const sptr<WindowNode>& node) override; 61 bool IsWindowAlreadyInTileQueue(const sptr<WindowNode>& node); 62 bool IsValidTileQueueAndPresetRects(DisplayId displayId); 63 64 std::map<DisplayId, uint32_t> maxTileWinNumMap_; 65 std::map<DisplayId, std::vector<std::vector<Rect>>> presetRectsMap_; 66 std::map<DisplayId, std::deque<sptr<WindowNode>>> foregroundNodesMap_; 67 }; 68 } 69 } 70 #endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_TILE_H 71