1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2022-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_TILE_H
17e0dac50fSopenharmony_ci#define OHOS_ROSEN_WINDOW_LAYOUT_POLICY_TILE_H
18e0dac50fSopenharmony_ci
19e0dac50fSopenharmony_ci#include <map>
20e0dac50fSopenharmony_ci#include <queue>
21e0dac50fSopenharmony_ci#include <refbase.h>
22e0dac50fSopenharmony_ci#include <set>
23e0dac50fSopenharmony_ci
24e0dac50fSopenharmony_ci#include "window_layout_policy.h"
25e0dac50fSopenharmony_ci#include "window_node.h"
26e0dac50fSopenharmony_ci#include "wm_common.h"
27e0dac50fSopenharmony_ci
28e0dac50fSopenharmony_cinamespace OHOS {
29e0dac50fSopenharmony_cinamespace Rosen {
30e0dac50fSopenharmony_ciclass WindowLayoutPolicyTile : public WindowLayoutPolicy {
31e0dac50fSopenharmony_cipublic:
32e0dac50fSopenharmony_ci    WindowLayoutPolicyTile() = delete;
33e0dac50fSopenharmony_ci    WindowLayoutPolicyTile(DisplayGroupWindowTree& displayGroupWindowTree);
34e0dac50fSopenharmony_ci    ~WindowLayoutPolicyTile() = default;
35e0dac50fSopenharmony_ci    void Launch() override;
36e0dac50fSopenharmony_ci    bool IsTileRectSatisfiedWithSizeLimits(const sptr<WindowNode>& node) override;
37e0dac50fSopenharmony_ci    void PerformWindowLayout(const sptr<WindowNode>& node, WindowUpdateType type) override;
38e0dac50fSopenharmony_ci
39e0dac50fSopenharmony_ciprivate:
40e0dac50fSopenharmony_ci    /*
41e0dac50fSopenharmony_ci     * methods for calculate maxTileNum and preset tileRects
42e0dac50fSopenharmony_ci     */
43e0dac50fSopenharmony_ci    void InitTileRects(DisplayId displayId);
44e0dac50fSopenharmony_ci    uint32_t GetMaxTileWinNum(DisplayId displayId) const;
45e0dac50fSopenharmony_ci
46e0dac50fSopenharmony_ci    /*
47e0dac50fSopenharmony_ci     * methods for update tile queue
48e0dac50fSopenharmony_ci     */
49e0dac50fSopenharmony_ci    void InitTileQueue(DisplayId displayId);
50e0dac50fSopenharmony_ci    void LayoutTileQueue(DisplayId displayId);
51e0dac50fSopenharmony_ci    void RefreshTileQueue(DisplayId displayId, std::vector<sptr<WindowNode>>& needMinimizeNodes,
52e0dac50fSopenharmony_ci        std::vector<sptr<WindowNode>>& needRecoverNodes);
53e0dac50fSopenharmony_ci    void PushBackNodeInTileQueue(const sptr<WindowNode>& node, DisplayId displayId);
54e0dac50fSopenharmony_ci    void RemoveNodeFromTileQueue(const sptr<WindowNode>& node);
55e0dac50fSopenharmony_ci
56e0dac50fSopenharmony_ci    /*
57e0dac50fSopenharmony_ci     * methods for calculate tile window rect
58e0dac50fSopenharmony_ci     */
59e0dac50fSopenharmony_ci    void ApplyPresetRectForTileWindows(DisplayId displayId);
60e0dac50fSopenharmony_ci    void UpdateLayoutRect(const sptr<WindowNode>& node) override;
61e0dac50fSopenharmony_ci    bool IsWindowAlreadyInTileQueue(const sptr<WindowNode>& node);
62e0dac50fSopenharmony_ci    bool IsValidTileQueueAndPresetRects(DisplayId displayId);
63e0dac50fSopenharmony_ci
64e0dac50fSopenharmony_ci    std::map<DisplayId, uint32_t> maxTileWinNumMap_;
65e0dac50fSopenharmony_ci    std::map<DisplayId, std::vector<std::vector<Rect>>> presetRectsMap_;
66e0dac50fSopenharmony_ci    std::map<DisplayId, std::deque<sptr<WindowNode>>> foregroundNodesMap_;
67e0dac50fSopenharmony_ci};
68e0dac50fSopenharmony_ci}
69e0dac50fSopenharmony_ci}
70e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_TILE_H
71