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 INVALID_MODE_OR_SIZE_IN_TILE = 1 << 9, 39 }; 40 41 class MinimizeApp : public RefBase { 42 public: 43 MinimizeApp() = delete; 44 ~MinimizeApp() = default; 45 46 static void AddNeedMinimizeApp(const sptr<WindowNode>& node, MinimizeReason reason); 47 static void ExecuteMinimizeAll(); 48 static void ExecuteMinimizeTargetReasons(uint32_t reasons); 49 static void SetMinimizedByOtherConfig(bool isMinimizedByOther); 50 static void ClearNodesWithReason(MinimizeReason reason); 51 static bool IsNodeNeedMinimize(const sptr<WindowNode>& node); 52 static std::vector<wptr<WindowNode>> GetNeedMinimizeAppNodesWithReason(MinimizeReason reason); 53 static sptr<WindowNode> GetRecoverdNodeFromMinimizeList(); 54 static bool IsNodeNeedMinimizeWithReason(const sptr<WindowNode>& node, MinimizeReason reason); 55 static bool EnableMinimize(MinimizeReason reason); 56 private: IsFromUser(MinimizeReason reason)57 static inline bool IsFromUser(MinimizeReason reason) 58 { 59 return (reason == MinimizeReason::MINIMIZE_ALL || reason == MinimizeReason::MINIMIZE_BUTTON || 60 reason == MinimizeReason::MAX_APP_COUNT || reason == MinimizeReason::LAYOUT_TILE || 61 reason == MinimizeReason::INVALID_MODE_OR_SIZE_IN_TILE || reason == MinimizeReason::SPLIT_REPLACE || 62 reason == MinimizeReason::SPLIT_QUIT); 63 } 64 65 static std::map<MinimizeReason, std::vector<wptr<WindowNode>>> needMinimizeAppNodes_; 66 static bool isMinimizedByOtherWindow_; 67 static std::recursive_mutex mutex_; 68 }; 69 } // Rosen 70 } // OHOS 71 #endif // OHOS_ROSEN_MINIMIZE_APP_H 72