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_DISPLAY_GROUP_CONTROLLER_H 17 #define OHOS_ROSEN_DISPLAY_GROUP_CONTROLLER_H 18 19 #include <refbase.h> 20 21 #include "avoid_area_controller.h" 22 #include "display_group_info.h" 23 #include "display_info.h" 24 #include "display_manager_service_inner.h" 25 #include "window_layout_policy.h" 26 #include "window_manager.h" 27 #include "window_node.h" 28 #include "window_pair.h" 29 #include "wm_common.h" 30 31 namespace OHOS { 32 namespace Rosen { 33 using SysBarNodeMap = std::unordered_map<WindowType, sptr<WindowNode>>; 34 using SysBarTintMap = std::unordered_map<WindowType, SystemBarRegionTint>; 35 class WindowNodeContainer; 36 37 class DisplayGroupController : public RefBase { 38 public: DisplayGroupController(const sptr<WindowNodeContainer> & windowNodeContainer)39 DisplayGroupController(const sptr<WindowNodeContainer>& windowNodeContainer) 40 : windowNodeContainer_(windowNodeContainer) {} 41 ~DisplayGroupController() = default; 42 43 void InitNewDisplay(DisplayId displayId); 44 void UpdateDisplayGroupWindowTree(); 45 void PreProcessWindowNode(const sptr<WindowNode>& node, WindowUpdateType type); 46 void PostProcessWindowNode(const sptr<WindowNode>& node); 47 void ProcessDisplayCreate(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 48 const std::map<DisplayId, Rect>& displayRectMap); 49 void ProcessDisplayDestroy(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 50 const std::map<DisplayId, Rect>& displayRectMap, 51 std::vector<uint32_t>& windowIds); 52 void ProcessDisplayChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 53 const std::map<DisplayId, Rect>& displayRectMap, 54 DisplayStateChangeType type); 55 sptr<WindowPair> GetWindowPairByDisplayId(DisplayId displayId); 56 void SetSplitRatioConfig(const SplitRatioConfig& splitRatioConfig); 57 58 DisplayGroupWindowTree displayGroupWindowTree_; 59 std::map<DisplayId, SysBarNodeMap> sysBarNodeMaps_; 60 std::map<DisplayId, SysBarTintMap> sysBarTintMaps_; 61 62 private: 63 std::vector<sptr<WindowNode>>* GetWindowNodesByDisplayIdAndRootType(DisplayId displayId, WindowRootNodeType type); 64 void AddWindowNodeOnWindowTree(sptr<WindowNode>& node, WindowRootNodeType rootType); 65 void ProcessNotCrossNodesOnDestroyedDisplay(DisplayId displayId, std::vector<uint32_t>& windowIds); 66 void ProcessDisplaySizeChangeOrRotation(DisplayId defaultDisplayId, DisplayId displayId, 67 const std::map<DisplayId, Rect>& displayRectMap, DisplayStateChangeType type); 68 void ProcessCrossNodes(DisplayId defaultDisplayId, DisplayStateChangeType type); 69 void MoveCrossNodeToTargetDisplay(const sptr<WindowNode>& node, DisplayId targetDisplayId); 70 void MoveNotCrossNodeToDefaultDisplay(const sptr<WindowNode>& node, DisplayId displayId); 71 void UpdateWindowDisplayIdIfNeeded(const sptr<WindowNode>& node); 72 void UpdateWindowShowingDisplays(const sptr<WindowNode>& node); 73 void UpdateWindowDisplayId(const sptr<WindowNode>& node, DisplayId newDisplayId); 74 void ClearMapOfDestroyedDisplay(DisplayId displayId); 75 void ChangeToRectInDisplayGroup(const sptr<WindowNode>& node, DisplayId displayId); 76 void UpdateNodeSizeChangeReasonWithRotation(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap); 77 void ProcessWindowPairWhenDisplayChange(bool rotateDisplay = false); 78 void UpdateSplitRatioPoints(DisplayId displayId); 79 void ProcessSystemBarRotation(const sptr<WindowNode>& node, const std::map<DisplayId, Rect>& displayRectMap); 80 81 sptr<WindowNodeContainer> windowNodeContainer_; 82 std::map<DisplayId, sptr<WindowPair>> windowPairMap_; 83 DisplayId defaultDisplayId_ { 0 }; 84 }; 85 } // namespace Rosen 86 } // namespace OHOS 87 #endif // OHOS_ROSEN_DISPLAY_GROUP_CONTROLLER_H 88