/* * Copyright (c) 2021-2022 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_LAYOUT_POLICY_H #define OHOS_ROSEN_WINDOW_LAYOUT_POLICY_H #include #include #include #include "window_node.h" #include "wm_common.h" namespace OHOS { namespace Rosen { class WindowLayoutPolicy : public RefBase { public: WindowLayoutPolicy() = delete; WindowLayoutPolicy(const Rect& displayRect, const uint64_t& screenId, sptr& belowAppNode, sptr& appNode, sptr& aboveAppNode); ~WindowLayoutPolicy() = default; virtual void Launch(); virtual void Clean(); virtual void Reset(); virtual void Reorder(); virtual void UpdateDisplayInfo(); virtual void AddWindowNode(sptr& node); virtual void LayoutWindowTree(); virtual void RemoveWindowNode(sptr& node); virtual void UpdateWindowNode(sptr& node, bool isAddWindow = false); virtual void UpdateLayoutRect(sptr& node) = 0; void UpdateDefaultFoatingRect(); float GetVirtualPixelRatio() const; Rect GetDisplayLimitRect() const; protected: const Rect& displayRect_; const uint64_t& screenId_; sptr& belowAppWindowNode_; sptr& appWindowNode_; sptr& aboveAppWindowNode_; Rect limitRect_ = { 0, 0, 0, 0 }; const std::set avoidTypes_ { WindowType::WINDOW_TYPE_STATUS_BAR, WindowType::WINDOW_TYPE_NAVIGATION_BAR, }; void UpdateFloatingLayoutRect(Rect& limitRect, Rect& winRect); void UpdateLimitRect(const sptr& node, Rect& limitRect); virtual void LayoutWindowNode(sptr& node); AvoidPosType GetAvoidPosType(const Rect& rect); void CalcAndSetNodeHotZone(Rect layoutOutRect, sptr& node); void LimitWindowSize(const sptr& node, const Rect& displayRect, Rect& winRect); void SetRectForFloating(const sptr& node); Rect ComputeDecoratedWindowRect(const Rect& winRect); bool IsVertical() const; bool IsFullScreenRecentWindowExist() const; Rect defaultFloatingRect_ = { 0, 0, 0, 0 }; }; } } #endif // OHOS_ROSEN_WINDOW_LAYOUT_POLICY_H