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