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 16e0dac50fSopenharmony_ci#ifndef OHOS_ROSEN_WINDOW_NODE_H 17e0dac50fSopenharmony_ci#define OHOS_ROSEN_WINDOW_NODE_H 18e0dac50fSopenharmony_ci 19e0dac50fSopenharmony_ci#include <ipc_skeleton.h> 20e0dac50fSopenharmony_ci#include <refbase.h> 21e0dac50fSopenharmony_ci#include <ui/rs_surface_node.h> 22e0dac50fSopenharmony_ci#include "zidl/window_interface.h" 23e0dac50fSopenharmony_ci#include "window_manager_hilog.h" 24e0dac50fSopenharmony_ci#include "window_node_state_machine.h" 25e0dac50fSopenharmony_ci#include "window_visibility_info.h" 26e0dac50fSopenharmony_ci 27e0dac50fSopenharmony_ci#ifdef POWER_MANAGER_ENABLE 28e0dac50fSopenharmony_ci#include <running_lock.h> 29e0dac50fSopenharmony_ci#endif 30e0dac50fSopenharmony_ci 31e0dac50fSopenharmony_cinamespace OHOS { 32e0dac50fSopenharmony_cinamespace Rosen { 33e0dac50fSopenharmony_ciclass WindowNode : public RefBase { 34e0dac50fSopenharmony_cipublic: 35e0dac50fSopenharmony_ci WindowNode(const sptr<WindowProperty>& property, const sptr<IWindow>& window, 36e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> surfaceNode) 37e0dac50fSopenharmony_ci : surfaceNode_(surfaceNode), property_(property), windowToken_(window) 38e0dac50fSopenharmony_ci { 39e0dac50fSopenharmony_ci if (property != nullptr) { 40e0dac50fSopenharmony_ci abilityInfo_ = property->GetAbilityInfo(); 41e0dac50fSopenharmony_ci } 42e0dac50fSopenharmony_ci } 43e0dac50fSopenharmony_ci WindowNode(const sptr<WindowProperty>& property, const sptr<IWindow>& window, 44e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> surfaceNode, int32_t pid, int32_t uid) 45e0dac50fSopenharmony_ci : surfaceNode_(surfaceNode), property_(property), windowToken_(window), callingPid_(pid), callingUid_(uid) 46e0dac50fSopenharmony_ci { 47e0dac50fSopenharmony_ci inputCallingPid_ = pid; 48e0dac50fSopenharmony_ci if (property != nullptr) { 49e0dac50fSopenharmony_ci abilityInfo_ = property->GetAbilityInfo(); 50e0dac50fSopenharmony_ci } 51e0dac50fSopenharmony_ci } 52e0dac50fSopenharmony_ci WindowNode() : property_(new WindowProperty()) 53e0dac50fSopenharmony_ci { 54e0dac50fSopenharmony_ci } 55e0dac50fSopenharmony_ci explicit WindowNode(const sptr<WindowProperty>& property) : property_(property) 56e0dac50fSopenharmony_ci { 57e0dac50fSopenharmony_ci } 58e0dac50fSopenharmony_ci ~WindowNode(); 59e0dac50fSopenharmony_ci 60e0dac50fSopenharmony_ci void SetDisplayId(DisplayId displayId); 61e0dac50fSopenharmony_ci void SetEntireWindowTouchHotArea(const Rect& rect); 62e0dac50fSopenharmony_ci void SetEntireWindowPointerHotArea(const Rect& rect); 63e0dac50fSopenharmony_ci void SetWindowRect(const Rect& rect); 64e0dac50fSopenharmony_ci void SetDecorEnable(bool decorEnable); 65e0dac50fSopenharmony_ci void SetDecoStatus(bool decoStatus); 66e0dac50fSopenharmony_ci void SetRequestRect(const Rect& rect); 67e0dac50fSopenharmony_ci void SetWindowProperty(const sptr<WindowProperty>& property); 68e0dac50fSopenharmony_ci void SetSystemBarProperty(WindowType type, const SystemBarProperty& property); 69e0dac50fSopenharmony_ci void SetWindowMode(WindowMode mode); 70e0dac50fSopenharmony_ci void SetBrightness(float brightness); 71e0dac50fSopenharmony_ci void SetFocusable(bool focusable); 72e0dac50fSopenharmony_ci void SetTouchable(bool touchable); 73e0dac50fSopenharmony_ci void SetTurnScreenOn(bool turnScreenOn); 74e0dac50fSopenharmony_ci void SetKeepScreenOn(bool keepScreenOn); 75e0dac50fSopenharmony_ci void SetCallingWindow(uint32_t windowId); 76e0dac50fSopenharmony_ci void SetInputEventCallingPid(int32_t pid); 77e0dac50fSopenharmony_ci void SetCallingPid(int32_t pid); 78e0dac50fSopenharmony_ci void SetCallingUid(int32_t uid); 79e0dac50fSopenharmony_ci void SetWindowToken(sptr<IWindow> window); 80e0dac50fSopenharmony_ci uint32_t GetCallingWindow() const; 81e0dac50fSopenharmony_ci void SetWindowSizeChangeReason(WindowSizeChangeReason reason); 82e0dac50fSopenharmony_ci void SetRequestedOrientation(Orientation orientation); 83e0dac50fSopenharmony_ci void SetShowingDisplays(const std::vector<DisplayId>& displayIdVec); 84e0dac50fSopenharmony_ci void SetModeSupportInfo(uint32_t modeSupportInfo); 85e0dac50fSopenharmony_ci void SetDragType(DragType dragType); 86e0dac50fSopenharmony_ci void SetOriginRect(const Rect& rect); 87e0dac50fSopenharmony_ci void SetTouchHotAreas(const std::vector<Rect>& rects); 88e0dac50fSopenharmony_ci void SetPointerHotAreas(const std::vector<Rect>& rects); 89e0dac50fSopenharmony_ci void SetWindowSizeLimits(const WindowLimits& sizeLimits); 90e0dac50fSopenharmony_ci void SetWindowUpdatedSizeLimits(const WindowLimits& sizeLimits); 91e0dac50fSopenharmony_ci void ComputeTransform(); 92e0dac50fSopenharmony_ci void SetTransform(const Transform& trans); 93e0dac50fSopenharmony_ci void SetSnapshot(std::shared_ptr<Media::PixelMap> pixelMap); 94e0dac50fSopenharmony_ci std::shared_ptr<Media::PixelMap> GetSnapshot(); 95e0dac50fSopenharmony_ci Transform GetZoomTransform() const; 96e0dac50fSopenharmony_ci void UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn); 97e0dac50fSopenharmony_ci void SetAspectRatio(float ratio); 98e0dac50fSopenharmony_ci void SetWindowGravity(WindowGravity gravity, uint32_t percent); 99e0dac50fSopenharmony_ci void SetVisibilityState(WindowVisibilityState state); 100e0dac50fSopenharmony_ci 101e0dac50fSopenharmony_ci const sptr<IWindow>& GetWindowToken() const; 102e0dac50fSopenharmony_ci uint32_t GetWindowId() const; 103e0dac50fSopenharmony_ci uint32_t GetParentId() const; 104e0dac50fSopenharmony_ci const std::string& GetWindowName() const; 105e0dac50fSopenharmony_ci DisplayId GetDisplayId() const; 106e0dac50fSopenharmony_ci Rect GetEntireWindowTouchHotArea() const; 107e0dac50fSopenharmony_ci Rect GetEntireWindowPointerHotArea() const; 108e0dac50fSopenharmony_ci Rect GetWindowRect() const; 109e0dac50fSopenharmony_ci bool GetDecoStatus() const; 110e0dac50fSopenharmony_ci Rect GetRequestRect() const; 111e0dac50fSopenharmony_ci WindowType GetWindowType() const; 112e0dac50fSopenharmony_ci WindowMode GetWindowMode() const; 113e0dac50fSopenharmony_ci float GetBrightness() const; 114e0dac50fSopenharmony_ci bool IsTurnScreenOn() const; 115e0dac50fSopenharmony_ci bool IsKeepScreenOn() const; 116e0dac50fSopenharmony_ci uint32_t GetWindowFlags() const; 117e0dac50fSopenharmony_ci const sptr<WindowProperty>& GetWindowProperty() const; 118e0dac50fSopenharmony_ci int32_t GetInputEventCallingPid() const; 119e0dac50fSopenharmony_ci int32_t GetCallingPid() const; 120e0dac50fSopenharmony_ci int32_t GetCallingUid() const; 121e0dac50fSopenharmony_ci const std::unordered_map<WindowType, SystemBarProperty>& GetSystemBarProperty() const; 122e0dac50fSopenharmony_ci bool IsSplitMode() const; 123e0dac50fSopenharmony_ci WindowSizeChangeReason GetWindowSizeChangeReason() const; 124e0dac50fSopenharmony_ci Orientation GetRequestedOrientation() const; 125e0dac50fSopenharmony_ci std::vector<DisplayId> GetShowingDisplays() const; 126e0dac50fSopenharmony_ci uint32_t GetModeSupportInfo() const; 127e0dac50fSopenharmony_ci DragType GetDragType() const; 128e0dac50fSopenharmony_ci bool GetStretchable() const; 129e0dac50fSopenharmony_ci const Rect& GetOriginRect() const; 130e0dac50fSopenharmony_ci void ResetWindowSizeChangeReason(); 131e0dac50fSopenharmony_ci void GetTouchHotAreas(std::vector<Rect>& rects) const; 132e0dac50fSopenharmony_ci void GetPointerHotAreas(std::vector<Rect>& rects) const; 133e0dac50fSopenharmony_ci uint32_t GetAccessTokenId() const; 134e0dac50fSopenharmony_ci WindowLimits GetWindowSizeLimits() const; 135e0dac50fSopenharmony_ci WindowLimits GetWindowUpdatedSizeLimits() const; 136e0dac50fSopenharmony_ci float GetAspectRatio() const; 137e0dac50fSopenharmony_ci void GetWindowGravity(WindowGravity& gravity, uint32_t& percent) const; 138e0dac50fSopenharmony_ci WindowVisibilityState GetVisibilityState() const; 139e0dac50fSopenharmony_ci bool GetTouchable() const; 140e0dac50fSopenharmony_ci 141e0dac50fSopenharmony_ci bool EnableDefaultAnimation(bool animationPlayed); 142e0dac50fSopenharmony_ci sptr<WindowNode> parent_; 143e0dac50fSopenharmony_ci std::vector<sptr<WindowNode>> children_; 144e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> surfaceNode_; 145e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode_ = nullptr; 146e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> startingWinSurfaceNode_ = nullptr; 147e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> closeWinSurfaceNode_ = nullptr; 148e0dac50fSopenharmony_ci sptr<IRemoteObject> dialogTargetToken_ = nullptr; 149e0dac50fSopenharmony_ci sptr<IRemoteObject> abilityToken_ = nullptr; 150e0dac50fSopenharmony_ci 151e0dac50fSopenharmony_ci#ifdef POWER_MANAGER_ENABLE 152e0dac50fSopenharmony_ci std::shared_ptr<PowerMgr::RunningLock> keepScreenLock_ = nullptr; 153e0dac50fSopenharmony_ci#endif 154e0dac50fSopenharmony_ci 155e0dac50fSopenharmony_ci int32_t priority_ { 0 }; 156e0dac50fSopenharmony_ci uint32_t zOrder_ { 0 }; 157e0dac50fSopenharmony_ci bool requestedVisibility_ { false }; 158e0dac50fSopenharmony_ci bool currentVisibility_ { false }; 159e0dac50fSopenharmony_ci WindowVisibilityState visibilityState_ { WINDOW_LAYER_STATE_MAX }; 160e0dac50fSopenharmony_ci bool isAppCrash_ { false }; 161e0dac50fSopenharmony_ci bool isPlayAnimationShow_ { false }; // delete when enable state machine 162e0dac50fSopenharmony_ci bool isPlayAnimationHide_ { false }; // delete when enable state machine 163e0dac50fSopenharmony_ci bool startingWindowShown_ { false }; 164e0dac50fSopenharmony_ci bool firstFrameAvailable_ { false }; 165e0dac50fSopenharmony_ci bool isShowingOnMultiDisplays_ { false }; 166e0dac50fSopenharmony_ci std::vector<DisplayId> showingDisplays_; 167e0dac50fSopenharmony_ci AbilityInfo abilityInfo_; 168e0dac50fSopenharmony_ci WindowNodeStateMachine stateMachine_; 169e0dac50fSopenharmony_ci bool isFocused_ { false }; 170e0dac50fSopenharmony_ci 171e0dac50fSopenharmony_ciprivate: 172e0dac50fSopenharmony_ci sptr<WindowProperty> property_ = nullptr; 173e0dac50fSopenharmony_ci sptr<IWindow> windowToken_ = nullptr; 174e0dac50fSopenharmony_ci Rect entireWindowTouchHotArea_ { 0, 0, 0, 0 }; 175e0dac50fSopenharmony_ci Rect entireWindowPointerHotArea_ { 0, 0, 0, 0 }; 176e0dac50fSopenharmony_ci std::vector<Rect> touchHotAreas_; // coordinates relative to display. 177e0dac50fSopenharmony_ci std::vector<Rect> pointerHotAreas_; // coordinates relative to display. 178e0dac50fSopenharmony_ci std::shared_ptr<Media::PixelMap> snapshot_; 179e0dac50fSopenharmony_ci int32_t callingPid_ = { 0 }; 180e0dac50fSopenharmony_ci int32_t inputCallingPid_ = { 0 }; 181e0dac50fSopenharmony_ci int32_t callingUid_ = { 0 }; 182e0dac50fSopenharmony_ci WindowSizeChangeReason windowSizeChangeReason_ {WindowSizeChangeReason::UNDEFINED}; 183e0dac50fSopenharmony_ci}; 184e0dac50fSopenharmony_ci} // Rosen 185e0dac50fSopenharmony_ci} // OHOS 186e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_WINDOW_NODE_H 187