1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2021-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#ifndef OHOS_ROSEN_WINDOW_ROOT_H 16e0dac50fSopenharmony_ci#define OHOS_ROSEN_WINDOW_ROOT_H 17e0dac50fSopenharmony_ci 18e0dac50fSopenharmony_ci#include <refbase.h> 19e0dac50fSopenharmony_ci#include <iremote_object.h> 20e0dac50fSopenharmony_ci#include <transaction/rs_interfaces.h> 21e0dac50fSopenharmony_ci 22e0dac50fSopenharmony_ci#include "agent_death_recipient.h" 23e0dac50fSopenharmony_ci#include "display_manager_service_inner.h" 24e0dac50fSopenharmony_ci#include "parameters.h" 25e0dac50fSopenharmony_ci#include "window_node_container.h" 26e0dac50fSopenharmony_ci#include "zidl/window_manager_agent_interface.h" 27e0dac50fSopenharmony_ci 28e0dac50fSopenharmony_cinamespace OHOS { 29e0dac50fSopenharmony_cinamespace Rosen { 30e0dac50fSopenharmony_cienum class Event : uint32_t { 31e0dac50fSopenharmony_ci REMOTE_DIED, 32e0dac50fSopenharmony_ci}; 33e0dac50fSopenharmony_ci 34e0dac50fSopenharmony_ciclass WindowRoot : public RefBase { 35e0dac50fSopenharmony_ciusing Callback = std::function<void (Event event, const sptr<IRemoteObject>& remoteObject)>; 36e0dac50fSopenharmony_ci 37e0dac50fSopenharmony_cipublic: 38e0dac50fSopenharmony_ci explicit WindowRoot(Callback callback) : callback_(callback) {} 39e0dac50fSopenharmony_ci ~WindowRoot() = default; 40e0dac50fSopenharmony_ci 41e0dac50fSopenharmony_ci sptr<WindowNodeContainer> GetOrCreateWindowNodeContainer(DisplayId displayId); 42e0dac50fSopenharmony_ci sptr<WindowNodeContainer> GetWindowNodeContainer(DisplayId displayId); 43e0dac50fSopenharmony_ci sptr<WindowNodeContainer> CreateWindowNodeContainer(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo); 44e0dac50fSopenharmony_ci sptr<WindowNode> GetWindowNode(uint32_t windowId) const; 45e0dac50fSopenharmony_ci sptr<WindowNode> GetWindowNodeByMissionId(uint32_t missionId) const; 46e0dac50fSopenharmony_ci void GetBackgroundNodesByScreenId(ScreenId screenGroupId, std::vector<sptr<WindowNode>>& windowNodes); 47e0dac50fSopenharmony_ci void GetForegroundNodes(std::vector<sptr<WindowNode>>& windowNodes); 48e0dac50fSopenharmony_ci 49e0dac50fSopenharmony_ci sptr<WindowNode> FindWallpaperWindow(); 50e0dac50fSopenharmony_ci WMError SaveWindow(const sptr<WindowNode>& node); 51e0dac50fSopenharmony_ci void AddDeathRecipient(sptr<WindowNode> node); 52e0dac50fSopenharmony_ci sptr<WindowNode> FindWindowNodeWithToken(const sptr<IRemoteObject>& token) const; 53e0dac50fSopenharmony_ci WMError AddWindowNode(uint32_t parentId, sptr<WindowNode>& node, bool fromStartingWin = false); 54e0dac50fSopenharmony_ci WMError RemoveWindowNode(uint32_t windowId, bool fromAnimation = false); 55e0dac50fSopenharmony_ci WMError DestroyWindow(uint32_t windowId, bool onlySelf); 56e0dac50fSopenharmony_ci WMError UpdateWindowNode(uint32_t windowId, WindowUpdateReason reason); 57e0dac50fSopenharmony_ci bool IsVerticalDisplay(sptr<WindowNode>& node) const; 58e0dac50fSopenharmony_ci bool IsForbidDockSliceMove(DisplayId displayId) const; 59e0dac50fSopenharmony_ci bool IsDockSliceInExitSplitModeArea(DisplayId displayId) const; 60e0dac50fSopenharmony_ci void ExitSplitMode(DisplayId displayId); 61e0dac50fSopenharmony_ci void NotifyWindowVisibilityChange(std::shared_ptr<RSOcclusionData> occlusionData); 62e0dac50fSopenharmony_ci void AddSurfaceNodeIdWindowNodePair(uint64_t surfaceNodeId, sptr<WindowNode> node); 63e0dac50fSopenharmony_ci 64e0dac50fSopenharmony_ci WMError RequestFocus(uint32_t windowId); 65e0dac50fSopenharmony_ci WMError RequestActiveWindow(uint32_t windowId); 66e0dac50fSopenharmony_ci WMError MinimizeStructuredAppWindowsExceptSelf(sptr<WindowNode>& node); 67e0dac50fSopenharmony_ci AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType); 68e0dac50fSopenharmony_ci WMError SetWindowMode(sptr<WindowNode>& node, WindowMode dstMode); 69e0dac50fSopenharmony_ci WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId); 70e0dac50fSopenharmony_ci void MinimizeAllAppWindows(DisplayId displayId); 71e0dac50fSopenharmony_ci WMError ToggleShownStateForAllAppWindows(); 72e0dac50fSopenharmony_ci WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode); 73e0dac50fSopenharmony_ci 74e0dac50fSopenharmony_ci void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason); 75e0dac50fSopenharmony_ci void ProcessDisplayChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 76e0dac50fSopenharmony_ci const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type); 77e0dac50fSopenharmony_ci void ProcessDisplayDestroy(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 78e0dac50fSopenharmony_ci const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap); 79e0dac50fSopenharmony_ci void ProcessDisplayCreate(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 80e0dac50fSopenharmony_ci const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap); 81e0dac50fSopenharmony_ci 82e0dac50fSopenharmony_ci void NotifySystemBarTints(); 83e0dac50fSopenharmony_ci WMError RaiseZOrderForAppWindow(sptr<WindowNode>& node); 84e0dac50fSopenharmony_ci void DispatchKeyEvent(sptr<WindowNode> node, std::shared_ptr<MMI::KeyEvent> event); 85e0dac50fSopenharmony_ci void FocusFaultDetection() const; 86e0dac50fSopenharmony_ci Rect GetDisplayGroupRect(DisplayId displayId) const; 87e0dac50fSopenharmony_ci WMError UpdateSizeChangeReason(uint32_t windowId, WindowSizeChangeReason reason); 88e0dac50fSopenharmony_ci void SetBrightness(uint32_t windowId, float brightness); 89e0dac50fSopenharmony_ci void HandleKeepScreenOn(uint32_t windowId, bool requireLock); 90e0dac50fSopenharmony_ci void UpdateFocusableProperty(uint32_t windowId); 91e0dac50fSopenharmony_ci void SetMaxAppWindowNumber(uint32_t windowNum); 92e0dac50fSopenharmony_ci WMError GetModeChangeHotZones(DisplayId displayId, 93e0dac50fSopenharmony_ci ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config); 94e0dac50fSopenharmony_ci std::vector<DisplayId> GetAllDisplayIds() const; 95e0dac50fSopenharmony_ci uint32_t GetTotalWindowNum() const; 96e0dac50fSopenharmony_ci uint32_t GetWindowIdByObject(const sptr<IRemoteObject>& remoteObject); 97e0dac50fSopenharmony_ci sptr<WindowNode> GetWindowForDumpAceHelpInfo() const; 98e0dac50fSopenharmony_ci void DestroyLeakStartingWindow(); 99e0dac50fSopenharmony_ci void SetSplitRatios(const std::vector<float>& splitRatioNumbers); 100e0dac50fSopenharmony_ci std::vector<sptr<WindowNode>> GetSplitScreenWindowNodes(DisplayId displayId); 101e0dac50fSopenharmony_ci void SetExitSplitRatios(const std::vector<float>& exitSplitRatios); 102e0dac50fSopenharmony_ci void MinimizeTargetWindows(std::vector<uint32_t>& windowIds); 103e0dac50fSopenharmony_ci WMError UpdateRsTree(uint32_t windowId, bool isAdd); 104e0dac50fSopenharmony_ci void RemoveSingleUserWindowNodes(int accountId); 105e0dac50fSopenharmony_ci sptr<WindowNode> FindMainWindowWithToken(sptr<IRemoteObject> token); 106e0dac50fSopenharmony_ci bool CheckMultiDialogWindows(WindowType type, sptr<IRemoteObject> token); 107e0dac50fSopenharmony_ci bool HasPrivateWindow(DisplayId displayId); 108e0dac50fSopenharmony_ci Rect GetDisplayRectWithoutSystemBarAreas(const sptr<WindowNode> destNode); 109e0dac50fSopenharmony_ci sptr<WindowNode> GetWindowNodeByAbilityToken(const sptr<IRemoteObject>& abilityToken); 110e0dac50fSopenharmony_ci bool TakeWindowPairSnapshot(DisplayId displayId); 111e0dac50fSopenharmony_ci void ClearWindowPairSnapshot(DisplayId displayId); 112e0dac50fSopenharmony_ci void LayoutWhenAddWindowNode(sptr<WindowNode>& node, bool afterAnimation = false); 113e0dac50fSopenharmony_ci void GetAllAnimationPlayingNodes(std::vector<wptr<WindowNode>>& windowNodes); 114e0dac50fSopenharmony_ci void GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) const; 115e0dac50fSopenharmony_ci void GetUnreliableWindowInfo(int32_t windowId, std::vector<sptr<UnreliableWindowInfo>>& infos) const; 116e0dac50fSopenharmony_ci WMError NotifyDesktopUnfrozen(); 117e0dac50fSopenharmony_ci void UpdateDisplayOrientationWhenHideWindow(sptr<WindowNode>& node); 118e0dac50fSopenharmony_ci bool HasMainFullScreenWindowShown(DisplayId displayId); 119e0dac50fSopenharmony_ci WMError SetGestureNavigationEnabled(bool enable); 120e0dac50fSopenharmony_ci 121e0dac50fSopenharmony_ciprivate: 122e0dac50fSopenharmony_ci void OnRemoteDied(const sptr<IRemoteObject>& remoteObject); 123e0dac50fSopenharmony_ci WMError DestroyWindowInner(sptr<WindowNode>& node); 124e0dac50fSopenharmony_ci WMError DestroyWindowSelf(sptr<WindowNode>& node, const sptr<WindowNodeContainer>& container); 125e0dac50fSopenharmony_ci WMError DestroyWindowWithChild(sptr<WindowNode>& node, const sptr<WindowNodeContainer>& container); 126e0dac50fSopenharmony_ci void UpdateFocusWindowWithWindowRemoved(const sptr<WindowNode>& node, 127e0dac50fSopenharmony_ci const sptr<WindowNodeContainer>& container) const; 128e0dac50fSopenharmony_ci void UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& node, 129e0dac50fSopenharmony_ci const sptr<WindowNodeContainer>& container) const; 130e0dac50fSopenharmony_ci void UpdateBrightnessWithWindowRemoved(uint32_t windowId, const sptr<WindowNodeContainer>& container) const; 131e0dac50fSopenharmony_ci std::string GenAllWindowsLogInfo() const; 132e0dac50fSopenharmony_ci bool CheckDisplayInfo(const sptr<DisplayInfo>& display); 133e0dac50fSopenharmony_ci ScreenId GetScreenGroupId(DisplayId displayId, bool& isRecordedDisplay); 134e0dac50fSopenharmony_ci void ProcessExpandDisplayCreate(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 135e0dac50fSopenharmony_ci std::map<DisplayId, Rect>& displayRectMap); 136e0dac50fSopenharmony_ci std::map<DisplayId, Rect> GetAllDisplayRectsByDMS(sptr<DisplayInfo> displayInfo); 137e0dac50fSopenharmony_ci std::map<DisplayId, Rect> GetAllDisplayRectsByDisplayInfo( 138e0dac50fSopenharmony_ci const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap); 139e0dac50fSopenharmony_ci void MoveNotShowingWindowToDefaultDisplay(DisplayId defaultDisplayId, DisplayId displayId); 140e0dac50fSopenharmony_ci WMError PostProcessAddWindowNode(sptr<WindowNode>& node, sptr<WindowNode>& parentNode, 141e0dac50fSopenharmony_ci sptr<WindowNodeContainer>& container); 142e0dac50fSopenharmony_ci std::vector<std::pair<uint64_t, WindowVisibilityState>> GetWindowVisibilityChangeInfo( 143e0dac50fSopenharmony_ci std::shared_ptr<RSOcclusionData> occlusionData); 144e0dac50fSopenharmony_ci bool CheckAddingModeAndSize(sptr<WindowNode>& node, const sptr<WindowNodeContainer>& container); 145e0dac50fSopenharmony_ci WMError BindDialogToParent(sptr<WindowNode>& node, sptr<WindowNode>& parentNode); 146e0dac50fSopenharmony_ci void CheckAndNotifyWaterMarkChangedResult(); 147e0dac50fSopenharmony_ci 148e0dac50fSopenharmony_ci std::map<uint32_t, sptr<WindowNode>> windowNodeMap_; 149e0dac50fSopenharmony_ci std::map<sptr<IRemoteObject>, uint32_t> windowIdMap_; 150e0dac50fSopenharmony_ci std::map<uint64_t, sptr<WindowNode>> surfaceIdWindowNodeMap_; 151e0dac50fSopenharmony_ci std::vector<std::pair<uint64_t, WindowVisibilityState> > lastVisibleData_; 152e0dac50fSopenharmony_ci std::map<ScreenId, sptr<WindowNodeContainer>> windowNodeContainerMap_; 153e0dac50fSopenharmony_ci std::map<ScreenId, std::vector<DisplayId>> displayIdMap_; 154e0dac50fSopenharmony_ci bool lastWaterMarkShowStates_ { false }; 155e0dac50fSopenharmony_ci bool needCheckFocusWindow = false; 156e0dac50fSopenharmony_ci bool lastGestureNativeEnabled_ { true }; 157e0dac50fSopenharmony_ci 158e0dac50fSopenharmony_ci std::map<WindowManagerAgentType, std::vector<sptr<IWindowManagerAgent>>> windowManagerAgents_; 159e0dac50fSopenharmony_ci 160e0dac50fSopenharmony_ci sptr<AgentDeathRecipient> windowDeath_ = new AgentDeathRecipient( 161e0dac50fSopenharmony_ci [this](const sptr<IRemoteObject>& remoteObject) { this->OnRemoteDied(remoteObject); }); 162e0dac50fSopenharmony_ci Callback callback_; 163e0dac50fSopenharmony_ci uint32_t maxAppWindowNumber_ = 100; 164e0dac50fSopenharmony_ci SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}}; 165e0dac50fSopenharmony_ci}; 166e0dac50fSopenharmony_ci} 167e0dac50fSopenharmony_ci} 168e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_WINDOW_ROOT_H 169