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_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,const sptr<DisplayGroupInfo> & displayGroupInfo)39 DisplayGroupController(const sptr<WindowNodeContainer>& windowNodeContainer, 40 const sptr<DisplayGroupInfo>& displayGroupInfo) 41 : windowNodeContainer_(windowNodeContainer), displayGroupInfo_(displayGroupInfo) {} 42 ~DisplayGroupController() = default; 43 44 void InitNewDisplay(DisplayId displayId); 45 void UpdateDisplayGroupWindowTree(); 46 void PreProcessWindowNode(const sptr<WindowNode>& node, WindowUpdateType type); 47 void PostProcessWindowNode(const sptr<WindowNode>& node); 48 void ProcessDisplayCreate(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 49 const std::map<DisplayId, Rect>& displayRectMap); 50 void ProcessDisplayDestroy(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 51 const std::map<DisplayId, Rect>& displayRectMap, 52 std::vector<uint32_t>& windowIds); 53 void ProcessDisplayChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 54 const std::map<DisplayId, Rect>& displayRectMap, 55 DisplayStateChangeType type); 56 sptr<WindowPair> GetWindowPairByDisplayId(DisplayId displayId); 57 void SetDividerRect(DisplayId displayId, const Rect& rect); 58 59 DisplayGroupWindowTree displayGroupWindowTree_; 60 std::map<DisplayId, SysBarNodeMap> sysBarNodeMaps_; 61 std::map<DisplayId, SysBarTintMap> sysBarTintMaps_; 62 63 private: 64 std::vector<sptr<WindowNode>>* GetWindowNodesByDisplayIdAndRootType(DisplayId displayId, WindowRootNodeType type); 65 void AddWindowNodeOnWindowTree(sptr<WindowNode>& node, WindowRootNodeType rootType); 66 void ProcessNotCrossNodesOnDestroyedDisplay(DisplayId displayId, std::vector<uint32_t>& windowIds); 67 void ProcessDisplaySizeChangeOrRotation(DisplayId defaultDisplayId, DisplayId displayId, 68 const std::map<DisplayId, Rect>& displayRectMap, DisplayStateChangeType type); 69 void ProcessCrossNodes(DisplayId defaultDisplayId, DisplayStateChangeType type); 70 void MoveCrossNodeToTargetDisplay(const sptr<WindowNode>& node, DisplayId targetDisplayId); 71 void MoveNotCrossNodeToDefaultDisplay(const sptr<WindowNode>& node, DisplayId displayId); 72 void UpdateWindowDisplayIdIfNeeded(const sptr<WindowNode>& node); 73 void UpdateWindowShowingDisplays(const sptr<WindowNode>& node); 74 void UpdateWindowDisplayId(const sptr<WindowNode>& node, DisplayId newDisplayId); 75 void ClearMapOfDestroyedDisplay(DisplayId displayId); 76 void ChangeToRectInDisplayGroup(const sptr<WindowNode>& node, DisplayId displayId); 77 void UpdateNodeSizeChangeReasonWithRotation(DisplayId displayId); 78 79 sptr<WindowNodeContainer> windowNodeContainer_; 80 sptr<DisplayGroupInfo> displayGroupInfo_; 81 std::map<DisplayId, sptr<WindowPair>> windowPairMap_; 82 DisplayId defaultDisplayId_ { 0 }; 83 }; 84 } // namespace Rosen 85 } // namespace OHOS 86 #endif // OHOS_ROSEN_DISPLAY_GROUP_CONTROLLER_H 87