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 LONG_PRESS_EVENT_H 17 #define LONG_PRESS_EVENT_H 18 19 #include "parcel.h" 20 21 namespace OHOS { 22 namespace MMI { 23 struct LongPressRequest : public Parcelable { 24 int32_t fingerCount { -1 }; 25 int32_t duration { -1 }; 26 MarshallingLongPressRequest27 bool Marshalling(Parcel &parcel) const 28 { 29 if (!parcel.WriteInt32(fingerCount)) { 30 return false; 31 } 32 if (!parcel.WriteInt32(duration)) { 33 return false; 34 } 35 return true; 36 }; 37 ReadFromParcelLongPressRequest38 bool ReadFromParcel(Parcel &parcel) 39 { 40 return ( 41 parcel.ReadInt32(fingerCount) && 42 parcel.ReadInt32(duration) 43 ); 44 } 45 UnmarshallingLongPressRequest46 static LongPressRequest* Unmarshalling(Parcel &parcel) 47 { 48 auto obj = new (std::nothrow) LongPressRequest(); 49 if (obj && !obj->ReadFromParcel(parcel)) { 50 delete obj; 51 obj = nullptr; 52 } 53 return obj; 54 }; 55 }; 56 57 struct LongPressEvent { 58 int32_t fingerCount { -1 }; 59 int32_t duration { -1 }; 60 int32_t pid { -1 }; 61 int32_t displayId { -1 }; 62 int32_t displayX { -1 }; 63 int32_t displayY { -1 }; 64 int32_t result { -1 }; // If the value is 0, it indicates correct reporting; non-zero indicates cancellation 65 int32_t windowId { -1 }; 66 int32_t pointerId { -1 }; 67 int64_t downTime { -1 }; 68 std::string bundleName; 69 }; 70 } // namespace MMI 71 } // namespace OHOS 72 #endif // LONG_PRESS_EVENT_H