• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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 <any>
20 #include <map>
21 #include <sstream>
22 #include <string>
23 #include <unordered_set>
24 
25 #include <float.h>
26 
27 #include <parcel.h>
28 #include "dm_common.h"
29 #include "securec.h"
30 #include "wm_type.h"
31 
32 namespace OHOS {
33 namespace Rosen {
34 namespace {
35 constexpr uint32_t DEFAULT_SPACING_BETWEEN_BUTTONS = 12;
36 constexpr uint32_t DEFAULT_BUTTON_BACKGROUND_SIZE = 28;
37 constexpr uint32_t DEFAULT_CLOSE_BUTTON_RIGHT_MARGIN = 20;
38 constexpr int32_t DEFAULT_COLOR_MODE = -1;
39 constexpr int32_t MIN_COLOR_MODE = -1;
40 constexpr int32_t MAX_COLOR_MODE = 1;
41 constexpr int32_t LIGHT_COLOR_MODE = 0;
42 constexpr int32_t DARK_COLOR_MODE = 1;
43 constexpr uint32_t MIN_SPACING_BETWEEN_BUTTONS = 12;
44 constexpr uint32_t MAX_SPACING_BETWEEN_BUTTONS = 24;
45 constexpr uint32_t MIN_BUTTON_BACKGROUND_SIZE = 20;
46 constexpr uint32_t MAX_BUTTON_BACKGROUND_SIZE = 40;
47 constexpr uint32_t MIN_CLOSE_BUTTON_RIGHT_MARGIN = 8;
48 constexpr uint32_t MAX_CLOSE_BUTTON_RIGHT_MARGIN = 22;
49 constexpr int32_t MINIMUM_Z_LEVEL = -10000;
50 constexpr int32_t MAXIMUM_Z_LEVEL = 10000;
51 }
52 
53 /**
54  * @brief Enumerates type of window
55  */
56 enum class WindowType : uint32_t {
57     APP_WINDOW_BASE = 1,
58     APP_MAIN_WINDOW_BASE = APP_WINDOW_BASE,
59     WINDOW_TYPE_APP_MAIN_WINDOW = APP_MAIN_WINDOW_BASE,
60     APP_MAIN_WINDOW_END,
61 
62     APP_SUB_WINDOW_BASE = 1000,
63     WINDOW_TYPE_MEDIA = APP_SUB_WINDOW_BASE,
64     WINDOW_TYPE_APP_SUB_WINDOW,
65     WINDOW_TYPE_APP_COMPONENT,
66     APP_SUB_WINDOW_END,
67     APP_WINDOW_END = APP_SUB_WINDOW_END,
68 
69     SYSTEM_WINDOW_BASE = 2000,
70     BELOW_APP_SYSTEM_WINDOW_BASE = SYSTEM_WINDOW_BASE,
71     WINDOW_TYPE_WALLPAPER = SYSTEM_WINDOW_BASE,
72     WINDOW_TYPE_DESKTOP,
73     BELOW_APP_SYSTEM_WINDOW_END,
74 
75     ABOVE_APP_SYSTEM_WINDOW_BASE = 2100,
76     WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE,
77     WINDOW_TYPE_DOCK_SLICE,
78     WINDOW_TYPE_INCOMING_CALL,
79     WINDOW_TYPE_SEARCHING_BAR,
80     WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
81     WINDOW_TYPE_INPUT_METHOD_FLOAT,
82     WINDOW_TYPE_FLOAT,
83     WINDOW_TYPE_TOAST,
84     WINDOW_TYPE_STATUS_BAR,
85     WINDOW_TYPE_PANEL,
86     WINDOW_TYPE_KEYGUARD,
87     WINDOW_TYPE_VOLUME_OVERLAY,
88     WINDOW_TYPE_NAVIGATION_BAR,
89     WINDOW_TYPE_DRAGGING_EFFECT,
90     WINDOW_TYPE_POINTER,
91     WINDOW_TYPE_LAUNCHER_RECENT,
92     WINDOW_TYPE_LAUNCHER_DOCK,
93     WINDOW_TYPE_BOOT_ANIMATION,
94     WINDOW_TYPE_FREEZE_DISPLAY,
95     WINDOW_TYPE_VOICE_INTERACTION,
96     WINDOW_TYPE_FLOAT_CAMERA,
97     WINDOW_TYPE_PLACEHOLDER,
98     WINDOW_TYPE_DIALOG,
99     WINDOW_TYPE_SCREENSHOT,
100     WINDOW_TYPE_INPUT_METHOD_STATUS_BAR,
101     WINDOW_TYPE_GLOBAL_SEARCH,
102     WINDOW_TYPE_SYSTEM_TOAST,
103     WINDOW_TYPE_SYSTEM_FLOAT,
104     WINDOW_TYPE_PIP,
105     WINDOW_TYPE_THEME_EDITOR,
106     WINDOW_TYPE_NAVIGATION_INDICATOR,
107     WINDOW_TYPE_HANDWRITE,
108     WINDOW_TYPE_SCENE_BOARD,
109     WINDOW_TYPE_KEYBOARD_PANEL,
110     WINDOW_TYPE_WALLET_SWIPE_CARD,
111     WINDOW_TYPE_SCREEN_CONTROL,
112     WINDOW_TYPE_FLOAT_NAVIGATION,
113     ABOVE_APP_SYSTEM_WINDOW_END,
114 
115     SYSTEM_SUB_WINDOW_BASE = 2500,
116     WINDOW_TYPE_SYSTEM_SUB_WINDOW = SYSTEM_SUB_WINDOW_BASE,
117     SYSTEM_SUB_WINDOW_END,
118 
119     SYSTEM_WINDOW_END = SYSTEM_SUB_WINDOW_END,
120 
121     WINDOW_TYPE_UI_EXTENSION = 3000
122 };
123 
124 /**
125  * @brief Enumerates state of window.
126  */
127 enum class WindowState : uint32_t {
128     STATE_INITIAL,
129     STATE_CREATED,
130     STATE_SHOWN,
131     STATE_HIDDEN,
132     STATE_FROZEN,
133     STATE_UNFROZEN,
134     STATE_DESTROYED,
135     STATE_BOTTOM = STATE_DESTROYED // Add state type after STATE_DESTROYED is not allowed.
136 };
137 
138 /**
139  * @brief Enumerates blur style of window.
140  */
141 enum class WindowBlurStyle : uint32_t {
142     WINDOW_BLUR_OFF = 0,
143     WINDOW_BLUR_THIN,
144     WINDOW_BLUR_REGULAR,
145     WINDOW_BLUR_THICK
146 };
147 
148 /**
149  * @brief Enumerates mode supported of window.
150  */
151 enum WindowModeSupport : uint32_t {
152     WINDOW_MODE_SUPPORT_FULLSCREEN = 1 << 0,
153     WINDOW_MODE_SUPPORT_FLOATING = 1 << 1,
154     WINDOW_MODE_SUPPORT_SPLIT_PRIMARY = 1 << 2,
155     WINDOW_MODE_SUPPORT_SPLIT_SECONDARY = 1 << 3,
156     WINDOW_MODE_SUPPORT_PIP = 1 << 4,
157     WINDOW_MODE_SUPPORT_ALL = WINDOW_MODE_SUPPORT_FLOATING |
158                               WINDOW_MODE_SUPPORT_FULLSCREEN |
159                               WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
160                               WINDOW_MODE_SUPPORT_SPLIT_SECONDARY |
161                               WINDOW_MODE_SUPPORT_PIP
162 };
163 
164 /**
165  * @brief Enumerates mode of window.
166  */
167 enum class WindowMode : uint32_t {
168     WINDOW_MODE_UNDEFINED = 0,
169     WINDOW_MODE_FULLSCREEN = 1,
170     WINDOW_MODE_SPLIT_PRIMARY = 100,
171     WINDOW_MODE_SPLIT_SECONDARY,
172     WINDOW_MODE_FLOATING,
173     WINDOW_MODE_PIP
174 };
175 
176 /**
177  * @brief Enumerates status of window.
178  */
179 enum class WindowStatus : uint32_t {
180     WINDOW_STATUS_UNDEFINED = 0,
181     WINDOW_STATUS_FULLSCREEN = 1,
182     WINDOW_STATUS_MAXIMIZE,
183     WINDOW_STATUS_MINIMIZE,
184     WINDOW_STATUS_FLOATING,
185     WINDOW_STATUS_SPLITSCREEN
186 };
187 
188 /**
189  * @brief Enumerates error code of window.
190  */
191 enum class WMError : int32_t {
192     WM_OK = 0,
193     WM_DO_NOTHING,
194     WM_ERROR_NO_MEM,
195     WM_ERROR_DESTROYED_OBJECT,
196     WM_ERROR_INVALID_WINDOW,
197     WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE,
198     WM_ERROR_INVALID_OPERATION,
199     WM_ERROR_INVALID_PERMISSION,
200     WM_ERROR_NOT_SYSTEM_APP,
201     WM_ERROR_NO_REMOTE_ANIMATION,
202     WM_ERROR_INVALID_DISPLAY,
203     WM_ERROR_INVALID_PARENT,
204     WM_ERROR_INVALID_OP_IN_CUR_STATUS,
205     WM_ERROR_REPEAT_OPERATION,
206     WM_ERROR_INVALID_SESSION,
207     WM_ERROR_INVALID_CALLING,
208     WM_ERROR_SYSTEM_ABNORMALLY,
209 
210     WM_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system.
211 
212     WM_ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report.
213     WM_ERROR_NULLPTR,
214     WM_ERROR_INVALID_TYPE,
215     WM_ERROR_INVALID_PARAM,
216     WM_ERROR_SAMGR,
217     WM_ERROR_IPC_FAILED,
218     WM_ERROR_NEED_REPORT_END,
219     WM_ERROR_START_ABILITY_FAILED,
220     WM_ERROR_PIP_DESTROY_FAILED,
221     WM_ERROR_PIP_STATE_ABNORMALLY,
222     WM_ERROR_PIP_CREATE_FAILED,
223     WM_ERROR_PIP_INTERNAL_ERROR,
224     WM_ERROR_PIP_REPEAT_OPERATION
225 };
226 
227 /**
228  * @brief Enumerates error code of window only used for js api.
229  */
230 enum class WmErrorCode : int32_t {
231     WM_OK = 0,
232     WM_ERROR_NO_PERMISSION = 201,
233     WM_ERROR_NOT_SYSTEM_APP = 202,
234     WM_ERROR_INVALID_PARAM = 401,
235     WM_ERROR_DEVICE_NOT_SUPPORT = 801,
236 
237     WM_ERROR_REPEAT_OPERATION = 1300001,
238     WM_ERROR_STATE_ABNORMALLY = 1300002,
239     WM_ERROR_SYSTEM_ABNORMALLY = 1300003,
240     WM_ERROR_INVALID_CALLING = 1300004,
241     WM_ERROR_STAGE_ABNORMALLY = 1300005,
242     WM_ERROR_CONTEXT_ABNORMALLY = 1300006,
243     WM_ERROR_START_ABILITY_FAILED = 1300007,
244     WM_ERROR_INVALID_DISPLAY = 1300008,
245     WM_ERROR_INVALID_PARENT = 1300009,
246     WM_ERROR_INVALID_OP_IN_CUR_STATUS = 1300010,
247     WM_ERROR_PIP_DESTROY_FAILED = 1300011,
248     WM_ERROR_PIP_STATE_ABNORMALLY = 1300012,
249     WM_ERROR_PIP_CREATE_FAILED = 1300013,
250     WM_ERROR_PIP_INTERNAL_ERROR = 1300014,
251     WM_ERROR_PIP_REPEAT_OPERATION = 1300015
252 };
253 
254 /**
255  * @brief Enumerates setting flag of systemStatusBar.
256  */
257 enum class SystemBarSettingFlag : uint32_t {
258     DEFAULT_SETTING = 0,
259     COLOR_SETTING = 1,
260     ENABLE_SETTING = 1 << 1,
261     ALL_SETTING = 0b11
262 };
263 
264 inline SystemBarSettingFlag operator|(SystemBarSettingFlag lhs, SystemBarSettingFlag rhs)
265 {
266     using T = std::underlying_type_t<SystemBarSettingFlag>;
267     return static_cast<SystemBarSettingFlag>(static_cast<T>(lhs) | static_cast<T>(rhs));
268 }
269 
270 inline SystemBarSettingFlag& operator|=
271     (SystemBarSettingFlag& lhs, SystemBarSettingFlag rhs) { return lhs = lhs | rhs; }
272 
273 /**
274  * @brief Enumerates flag of window.
275  */
276 enum class WindowFlag : uint32_t {
277     WINDOW_FLAG_NEED_AVOID = 1,
278     WINDOW_FLAG_PARENT_LIMIT = 1 << 1,
279     WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
280     WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3,
281     WINDOW_FLAG_WATER_MARK = 1 << 4,
282     WINDOW_FLAG_IS_MODAL = 1 << 5,
283     WINDOW_FLAG_HANDWRITING = 1 << 6,
284     WINDOW_FLAG_IS_TOAST = 1 << 7,
285     WINDOW_FLAG_IS_APPLICATION_MODAL = 1 << 8,
286     WINDOW_FLAG_IS_TEXT_MENU = 1 << 9,
287     WINDOW_FLAG_END = 1 << 10,
288 };
289 
290 /**
291  * @brief Enumerates system and app sub window avoid area options
292  */
293 enum class AvoidAreaOption : uint32_t {
294     ENABLE_SYSTEM_WINDOW = 1,
295     ENABLE_APP_SUB_WINDOW = 1 << 1,
296 };
297 
298 /**
299  * @brief Enumerates flag of multiWindowUIType.
300  */
301 enum class WindowUIType : uint8_t {
302     PHONE_WINDOW = 0,
303     PC_WINDOW,
304     PAD_WINDOW,
305     INVALID_WINDOW
306 };
307 
308 /**
309  * @brief Used to map from WMError to WmErrorCode.
310  */
311 const std::map<WMError, WmErrorCode> WM_JS_TO_ERROR_CODE_MAP {
312     {WMError::WM_OK,                                   WmErrorCode::WM_OK                             },
313     {WMError::WM_DO_NOTHING,                           WmErrorCode::WM_ERROR_STATE_ABNORMALLY         },
314     {WMError::WM_ERROR_DESTROYED_OBJECT,               WmErrorCode::WM_ERROR_STATE_ABNORMALLY         },
315     {WMError::WM_ERROR_DEVICE_NOT_SUPPORT,             WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT       },
316     {WMError::WM_ERROR_INVALID_OPERATION,              WmErrorCode::WM_ERROR_STATE_ABNORMALLY         },
317     {WMError::WM_ERROR_INVALID_PARAM,                  WmErrorCode::WM_ERROR_INVALID_PARAM            },
318     {WMError::WM_ERROR_INVALID_PERMISSION,             WmErrorCode::WM_ERROR_NO_PERMISSION            },
319     {WMError::WM_ERROR_NOT_SYSTEM_APP,                 WmErrorCode::WM_ERROR_NOT_SYSTEM_APP           },
320     {WMError::WM_ERROR_INVALID_TYPE,                   WmErrorCode::WM_ERROR_STATE_ABNORMALLY         },
321     {WMError::WM_ERROR_INVALID_WINDOW,                 WmErrorCode::WM_ERROR_STATE_ABNORMALLY         },
322     {WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE,    WmErrorCode::WM_ERROR_STATE_ABNORMALLY         },
323     {WMError::WM_ERROR_IPC_FAILED,                     WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY        },
324     {WMError::WM_ERROR_NO_MEM,                         WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY        },
325     {WMError::WM_ERROR_NO_REMOTE_ANIMATION,            WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY        },
326     {WMError::WM_ERROR_INVALID_DISPLAY,                WmErrorCode::WM_ERROR_INVALID_DISPLAY          },
327     {WMError::WM_ERROR_INVALID_PARENT,                 WmErrorCode::WM_ERROR_INVALID_PARENT           },
328     {WMError::WM_ERROR_INVALID_OP_IN_CUR_STATUS,       WmErrorCode::WM_ERROR_INVALID_OP_IN_CUR_STATUS },
329     {WMError::WM_ERROR_REPEAT_OPERATION,               WmErrorCode::WM_ERROR_REPEAT_OPERATION         },
330     {WMError::WM_ERROR_NULLPTR,                        WmErrorCode::WM_ERROR_STATE_ABNORMALLY         },
331     {WMError::WM_ERROR_SAMGR,                          WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY        },
332     {WMError::WM_ERROR_START_ABILITY_FAILED,           WmErrorCode::WM_ERROR_START_ABILITY_FAILED     },
333     {WMError::WM_ERROR_SYSTEM_ABNORMALLY,              WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY        },
334 };
335 
336 /**
337  * @brief Enumerates window size change reason.
338  */
339 enum class WindowSizeChangeReason : uint32_t {
340     UNDEFINED = 0,
341     MAXIMIZE,
342     RECOVER,
343     ROTATION,
344     DRAG,
345     DRAG_START,
346     DRAG_END,
347     RESIZE,
348     RESIZE_WITH_ANIMATION,
349     MOVE,
350     MOVE_WITH_ANIMATION,
351     HIDE,
352     TRANSFORM,
353     CUSTOM_ANIMATION_SHOW,
354     FULL_TO_SPLIT,
355     SPLIT_TO_FULL,
356     FULL_TO_FLOATING,
357     FLOATING_TO_FULL,
358     PIP_START,
359     PIP_SHOW,
360     PIP_AUTO_START,
361     PIP_RATIO_CHANGE,
362     PIP_RESTORE,
363     UPDATE_DPI_SYNC,
364     DRAG_MOVE,
365     AVOID_AREA_CHANGE,
366     MAXIMIZE_TO_SPLIT,
367     SPLIT_TO_MAXIMIZE,
368     END
369 };
370 
371 /**
372  * @brief Enumerates window gravity.
373  */
374 enum class WindowGravity : uint32_t {
375     WINDOW_GRAVITY_FLOAT = 0,
376     WINDOW_GRAVITY_BOTTOM
377 };
378 
379 /**
380  * @brief Enumerates window session type.
381  */
382 enum class WindowSessionType : uint32_t {
383     SCENE_SESSION = 0,
384     EXTENSION_SESSION = 1
385 };
386 
387 /**
388  * @brief Enumerates window tag.
389  */
390 enum class WindowTag : uint32_t {
391     MAIN_WINDOW = 0,
392     SUB_WINDOW = 1,
393     SYSTEM_WINDOW = 2
394 };
395 
396 /**
397  * @brief Enumerates drag event.
398  */
399 enum class DragEvent : uint32_t {
400     DRAG_EVENT_IN  = 1,
401     DRAG_EVENT_OUT,
402     DRAG_EVENT_MOVE,
403     DRAG_EVENT_END
404 };
405 
406 /**
407  * @brief Enumerates layout mode of window.
408  */
409 enum class WindowLayoutMode : uint32_t {
410     BASE = 0,
411     CASCADE = BASE,
412     TILE = 1,
413     END,
414 };
415 
416 namespace {
417 constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF;
418 constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000;
419 constexpr float UNDEFINED_BRIGHTNESS = -1.0f;
420 constexpr float MINIMUM_BRIGHTNESS = 0.0f;
421 constexpr float MAXIMUM_BRIGHTNESS = 1.0f;
422 
423 constexpr uint32_t INVALID_WINDOW_ID = 0;
424 constexpr int32_t INVALID_PID = -1;
425 constexpr int32_t INVALID_UID = -1;
426 
427 constexpr float UNDEFINED_DENSITY = -1.0f;
428 constexpr float MINIMUM_CUSTOM_DENSITY = 0.5f;
429 constexpr float MAXIMUM_CUSTOM_DENSITY = 4.0f;
430 }
431 
432 /**
433  * @struct PointInfo.
434  *
435  * @brief Point info.
436  */
437 struct PointInfo {
438     int32_t x;
439     int32_t y;
440 };
441 
442 /**
443  * @class Transform
444  *
445  * @brief parameter of transform and rotate.
446  */
447 class Transform {
448 public:
Transform()449     Transform()
450         : pivotX_(0.5f), pivotY_(0.5f), scaleX_(1.f), scaleY_(1.f), scaleZ_(1.f), rotationX_(0.f),
451           rotationY_(0.f), rotationZ_(0.f), translateX_(0.f), translateY_(0.f), translateZ_(0.f)
452     {}
~Transform()453     ~Transform() {}
454 
455     bool operator==(const Transform& right) const
456     {
457         return NearZero(scaleX_ - right.scaleX_) &&
458             NearZero(scaleY_ - right.scaleY_) &&
459             NearZero(scaleZ_ - right.scaleZ_) &&
460             NearZero(pivotX_ - right.pivotX_) &&
461             NearZero(pivotY_ - right.pivotY_) &&
462             NearZero(translateX_ - right.translateX_) &&
463             NearZero(translateY_ - right.translateY_) &&
464             NearZero(translateZ_ - right.translateZ_) &&
465             NearZero(rotationX_ - right.rotationX_) &&
466             NearZero(rotationY_ - right.rotationY_) &&
467             NearZero(rotationZ_ - right.rotationZ_);
468     }
469 
470     bool operator!=(const Transform& right) const
471     {
472         return !(*this == right);
473     }
474 
Identity()475     static const Transform& Identity()
476     {
477         static Transform I;
478         return I;
479     }
480 
481     float pivotX_;
482     float pivotY_;
483     float scaleX_;
484     float scaleY_;
485     float scaleZ_;
486     float rotationX_;
487     float rotationY_;
488     float rotationZ_;
489     float translateX_;
490     float translateY_;
491     float translateZ_;
492 
Unmarshalling(Parcel & parcel)493     void Unmarshalling(Parcel& parcel)
494     {
495         pivotX_ = parcel.ReadFloat();
496         pivotY_ = parcel.ReadFloat();
497         scaleX_ = parcel.ReadFloat();
498         scaleY_ = parcel.ReadFloat();
499         scaleZ_ = parcel.ReadFloat();
500         rotationX_ = parcel.ReadFloat();
501         rotationY_ = parcel.ReadFloat();
502         rotationZ_ = parcel.ReadFloat();
503         translateX_ = parcel.ReadFloat();
504         translateY_ = parcel.ReadFloat();
505         translateZ_ = parcel.ReadFloat();
506     }
507 
Marshalling(Parcel & parcel)508     bool Marshalling(Parcel& parcel) const
509     {
510         return parcel.WriteFloat(pivotX_) && parcel.WriteFloat(pivotY_) &&
511                parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) && parcel.WriteFloat(scaleZ_) &&
512                parcel.WriteFloat(rotationX_) && parcel.WriteFloat(rotationY_) && parcel.WriteFloat(rotationZ_) &&
513                parcel.WriteFloat(translateX_) && parcel.WriteFloat(translateY_) && parcel.WriteFloat(translateZ_);
514     }
515 
516 private:
NearZero(float val)517     static inline bool NearZero(float val)
518     {
519         return -0.001f < val && val < 0.001f;
520     }
521 };
522 
523 /**
524  * @struct RectAnimationConfig
525  *
526  * @brief Window RectAnimationConfig
527  */
528 struct RectAnimationConfig {
529     uint32_t duration = 0; // Duartion of the animation, in milliseconds.
530     float x1 = 0.0f;       // X coordinate of the first point on the Bezier curve.
531     float y1 = 0.0f;       // Y coordinate of the first point on the Bezier curve.
532     float x2 = 0.0f;       // X coordinate of the second point on the Bezier curve.
533     float y2 = 0.0f;       // Y coordinate of the second point on the Bezier curve.
534 };
535 
536 /**
537  * @struct SystemBarPropertyFlag
538  *
539  * @brief Flag of system bar
540  */
541 struct SystemBarPropertyFlag {
542     bool enableFlag = false;
543     bool backgroundColorFlag = false;
544     bool contentColorFlag = false;
545     bool enableAnimationFlag = false;
546 };
547 
548 /**
549  * @struct Rect
550  *
551  * @brief Window Rect.
552  */
553 struct Rect {
554     int32_t posX_;
555     int32_t posY_;
556     uint32_t width_;
557     uint32_t height_;
558 
559     bool operator==(const Rect& a) const
560     {
561         return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_);
562     }
563 
564     bool operator!=(const Rect& a) const
565     {
566         return !this->operator==(a);
567     }
568 
IsInsideOfRect569     bool IsInsideOf(const Rect& a) const
570     {
571         return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
572             posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
573     }
574 
IsUninitializedRectRect575     bool IsUninitializedRect() const
576     {
577         return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
578     }
579 
IsUninitializedSizeRect580     bool IsUninitializedSize() const
581     {
582         return width_ == 0 && height_ == 0;
583     }
584 
ToStringRect585     inline std::string ToString() const
586     {
587         std::ostringstream oss;
588         oss << "[" << posX_ << " " << posY_ << " " << width_ << " " << height_ << "]";
589         return oss.str();
590     }
591 
592     static const Rect EMPTY_RECT;
593 };
594 
595 inline constexpr Rect Rect::EMPTY_RECT { 0, 0, 0, 0 };
596 
597 /**
598  * @struct SystemBarProperty
599  *
600  * @brief Property of system bar.
601  */
602 struct SystemBarProperty {
603     bool enable_;
604     uint32_t backgroundColor_;
605     uint32_t contentColor_;
606     bool enableAnimation_;
607     SystemBarSettingFlag settingFlag_;
SystemBarPropertySystemBarProperty608     SystemBarProperty() : enable_(true), backgroundColor_(SYSTEM_COLOR_BLACK), contentColor_(SYSTEM_COLOR_WHITE),
609                           enableAnimation_(false), settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarPropertySystemBarProperty610     SystemBarProperty(bool enable, uint32_t background, uint32_t content, bool enableAnimation)
611         : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
612           settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarPropertySystemBarProperty613     SystemBarProperty(bool enable, uint32_t background, uint32_t content)
614         : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(false),
615           settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarPropertySystemBarProperty616     SystemBarProperty(bool enable, uint32_t background, uint32_t content,
617                       bool enableAnimation, SystemBarSettingFlag settingFlag)
618         : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
619           settingFlag_(settingFlag) {}
620 
621     bool operator == (const SystemBarProperty& a) const
622     {
623         return (enable_ == a.enable_ && backgroundColor_ == a.backgroundColor_ && contentColor_ == a.contentColor_ &&
624             enableAnimation_ == a.enableAnimation_);
625     }
626 };
627 
628 /**
629  * @struct WindowDensityInfo
630  *
631  * @brief Currently available density
632  */
633 struct WindowDensityInfo {
634     float systemDensity = UNDEFINED_DENSITY;
635     float defaultDensity = UNDEFINED_DENSITY;
636     float customDensity = UNDEFINED_DENSITY;
637 
ToStringWindowDensityInfo638     std::string ToString() const
639     {
640         std::string str;
641         constexpr int BUFFER_SIZE = 64;
642         char buffer[BUFFER_SIZE] = { 0 };
643         if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1,
644             "[%f, %f, %f]", systemDensity, defaultDensity, customDensity) > 0) {
645             str.append(buffer);
646         }
647         return str;
648     }
649 };
650 
651 /**
652  * @brief Enumerates avoid area type.
653  */
654 enum class AvoidAreaType : uint32_t {
655     TYPE_START = 0,
656     TYPE_SYSTEM = TYPE_START,           // area of SystemUI
657     TYPE_CUTOUT,                        // cutout of screen
658     TYPE_SYSTEM_GESTURE,                // area for system gesture
659     TYPE_KEYBOARD,                      // area for soft input keyboard
660     TYPE_NAVIGATION_INDICATOR,          // area for navigation indicator
661     TYPE_END,
662 };
663 
664 /**
665  * @brief Enumerates color space.
666  */
667 enum class ColorSpace : uint32_t {
668     COLOR_SPACE_DEFAULT = 0, // Default color space.
669     COLOR_SPACE_WIDE_GAMUT,  // Wide gamut color space. The specific wide color gamut depends on the screen.
670 };
671 
672 /**
673  * @brief Enumerates occupied area type.
674  */
675 enum class OccupiedAreaType : uint32_t {
676     TYPE_INPUT, // area of input window
677 };
678 
679 /**
680  * @brief Enumerates window maximize mode.
681  */
682 enum class MaximizeMode : uint32_t {
683     MODE_AVOID_SYSTEM_BAR,
684     MODE_FULL_FILL,
685     MODE_RECOVER
686 };
687 
688 /**
689  * @brief Enumerates window animation.
690  */
691 enum class WindowAnimation : uint32_t {
692     NONE,
693     DEFAULT,
694     INPUTE,
695     CUSTOM
696 };
697 
698 struct DecorButtonStyle {
699     int32_t  colorMode = DEFAULT_COLOR_MODE;
700     uint32_t spacingBetweenButtons = DEFAULT_SPACING_BETWEEN_BUTTONS;
701     uint32_t closeButtonRightMargin = DEFAULT_CLOSE_BUTTON_RIGHT_MARGIN;
702     uint32_t buttonBackgroundSize = DEFAULT_BUTTON_BACKGROUND_SIZE;
703 };
704 
705 /**
706  * @class AvoidArea
707  *
708  * @brief Area needed to avoid.
709  */
710 class AvoidArea : virtual public RefBase {
711 public:
712     Rect topRect_ { 0, 0, 0, 0 };
713     Rect leftRect_ { 0, 0, 0, 0 };
714     Rect rightRect_ { 0, 0, 0, 0 };
715     Rect bottomRect_ { 0, 0, 0, 0 };
716 
717     bool operator==(const AvoidArea& a) const
718     {
719         return (topRect_ == a.topRect_ && leftRect_ == a.leftRect_ &&
720             rightRect_ == a.rightRect_ && bottomRect_ == a.bottomRect_);
721     }
722 
723     bool operator!=(const AvoidArea& a) const
724     {
725         return !this->operator==(a);
726     }
727 
ReadParcel(Parcel & parcel,Rect & rect)728     static inline bool ReadParcel(Parcel& parcel, Rect& rect)
729     {
730         return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) &&
731             parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_);
732     }
733 
WriteParcel(Parcel & parcel,const Rect & rect)734     static inline bool WriteParcel(Parcel& parcel, const Rect& rect)
735     {
736         return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) &&
737             parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
738     }
739 
isEmptyAvoidArea()740     bool isEmptyAvoidArea() const
741     {
742         return topRect_.IsUninitializedRect() && leftRect_.IsUninitializedRect() &&
743             rightRect_.IsUninitializedRect() && bottomRect_.IsUninitializedRect();
744     }
745 };
746 
747 /**
748  * @struct VsyncCallback
749  *
750  * @brief Vsync callback
751  */
752 struct VsyncCallback {
753     OnCallback onCallback;
754 };
755 
756 /**
757  * @brief Enumerates window update type.
758  */
759 enum class WindowUpdateType : int32_t {
760     WINDOW_UPDATE_ADDED = 1,
761     WINDOW_UPDATE_REMOVED,
762     WINDOW_UPDATE_FOCUSED,
763     WINDOW_UPDATE_BOUNDS,
764     WINDOW_UPDATE_ACTIVE,
765     WINDOW_UPDATE_PROPERTY
766 };
767 
768 struct WindowLimits {
769     uint32_t maxWidth_ = static_cast<uint32_t>(INT32_MAX); // The width and height are no larger than INT32_MAX.
770     uint32_t maxHeight_ = static_cast<uint32_t>(INT32_MAX);
771     uint32_t minWidth_ = 1; // The width and height of the window cannot be less than or equal to 0.
772     uint32_t minHeight_ = 1;
773     float maxRatio_ = FLT_MAX;
774     float minRatio_ = 0.0f;
775     float vpRatio_ = 1.0f;
776 
WindowLimitsWindowLimits777     WindowLimits() {}
WindowLimitsWindowLimits778     WindowLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, uint32_t minHeight, float maxRatio,
779         float minRatio) : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth), minHeight_(minHeight),
780         maxRatio_(maxRatio), minRatio_(minRatio) {}
WindowLimitsWindowLimits781     WindowLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, uint32_t minHeight, float maxRatio,
782         float minRatio, float vpRatio) : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth),
783         minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio), vpRatio_(vpRatio) {}
784 
IsEmptyWindowLimits785     bool IsEmpty() const
786     {
787         return (maxHeight_ == 0 || minHeight_ == 0 || maxWidth_ == 0 || minWidth_ == 0);
788     }
789 };
790 
791 /**
792  * @struct TitleButtonRect
793  *
794  * @brief An area of title buttons relative to the upper right corner of the window.
795  */
796 struct TitleButtonRect {
797     int32_t posX_ = 0;
798     int32_t posY_ = 0;
799     uint32_t width_ = 0;
800     uint32_t height_ = 0;
801 
802     bool operator==(const TitleButtonRect& a) const
803     {
804         return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_);
805     }
806 
807     bool operator!=(const TitleButtonRect& a) const
808     {
809         return !this->operator==(a);
810     }
811 
ResetRectTitleButtonRect812     void ResetRect()
813     {
814         posX_ = 0;
815         posY_ = 0;
816         width_ = 0;
817         height_ = 0;
818     }
819 
IsInsideOfTitleButtonRect820     bool IsInsideOf(const TitleButtonRect& a) const
821     {
822         return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
823             posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
824     }
825 
IsUninitializedRectTitleButtonRect826     bool IsUninitializedRect() const
827     {
828         return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
829     }
830 };
831 
832 /**
833  * @brief WindowInfo filter Option
834  */
835 enum class WindowInfoFilterOption : WindowInfoFilterOptionDataType {
836     ALL = 0,
837     EXCLUDE_SYSTEM = 1,
838     VISIBLE = 1 << 1,
839     FOREGROUND = 1 << 2,
840 };
841 
842 inline WindowInfoFilterOption operator|(WindowInfoFilterOption lhs, WindowInfoFilterOption rhs)
843 {
844     return static_cast<WindowInfoFilterOption>(static_cast<WindowInfoFilterOptionDataType>(lhs) |
845         static_cast<WindowInfoFilterOptionDataType>(rhs));
846 }
847 
IsChosenWindowOption(WindowInfoFilterOption options,WindowInfoFilterOption option)848 inline bool IsChosenWindowOption(WindowInfoFilterOption options, WindowInfoFilterOption option)
849 {
850     return (static_cast<WindowInfoFilterOptionDataType>(options) &
851         static_cast<WindowInfoFilterOptionDataType>(option)) != 0;
852 }
853 
854 /**
855  * @brief WindowInfo Type Option
856  */
857 enum class WindowInfoTypeOption : WindowInfoTypeOptionDataType {
858     WINDOW_UI_INFO = 1,
859     WINDOW_DISPLAY_INFO = 1 << 1,
860     WINDOW_LAYOUT_INFO = 1 << 2,
861     WINDOW_META_INFO = 1 << 3,
862     ALL = ~0,
863 };
864 
865 inline WindowInfoTypeOption operator|(WindowInfoTypeOption lhs, WindowInfoTypeOption rhs)
866 {
867     return static_cast<WindowInfoTypeOption>(static_cast<WindowInfoTypeOptionDataType>(lhs) |
868         static_cast<WindowInfoTypeOptionDataType>(rhs));
869 }
870 
IsChosenWindowOption(WindowInfoTypeOption options,WindowInfoTypeOption option)871 inline bool IsChosenWindowOption(WindowInfoTypeOption options, WindowInfoTypeOption option)
872 {
873     return (static_cast<WindowInfoTypeOptionDataType>(options) &
874         static_cast<WindowInfoTypeOptionDataType>(option)) != 0;
875 }
876 
877 /**
878  * @enum WindowVisibilityState
879  *
880  * @brief Visibility state of a window
881  */
882 enum WindowVisibilityState : uint32_t {
883     START = 0,
884     WINDOW_VISIBILITY_STATE_NO_OCCLUSION = START,
885     WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION,
886     WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION,
887     WINDOW_LAYER_STATE_MAX,
888     END = WINDOW_LAYER_STATE_MAX,
889 };
890 
891 /**
892  * @struct WindowUIInfo
893  *
894  * @brief Window UI info
895  */
896 struct WindowUIInfo : public Parcelable {
897     WindowVisibilityState visibilityState = WINDOW_LAYER_STATE_MAX;
898 
MarshallingWindowUIInfo899     bool Marshalling(Parcel& parcel) const override
900     {
901         return parcel.WriteUint32(static_cast<uint32_t>(visibilityState));
902     }
903 
UnmarshallingWindowUIInfo904     static WindowUIInfo* Unmarshalling(Parcel& parcel)
905     {
906         WindowUIInfo* windowUIInfo = new WindowUIInfo();
907         uint32_t visibilityState = 0;
908         if (!parcel.ReadUint32(visibilityState)) {
909             delete windowUIInfo;
910             return nullptr;
911         }
912         windowUIInfo->visibilityState = static_cast<WindowVisibilityState>(visibilityState);
913         return windowUIInfo;
914     }
915 };
916 
917 /**
918  * @struct WindowDisplayInfo
919  *
920  * @brief Window display info
921  */
922 struct WindowDisplayInfo : public Parcelable {
923     DisplayId displayId = DISPLAY_ID_INVALID;
MarshallingWindowDisplayInfo924     bool Marshalling(Parcel& parcel) const override
925     {
926         return parcel.WriteUint64(displayId);
927     }
928 
UnmarshallingWindowDisplayInfo929     static WindowDisplayInfo* Unmarshalling(Parcel& parcel)
930     {
931         WindowDisplayInfo* windowDisplayInfo = new WindowDisplayInfo();
932         if (!parcel.ReadUint64(windowDisplayInfo->displayId)) {
933             delete windowDisplayInfo;
934             return nullptr;
935         }
936         return windowDisplayInfo;
937     }
938 };
939 
940 /**
941  * @struct WindowLayoutInfo
942  *
943  * @brief Layout info for all windows on the screen.
944  */
945 struct WindowLayoutInfo : public Parcelable {
946     Rect rect = Rect::EMPTY_RECT;
947 
MarshallingWindowLayoutInfo948     bool Marshalling(Parcel& parcel) const override
949     {
950         return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) && parcel.WriteUint32(rect.width_) &&
951                parcel.WriteUint32(rect.height_);
952     }
953 
UnmarshallingWindowLayoutInfo954     static WindowLayoutInfo* Unmarshalling(Parcel& parcel)
955     {
956         WindowLayoutInfo* windowLayoutInfo = new WindowLayoutInfo();
957         if (!parcel.ReadInt32(windowLayoutInfo->rect.posX_) || !parcel.ReadInt32(windowLayoutInfo->rect.posY_) ||
958             !parcel.ReadUint32(windowLayoutInfo->rect.width_) || !parcel.ReadUint32(windowLayoutInfo->rect.height_)) {
959             delete windowLayoutInfo;
960             return nullptr;
961         }
962         return windowLayoutInfo;
963     }
964 };
965 
966 /**
967  * @struct WindowMetaInfo
968  *
969  * @brief Window meta info
970  */
971 struct WindowMetaInfo : public Parcelable {
972     int32_t windowId = 0;
973     std::string windowName;
974     std::string bundleName;
975     std::string abilityName;
976     int32_t appIndex = 0;
977 
MarshallingWindowMetaInfo978     bool Marshalling(Parcel& parcel) const override
979     {
980         return parcel.WriteInt32(windowId) && parcel.WriteString(windowName) && parcel.WriteString(bundleName) &&
981                parcel.WriteString(abilityName) && parcel.WriteInt32(appIndex);
982     }
UnmarshallingWindowMetaInfo983     static WindowMetaInfo* Unmarshalling(Parcel& parcel)
984     {
985         WindowMetaInfo* windowMetaInfo = new WindowMetaInfo();
986         if (!parcel.ReadInt32(windowMetaInfo->windowId) || !parcel.ReadString(windowMetaInfo->windowName) ||
987             !parcel.ReadString(windowMetaInfo->bundleName) || !parcel.ReadString(windowMetaInfo->abilityName) ||
988             !parcel.ReadInt32(windowMetaInfo->appIndex)) {
989             delete windowMetaInfo;
990             return nullptr;
991         }
992         return windowMetaInfo;
993     }
994 };
995 
996 /**
997  * @struct WindowInfo
998  *
999  * @brief Classified window info
1000  */
1001 struct WindowInfo : public Parcelable {
1002     WindowUIInfo windowUIInfo;
1003     WindowDisplayInfo windowDisplayInfo;
1004     WindowLayoutInfo windowLayoutInfo;
1005     WindowMetaInfo windowMetaInfo;
1006 
MarshallingWindowInfo1007     bool Marshalling(Parcel& parcel) const override
1008     {
1009         return parcel.WriteParcelable(&windowUIInfo) && parcel.WriteParcelable(&windowDisplayInfo) &&
1010                parcel.WriteParcelable(&windowLayoutInfo) && parcel.WriteParcelable(&windowMetaInfo);
1011     }
1012 
UnmarshallingWindowInfo1013     static WindowInfo* Unmarshalling(Parcel& parcel)
1014     {
1015         WindowInfo* windowInfo = new WindowInfo();
1016         sptr<WindowUIInfo> windowUIInfo = parcel.ReadParcelable<WindowUIInfo>();
1017         sptr<WindowDisplayInfo> windowDisplayInfo = parcel.ReadParcelable<WindowDisplayInfo>();
1018         sptr<WindowLayoutInfo> windowLayoutInfo = parcel.ReadParcelable<WindowLayoutInfo>();
1019         sptr<WindowMetaInfo> windowMetaInfo = parcel.ReadParcelable<WindowMetaInfo>();
1020         if (!windowUIInfo || !windowDisplayInfo || !windowLayoutInfo || !windowMetaInfo) {
1021             delete windowInfo;
1022             return nullptr;
1023         }
1024         windowInfo->windowUIInfo = *windowUIInfo;
1025         windowInfo->windowDisplayInfo = *windowDisplayInfo;
1026         windowInfo->windowLayoutInfo = *windowLayoutInfo;
1027         windowInfo->windowMetaInfo = *windowMetaInfo;
1028         return windowInfo;
1029     }
1030 };
1031 
1032 /**
1033  * @struct WindowInfoOption
1034  *
1035  * @brief Option of list window info
1036  */
1037 struct WindowInfoOption : public Parcelable {
1038     WindowInfoFilterOption windowInfoFilterOption = WindowInfoFilterOption::ALL;
1039     WindowInfoTypeOption windowInfoTypeOption = WindowInfoTypeOption::ALL;
1040     DisplayId displayId = DISPLAY_ID_INVALID;
1041     int32_t windowId = 0;
1042 
MarshallingWindowInfoOption1043     bool Marshalling(Parcel& parcel) const override
1044     {
1045         return parcel.WriteUint32(static_cast<uint32_t>(windowInfoFilterOption)) &&
1046                parcel.WriteUint32(static_cast<uint32_t>(windowInfoTypeOption)) &&
1047                parcel.WriteUint64(displayId) &&
1048                parcel.WriteInt32(windowId);
1049     }
1050 
UnmarshallingWindowInfoOption1051     static WindowInfoOption* Unmarshalling(Parcel& parcel)
1052     {
1053         WindowInfoOption* windowInfoOption = new WindowInfoOption();
1054         uint32_t windowInfoFilterOption;
1055         uint32_t windowInfoTypeOption;
1056         if (!parcel.ReadUint32(windowInfoFilterOption) || !parcel.ReadUint32(windowInfoTypeOption) ||
1057             !parcel.ReadUint64(windowInfoOption->displayId) || !parcel.ReadInt32(windowInfoOption->windowId)) {
1058             delete windowInfoOption;
1059             return nullptr;
1060         }
1061         windowInfoOption->windowInfoFilterOption = static_cast<WindowInfoFilterOption>(windowInfoFilterOption);
1062         windowInfoOption->windowInfoTypeOption = static_cast<WindowInfoTypeOption>(windowInfoTypeOption);
1063         return windowInfoOption;
1064     }
1065 };
1066 
1067 /**
1068  * Config of keyboard animation
1069  */
1070 class KeyboardAnimationCurve : public Parcelable {
1071 public:
1072     KeyboardAnimationCurve() = default;
KeyboardAnimationCurve(const std::string & curveType,const std::vector<float> & curveParams,uint32_t duration)1073     KeyboardAnimationCurve(const std::string& curveType, const std::vector<float>& curveParams, uint32_t duration)
1074         : curveType_(curveType), duration_(duration)
1075     {
1076         curveParams_.assign(curveParams.begin(), curveParams.end());
1077     }
1078 
Marshalling(Parcel & parcel)1079     virtual bool Marshalling(Parcel& parcel) const override
1080     {
1081         if (!parcel.WriteString(curveType_)) {
1082             return false;
1083         }
1084 
1085         auto paramSize = curveParams_.size();
1086         if (paramSize == 4) { // 4: param size
1087             if (!parcel.WriteUint32(static_cast<uint32_t>(paramSize))) {
1088                 return false;
1089             }
1090             for (auto& param : curveParams_) {
1091                 if (!parcel.WriteFloat(param)) {
1092                     return false;
1093                 }
1094             }
1095         } else {
1096             if (!parcel.WriteUint32(0)) {
1097                 return false;
1098             }
1099         }
1100 
1101         if (!parcel.WriteUint32(duration_)) {
1102             return false;
1103         }
1104         return true;
1105     }
1106 
Unmarshalling(Parcel & parcel)1107     static KeyboardAnimationCurve* Unmarshalling(Parcel& parcel)
1108     {
1109         KeyboardAnimationCurve* config = new KeyboardAnimationCurve;
1110         uint32_t paramSize = 0;
1111         if (!parcel.ReadString(config->curveType_) || !parcel.ReadUint32(paramSize)) {
1112             delete config;
1113             return nullptr;
1114         }
1115 
1116         if (paramSize == 4) { // 4: paramSize
1117             for (uint32_t i = 0; i < paramSize; i++) {
1118                 float param = 0.0f;
1119                 if (!parcel.ReadFloat(param)) {
1120                     delete config;
1121                     return nullptr;
1122                 } else {
1123                     config->curveParams_.push_back(param);
1124                 }
1125             }
1126         }
1127 
1128         if (!parcel.ReadUint32(config->duration_)) {
1129             delete config;
1130             return nullptr;
1131         }
1132         return config;
1133     }
1134 
1135     std::string curveType_ = "";
1136     std::vector<float> curveParams_ = {};
1137     uint32_t duration_ = 0;
1138 };
1139 
1140 struct KeyboardAnimationConfig {
1141     KeyboardAnimationCurve curveIn;
1142     KeyboardAnimationCurve curveOut;
1143 };
1144 
1145 struct MoveConfiguration {
1146     DisplayId displayId = DISPLAY_ID_INVALID;
1147     RectAnimationConfig rectAnimationConfig = { 0, 0.0f, 0.0f, 0.0f, 0.0f };
ToStringMoveConfiguration1148     std::string ToString() const
1149     {
1150         std::string str;
1151         constexpr int BUFFER_SIZE = 1024;
1152         char buffer[BUFFER_SIZE] = { 0 };
1153         if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1,
1154             "[displayId: %llu, rectAnimationConfig: [%u, %f, %f, %f, %f]]", displayId, rectAnimationConfig.duration,
1155             rectAnimationConfig.x1, rectAnimationConfig.y1, rectAnimationConfig.x2, rectAnimationConfig.y2) > 0) {
1156             str.append(buffer);
1157         }
1158         return str;
1159     }
1160 };
1161 
1162 enum class MaximizePresentation {
1163     FOLLOW_APP_IMMERSIVE_SETTING = 0,   // follow app set immersiveStateEnable
1164     EXIT_IMMERSIVE = 1,                 // immersiveStateEnable will be set as false
1165     ENTER_IMMERSIVE = 2,                // immersiveStateEnable will be set as true
1166     // immersiveStateEnable will be set as true, titleHoverShowEnabled and dockHoverShowEnabled will be set as false
1167     ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER = 3,
1168 };
1169 
1170 enum class ExtensionWindowAttribute : int32_t {
1171     SYSTEM_WINDOW = 0,
1172     SUB_WINDOW = 1,
1173     UNKNOWN = 2
1174 };
1175 
1176 struct SystemWindowOptions {
1177     int32_t windowType = -1;
1178 };
1179 
1180 enum class ModalityType : uint8_t {
1181     WINDOW_MODALITY,
1182     APPLICATION_MODALITY,
1183 };
1184 
1185 struct SubWindowOptions {
1186     std::string title;
1187     bool decorEnabled = false;
1188     bool isModal = false;
1189     bool isTopmost = false;
1190     bool maximizeSupported = false;
1191     ModalityType modalityType = ModalityType::WINDOW_MODALITY;
1192 };
1193 
1194 struct ExtensionWindowConfig {
1195     std::string windowName;
1196     ExtensionWindowAttribute windowAttribute = ExtensionWindowAttribute::UNKNOWN;
1197     Rect windowRect;
1198     SubWindowOptions subWindowOptions;
1199     SystemWindowOptions systemWindowOptions;
1200 };
1201 
1202 enum class BackupAndRestoreType : int32_t {
1203     NONE = 0,                       // no backup and restore
1204     CONTINUATION = 1,               // distribute
1205     APP_RECOVERY = 2,               // app recovery
1206     RESOURCESCHEDULE_RECOVERY = 3,  // app is killed due to resource schedule
1207 };
1208 
1209 /**
1210  * @brief Windowinfokey
1211  */
1212 enum class WindowInfoKey : int32_t {
1213     WINDOW_ID,
1214     BUNDLE_NAME,
1215     ABILITY_NAME,
1216     APP_INDEX,
1217     VISIBILITY_STATE,
1218 };
1219 }
1220 }
1221 #endif // OHOS_ROSEN_WM_COMMON_H
1222