• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MINIMIZE_APP_H
17 #define OHOS_ROSEN_MINIMIZE_APP_H
18 
19 #include <map>
20 #include <vector>
21 
22 #include <refbase.h>
23 #include "wm_common.h"
24 #include "window_node.h"
25 
26 namespace OHOS {
27 namespace Rosen {
28 enum MinimizeReason : uint32_t {
29     MINIMIZE_BUTTON = 1,
30     MINIMIZE_ALL = 1 << 1,
31     LAYOUT_TILE = 1 << 2,
32     LAYOUT_CASCADE = 1 << 3,
33     MAX_APP_COUNT = 1 << 4,
34     SPLIT_REPLACE = 1 << 5,
35     SPLIT_QUIT = 1 << 6,
36     GESTURE_ANIMATION = 1 << 7,
37     OTHER_WINDOW = 1 << 8,
38 };
39 
40 class MinimizeApp : public RefBase {
41 public:
42     MinimizeApp() = delete;
43     ~MinimizeApp() = default;
44 
45     static void AddNeedMinimizeApp(const sptr<WindowNode>& node, MinimizeReason reason);
46     static void ExecuteMinimizeAll();
47     static void ExecuteMinimizeTargetReasons(uint32_t reasons);
48     static void SetMinimizedByOtherConfig(bool isMinimizedByOther);
49     static void ClearNodesWithReason(MinimizeReason reason);
50     static bool IsNodeNeedMinimize(const sptr<WindowNode>& node);
51     static std::vector<wptr<WindowNode>> GetNeedMinimizeAppNodesWithReason(MinimizeReason reason);
52     static sptr<WindowNode> GetRecoverdNodeFromMinimizeList();
53     static bool IsNodeNeedMinimizeWithReason(const sptr<WindowNode>& node, MinimizeReason reason);
54     static bool EnableMinimize(MinimizeReason reason);
55 private:
IsFromUser(MinimizeReason reason)56     static inline bool IsFromUser(MinimizeReason reason)
57     {
58         return (reason == MinimizeReason::MINIMIZE_ALL || reason == MinimizeReason::MINIMIZE_BUTTON ||
59             reason == MinimizeReason::MAX_APP_COUNT || reason == MinimizeReason::LAYOUT_TILE ||
60             reason == MinimizeReason::SPLIT_REPLACE || reason == MinimizeReason::SPLIT_QUIT);
61     }
62 
63     static std::map<MinimizeReason, std::vector<wptr<WindowNode>>> needMinimizeAppNodes_;
64     static bool isMinimizedByOtherWindow_;
65     static std::recursive_mutex mutex_;
66 };
67 } // Rosen
68 } // OHOS
69 #endif // OHOS_ROSEN_MINIMIZE_APP_H
70