• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_VISIBILITY_INFO_H
17 #define OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H
18 
19 #include "wm_common.h"
20 
21 namespace OHOS::Rosen {
22 /**
23  * @enum WindowLayerState
24  *
25  * @brief Layer state of a window
26  */
27 enum WindowLayerState {
28     WINDOW_ALL_VISIBLE = 0,
29     WINDOW_SEMI_VISIBLE,
30     WINDOW_IN_VISIBLE,
31     WINDOW_LAYER_DRAWING,
32     WINDOW_LAYER_NO_DRAWING,
33     WINDOW_LAYER_UNKNOWN_STATE,
34 };
35 
36 /**
37  * @class WindowVisibilityInfo
38  *
39  * @brief Visibility info of window.
40  */
41 class WindowVisibilityInfo : public Parcelable {
42 public:
43     /**
44      * @brief Default construct of WindowVisibilityInfo.
45      */
46     WindowVisibilityInfo() = default;
47 
48     /**
49      * @brief Construct of WindowVisibilityInfo.
50      *
51      * @param winId Window id.
52      * @param pid Process id.
53      * @param uid User id.
54      * @param visibility True means window is visible, false means the opposite.
55      * @param winType Type of window.
56      */
WindowVisibilityInfo(uint32_t winId,int32_t pid,int32_t uid,WindowVisibilityState visibilityState,WindowType winType)57     WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState,
58         WindowType winType) : windowId_(winId), pid_(pid), uid_(uid), visibilityState_(visibilityState),
59         windowType_(winType) {};
60 
WindowVisibilityInfo(uint32_t winId,int32_t pid,int32_t uid,WindowVisibilityState visibilityState,WindowType winType,WindowStatus windowStatus,const Rect & rect,const std::string & bundleName,const std::string & abilityName,bool isFocused)61     WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState,
62         WindowType winType, WindowStatus windowStatus, const Rect& rect, const std::string& bundleName,
63         const std::string& abilityName, bool isFocused) : windowId_(winId), pid_(pid), uid_(uid),
64         visibilityState_(visibilityState), windowType_(winType), windowStatus_(windowStatus), rect_(rect),
65         bundleName_(bundleName), abilityName_(abilityName), isFocused_(isFocused) {}
66 
67     /**
68      * @brief Deconstruct of WindowVisibilityInfo.
69      */
70     ~WindowVisibilityInfo() = default;
71 
72     /**
73      * @brief Marshalling WindowVisibilityInfo.
74      *
75      * @param parcel Package of WindowVisibilityInfo.
76      * @return True means marshall success, false means marshall failed.
77      */
78     virtual bool Marshalling(Parcel& parcel) const override;
79 
80     /**
81      * @brief Unmarshalling WindowVisibilityInfo.
82      *
83      * @param parcel Package of WindowVisibilityInfo.
84      * @return WindowVisibilityInfo object.
85      */
86     static WindowVisibilityInfo* Unmarshalling(Parcel& parcel);
87 
GetWindowId()88     uint32_t GetWindowId() const { return windowId_; }
89 
GetRect()90     const Rect& GetRect() const { return rect_; }
91 
GetBundleName()92     const std::string& GetBundleName() const { return bundleName_; }
93 
SetBundleName(const std::string & bundleName)94     void SetBundleName(const std::string& bundleName) { bundleName_ = bundleName; }
95 
GetAbilityName()96     const std::string& GetAbilityName() const { return abilityName_; }
97 
SetAbilityName(const std::string & abilityName)98     void SetAbilityName(const std::string& abilityName) { abilityName_ = abilityName; }
99 
GetWindowStatus()100     WindowStatus GetWindowStatus() const { return windowStatus_; }
101 
GetWindowType()102     WindowType GetWindowType() const { return windowType_; }
103 
GetWindowVisibilityState()104     WindowVisibilityState GetWindowVisibilityState() const { return visibilityState_; }
105 
IsFocused()106     bool IsFocused() const { return isFocused_; }
107 
GetAppIndex()108     int32_t GetAppIndex() const { return appIndex_; }
109 
SetAppIndex(int32_t appIndex)110     void SetAppIndex(int32_t appIndex) { appIndex_ = appIndex; }
111 
IsSystem()112     bool IsSystem() const { return isSystem_; }
113 
SetIsSystem(bool isSystem)114     void SetIsSystem(bool isSystem) { isSystem_ = isSystem; }
115 
116     uint32_t windowId_ { INVALID_WINDOW_ID };
117     int32_t pid_ { 0 };
118     int32_t uid_ { 0 };
119     WindowVisibilityState visibilityState_ = WINDOW_LAYER_STATE_MAX;
120     WindowType windowType_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
121     WindowStatus windowStatus_ = WindowStatus::WINDOW_STATUS_UNDEFINED;
122     Rect rect_ = {0, 0, 0, 0};
123     std::string bundleName_;
124     std::string abilityName_;
125     bool isFocused_ = false;
126     int32_t appIndex_ { 0 };
127     bool isSystem_ = false;
128 };
129 } // namespace OHOS::Rosen
130 #endif // OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H