/* * 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_NODE_H #define OHOS_ROSEN_WINDOW_NODE_H #include #include #include #include "zidl/window_interface.h" #include "window_manager_hilog.h" #include "window_node_state_machine.h" #include "window_visibility_info.h" #ifdef POWER_MANAGER_ENABLE #include #endif namespace OHOS { namespace Rosen { class WindowNode : public RefBase { public: WindowNode(const sptr& property, const sptr& window, std::shared_ptr surfaceNode) : surfaceNode_(surfaceNode), property_(property), windowToken_(window) { if (property != nullptr) { abilityInfo_ = property->GetAbilityInfo(); } } WindowNode(const sptr& property, const sptr& window, std::shared_ptr surfaceNode, int32_t pid, int32_t uid) : surfaceNode_(surfaceNode), property_(property), windowToken_(window), callingPid_(pid), callingUid_(uid) { inputCallingPid_ = pid; if (property != nullptr) { abilityInfo_ = property->GetAbilityInfo(); } } WindowNode() : property_(new WindowProperty()) { } explicit WindowNode(const sptr& property) : property_(property) { } ~WindowNode(); void SetDisplayId(DisplayId displayId); void SetEntireWindowTouchHotArea(const Rect& rect); void SetEntireWindowPointerHotArea(const Rect& rect); void SetWindowRect(const Rect& rect); void SetDecorEnable(bool decorEnable); void SetDecoStatus(bool decoStatus); void SetRequestRect(const Rect& rect); void SetWindowProperty(const sptr& property); void SetSystemBarProperty(WindowType type, const SystemBarProperty& property); void SetWindowMode(WindowMode mode); void SetBrightness(float brightness); void SetFocusable(bool focusable); void SetTouchable(bool touchable); void SetTurnScreenOn(bool turnScreenOn); void SetKeepScreenOn(bool keepScreenOn); void SetCallingWindow(uint32_t windowId); void SetInputEventCallingPid(int32_t pid); void SetCallingPid(int32_t pid); void SetCallingUid(int32_t uid); void SetWindowToken(sptr window); uint32_t GetCallingWindow() const; void SetWindowSizeChangeReason(WindowSizeChangeReason reason); void SetRequestedOrientation(Orientation orientation); void SetShowingDisplays(const std::vector& displayIdVec); void SetWindowModeSupportType(uint32_t windowModeSupportType); void SetDragType(DragType dragType); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); void SetPointerHotAreas(const std::vector& rects); void SetWindowSizeLimits(const WindowLimits& sizeLimits); void SetWindowUpdatedSizeLimits(const WindowLimits& sizeLimits); void ComputeTransform(); void SetTransform(const Transform& trans); void SetSnapshot(std::shared_ptr pixelMap); std::shared_ptr GetSnapshot(); Transform GetZoomTransform() const; void UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn); void SetAspectRatio(float ratio); void SetWindowGravity(WindowGravity gravity, uint32_t percent); void SetVisibilityState(WindowVisibilityState state); const sptr& GetWindowToken() const; uint32_t GetWindowId() const; uint32_t GetParentId() const; const std::string& GetWindowName() const; DisplayId GetDisplayId() const; Rect GetEntireWindowTouchHotArea() const; Rect GetEntireWindowPointerHotArea() const; Rect GetWindowRect() const; bool GetDecoStatus() const; Rect GetRequestRect() const; WindowType GetWindowType() const; WindowMode GetWindowMode() const; float GetBrightness() const; bool IsTurnScreenOn() const; bool IsKeepScreenOn() const; uint32_t GetWindowFlags() const; const sptr& GetWindowProperty() const; int32_t GetInputEventCallingPid() const; int32_t GetCallingPid() const; int32_t GetCallingUid() const; const std::unordered_map& GetSystemBarProperty() const; bool IsSplitMode() const; WindowSizeChangeReason GetWindowSizeChangeReason() const; Orientation GetRequestedOrientation() const; std::vector GetShowingDisplays() const; uint32_t GetWindowModeSupportType() const; DragType GetDragType() const; bool GetStretchable() const; const Rect& GetOriginRect() const; void ResetWindowSizeChangeReason(); void GetTouchHotAreas(std::vector& rects) const; void GetPointerHotAreas(std::vector& rects) const; uint32_t GetAccessTokenId() const; WindowLimits GetWindowSizeLimits() const; WindowLimits GetWindowUpdatedSizeLimits() const; float GetAspectRatio() const; void GetWindowGravity(WindowGravity& gravity, uint32_t& percent) const; WindowVisibilityState GetVisibilityState() const; bool GetTouchable() const; bool EnableDefaultAnimation(bool animationPlayed); sptr parent_; std::vector> children_; std::shared_ptr surfaceNode_; std::shared_ptr leashWinSurfaceNode_ = nullptr; std::shared_ptr startingWinSurfaceNode_ = nullptr; std::shared_ptr closeWinSurfaceNode_ = nullptr; sptr dialogTargetToken_ = nullptr; sptr abilityToken_ = nullptr; #ifdef POWER_MANAGER_ENABLE std::shared_ptr keepScreenLock_ = nullptr; #endif int32_t priority_ { 0 }; uint32_t zOrder_ { 0 }; bool requestedVisibility_ { false }; bool currentVisibility_ { false }; WindowVisibilityState visibilityState_ { WINDOW_LAYER_STATE_MAX }; bool isAppCrash_ { false }; bool isPlayAnimationShow_ { false }; // delete when enable state machine bool isPlayAnimationHide_ { false }; // delete when enable state machine bool startingWindowShown_ { false }; bool firstFrameAvailable_ { false }; bool isShowingOnMultiDisplays_ { false }; std::vector showingDisplays_; AbilityInfo abilityInfo_; WindowNodeStateMachine stateMachine_; bool isFocused_ { false }; private: sptr property_ = nullptr; sptr windowToken_ = nullptr; Rect entireWindowTouchHotArea_ { 0, 0, 0, 0 }; Rect entireWindowPointerHotArea_ { 0, 0, 0, 0 }; std::vector touchHotAreas_; // coordinates relative to display. std::vector pointerHotAreas_; // coordinates relative to display. std::shared_ptr snapshot_; int32_t callingPid_ = { 0 }; int32_t inputCallingPid_ = { 0 }; int32_t callingUid_ = { 0 }; WindowSizeChangeReason windowSizeChangeReason_ {WindowSizeChangeReason::UNDEFINED}; }; } // Rosen } // OHOS #endif // OHOS_ROSEN_WINDOW_NODE_H