/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ROSEN_WINDOW_ROOT_H #define OHOS_ROSEN_WINDOW_ROOT_H #include #include #include #include "agent_death_recipient.h" #include "display_manager_service_inner.h" #include "parameters.h" #include "window_node_container.h" #include "zidl/window_manager_agent_interface.h" namespace OHOS { namespace Rosen { enum class Event : uint32_t { REMOTE_DIED, }; class WindowRoot : public RefBase { using Callback = std::function& remoteObject)>; public: explicit WindowRoot(Callback callback) : callback_(callback) {} ~WindowRoot() = default; sptr GetOrCreateWindowNodeContainer(DisplayId displayId); sptr GetWindowNodeContainer(DisplayId displayId); sptr CreateWindowNodeContainer(sptr displayInfo); sptr GetWindowNode(uint32_t windowId) const; void GetBackgroundNodesByScreenId(ScreenId screenGroupId, std::vector>& windowNodes) const; WMError SaveWindow(const sptr& node); void AddDeathRecipient(sptr node); sptr FindWindowNodeWithToken(const sptr& token) const; WMError AddWindowNode(uint32_t parentId, sptr& node, bool fromStartingWin = false); WMError RemoveWindowNode(uint32_t windowId, bool fromAnimation = false); WMError DestroyWindow(uint32_t windowId, bool onlySelf); WMError UpdateWindowNode(uint32_t windowId, WindowUpdateReason reason); bool IsVerticalDisplay(sptr& node) const; bool IsForbidDockSliceMove(DisplayId displayId) const; bool IsDockSliceInExitSplitModeArea(DisplayId displayId) const; void ExitSplitMode(DisplayId displayId); void NotifyWindowVisibilityChange(std::shared_ptr occlusionData); void AddSurfaceNodeIdWindowNodePair(uint64_t surfaceNodeId, sptr node); WMError RequestFocus(uint32_t windowId); WMError RequestActiveWindow(uint32_t windowId); WMError MinimizeStructuredAppWindowsExceptSelf(sptr& node); AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType); WMError SetWindowMode(sptr& node, WindowMode dstMode); WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId); void MinimizeAllAppWindows(DisplayId displayId); WMError ToggleShownStateForAllAppWindows(); WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode); void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason); void ProcessDisplayChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type); void ProcessDisplayDestroy(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap); void ProcessDisplayCreate(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap); void NotifySystemBarTints(); WMError RaiseZOrderForAppWindow(sptr& node); void FocusFaultDetection() const; float GetVirtualPixelRatio(DisplayId displayId) const; Rect GetDisplayGroupRect(DisplayId displayId) const; WMError UpdateSizeChangeReason(uint32_t windowId, WindowSizeChangeReason reason); void SetBrightness(uint32_t windowId, float brightness); void HandleKeepScreenOn(uint32_t windowId, bool requireLock); void UpdateFocusableProperty(uint32_t windowId); void SetMaxAppWindowNumber(uint32_t windowNum); void SetMaxUniRenderAppWindowNumber(uint32_t uniAppWindowNum); uint32_t GetMaxUniRenderAppWindowNumber() const; WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config); std::vector GetAllDisplayIds() const; uint32_t GetTotalWindowNum() const; uint32_t GetWindowIdByObject(const sptr& remoteObject); sptr GetWindowForDumpAceHelpInfo() const; void DestroyLeakStartingWindow(); void SetSplitRatios(const std::vector& splitRatioNumbers); std::vector> GetSplitScreenWindowNodes(DisplayId displayId); void SetExitSplitRatios(const std::vector& exitSplitRatios); void MinimizeTargetWindows(std::vector& windowIds); WMError UpdateRsTree(uint32_t windowId, bool isAdd); void RemoveSingleUserWindowNodes(int accountId); sptr FindDialogCallerNode(WindowType type, sptr token); bool CheckMultiDialogWindows(WindowType type, sptr token); bool HasPrivateWindow(DisplayId displayId); Rect GetDisplayRectWithoutSystemBarAreas(DisplayId displayId); void SwitchRenderModeIfNeeded(); void OnRenderModeChanged(bool isUniRender); sptr GetWindowNodeByAbilityToken(const sptr& abilityToken); bool TakeWindowPairSnapshot(DisplayId displayId); void ClearWindowPairSnapshot(DisplayId displayId); bool IsUniRender() { return renderMode_ == RenderMode::UNIFIED; } void LayoutWhenAddWindowNode(sptr& node, bool afterAnimation = false); void GetAllAnimationPlayingNodes(std::vector>& windowNodes); void GetVisibilityWindowInfo(std::vector>& infos) const; private: enum class RenderMode : uint8_t { SEPARATED, UNIFIED, SEPARATING, UNIFYING, }; void OnRemoteDied(const sptr& remoteObject); WMError DestroyWindowInner(sptr& node); WMError DestroyWindowSelf(sptr& node, const sptr& container); WMError DestroyWindowWithChild(sptr& node, const sptr& container); void UpdateFocusWindowWithWindowRemoved(const sptr& node, const sptr& container) const; void UpdateActiveWindowWithWindowRemoved(const sptr& node, const sptr& container) const; void UpdateBrightnessWithWindowRemoved(uint32_t windowId, const sptr& container) const; std::string GenAllWindowsLogInfo() const; bool CheckDisplayInfo(const sptr& display); ScreenId GetScreenGroupId(DisplayId displayId, bool& isRecordedDisplay); void ProcessExpandDisplayCreate(DisplayId defaultDisplayId, sptr displayInfo, std::map& displayRectMap); std::map> GetAllDisplayInfos(const std::vector& displayIdVec); std::map GetAllDisplayRectsByDMS(sptr displayInfo); std::map GetAllDisplayRectsByDisplayInfo( const std::map>& displayInfoMap); void MoveNotShowingWindowToDefaultDisplay(DisplayId defaultDisplayId, DisplayId displayId); WMError PostProcessAddWindowNode(sptr& node, sptr& parentNode, sptr& container); std::vector> GetWindowVisibilityChangeInfo( std::shared_ptr occlusionData); bool NeedToStopAddingNode(sptr& node, const sptr& container); void ChangeRSRenderModeIfNeeded(bool isToUnified); bool IsAppWindowExceed() const; std::map> windowNodeMap_; std::map, uint32_t> windowIdMap_; std::map> surfaceIdWindowNodeMap_; std::shared_ptr lastOcclusionData_ = std::make_shared(); std::map> windowNodeContainerMap_; std::map> displayIdMap_; bool needCheckFocusWindow = false; std::map>> windowManagerAgents_; sptr windowDeath_ = new AgentDeathRecipient(std::bind(&WindowRoot::OnRemoteDied, this, std::placeholders::_1)); Callback callback_; uint32_t maxAppWindowNumber_ = 100; uint32_t maxUniRenderAppWindowNumber_ { maxAppWindowNumber_ }; SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}}; RenderMode renderMode_ { RenderMode::UNIFIED }; }; } } #endif // OHOS_ROSEN_WINDOW_ROOT_H