/* * Copyright (c) 2021-2023 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(DisplayId defaultDisplayId, sptr displayInfo); sptr GetWindowNode(uint32_t windowId) const; sptr GetWindowNodeByMissionId(uint32_t missionId) const; void GetBackgroundNodesByScreenId(ScreenId screenGroupId, std::vector>& windowNodes); void GetForegroundNodes(std::vector>& windowNodes); sptr FindWallpaperWindow(); 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 DispatchKeyEvent(sptr node, std::shared_ptr event); void FocusFaultDetection() 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); 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 FindMainWindowWithToken(sptr token); bool CheckMultiDialogWindows(WindowType type, sptr token); bool HasPrivateWindow(DisplayId displayId); Rect GetDisplayRectWithoutSystemBarAreas(const sptr destNode); sptr GetWindowNodeByAbilityToken(const sptr& abilityToken); bool TakeWindowPairSnapshot(DisplayId displayId); void ClearWindowPairSnapshot(DisplayId displayId); void LayoutWhenAddWindowNode(sptr& node, bool afterAnimation = false); void GetAllAnimationPlayingNodes(std::vector>& windowNodes); void GetVisibilityWindowInfo(std::vector>& infos) const; void GetUnreliableWindowInfo(int32_t windowId, std::vector>& infos) const; WMError NotifyDesktopUnfrozen(); void UpdateDisplayOrientationWhenHideWindow(sptr& node); bool HasMainFullScreenWindowShown(DisplayId displayId); WMError SetGestureNavigaionEnabled(bool enable); private: 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 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 CheckAddingModeAndSize(sptr& node, const sptr& container); WMError BindDialogToParent(sptr& node, sptr& parentNode); void CheckAndNotifyWaterMarkChangedResult(); std::map> windowNodeMap_; std::map, uint32_t> windowIdMap_; std::map> surfaceIdWindowNodeMap_; std::vector > lastVisibleData_; std::map> windowNodeContainerMap_; std::map> displayIdMap_; bool lastWaterMarkShowStates_ { false }; bool needCheckFocusWindow = false; bool lastGestureNativeEnabled_ { true }; std::map>> windowManagerAgents_; sptr windowDeath_ = new AgentDeathRecipient( [this](const sptr& remoteObject) { this->OnRemoteDied(remoteObject); }); Callback callback_; uint32_t maxAppWindowNumber_ = 100; SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}}; }; } } #endif // OHOS_ROSEN_WINDOW_ROOT_H