• 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_ROSEN_WM_COMMON_H
17 #define OHOS_ROSEN_WM_COMMON_H
18 
19 #include <parcel.h>
20 #include <map>
21 
22 namespace OHOS {
23 namespace Rosen {
24 using DisplayId = uint64_t;
25 /**
26  * @brief Enumerates type of window.
27  */
28 enum class WindowType : uint32_t {
29     APP_WINDOW_BASE = 1,
30     APP_MAIN_WINDOW_BASE = APP_WINDOW_BASE,
31     WINDOW_TYPE_APP_MAIN_WINDOW = APP_MAIN_WINDOW_BASE,
32     APP_MAIN_WINDOW_END,
33 
34     APP_SUB_WINDOW_BASE = 1000,
35     WINDOW_TYPE_MEDIA = APP_SUB_WINDOW_BASE,
36     WINDOW_TYPE_APP_SUB_WINDOW,
37     WINDOW_TYPE_APP_COMPONENT,
38     APP_SUB_WINDOW_END,
39     APP_WINDOW_END = APP_SUB_WINDOW_END,
40 
41     SYSTEM_WINDOW_BASE = 2000,
42     BELOW_APP_SYSTEM_WINDOW_BASE = SYSTEM_WINDOW_BASE,
43     WINDOW_TYPE_WALLPAPER = SYSTEM_WINDOW_BASE,
44     WINDOW_TYPE_DESKTOP,
45     BELOW_APP_SYSTEM_WINDOW_END,
46 
47     ABOVE_APP_SYSTEM_WINDOW_BASE = 2100,
48     WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE,
49     WINDOW_TYPE_DOCK_SLICE,
50     WINDOW_TYPE_INCOMING_CALL,
51     WINDOW_TYPE_SEARCHING_BAR,
52     WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
53     WINDOW_TYPE_INPUT_METHOD_FLOAT,
54     WINDOW_TYPE_FLOAT,
55     WINDOW_TYPE_TOAST,
56     WINDOW_TYPE_STATUS_BAR,
57     WINDOW_TYPE_PANEL,
58     WINDOW_TYPE_KEYGUARD,
59     WINDOW_TYPE_VOLUME_OVERLAY,
60     WINDOW_TYPE_NAVIGATION_BAR,
61     WINDOW_TYPE_DRAGGING_EFFECT,
62     WINDOW_TYPE_POINTER,
63     WINDOW_TYPE_LAUNCHER_RECENT,
64     WINDOW_TYPE_LAUNCHER_DOCK,
65     WINDOW_TYPE_BOOT_ANIMATION,
66     WINDOW_TYPE_FREEZE_DISPLAY,
67     WINDOW_TYPE_VOICE_INTERACTION,
68     WINDOW_TYPE_FLOAT_CAMERA,
69     WINDOW_TYPE_PLACEHOLDER,
70     WINDOW_TYPE_DIALOG,
71     WINDOW_TYPE_SCREENSHOT,
72     ABOVE_APP_SYSTEM_WINDOW_END,
73 
74     SYSTEM_SUB_WINDOW_BASE = 2500,
75     WINDOW_TYPE_SYSTEM_SUB_WINDOW = SYSTEM_SUB_WINDOW_BASE,
76     SYSTEM_SUB_WINDOW_END,
77 
78     SYSTEM_WINDOW_END = SYSTEM_SUB_WINDOW_END,
79 
80     WINDOW_TYPE_UI_EXTENSION = 3000,
81     WINDOW_TYPE_SCENE_BOARD
82 };
83 
84 /**
85  * @brief Enumerates mode of window.
86  */
87 enum class WindowMode : uint32_t {
88     WINDOW_MODE_UNDEFINED = 0,
89     WINDOW_MODE_FULLSCREEN = 1,
90     WINDOW_MODE_SPLIT_PRIMARY = 100,
91     WINDOW_MODE_SPLIT_SECONDARY,
92     WINDOW_MODE_FLOATING,
93     WINDOW_MODE_PIP
94 };
95 
96 /**
97  * @brief Enumerates mode supported of window.
98  */
99 enum WindowModeSupport : uint32_t {
100     WINDOW_MODE_SUPPORT_FULLSCREEN = 1 << 0,
101     WINDOW_MODE_SUPPORT_FLOATING = 1 << 1,
102     WINDOW_MODE_SUPPORT_SPLIT_PRIMARY = 1 << 2,
103     WINDOW_MODE_SUPPORT_SPLIT_SECONDARY = 1 << 3,
104     WINDOW_MODE_SUPPORT_PIP = 1 << 4,
105     WINDOW_MODE_SUPPORT_ALL = WINDOW_MODE_SUPPORT_FULLSCREEN |
106                               WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
107                               WINDOW_MODE_SUPPORT_SPLIT_SECONDARY |
108                               WINDOW_MODE_SUPPORT_FLOATING |
109                               WINDOW_MODE_SUPPORT_PIP
110 };
111 
112 /**
113  * @brief Enumerates blur style of window.
114  */
115 enum class WindowBlurStyle : uint32_t {
116     WINDOW_BLUR_OFF = 0,
117     WINDOW_BLUR_THIN,
118     WINDOW_BLUR_REGULAR,
119     WINDOW_BLUR_THICK
120 };
121 
122 /**
123  * @brief Enumerates state of window.
124  */
125 enum class WindowState : uint32_t {
126     STATE_INITIAL,
127     STATE_CREATED,
128     STATE_SHOWN,
129     STATE_HIDDEN,
130     STATE_FROZEN,
131     STATE_UNFROZEN,
132     STATE_DESTROYED,
133     STATE_BOTTOM = STATE_DESTROYED, // Add state type after STATE_DESTROYED is not allowed
134 };
135 
136 /**
137  * @brief Enumerates error code of window.
138  */
139 enum class WMError : int32_t {
140     WM_OK = 0,
141     WM_DO_NOTHING,
142     WM_ERROR_NO_MEM,
143     WM_ERROR_DESTROYED_OBJECT,
144     WM_ERROR_INVALID_WINDOW,
145     WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE,
146     WM_ERROR_INVALID_OPERATION,
147     WM_ERROR_INVALID_PERMISSION,
148     WM_ERROR_NOT_SYSTEM_APP,
149     WM_ERROR_NO_REMOTE_ANIMATION,
150     WM_ERROR_INVALID_DISPLAY,
151     WM_ERROR_INVALID_PARENT,
152     WM_ERROR_OPER_FULLSCREEN_FAILED,
153     WM_ERROR_REPEAT_OPERATION,
154     WM_ERROR_INVALID_SESSION,
155 
156     WM_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system
157 
158     WM_ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report
159     WM_ERROR_NULLPTR,
160     WM_ERROR_INVALID_TYPE,
161     WM_ERROR_INVALID_PARAM,
162     WM_ERROR_SAMGR,
163     WM_ERROR_IPC_FAILED,
164     WM_ERROR_NEED_REPORT_END,
165     WM_ERROR_START_ABILITY_FAILED,
166 };
167 
168 /**
169  * @brief Enumerates error code of window only used for js api.
170  */
171 enum class WmErrorCode : int32_t {
172     WM_OK = 0,
173     WM_ERROR_NO_PERMISSION = 201,
174     WM_ERROR_NOT_SYSTEM_APP = 202,
175     WM_ERROR_INVALID_PARAM = 401,
176     WM_ERROR_DEVICE_NOT_SUPPORT = 801,
177     WM_ERROR_REPEAT_OPERATION = 1300001,
178     WM_ERROR_STATE_ABNORMALLY = 1300002,
179     WM_ERROR_SYSTEM_ABNORMALLY = 1300003,
180     WM_ERROR_INVALID_CALLING = 1300004,
181     WM_ERROR_STAGE_ABNORMALLY = 1300005,
182     WM_ERROR_CONTEXT_ABNORMALLY = 1300006,
183     WM_ERROR_START_ABILITY_FAILED = 1300007,
184     WM_ERROR_INVALID_DISPLAY = 1300008,
185     WM_ERROR_INVALID_PARENT = 1300009,
186     WM_ERROR_OPER_FULLSCREEN_FAILED = 1300010,
187 };
188 
189 /**
190  * @brief Used to map from WMError to WmErrorCode.
191  */
192 const std::map<WMError, WmErrorCode> WM_JS_TO_ERROR_CODE_MAP {
193     {WMError::WM_OK,                                   WmErrorCode::WM_OK                           },
194     {WMError::WM_DO_NOTHING,                           WmErrorCode::WM_ERROR_STATE_ABNORMALLY       },
195     {WMError::WM_ERROR_DESTROYED_OBJECT,               WmErrorCode::WM_ERROR_STATE_ABNORMALLY       },
196     {WMError::WM_ERROR_DEVICE_NOT_SUPPORT,             WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT     },
197     {WMError::WM_ERROR_INVALID_OPERATION,              WmErrorCode::WM_ERROR_STATE_ABNORMALLY       },
198     {WMError::WM_ERROR_INVALID_PARAM,                  WmErrorCode::WM_ERROR_INVALID_PARAM          },
199     {WMError::WM_ERROR_INVALID_PERMISSION,             WmErrorCode::WM_ERROR_NO_PERMISSION          },
200     {WMError::WM_ERROR_NOT_SYSTEM_APP,                 WmErrorCode::WM_ERROR_NOT_SYSTEM_APP         },
201     {WMError::WM_ERROR_INVALID_TYPE,                   WmErrorCode::WM_ERROR_STATE_ABNORMALLY       },
202     {WMError::WM_ERROR_INVALID_WINDOW,                 WmErrorCode::WM_ERROR_STATE_ABNORMALLY       },
203     {WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE,    WmErrorCode::WM_ERROR_STATE_ABNORMALLY       },
204     {WMError::WM_ERROR_IPC_FAILED,                     WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY      },
205     {WMError::WM_ERROR_NO_MEM,                         WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY      },
206     {WMError::WM_ERROR_NO_REMOTE_ANIMATION,            WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY      },
207     {WMError::WM_ERROR_INVALID_DISPLAY,                WmErrorCode::WM_ERROR_INVALID_DISPLAY        },
208     {WMError::WM_ERROR_INVALID_PARENT,                 WmErrorCode::WM_ERROR_INVALID_PARENT         },
209     {WMError::WM_ERROR_OPER_FULLSCREEN_FAILED,         WmErrorCode::WM_ERROR_OPER_FULLSCREEN_FAILED },
210     {WMError::WM_ERROR_REPEAT_OPERATION,               WmErrorCode::WM_ERROR_REPEAT_OPERATION       },
211     {WMError::WM_ERROR_NULLPTR,                        WmErrorCode::WM_ERROR_STATE_ABNORMALLY       },
212     {WMError::WM_ERROR_SAMGR,                          WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY      },
213     {WMError::WM_ERROR_START_ABILITY_FAILED,           WmErrorCode::WM_ERROR_START_ABILITY_FAILED   },
214 };
215 
216 /**
217  * @brief Enumerates flag of window.
218  */
219 enum class WindowFlag : uint32_t {
220     WINDOW_FLAG_NEED_AVOID = 1,
221     WINDOW_FLAG_PARENT_LIMIT = 1 << 1,
222     WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
223     WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3,
224     WINDOW_FLAG_WATER_MARK = 1 << 4,
225     WINDOW_FLAG_END = 1 << 5,
226 };
227 
228 /**
229  * @brief Enumerates window size change reason.
230  */
231 enum class WindowSizeChangeReason : uint32_t {
232     UNDEFINED = 0,
233     MAXIMIZE,
234     RECOVER,
235     ROTATION,
236     DRAG,
237     DRAG_START,
238     DRAG_END,
239     RESIZE,
240     MOVE,
241     HIDE,
242     TRANSFORM,
243     CUSTOM_ANIMATION_SHOW,
244     FULL_TO_SPLIT,
245     SPLIT_TO_FULL,
246     END,
247 };
248 
249 /**
250  * @brief Enumerates layout mode of window.
251  */
252 enum class WindowLayoutMode : uint32_t {
253     BASE = 0,
254     CASCADE = BASE,
255     TILE = 1,
256     END,
257 };
258 
259 /**
260  * @brief Enumerates drag event.
261  */
262 enum class DragEvent : uint32_t {
263     DRAG_EVENT_IN  = 1,
264     DRAG_EVENT_OUT,
265     DRAG_EVENT_MOVE,
266     DRAG_EVENT_END,
267 };
268 
269 /**
270  * @brief Enumerates window tag.
271  */
272 enum class WindowTag : uint32_t {
273     MAIN_WINDOW = 0,
274     SUB_WINDOW = 1,
275     SYSTEM_WINDOW = 2,
276 };
277 
278 /**
279  * @brief Enumerates window session type.
280  */
281 enum class WindowSessionType : uint32_t {
282     SCENE_SESSION = 0,
283     EXTENSION_SESSION = 1,
284 };
285 
286 /**
287  * @brief Enumerates window gravity.
288  */
289 enum class WindowGravity : uint32_t {
290     WINDOW_GRAVITY_FLOAT = 0,
291     WINDOW_GRAVITY_BOTTOM,
292 };
293 
294 /**
295  * @struct PointInfo.
296  *
297  * @brief point Info.
298  */
299 struct PointInfo {
300     int32_t x;
301     int32_t y;
302 };
303 
304 namespace {
305     constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF;
306     constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000;
307     constexpr uint32_t INVALID_WINDOW_ID = 0;
308     constexpr float UNDEFINED_BRIGHTNESS = -1.0f;
309     constexpr float MINIMUM_BRIGHTNESS = 0.0f;
310     constexpr float MAXIMUM_BRIGHTNESS = 1.0f;
311     constexpr int32_t INVALID_PID = -1;
312     constexpr int32_t INVALID_UID = -1;
313 }
314 
315 /**
316  * @class Transform
317  *
318  * @brief parameter of transform and rotate.
319  */
320 class Transform {
321 public:
Transform()322     Transform()
323         : pivotX_(0.5f), pivotY_(0.5f), scaleX_(1.f), scaleY_(1.f), scaleZ_(1.f), rotationX_(0.f),
324           rotationY_(0.f), rotationZ_(0.f), translateX_(0.f), translateY_(0.f), translateZ_(0.f)
325     {}
~Transform()326     ~Transform() {}
327 
328     bool operator==(const Transform& right) const
329     {
330         return NearZero(pivotX_ - right.pivotX_) &&
331             NearZero(pivotY_ - right.pivotY_) &&
332             NearZero(scaleX_ - right.scaleX_) &&
333             NearZero(scaleY_ - right.scaleY_) &&
334             NearZero(scaleZ_ - right.scaleZ_) &&
335             NearZero(rotationX_ - right.rotationX_) &&
336             NearZero(rotationY_ - right.rotationY_) &&
337             NearZero(rotationZ_ - right.rotationZ_) &&
338             NearZero(translateX_ - right.translateX_) &&
339             NearZero(translateY_ - right.translateY_) &&
340             NearZero(translateZ_ - right.translateZ_);
341     }
342 
343     bool operator!=(const Transform& right) const
344     {
345         return !(*this == right);
346     }
347 
348     float pivotX_;
349     float pivotY_;
350     float scaleX_;
351     float scaleY_;
352     float scaleZ_;
353     float rotationX_;
354     float rotationY_;
355     float rotationZ_;
356     float translateX_;
357     float translateY_;
358     float translateZ_;
359 
Identity()360     static const Transform& Identity()
361     {
362         static Transform I;
363         return I;
364     }
365 
Marshalling(Parcel & parcel)366     bool Marshalling(Parcel& parcel) const
367     {
368         return parcel.WriteFloat(pivotX_) && parcel.WriteFloat(pivotY_) &&
369                parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) && parcel.WriteFloat(scaleZ_) &&
370                parcel.WriteFloat(rotationX_) && parcel.WriteFloat(rotationY_) && parcel.WriteFloat(rotationZ_) &&
371                parcel.WriteFloat(translateX_) && parcel.WriteFloat(translateY_) && parcel.WriteFloat(translateZ_);
372     }
373 
Unmarshalling(Parcel & parcel)374     void Unmarshalling(Parcel& parcel)
375     {
376         pivotX_ = parcel.ReadFloat();
377         pivotY_ = parcel.ReadFloat();
378         scaleX_ = parcel.ReadFloat();
379         scaleY_ = parcel.ReadFloat();
380         scaleZ_ = parcel.ReadFloat();
381         rotationX_ = parcel.ReadFloat();
382         rotationY_ = parcel.ReadFloat();
383         rotationZ_ = parcel.ReadFloat();
384         translateX_ = parcel.ReadFloat();
385         translateY_ = parcel.ReadFloat();
386         translateZ_ = parcel.ReadFloat();
387     }
388 private:
NearZero(float val)389     static inline bool NearZero(float val)
390     {
391         return val < 0.001f && val > -0.001f;
392     }
393 };
394 
395 /**
396  * @struct SystemBarProperty
397  *
398  * @brief Property of system bar
399  */
400 struct SystemBarProperty {
401     bool enable_;
402     uint32_t backgroundColor_;
403     uint32_t contentColor_;
SystemBarPropertySystemBarProperty404     SystemBarProperty() : enable_(true), backgroundColor_(SYSTEM_COLOR_BLACK), contentColor_(SYSTEM_COLOR_WHITE) {}
SystemBarPropertySystemBarProperty405     SystemBarProperty(bool enable, uint32_t background, uint32_t content)
406         : enable_(enable), backgroundColor_(background), contentColor_(content) {}
407     bool operator == (const SystemBarProperty& a) const
408     {
409         return (enable_ == a.enable_ && backgroundColor_ == a.backgroundColor_ && contentColor_ == a.contentColor_);
410     }
411 };
412 
413 /**
414  * @struct Rect
415  *
416  * @brief Window Rect
417  */
418 struct Rect {
419     int32_t posX_;
420     int32_t posY_;
421     uint32_t width_;
422     uint32_t height_;
423 
424     bool operator==(const Rect& a) const
425     {
426         return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_);
427     }
428 
429     bool operator!=(const Rect& a) const
430     {
431         return !this->operator==(a);
432     }
433 
IsUninitializedRectRect434     bool IsUninitializedRect() const
435     {
436         return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
437     }
438 
IsInsideOfRect439     bool IsInsideOf(const Rect& a) const
440     {
441         return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
442             posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
443     }
444 };
445 
446 /**
447  * @brief Enumerates avoid area type.
448  */
449 enum class AvoidAreaType : uint32_t {
450     TYPE_SYSTEM,           // area of SystemUI
451     TYPE_CUTOUT,           // cutout of screen
452     TYPE_SYSTEM_GESTURE,   // area for system gesture
453     TYPE_KEYBOARD,         // area for soft input keyboard
454 };
455 
456 /**
457  * @brief Enumerates occupied area type.
458  */
459 enum class OccupiedAreaType : uint32_t {
460     TYPE_INPUT, // area of input window
461 };
462 
463 /**
464  * @brief Enumerates color space.
465  */
466 enum class ColorSpace : uint32_t {
467     COLOR_SPACE_DEFAULT = 0, // Default color space.
468     COLOR_SPACE_WIDE_GAMUT,  // Wide gamut color space. The specific wide color gamut depends on the screen.
469 };
470 
471 /**
472  * @brief Enumerates window animation.
473  */
474 enum class WindowAnimation : uint32_t {
475     NONE,
476     DEFAULT,
477     INPUTE,
478     CUSTOM,
479 };
480 
481 /**
482  * @brief Enumerates window maximize mode.
483  */
484 enum class MaximizeMode : uint32_t {
485     MODE_AVOID_SYSTEM_BAR,
486     MODE_FULL_FILL,
487     MODE_RECOVER,
488 };
489 
490 /**
491  * @class AvoidArea
492  *
493  * @brief Area needed to avoid.
494  */
495 class AvoidArea : public Parcelable {
496 public:
497     Rect topRect_ { 0, 0, 0, 0 };
498     Rect leftRect_ { 0, 0, 0, 0 };
499     Rect rightRect_ { 0, 0, 0, 0 };
500     Rect bottomRect_ { 0, 0, 0, 0 };
501 
502     bool operator==(const AvoidArea& a) const
503     {
504         return (leftRect_ == a.leftRect_ && topRect_ == a.topRect_ &&
505             rightRect_ == a.rightRect_ && bottomRect_ == a.bottomRect_);
506     }
507 
508     bool operator!=(const AvoidArea& a) const
509     {
510         return !this->operator==(a);
511     }
512 
isEmptyAvoidArea()513     bool isEmptyAvoidArea() const
514     {
515         return topRect_.IsUninitializedRect() && leftRect_.IsUninitializedRect() &&
516             rightRect_.IsUninitializedRect() && bottomRect_.IsUninitializedRect();
517     }
518 
WriteParcel(Parcel & parcel,const Rect & rect)519     static inline bool WriteParcel(Parcel& parcel, const Rect& rect)
520     {
521         return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) &&
522             parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
523     }
524 
ReadParcel(Parcel & parcel,Rect & rect)525     static inline bool ReadParcel(Parcel& parcel, Rect& rect)
526     {
527         return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) &&
528             parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_);
529     }
530 
Marshalling(Parcel & parcel)531     virtual bool Marshalling(Parcel& parcel) const override
532     {
533         return (WriteParcel(parcel, leftRect_) && WriteParcel(parcel, topRect_) &&
534             WriteParcel(parcel, rightRect_) && WriteParcel(parcel, bottomRect_));
535     }
536 
Unmarshalling(Parcel & parcel)537     static AvoidArea* Unmarshalling(Parcel& parcel)
538     {
539         AvoidArea *avoidArea = new(std::nothrow) AvoidArea();
540         if (avoidArea == nullptr) {
541             return nullptr;
542         }
543         if (ReadParcel(parcel, avoidArea->leftRect_) && ReadParcel(parcel, avoidArea->topRect_) &&
544             ReadParcel(parcel, avoidArea->rightRect_) && ReadParcel(parcel, avoidArea->bottomRect_)) {
545             return avoidArea;
546         }
547         delete avoidArea;
548         return nullptr;
549     }
550 };
551 
552 /**
553  * @brief Enumerates window update type.
554  */
555 enum class WindowUpdateType : int32_t {
556     WINDOW_UPDATE_ADDED = 1,
557     WINDOW_UPDATE_REMOVED,
558     WINDOW_UPDATE_FOCUSED,
559     WINDOW_UPDATE_BOUNDS,
560     WINDOW_UPDATE_ACTIVE,
561     WINDOW_UPDATE_PROPERTY,
562 };
563 
564 using OnCallback = std::function<void(int64_t)>;
565 
566 /**
567  * @struct VsyncCallback
568  *
569  * @brief Vsync callback
570  */
571 struct VsyncCallback {
572     OnCallback onCallback;
573 };
574 
575 /*
576  * Config of keyboard animation
577  */
578 class KeyboardAnimationConfig : public Parcelable {
579 public:
580     std::string curveType_ = "";
581     std::vector<float> curveParams_ = {};
582     uint32_t durationIn_ = 0;
583     uint32_t durationOut_ = 0;
584 
Marshalling(Parcel & parcel)585     virtual bool Marshalling(Parcel& parcel) const override
586     {
587         if (!parcel.WriteString(curveType_)) {
588             return false;
589         }
590 
591         auto paramSize = curveParams_.size();
592         if (paramSize == 4) { // 4: param size
593             if (!parcel.WriteUint32(static_cast<uint32_t>(paramSize))) {
594                 return false;
595             }
596             for (auto& param : curveParams_) {
597                 if (!parcel.WriteFloat(param)) {
598                     return false;
599                 }
600             }
601         } else {
602             if (!parcel.WriteUint32(0)) {
603                 return false;
604             }
605         }
606 
607         if (!parcel.WriteUint32(durationIn_) || !parcel.WriteUint32(durationOut_)) {
608             return false;
609         }
610         return true;
611     }
612 
Unmarshalling(Parcel & parcel)613     static KeyboardAnimationConfig* Unmarshalling(Parcel& parcel)
614     {
615         KeyboardAnimationConfig* config = new KeyboardAnimationConfig;
616         config->curveType_ = parcel.ReadString();
617         auto paramSize = parcel.ReadUint32();
618         if (paramSize == 4) { // 4: param size
619             for (uint32_t i = 0; i < paramSize; i++) {
620                 config->curveParams_.push_back(parcel.ReadFloat());
621             }
622         }
623         config->durationIn_ = parcel.ReadUint32();
624         config->durationOut_ = parcel.ReadUint32();
625         return config;
626     }
627 };
628 }
629 }
630 #endif // OHOS_ROSEN_WM_COMMON_H
631