• 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_OCCUPIED_AREA_CHANGE_INFO_H
17 #define OHOS_OCCUPIED_AREA_CHANGE_INFO_H
18 
19 #include <cstdint>
20 #include <parcel.h>
21 
22 #include "wm_common.h"
23 
24 namespace OHOS::Rosen {
25 class OccupiedAreaChangeInfo : public Parcelable {
26 public:
27 
28     OccupiedAreaChangeInfo() = default;
OccupiedAreaChangeInfo(OccupiedAreaType type,Rect rect)29     OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect) : type_(type), rect_(rect) {};
OccupiedAreaChangeInfo(OccupiedAreaType type,Rect rect,uint32_t safeHeight)30     OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect, uint32_t safeHeight)
31         : type_(type), rect_(rect), safeHeight_(safeHeight) {};
32     ~OccupiedAreaChangeInfo() = default;
33 
Marshalling(Parcel & parcel)34     virtual bool Marshalling(Parcel& parcel) const
35     {
36         return parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) &&
37             parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
38             parcel.WriteUint32(static_cast<uint32_t>(type_)) &&
39             parcel.WriteUint32(safeHeight_);
40     }
41 
Unmarshalling(Parcel & parcel)42     static OccupiedAreaChangeInfo* Unmarshalling(Parcel& parcel)
43     {
44         OccupiedAreaChangeInfo* occupiedAreaChangeInfo = new OccupiedAreaChangeInfo();
45         bool res = parcel.ReadInt32(occupiedAreaChangeInfo->rect_.posX_) &&
46             parcel.ReadInt32(occupiedAreaChangeInfo->rect_.posY_) &&
47             parcel.ReadUint32(occupiedAreaChangeInfo->rect_.width_) &&
48             parcel.ReadUint32(occupiedAreaChangeInfo->rect_.height_);
49         if (!res) {
50             delete occupiedAreaChangeInfo;
51             return nullptr;
52         }
53         occupiedAreaChangeInfo->type_ = static_cast<OccupiedAreaType>(parcel.ReadUint32());
54         occupiedAreaChangeInfo->safeHeight_ = parcel.ReadUint32();
55         return occupiedAreaChangeInfo;
56     }
57 
58     OccupiedAreaType type_ = OccupiedAreaType::TYPE_INPUT;
59     Rect rect_ = { 0, 0, 0, 0 };
60     uint32_t safeHeight_ = 0;
61 };
62 } // namespace OHOS::Rosen
63 #endif // OHOS_OCCUPIED_AREA_CHANGE_INFO_H