• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
26 namespace OHOS {
27 namespace Rosen {
28 class WindowNode : public RefBase {
29 public:
WindowNode(const sptr<WindowProperty> & property,const sptr<IWindow> & window,std::shared_ptr<RSSurfaceNode> surfaceNode)30     WindowNode(const sptr<WindowProperty>& property, const sptr<IWindow>& window,
31         std::shared_ptr<RSSurfaceNode> surfaceNode)
32         : surfaceNode_(surfaceNode), property_(property), windowToken_(window)
33     {
34         callingPid_ = IPCSkeleton::GetCallingPid();
35         callingUid_ = IPCSkeleton::GetCallingUid();
36     }
WindowNode()37     WindowNode() : property_(new WindowProperty())
38     {
39         callingPid_ = IPCSkeleton::GetCallingPid();
40         callingUid_ = IPCSkeleton::GetCallingUid();
41     }
42     ~WindowNode() = default;
43 
44     void SetDisplayId(DisplayId displayId);
45     void SetLayoutRect(const Rect& rect);
46     void SetHotZoneRect(const Rect& rect);
47     void SetWindowRect(const Rect& rect);
48     void SetWindowProperty(const sptr<WindowProperty>& property);
49     void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
50     void SetWindowMode(WindowMode mode);
51     void SetWindowBackgroundBlur(WindowBlurLevel level);
52     void SetAlpha(float alpha);
53     void SetBrightness(float brightness);
54     void SetFocusable(bool focusable);
55     void SetTouchable(bool touchable);
56     void SetTurnScreenOn(bool turnScreenOn);
57     void SetKeepScreenOn(bool keepScreenOn);
58     void SetCallingWindow(uint32_t windowId);
59     uint32_t GetCallingWindow() const;
60     void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
61     void SetRequestedOrientation(Orientation orientation);
62     const sptr<IWindow>& GetWindowToken() const;
63     uint32_t GetWindowId() const;
64     uint32_t GetParentId() const;
65     const std::string& GetWindowName() const;
66     DisplayId GetDisplayId() const;
67     const Rect& GetLayoutRect() const;
68     Rect GetHotZoneRect() const;
69     Rect GetWindowRect() const;
70     WindowType GetWindowType() const;
71     WindowMode GetWindowMode() const;
72     WindowBlurLevel GetWindowBackgroundBlur() const;
73     float GetAlpha() const;
74     float GetBrightness() const;
75     bool IsTurnScreenOn() const;
76     bool IsKeepScreenOn() const;
77     uint32_t GetWindowFlags() const;
78     const sptr<WindowProperty>& GetWindowProperty() const;
79     int32_t GetCallingPid() const;
80     int32_t GetCallingUid() const;
81     const std::unordered_map<WindowType, SystemBarProperty>& GetSystemBarProperty() const;
82     bool IsSplitMode() const;
83     WindowSizeChangeReason GetWindowSizeChangeReason() const;
84     Orientation GetRequestedOrientation() const;
85     void ResetWindowSizeChangeReason();
86 
87     sptr<WindowNode> parent_;
88     std::vector<sptr<WindowNode>> children_;
89     std::shared_ptr<RSSurfaceNode> surfaceNode_;
90     sptr<IRemoteObject> abilityToken_ = nullptr;
91     std::shared_ptr<PowerMgr::RunningLock> keepScreenLock_;
92     int32_t priority_ { 0 };
93     bool requestedVisibility_ { false };
94     bool currentVisibility_ { false };
95     bool hasDecorated_ { false };
96     bool isDefultLayoutRect_ { false };
97     bool isCovered_ { true }; // initial value true to ensure notification when this window is shown
98 
99 private:
100     sptr<WindowProperty> property_;
101     sptr<IWindow> windowToken_;
102     Rect layoutRect_ { 0, 0, 0, 0 };
103     Rect hotZoneRect_ { 0, 0, 0, 0 };
104     int32_t callingPid_;
105     int32_t callingUid_;
106     WindowSizeChangeReason windowSizeChangeReason_ {WindowSizeChangeReason::UNDEFINED};
107 };
108 } // Rosen
109 } // OHOS
110 #endif // OHOS_ROSEN_WINDOW_NODE_H
111