1 /* 2 * Copyright (c) 2022-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 POINTER_STYLE_H 17 #define POINTER_STYLE_H 18 19 #include <iostream> 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace MMI { 24 struct PointerStyle : public Parcelable { 25 int32_t size { -1 }; 26 int32_t color { 0 }; 27 int32_t id { 0 }; 28 int32_t options { 0 }; 29 bool operator==(const PointerStyle &rhs) const 30 { 31 return id == rhs.id && size == rhs.size && color == rhs.color && options == rhs.options; 32 } MarshallingPointerStyle33 bool Marshalling(Parcel &out) const 34 { 35 if (!out.WriteInt32(size)) { 36 return false; 37 } 38 39 if (!out.WriteInt32(color)) { 40 return false; 41 } 42 43 if (!out.WriteInt32(id)) { 44 return false; 45 } 46 47 if (!out.WriteInt32(options)) { 48 return false; 49 } 50 return true; 51 } 52 ReadFromParcelPointerStyle53 bool ReadFromParcel(Parcel &in) 54 { 55 return ( 56 in.ReadInt32(size) && 57 in.ReadInt32(color) && 58 in.ReadInt32(id) && 59 in.ReadInt32(options) 60 ); 61 } 62 UnmarshallingPointerStyle63 static PointerStyle *Unmarshalling(Parcel &in) 64 { 65 PointerStyle *data = new (std::nothrow) PointerStyle(); 66 if (data && !data->ReadFromParcel(in)) { 67 delete data; 68 data = nullptr; 69 } 70 return data; 71 } 72 }; 73 74 struct CustomCursor { 75 void* pixelMap { nullptr }; 76 int32_t focusX { 0 }; 77 int32_t focusY { 0 }; 78 }; 79 80 struct CustomCursorParcel : public Parcelable { 81 CustomCursorParcel() = default; 82 explicit CustomCursorParcel(void* pixelMap, int32_t focusX, int32_t focusY); 83 void* pixelMap { nullptr }; 84 int32_t focusX { 0 }; 85 int32_t focusY { 0 }; 86 bool Marshalling(Parcel &out) const; 87 bool ReadFromParcel(Parcel &in); 88 static CustomCursorParcel *Unmarshalling(Parcel &in); 89 }; 90 91 struct CursorOptions { 92 bool followSystem { false }; 93 }; 94 95 struct CursorOptionsParcel : public Parcelable { 96 bool followSystem { false }; 97 bool Marshalling(Parcel &out) const; 98 bool ReadFromParcel(Parcel &in); 99 static CursorOptionsParcel *Unmarshalling(Parcel &in); 100 }; 101 102 struct CursorPixelMap : public Parcelable { 103 void* pixelMap { nullptr }; 104 bool Marshalling(Parcel &out) const; 105 bool ReadFromParcel(Parcel &in); 106 static CursorPixelMap *Unmarshalling(Parcel &in); 107 }; 108 109 } // namespace MMI 110 } // namespace OHOS 111 #endif // POINTER_STYLE_H