1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ROSEN_WINDOW_NODE_H 17 #define OHOS_ROSEN_WINDOW_NODE_H 18 19 #include <ipc_skeleton.h> 20 #include <refbase.h> 21 #include <running_lock.h> 22 #include <ui/rs_surface_node.h> 23 #include "zidl/window_interface.h" 24 #include "window_manager_hilog.h" 25 #include "window_node_state_machine.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 class WindowNode : public RefBase { 30 public: WindowNode(const sptr<WindowProperty> & property,const sptr<IWindow> & window,std::shared_ptr<RSSurfaceNode> surfaceNode)31 WindowNode(const sptr<WindowProperty>& property, const sptr<IWindow>& window, 32 std::shared_ptr<RSSurfaceNode> surfaceNode) 33 : surfaceNode_(surfaceNode), property_(property), windowToken_(window) 34 { 35 if (property != nullptr) { 36 abilityInfo_ = property->GetAbilityInfo(); 37 } 38 } WindowNode(const sptr<WindowProperty> & property,const sptr<IWindow> & window,std::shared_ptr<RSSurfaceNode> surfaceNode,int32_t pid,int32_t uid)39 WindowNode(const sptr<WindowProperty>& property, const sptr<IWindow>& window, 40 std::shared_ptr<RSSurfaceNode> surfaceNode, int32_t pid, int32_t uid) 41 : surfaceNode_(surfaceNode), property_(property), windowToken_(window), callingPid_(pid), callingUid_(uid) 42 { 43 inputCallingPid_ = pid; 44 if (property != nullptr) { 45 abilityInfo_ = property->GetAbilityInfo(); 46 } 47 } WindowNode()48 WindowNode() : property_(new WindowProperty()) 49 { 50 } WindowNode(const sptr<WindowProperty> & property)51 explicit WindowNode(const sptr<WindowProperty>& property) : property_(property) 52 { 53 } 54 ~WindowNode(); 55 56 void SetDisplayId(DisplayId displayId); 57 void SetEntireWindowTouchHotArea(const Rect& rect); 58 void SetEntireWindowPointerHotArea(const Rect& rect); 59 void SetWindowRect(const Rect& rect); 60 void SetDecoStatus(bool decoStatus); 61 void SetRequestRect(const Rect& rect); 62 void SetWindowProperty(const sptr<WindowProperty>& property); 63 void SetSystemBarProperty(WindowType type, const SystemBarProperty& property); 64 void SetWindowMode(WindowMode mode); 65 void SetBrightness(float brightness); 66 void SetFocusable(bool focusable); 67 void SetTouchable(bool touchable); 68 void SetTurnScreenOn(bool turnScreenOn); 69 void SetKeepScreenOn(bool keepScreenOn); 70 void SetCallingWindow(uint32_t windowId); 71 void SetInputEventCallingPid(int32_t pid); 72 void SetCallingPid(int32_t pid); 73 void SetCallingUid(int32_t uid); 74 void SetWindowToken(sptr<IWindow> window); 75 uint32_t GetCallingWindow() const; 76 void SetWindowSizeChangeReason(WindowSizeChangeReason reason); 77 void SetRequestedOrientation(Orientation orientation); 78 void SetShowingDisplays(const std::vector<DisplayId>& displayIdVec); 79 void SetModeSupportInfo(uint32_t modeSupportInfo); 80 void SetDragType(DragType dragType); 81 void SetOriginRect(const Rect& rect); 82 void SetTouchHotAreas(const std::vector<Rect>& rects); 83 void SetPointerHotAreas(const std::vector<Rect>& rects); 84 void SetWindowSizeLimits(const WindowSizeLimits& sizeLimits); 85 void SetWindowUpdatedSizeLimits(const WindowSizeLimits& sizeLimits); 86 void ComputeTransform(); 87 void SetTransform(const Transform& trans); 88 void SetSnapshot(std::shared_ptr<Media::PixelMap> pixelMap); 89 std::shared_ptr<Media::PixelMap> GetSnapshot(); 90 Transform GetZoomTransform() const; 91 void UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn); 92 93 const sptr<IWindow>& GetWindowToken() const; 94 uint32_t GetWindowId() const; 95 uint32_t GetParentId() const; 96 const std::string& GetWindowName() const; 97 DisplayId GetDisplayId() const; 98 Rect GetEntireWindowTouchHotArea() const; 99 Rect GetEntireWindowPointerHotArea() const; 100 Rect GetWindowRect() const; 101 bool GetDecoStatus() const; 102 Rect GetRequestRect() const; 103 WindowType GetWindowType() const; 104 WindowMode GetWindowMode() const; 105 float GetBrightness() const; 106 bool IsTurnScreenOn() const; 107 bool IsKeepScreenOn() const; 108 uint32_t GetWindowFlags() const; 109 const sptr<WindowProperty>& GetWindowProperty() const; 110 int32_t GetInputEventCallingPid() const; 111 int32_t GetCallingPid() const; 112 int32_t GetCallingUid() const; 113 const std::unordered_map<WindowType, SystemBarProperty>& GetSystemBarProperty() const; 114 bool IsSplitMode() const; 115 WindowSizeChangeReason GetWindowSizeChangeReason() const; 116 Orientation GetRequestedOrientation() const; 117 std::vector<DisplayId> GetShowingDisplays() const; 118 uint32_t GetModeSupportInfo() const; 119 DragType GetDragType() const; 120 bool GetStretchable() const; 121 const Rect& GetOriginRect() const; 122 void ResetWindowSizeChangeReason(); 123 void GetTouchHotAreas(std::vector<Rect>& rects) const; 124 void GetPointerHotAreas(std::vector<Rect>& rects) const; 125 uint32_t GetAccessTokenId() const; 126 WindowSizeLimits GetWindowSizeLimits() const; 127 WindowSizeLimits GetWindowUpdatedSizeLimits() const; 128 129 bool EnableDefaultAnimation(bool animationPlayed); 130 sptr<WindowNode> parent_; 131 std::vector<sptr<WindowNode>> children_; 132 std::shared_ptr<RSSurfaceNode> surfaceNode_; 133 std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode_ = nullptr; 134 std::shared_ptr<RSSurfaceNode> startingWinSurfaceNode_ = nullptr; 135 sptr<IRemoteObject> dialogTargetToken_ = nullptr; 136 sptr<IRemoteObject> abilityToken_ = nullptr; 137 std::shared_ptr<PowerMgr::RunningLock> keepScreenLock_; 138 int32_t priority_ { 0 }; 139 uint32_t zOrder_ { 0 }; 140 bool requestedVisibility_ { false }; 141 bool currentVisibility_ { false }; 142 bool isVisible_ { false }; 143 bool isAppCrash_ { false }; 144 bool isPlayAnimationShow_ { false }; // delete when enable state machine 145 bool isPlayAnimationHide_ { false }; // delete when enable state machine 146 bool startingWindowShown_ { false }; 147 bool firstFrameAvaliable_ { false }; 148 bool isShowingOnMultiDisplays_ { false }; 149 std::vector<DisplayId> showingDisplays_; 150 AbilityInfo abilityInfo_; 151 WindowNodeStateMachine stateMachine_; 152 153 private: 154 sptr<WindowProperty> property_ = nullptr; 155 sptr<IWindow> windowToken_ = nullptr; 156 Rect entireWindowTouchHotArea_ { 0, 0, 0, 0 }; 157 Rect entireWindowPointerHotArea_ { 0, 0, 0, 0 }; 158 std::vector<Rect> touchHotAreas_; // coordinates relative to display. 159 std::vector<Rect> pointerHotAreas_; // coordinates relative to display. 160 std::shared_ptr<Media::PixelMap> snapshot_; 161 int32_t callingPid_ = { 0 }; 162 int32_t inputCallingPid_ = { 0 }; 163 int32_t callingUid_ = { 0 }; 164 WindowSizeChangeReason windowSizeChangeReason_ {WindowSizeChangeReason::UNDEFINED}; 165 }; 166 } // Rosen 167 } // OHOS 168 #endif // OHOS_ROSEN_WINDOW_NODE_H 169