1 /* 2 * Copyright (c) 2024-2025 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 SHIFT_INFO_H 17 #define SHIFT_INFO_H 18 19 #include "window_info.h" 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace MMI { 24 struct ShiftWindowParam : public Parcelable { 25 int32_t sourceWindowId { -1 }; 26 int32_t targetWindowId { -1 }; 27 int32_t x { -1 }; 28 int32_t y { -1 }; 29 int32_t fingerId { -1 }; 30 int32_t sourceType { PointerEvent::SOURCE_TYPE_UNKNOWN }; 31 MarshallingShiftWindowParam32 bool Marshalling(Parcel &out) const 33 { 34 if (!out.WriteInt32(sourceWindowId)) { 35 return false; 36 } 37 if (!out.WriteInt32(targetWindowId)) { 38 return false; 39 } 40 if (!out.WriteInt32(x)) { 41 return false; 42 } 43 if (!out.WriteInt32(y)) { 44 return false; 45 } 46 if (!out.WriteInt32(fingerId)) { 47 return false; 48 } 49 if (!out.WriteInt32(sourceType)) { 50 } 51 return true; 52 } 53 ReadFromParcelShiftWindowParam54 bool ReadFromParcel(Parcel &in) 55 { 56 return ( 57 in.ReadInt32(sourceWindowId) && 58 in.ReadInt32(targetWindowId) && 59 in.ReadInt32(x) && 60 in.ReadInt32(y) && 61 in.ReadInt32(fingerId) && 62 in.ReadInt32(sourceType) 63 ); 64 } 65 UnmarshallingShiftWindowParam66 static ShiftWindowParam* Unmarshalling(Parcel &in) 67 { 68 auto obj = new (std::nothrow) ShiftWindowParam(); 69 if (obj && !obj->ReadFromParcel(in)) { 70 delete obj; 71 obj = nullptr; 72 } 73 return obj; 74 }; 75 }; 76 77 struct ShiftWindowInfo { 78 WindowInfo sourceWindowInfo; 79 WindowInfo targetWindowInfo; 80 int32_t x { -1 }; 81 int32_t y { -1 }; 82 int32_t fingerId { -1 }; 83 int32_t sourceType { PointerEvent::SOURCE_TYPE_UNKNOWN }; 84 }; 85 } // namespace MMI 86 } // namespace OHOS 87 #endif // SHIFT_INFO_H