1/* 2 * Copyright (c) 2021-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#include <float.h> 22#include <sstream> 23#include <string> 24#include <vector> 25 26namespace OHOS { 27namespace Rosen { 28using DisplayId = uint64_t; 29/** 30 * @brief Enumerates type of window. 31 */ 32enum class WindowType : uint32_t { 33 APP_WINDOW_BASE = 1, 34 APP_MAIN_WINDOW_BASE = APP_WINDOW_BASE, 35 WINDOW_TYPE_APP_MAIN_WINDOW = APP_MAIN_WINDOW_BASE, 36 APP_MAIN_WINDOW_END, 37 38 APP_SUB_WINDOW_BASE = 1000, 39 WINDOW_TYPE_MEDIA = APP_SUB_WINDOW_BASE, 40 WINDOW_TYPE_APP_SUB_WINDOW, 41 WINDOW_TYPE_APP_COMPONENT, 42 APP_SUB_WINDOW_END, 43 APP_WINDOW_END = APP_SUB_WINDOW_END, 44 45 SYSTEM_WINDOW_BASE = 2000, 46 BELOW_APP_SYSTEM_WINDOW_BASE = SYSTEM_WINDOW_BASE, 47 WINDOW_TYPE_WALLPAPER = SYSTEM_WINDOW_BASE, 48 WINDOW_TYPE_DESKTOP, 49 BELOW_APP_SYSTEM_WINDOW_END, 50 51 ABOVE_APP_SYSTEM_WINDOW_BASE = 2100, 52 WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE, 53 WINDOW_TYPE_DOCK_SLICE, 54 WINDOW_TYPE_INCOMING_CALL, 55 WINDOW_TYPE_SEARCHING_BAR, 56 WINDOW_TYPE_SYSTEM_ALARM_WINDOW, 57 WINDOW_TYPE_INPUT_METHOD_FLOAT, 58 WINDOW_TYPE_FLOAT, 59 WINDOW_TYPE_TOAST, 60 WINDOW_TYPE_STATUS_BAR, 61 WINDOW_TYPE_PANEL, 62 WINDOW_TYPE_KEYGUARD, 63 WINDOW_TYPE_VOLUME_OVERLAY, 64 WINDOW_TYPE_NAVIGATION_BAR, 65 WINDOW_TYPE_DRAGGING_EFFECT, 66 WINDOW_TYPE_POINTER, 67 WINDOW_TYPE_LAUNCHER_RECENT, 68 WINDOW_TYPE_LAUNCHER_DOCK, 69 WINDOW_TYPE_BOOT_ANIMATION, 70 WINDOW_TYPE_FREEZE_DISPLAY, 71 WINDOW_TYPE_VOICE_INTERACTION, 72 WINDOW_TYPE_FLOAT_CAMERA, 73 WINDOW_TYPE_PLACEHOLDER, 74 WINDOW_TYPE_DIALOG, 75 WINDOW_TYPE_SCREENSHOT, 76 WINDOW_TYPE_INPUT_METHOD_STATUS_BAR, 77 WINDOW_TYPE_GLOBAL_SEARCH, 78 WINDOW_TYPE_NEGATIVE_SCREEN, 79 WINDOW_TYPE_SYSTEM_TOAST, 80 WINDOW_TYPE_SYSTEM_FLOAT, 81 WINDOW_TYPE_PIP, 82 WINDOW_TYPE_THEME_EDITOR, 83 WINDOW_TYPE_NAVIGATION_INDICATOR, 84 WINDOW_TYPE_HANDWRITE, 85 WINDOW_TYPE_SCENE_BOARD, 86 WINDOW_TYPE_KEYBOARD_PANEL, 87 WINDOW_TYPE_SCB_DEFAULT, 88 WINDOW_TYPE_TRANSPARENT_VIEW, 89 ABOVE_APP_SYSTEM_WINDOW_END, 90 91 SYSTEM_SUB_WINDOW_BASE = 2500, 92 WINDOW_TYPE_SYSTEM_SUB_WINDOW = SYSTEM_SUB_WINDOW_BASE, 93 SYSTEM_SUB_WINDOW_END, 94 95 SYSTEM_WINDOW_END = SYSTEM_SUB_WINDOW_END, 96 97 WINDOW_TYPE_UI_EXTENSION = 3000 98}; 99 100/** 101 * @struct HookInfo. 102 * 103 * @brief hook diaplayinfo deepending on the window size. 104 */ 105struct HookInfo { 106 uint32_t width_; 107 uint32_t height_; 108 float_t density_; 109 uint32_t rotation_; 110 bool enableHookRotation_; 111}; 112 113/** 114 * @brief Enumerates mode of window. 115 */ 116enum class WindowMode : uint32_t { 117 WINDOW_MODE_UNDEFINED = 0, 118 WINDOW_MODE_FULLSCREEN = 1, 119 WINDOW_MODE_SPLIT_PRIMARY = 100, 120 WINDOW_MODE_SPLIT_SECONDARY, 121 WINDOW_MODE_FLOATING, 122 WINDOW_MODE_PIP 123}; 124 125/** 126 * @brief Enumerates modeType of window. 127 */ 128enum class WindowModeType : uint8_t { 129 WINDOW_MODE_SPLIT_FLOATING = 0, 130 WINDOW_MODE_SPLIT = 1, 131 WINDOW_MODE_FLOATING = 2, 132 WINDOW_MODE_FULLSCREEN = 3, 133 WINDOW_MODE_FULLSCREEN_FLOATING = 4, 134 WINDOW_MODE_OTHER = 5 135}; 136 137/** 138 * @brief Enumerates modal of sub session. 139 */ 140enum class SubWindowModalType : uint32_t { 141 TYPE_UNDEFINED = 0, 142 TYPE_NORMAL, 143 TYPE_DIALOG, 144 TYPE_WINDOW_MODALITY, 145 TYPE_TOAST, 146 TYPE_APPLICATION_MODALITY, 147}; 148 149/** 150 * @brief Enumerates mode supported of window. 151 */ 152enum WindowModeSupport : uint32_t { 153 WINDOW_MODE_SUPPORT_FULLSCREEN = 1 << 0, 154 WINDOW_MODE_SUPPORT_FLOATING = 1 << 1, 155 WINDOW_MODE_SUPPORT_SPLIT_PRIMARY = 1 << 2, 156 WINDOW_MODE_SUPPORT_SPLIT_SECONDARY = 1 << 3, 157 WINDOW_MODE_SUPPORT_PIP = 1 << 4, 158 WINDOW_MODE_SUPPORT_ALL = WINDOW_MODE_SUPPORT_FULLSCREEN | 159 WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | 160 WINDOW_MODE_SUPPORT_SPLIT_SECONDARY | 161 WINDOW_MODE_SUPPORT_FLOATING | 162 WINDOW_MODE_SUPPORT_PIP 163}; 164 165/** 166 * @brief Enumerates blur style of window. 167 */ 168enum class WindowBlurStyle : uint32_t { 169 WINDOW_BLUR_OFF = 0, 170 WINDOW_BLUR_THIN, 171 WINDOW_BLUR_REGULAR, 172 WINDOW_BLUR_THICK 173}; 174 175/** 176 * @brief Enumerates state of window. 177 */ 178enum class WindowState : uint32_t { 179 STATE_INITIAL, 180 STATE_CREATED, 181 STATE_SHOWN, 182 STATE_HIDDEN, 183 STATE_FROZEN, 184 STATE_UNFROZEN, 185 STATE_DESTROYED, 186 STATE_BOTTOM = STATE_DESTROYED, // Add state type after STATE_DESTROYED is not allowed 187}; 188 189/** 190 * @brief Enumerates error code of window. 191 */ 192enum class WMError : int32_t { 193 WM_OK = 0, 194 WM_DO_NOTHING, 195 WM_ERROR_NO_MEM, 196 WM_ERROR_DESTROYED_OBJECT, 197 WM_ERROR_INVALID_WINDOW, 198 WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, 199 WM_ERROR_INVALID_OPERATION, 200 WM_ERROR_INVALID_PERMISSION, 201 WM_ERROR_NOT_SYSTEM_APP, 202 WM_ERROR_NO_REMOTE_ANIMATION, 203 WM_ERROR_INVALID_DISPLAY, 204 WM_ERROR_INVALID_PARENT, 205 WM_ERROR_OPER_FULLSCREEN_FAILED, 206 WM_ERROR_REPEAT_OPERATION, 207 WM_ERROR_INVALID_SESSION, 208 WM_ERROR_INVALID_CALLING, 209 WM_ERROR_SYSTEM_ABNORMALLY, 210 211 WM_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system 212 213 WM_ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report 214 WM_ERROR_NULLPTR, 215 WM_ERROR_INVALID_TYPE, 216 WM_ERROR_INVALID_PARAM, 217 WM_ERROR_SAMGR, 218 WM_ERROR_IPC_FAILED, 219 WM_ERROR_NEED_REPORT_END, 220 WM_ERROR_START_ABILITY_FAILED, 221 WM_ERROR_PIP_DESTROY_FAILED, 222 WM_ERROR_PIP_STATE_ABNORMALLY, 223 WM_ERROR_PIP_CREATE_FAILED, 224 WM_ERROR_PIP_INTERNAL_ERROR, 225 WM_ERROR_PIP_REPEAT_OPERATION, 226}; 227 228/** 229 * @brief Enumerates error code of window only used for js api. 230 */ 231enum class WmErrorCode : int32_t { 232 WM_OK = 0, 233 WM_ERROR_NO_PERMISSION = 201, 234 WM_ERROR_NOT_SYSTEM_APP = 202, 235 WM_ERROR_INVALID_PARAM = 401, 236 WM_ERROR_DEVICE_NOT_SUPPORT = 801, 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_OPER_FULLSCREEN_FAILED = 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 status of window. 256 */ 257enum class WindowStatus : uint32_t { 258 WINDOW_STATUS_UNDEFINED = 0, 259 WINDOW_STATUS_FULLSCREEN = 1, 260 WINDOW_STATUS_MAXIMIZE, 261 WINDOW_STATUS_MINIMIZE, 262 WINDOW_STATUS_FLOATING, 263 WINDOW_STATUS_SPLITSCREEN 264}; 265 266/** 267 * @brief Enumerates setting flag of systemStatusBar 268 */ 269enum class SystemBarSettingFlag : uint32_t { 270 DEFAULT_SETTING = 0, 271 COLOR_SETTING = 1, 272 ENABLE_SETTING = 1 << 1, 273 ALL_SETTING = COLOR_SETTING | ENABLE_SETTING, 274 FOLLOW_SETTING = 1 << 2 275}; 276 277inline SystemBarSettingFlag operator|(SystemBarSettingFlag lhs, SystemBarSettingFlag rhs) 278{ 279 using T = std::underlying_type_t<SystemBarSettingFlag>; 280 return static_cast<SystemBarSettingFlag>(static_cast<T>(lhs) | static_cast<T>(rhs)); 281} 282 283/** 284 * @brief Enumerates flag of multiWindowUIType. 285 */ 286enum class WindowUIType : uint8_t { 287 PHONE_WINDOW = 0, 288 PC_WINDOW, 289 PAD_WINDOW, 290 INVALID_WINDOW 291}; 292 293/** 294 * @brief Used to map from WMError to WmErrorCode. 295 */ 296extern const std::map<WMError, WmErrorCode> WM_JS_TO_ERROR_CODE_MAP; 297 298/** 299 * @brief Enumerates flag of window. 300 */ 301enum class WindowFlag : uint32_t { 302 WINDOW_FLAG_NEED_AVOID = 1, 303 WINDOW_FLAG_PARENT_LIMIT = 1 << 1, 304 WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, 305 WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, 306 WINDOW_FLAG_WATER_MARK = 1 << 4, 307 WINDOW_FLAG_IS_MODAL = 1 << 5, 308 WINDOW_FLAG_IS_APPLICATION_MODAL = 1 << 6, 309 WINDOW_FLAG_HANDWRITING = 1 << 7, 310 WINDOW_FLAG_IS_TOAST = 1 << 8, 311 WINDOW_FLAG_END = 1 << 9, 312}; 313 314/** 315 * @brief Flag of uiextension window. 316 */ 317union ExtensionWindowFlags { 318 uint32_t bitData; 319 struct { 320 // Each flag should be false default, true when active 321 bool hideNonSecureWindowsFlag : 1; 322 bool waterMarkFlag : 1; 323 bool privacyModeFlag : 1; 324 }; 325 ExtensionWindowFlags() : bitData(0) {} 326 ExtensionWindowFlags(uint32_t bits) : bitData(bits) {} 327 ~ExtensionWindowFlags() {} 328 void SetAllActive() 329 { 330 hideNonSecureWindowsFlag = true; 331 waterMarkFlag = true; 332 privacyModeFlag = true; 333 } 334}; 335 336/** 337 * @brief Enumerates window size change reason. 338 */ 339enum class WindowSizeChangeReason : uint32_t { 340 UNDEFINED = 0, 341 MAXIMIZE, 342 RECOVER, 343 ROTATION, 344 DRAG, 345 DRAG_START, 346 DRAG_END, 347 RESIZE, 348 MOVE, 349 HIDE, 350 TRANSFORM, 351 CUSTOM_ANIMATION_SHOW, 352 FULL_TO_SPLIT, 353 SPLIT_TO_FULL, 354 FULL_TO_FLOATING, 355 FLOATING_TO_FULL, 356 PIP_START, 357 PIP_SHOW, 358 PIP_AUTO_START, 359 PIP_RATIO_CHANGE, 360 PIP_RESTORE, 361 UPDATE_DPI_SYNC, 362 END, 363}; 364 365/** 366 * @brief Enumerates layout mode of window. 367 */ 368enum class WindowLayoutMode : uint32_t { 369 BASE = 0, 370 CASCADE = BASE, 371 TILE = 1, 372 END, 373}; 374 375/** 376 * @brief Enumerates drag event. 377 */ 378enum class DragEvent : uint32_t { 379 DRAG_EVENT_IN = 1, 380 DRAG_EVENT_OUT, 381 DRAG_EVENT_MOVE, 382 DRAG_EVENT_END, 383}; 384 385/** 386 * @brief Enumerates window tag. 387 */ 388enum class WindowTag : uint32_t { 389 MAIN_WINDOW = 0, 390 SUB_WINDOW = 1, 391 SYSTEM_WINDOW = 2, 392}; 393 394/** 395 * @brief Enumerates window session type. 396 */ 397enum class WindowSessionType : uint32_t { 398 SCENE_SESSION = 0, 399 EXTENSION_SESSION = 1, 400}; 401 402/** 403 * @brief Enumerates window gravity. 404 */ 405enum class WindowGravity : uint32_t { 406 WINDOW_GRAVITY_FLOAT = 0, 407 WINDOW_GRAVITY_BOTTOM, 408 WINDOW_GRAVITY_DEFAULT, 409}; 410 411/** 412 * @brief Enumerates window setuicontent type. 413 */ 414enum class WindowSetUIContentType : uint32_t { 415 DEFAULT, 416 RESTORE, 417 BY_NAME, 418 BY_ABC, 419}; 420 421/** 422 * @brief Enumerates restore type. 423 */ 424enum class BackupAndRestoreType : int32_t { 425 NONE = 0, // no backup and restore 426 CONTINUATION = 1, // distribute 427 APP_RECOVERY = 2, // app recovery 428 RESOURCESCHEDULE_RECOVERY = 3, // app is killed due to resource schedule 429}; 430 431/** 432 * @brief Enumerates window Style type. 433 */ 434enum class WindowStyleType : uint8_t { 435 WINDOW_STYLE_DEFAULT = 0, 436 WINDOW_STYLE_FREE_MULTI_WINDOW = 1, 437}; 438 439/** 440 * @brief Disable Gesture Back Type 441 */ 442enum class GestureBackType : uint8_t { 443 GESTURE_SIDE = 0, 444 GESTURE_SWIPE_UP = 1, 445 GESTURE_ALL = 2, 446}; 447 448/** 449 * @struct PointInfo. 450 * 451 * @brief point Info. 452 */ 453struct PointInfo { 454 int32_t x; 455 int32_t y; 456}; 457 458/** 459 * @struct MainWindowInfo. 460 * 461 * @brief topN main window info. 462 */ 463struct MainWindowInfo : public Parcelable { 464 virtual bool Marshalling(Parcel& parcel) const override 465 { 466 if (!parcel.WriteInt32(pid_)) { 467 return false; 468 } 469 470 if (!parcel.WriteString(bundleName_)) { 471 return false; 472 } 473 474 if (!parcel.WriteInt32(persistentId_)) { 475 return false; 476 } 477 478 if (!parcel.WriteInt32(bundleType_)) { 479 return false; 480 } 481 return true; 482 } 483 484 static MainWindowInfo* Unmarshalling(Parcel& parcel) 485 { 486 MainWindowInfo* mainWindowInfo = new MainWindowInfo; 487 mainWindowInfo->pid_ = parcel.ReadInt32(); 488 mainWindowInfo->bundleName_ = parcel.ReadString(); 489 mainWindowInfo->persistentId_ = parcel.ReadInt32(); 490 mainWindowInfo->bundleType_ = parcel.ReadInt32(); 491 return mainWindowInfo; 492 } 493 494 int32_t pid_ = 0; 495 std::string bundleName_ = ""; 496 int32_t persistentId_ = 0; 497 int32_t bundleType_ = 0; 498}; 499 500/** 501 * @struct MainWindowState. 502 * 503 * @brief main window state info. 504 */ 505struct MainWindowState : public Parcelable { 506 bool Marshalling(Parcel& parcel) const override 507 { 508 if (!parcel.WriteInt32(state_)) { 509 return false; 510 } 511 if (!parcel.WriteBool(isVisible_)) { 512 return false; 513 } 514 if (!parcel.WriteBool(isForegroundInteractive_)) { 515 return false; 516 } 517 if (!parcel.WriteBool(isPcOrPadEnableActivation_)) { 518 return false; 519 } 520 return true; 521 } 522 523 static MainWindowState* Unmarshalling(Parcel& parcel) 524 { 525 MainWindowState* mainWindowState = new MainWindowState(); 526 if (!mainWindowState) { 527 return nullptr; 528 } 529 if (!parcel.ReadInt32(mainWindowState->state_) || 530 !parcel.ReadBool(mainWindowState->isVisible_) || 531 !parcel.ReadBool(mainWindowState->isForegroundInteractive_) || 532 !parcel.ReadBool(mainWindowState->isPcOrPadEnableActivation_)) { 533 delete mainWindowState; 534 return nullptr; 535 } 536 return mainWindowState; 537 } 538 539 int32_t state_ = 0; 540 bool isVisible_ = false; 541 bool isForegroundInteractive_ = false; 542 bool isPcOrPadEnableActivation_ = false; 543}; 544 545namespace { 546 constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF; 547 constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000; 548 constexpr uint32_t INVALID_WINDOW_ID = 0; 549 constexpr float UNDEFINED_BRIGHTNESS = -1.0f; 550 constexpr float MINIMUM_BRIGHTNESS = 0.0f; 551 constexpr float MAXIMUM_BRIGHTNESS = 1.0f; 552 constexpr int32_t INVALID_PID = -1; 553 constexpr int32_t INVALID_UID = -1; 554 constexpr int32_t INVALID_USER_ID = -1; 555 constexpr int32_t SYSTEM_USERID = 0; 556 constexpr int32_t BASE_USER_RANGE = 200000; 557 constexpr int32_t DEFAULT_SCREEN_ID = 0; 558 constexpr int32_t FULL_CIRCLE_DEGREE = 360; 559 constexpr int32_t ONE_FOURTH_FULL_CIRCLE_DEGREE = 90; 560} 561 562inline int32_t GetUserIdByUid(int32_t uid) 563{ 564 return uid / BASE_USER_RANGE; 565} 566 567/** 568 * @class Transform 569 * 570 * @brief parameter of transform and rotate. 571 */ 572class Transform { 573public: 574 Transform() 575 : pivotX_(0.5f), pivotY_(0.5f), scaleX_(1.f), scaleY_(1.f), scaleZ_(1.f), rotationX_(0.f), 576 rotationY_(0.f), rotationZ_(0.f), translateX_(0.f), translateY_(0.f), translateZ_(0.f) 577 {} 578 ~Transform() {} 579 580 bool operator==(const Transform& right) const 581 { 582 return NearZero(pivotX_ - right.pivotX_) && 583 NearZero(pivotY_ - right.pivotY_) && 584 NearZero(scaleX_ - right.scaleX_) && 585 NearZero(scaleY_ - right.scaleY_) && 586 NearZero(scaleZ_ - right.scaleZ_) && 587 NearZero(rotationX_ - right.rotationX_) && 588 NearZero(rotationY_ - right.rotationY_) && 589 NearZero(rotationZ_ - right.rotationZ_) && 590 NearZero(translateX_ - right.translateX_) && 591 NearZero(translateY_ - right.translateY_) && 592 NearZero(translateZ_ - right.translateZ_); 593 } 594 595 bool operator!=(const Transform& right) const 596 { 597 return !(*this == right); 598 } 599 600 float pivotX_; 601 float pivotY_; 602 float scaleX_; 603 float scaleY_; 604 float scaleZ_; 605 float rotationX_; 606 float rotationY_; 607 float rotationZ_; 608 float translateX_; 609 float translateY_; 610 float translateZ_; 611 612 static const Transform& Identity() 613 { 614 static Transform I; 615 return I; 616 } 617 618 bool Marshalling(Parcel& parcel) const 619 { 620 return parcel.WriteFloat(pivotX_) && parcel.WriteFloat(pivotY_) && 621 parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) && parcel.WriteFloat(scaleZ_) && 622 parcel.WriteFloat(rotationX_) && parcel.WriteFloat(rotationY_) && parcel.WriteFloat(rotationZ_) && 623 parcel.WriteFloat(translateX_) && parcel.WriteFloat(translateY_) && parcel.WriteFloat(translateZ_); 624 } 625 626 void Unmarshalling(Parcel& parcel) 627 { 628 pivotX_ = parcel.ReadFloat(); 629 pivotY_ = parcel.ReadFloat(); 630 scaleX_ = parcel.ReadFloat(); 631 scaleY_ = parcel.ReadFloat(); 632 scaleZ_ = parcel.ReadFloat(); 633 rotationX_ = parcel.ReadFloat(); 634 rotationY_ = parcel.ReadFloat(); 635 rotationZ_ = parcel.ReadFloat(); 636 translateX_ = parcel.ReadFloat(); 637 translateY_ = parcel.ReadFloat(); 638 translateZ_ = parcel.ReadFloat(); 639 } 640private: 641 static inline bool NearZero(float val) 642 { 643 return val < 0.001f && val > -0.001f; 644 } 645}; 646 647/** 648 * @struct SystemBarProperty 649 * 650 * @brief Property of system bar 651 */ 652struct SystemBarProperty { 653 bool enable_; 654 uint32_t backgroundColor_; 655 uint32_t contentColor_; 656 bool enableAnimation_; 657 SystemBarSettingFlag settingFlag_; 658 SystemBarProperty() : enable_(true), backgroundColor_(SYSTEM_COLOR_BLACK), contentColor_(SYSTEM_COLOR_WHITE), 659 enableAnimation_(false), settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {} 660 SystemBarProperty(bool enable, uint32_t background, uint32_t content) 661 : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(false), 662 settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {} 663 SystemBarProperty(bool enable, uint32_t background, uint32_t content, bool enableAnimation) 664 : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation), 665 settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {} 666 SystemBarProperty(bool enable, uint32_t background, uint32_t content, 667 bool enableAnimation, SystemBarSettingFlag settingFlag) 668 : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation), 669 settingFlag_(settingFlag) {} 670 bool operator == (const SystemBarProperty& a) const 671 { 672 return (enable_ == a.enable_ && backgroundColor_ == a.backgroundColor_ && contentColor_ == a.contentColor_ && 673 enableAnimation_ == a.enableAnimation_); 674 } 675}; 676 677/** 678 * @struct SystemBarPropertyFlag 679 * 680 * @brief Flag of system bar 681 */ 682struct SystemBarPropertyFlag { 683 bool enableFlag = false; 684 bool backgroundColorFlag = false; 685 bool contentColorFlag = false; 686 bool enableAnimationFlag = false; 687}; 688 689/** 690 * @struct Rect 691 * 692 * @brief Window Rect 693 */ 694struct Rect { 695 int32_t posX_; 696 int32_t posY_; 697 uint32_t width_; 698 uint32_t height_; 699 700 bool operator==(const Rect& a) const 701 { 702 return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_); 703 } 704 705 bool operator!=(const Rect& a) const 706 { 707 return !this->operator==(a); 708 } 709 710 bool IsUninitializedRect() const 711 { 712 return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0); 713 } 714 715 bool IsInsideOf(const Rect& a) const 716 { 717 return (posX_ >= a.posX_ && posY_ >= a.posY_ && 718 posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_); 719 } 720 721 inline std::string ToString() const 722 { 723 std::stringstream ss; 724 ss << "[" << posX_ << " " << posY_ << " " << width_ << " " << height_ << "]"; 725 return ss.str(); 726 } 727}; 728 729/** 730 * @brief UIExtension usage 731 */ 732enum class UIExtensionUsage : uint32_t { 733 MODAL = 0, 734 EMBEDDED, 735 CONSTRAINED_EMBEDDED, 736 UIEXTENSION_USAGE_END 737}; 738 739/** 740 * @brief UIExtension info for event 741 */ 742struct ExtensionWindowEventInfo { 743 int32_t persistentId = 0; 744 int32_t pid = -1; 745 Rect windowRect {0, 0, 0, 0}; 746}; 747 748/** 749 * @brief UIExtension info from ability 750 */ 751struct ExtensionWindowAbilityInfo { 752 int32_t persistentId { 0 }; 753 int32_t parentId { 0 }; 754 UIExtensionUsage usage { UIExtensionUsage::UIEXTENSION_USAGE_END }; 755}; 756 757/** 758 * @struct KeyboardPanelInfo 759 * 760 * @brief Info of keyboard panel 761 */ 762struct KeyboardPanelInfo : public Parcelable { 763 Rect rect_ = {0, 0, 0, 0}; 764 WindowGravity gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM; 765 bool isShowing_ = false; 766 767 bool Marshalling(Parcel& parcel) const 768 { 769 return parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) && 770 parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) && 771 parcel.WriteUint32(static_cast<uint32_t>(gravity_)) && 772 parcel.WriteBool(isShowing_); 773 } 774 775 static KeyboardPanelInfo* Unmarshalling(Parcel& parcel) 776 { 777 KeyboardPanelInfo* keyboardPanelInfo = new(std::nothrow)KeyboardPanelInfo; 778 if (keyboardPanelInfo == nullptr) { 779 return nullptr; 780 } 781 bool res = parcel.ReadInt32(keyboardPanelInfo->rect_.posX_) && 782 parcel.ReadInt32(keyboardPanelInfo->rect_.posY_) && parcel.ReadUint32(keyboardPanelInfo->rect_.width_) && 783 parcel.ReadUint32(keyboardPanelInfo->rect_.height_); 784 if (!res) { 785 delete keyboardPanelInfo; 786 return nullptr; 787 } 788 keyboardPanelInfo->gravity_ = static_cast<WindowGravity>(parcel.ReadUint32()); 789 keyboardPanelInfo->isShowing_ = parcel.ReadBool(); 790 791 return keyboardPanelInfo; 792 } 793}; 794 795/** 796 * @brief Enumerates avoid area type. 797 */ 798enum class AvoidAreaType : uint32_t { 799 TYPE_SYSTEM, // area of SystemUI 800 TYPE_CUTOUT, // cutout of screen 801 TYPE_SYSTEM_GESTURE, // area for system gesture 802 TYPE_KEYBOARD, // area for soft input keyboard 803 TYPE_NAVIGATION_INDICATOR, // area for navigation indicator 804}; 805 806/** 807 * @brief Enumerates occupied area type. 808 */ 809enum class OccupiedAreaType : uint32_t { 810 TYPE_INPUT, // area of input window 811}; 812 813/** 814 * @brief Enumerates color space. 815 */ 816enum class ColorSpace : uint32_t { 817 COLOR_SPACE_DEFAULT = 0, // Default color space. 818 COLOR_SPACE_WIDE_GAMUT, // Wide gamut color space. The specific wide color gamut depends on the screen. 819}; 820 821/** 822 * @brief Enumerates window animation. 823 */ 824enum class WindowAnimation : uint32_t { 825 NONE, 826 DEFAULT, 827 INPUTE, 828 CUSTOM, 829}; 830 831/** 832 * @brief Enumerates window maximize mode. 833 */ 834enum class MaximizeMode : uint32_t { 835 MODE_AVOID_SYSTEM_BAR, 836 MODE_FULL_FILL, 837 MODE_RECOVER, 838 MODE_END, 839}; 840 841/** 842 * @class AvoidArea 843 * 844 * @brief Area needed to avoid. 845 */ 846class AvoidArea : public Parcelable { 847public: 848 Rect topRect_ { 0, 0, 0, 0 }; 849 Rect leftRect_ { 0, 0, 0, 0 }; 850 Rect rightRect_ { 0, 0, 0, 0 }; 851 Rect bottomRect_ { 0, 0, 0, 0 }; 852 853 bool operator==(const AvoidArea& a) const 854 { 855 return (leftRect_ == a.leftRect_ && topRect_ == a.topRect_ && 856 rightRect_ == a.rightRect_ && bottomRect_ == a.bottomRect_); 857 } 858 859 bool operator!=(const AvoidArea& a) const 860 { 861 return !this->operator==(a); 862 } 863 864 bool isEmptyAvoidArea() const 865 { 866 return topRect_.IsUninitializedRect() && leftRect_.IsUninitializedRect() && 867 rightRect_.IsUninitializedRect() && bottomRect_.IsUninitializedRect(); 868 } 869 870 static inline bool WriteParcel(Parcel& parcel, const Rect& rect) 871 { 872 return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) && 873 parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_); 874 } 875 876 static inline bool ReadParcel(Parcel& parcel, Rect& rect) 877 { 878 return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) && 879 parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_); 880 } 881 882 virtual bool Marshalling(Parcel& parcel) const override 883 { 884 return (WriteParcel(parcel, leftRect_) && WriteParcel(parcel, topRect_) && 885 WriteParcel(parcel, rightRect_) && WriteParcel(parcel, bottomRect_)); 886 } 887 888 static AvoidArea* Unmarshalling(Parcel& parcel) 889 { 890 AvoidArea *avoidArea = new(std::nothrow) AvoidArea(); 891 if (avoidArea == nullptr) { 892 return nullptr; 893 } 894 if (ReadParcel(parcel, avoidArea->leftRect_) && ReadParcel(parcel, avoidArea->topRect_) && 895 ReadParcel(parcel, avoidArea->rightRect_) && ReadParcel(parcel, avoidArea->bottomRect_)) { 896 return avoidArea; 897 } 898 delete avoidArea; 899 return nullptr; 900 } 901 902 std::string ToString() const 903 { 904 std::stringstream ss; 905 if (isEmptyAvoidArea()) { 906 ss << "empty"; 907 return ss.str(); 908 } 909 if (!topRect_.IsUninitializedRect()) { 910 ss << "top " << topRect_.ToString() << " "; 911 } 912 if (!bottomRect_.IsUninitializedRect()) { 913 ss << "bottom " << bottomRect_.ToString() << " "; 914 } 915 if (!leftRect_.IsUninitializedRect()) { 916 ss << "left " << leftRect_.ToString() << " "; 917 } 918 if (!rightRect_.IsUninitializedRect()) { 919 ss << "right " << rightRect_.ToString() << " "; 920 } 921 return ss.str(); 922 } 923}; 924 925/** 926 * @brief Enumerates window update type. 927 */ 928enum class WindowUpdateType : int32_t { 929 WINDOW_UPDATE_ADDED = 1, 930 WINDOW_UPDATE_REMOVED, 931 WINDOW_UPDATE_FOCUSED, 932 WINDOW_UPDATE_BOUNDS, 933 WINDOW_UPDATE_ACTIVE, 934 WINDOW_UPDATE_PROPERTY, 935 WINDOW_UPDATE_ALL, 936}; 937 938/** 939 * @brief Enumerates picture in picture window state. 940 */ 941enum class PiPWindowState : uint32_t { 942 STATE_UNDEFINED = 0, 943 STATE_STARTING = 1, 944 STATE_STARTED = 2, 945 STATE_STOPPING = 3, 946 STATE_STOPPED = 4, 947 STATE_RESTORING = 5, 948}; 949 950/** 951 * @brief Enumerates picture in picture template type. 952 */ 953enum class PiPTemplateType : uint32_t { 954 VIDEO_PLAY = 0, 955 VIDEO_CALL = 1, 956 VIDEO_MEETING = 2, 957 VIDEO_LIVE = 3, 958 END, 959}; 960 961/** 962 * @brief Enumerates picture in picture control group. 963 */ 964enum class PiPControlGroup : uint32_t { 965 VIDEO_PLAY_START = 100, 966 VIDEO_PREVIOUS_NEXT = 101, 967 FAST_FORWARD_BACKWARD = 102, 968 VIDEO_PLAY_END, 969 970 VIDEO_CALL_START = 200, 971 VIDEO_CALL_MICROPHONE_SWITCH = 201, 972 VIDEO_CALL_HANG_UP_BUTTON = 202, 973 VIDEO_CALL_CAMERA_SWITCH = 203, 974 VIDEO_CALL_MUTE_SWITCH = 204, 975 VIDEO_CALL_END, 976 977 VIDEO_MEETING_START = 300, 978 VIDEO_MEETING_HANG_UP_BUTTON = 301, 979 VIDEO_MEETING_CAMERA_SWITCH = 302, 980 VIDEO_MEETING_MUTE_SWITCH = 303, 981 VIDEO_MEETING_MICROPHONE_SWITCH = 304, 982 VIDEO_MEETING_END, 983 984 VIDEO_LIVE_START = 400, 985 VIDEO_PLAY_PAUSE = 401, 986 VIDEO_LIVE_MUTE_SWITCH = 402, 987 VIDEO_LIVE_END, 988 END, 989}; 990 991/** 992 * @brief Enumerates picture in picture state. 993 */ 994enum class PiPState : int32_t { 995 ABOUT_TO_START = 1, 996 STARTED = 2, 997 ABOUT_TO_STOP = 3, 998 STOPPED = 4, 999 ABOUT_TO_RESTORE = 5, 1000 ERROR = 6, 1001}; 1002 1003/** 1004 * @brief Enumerates picture in picture control status. 1005 */ 1006enum class PiPControlStatus : int32_t { 1007 PLAY = 1, 1008 PAUSE = 0, 1009 OPEN = 1, 1010 CLOSE = 0, 1011 ENABLED = -2, 1012 DISABLED = -3, 1013}; 1014 1015/** 1016 * @brief Enumerates picture in picture control type. 1017 */ 1018enum class PiPControlType : uint32_t { 1019 VIDEO_PLAY_PAUSE = 0, 1020 VIDEO_PREVIOUS = 1, 1021 VIDEO_NEXT = 2, 1022 FAST_FORWARD = 3, 1023 FAST_BACKWARD = 4, 1024 HANG_UP_BUTTON = 5, 1025 MICROPHONE_SWITCH = 6, 1026 CAMERA_SWITCH = 7, 1027 MUTE_SWITCH = 8, 1028 END, 1029}; 1030 1031struct PiPControlStatusInfo { 1032 PiPControlType controlType; 1033 PiPControlStatus status; 1034}; 1035 1036struct PiPControlEnableInfo { 1037 PiPControlType controlType; 1038 PiPControlStatus enabled; 1039}; 1040 1041struct PiPTemplateInfo { 1042 uint32_t pipTemplateType; 1043 uint32_t priority; 1044 std::vector<uint32_t> controlGroup; 1045 std::vector<PiPControlStatusInfo> pipControlStatusInfoList; 1046 std::vector<PiPControlEnableInfo> pipControlEnableInfoList; 1047}; 1048 1049using OnCallback = std::function<void(int64_t, int64_t)>; 1050 1051/** 1052 * @struct VsyncCallback 1053 * 1054 * @brief Vsync callback 1055 */ 1056struct VsyncCallback { 1057 OnCallback onCallback; 1058}; 1059 1060struct WindowLimits { 1061 uint32_t maxWidth_ = INT32_MAX; 1062 uint32_t maxHeight_ = INT32_MAX; 1063 uint32_t minWidth_ = 1; 1064 uint32_t minHeight_ = 1; 1065 float maxRatio_ = FLT_MAX; 1066 float minRatio_ = 0.0f; 1067 float vpRatio_ = 1.0f; 1068 1069 WindowLimits() {} 1070 WindowLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, uint32_t minHeight, float maxRatio, 1071 float minRatio) : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth), minHeight_(minHeight), 1072 maxRatio_(maxRatio), minRatio_(minRatio) {} 1073 WindowLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, uint32_t minHeight, float maxRatio, 1074 float minRatio, float vpRatio) : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth), 1075 minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio), vpRatio_(vpRatio) {} 1076 1077 bool IsEmpty() const 1078 { 1079 return (maxWidth_ == 0 || minWidth_ == 0 || maxHeight_ == 0 || minHeight_ == 0); 1080 } 1081}; 1082 1083/** 1084 * @struct TitleButtonRect 1085 * 1086 * @brief An area of title buttons relative to the upper right corner of the window. 1087 */ 1088struct TitleButtonRect { 1089 int32_t posX_; 1090 int32_t posY_; 1091 uint32_t width_; 1092 uint32_t height_; 1093 1094 bool operator==(const TitleButtonRect& a) const 1095 { 1096 return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_); 1097 } 1098 1099 bool operator!=(const TitleButtonRect& a) const 1100 { 1101 return !this->operator==(a); 1102 } 1103 1104 bool IsUninitializedRect() const 1105 { 1106 return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0); 1107 } 1108 1109 bool IsInsideOf(const TitleButtonRect& a) const 1110 { 1111 return (posX_ >= a.posX_ && posY_ >= a.posY_ && 1112 posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_); 1113 } 1114}; 1115 1116/* 1117 * Config of keyboard animation 1118 */ 1119class KeyboardAnimationCurve : public Parcelable { 1120public: 1121 KeyboardAnimationCurve() = default; 1122 KeyboardAnimationCurve(const std::string& curveType, const std::vector<float>& curveParams, uint32_t duration) 1123 : curveType_(curveType), duration_(duration) 1124 { 1125 curveParams_.assign(curveParams.begin(), curveParams.end()); 1126 } 1127 1128 virtual bool Marshalling(Parcel& parcel) const override 1129 { 1130 if (!parcel.WriteString(curveType_)) { 1131 return false; 1132 } 1133 1134 auto paramSize = curveParams_.size(); 1135 if (paramSize == 4) { // 4: param size 1136 if (!parcel.WriteUint32(static_cast<uint32_t>(paramSize))) { 1137 return false; 1138 } 1139 for (auto& param : curveParams_) { 1140 if (!parcel.WriteFloat(param)) { 1141 return false; 1142 } 1143 } 1144 } else { 1145 if (!parcel.WriteUint32(0)) { 1146 return false; 1147 } 1148 } 1149 1150 if (!parcel.WriteUint32(duration_)) { 1151 return false; 1152 } 1153 return true; 1154 } 1155 1156 static KeyboardAnimationCurve* Unmarshalling(Parcel& parcel) 1157 { 1158 KeyboardAnimationCurve* config = new KeyboardAnimationCurve; 1159 uint32_t paramSize = 0; 1160 if (!parcel.ReadString(config->curveType_) || !parcel.ReadUint32(paramSize)) { 1161 delete config; 1162 return nullptr; 1163 } 1164 1165 if (paramSize == 4) { // 4: paramSize 1166 for (uint32_t i = 0; i < paramSize; i++) { 1167 float param = 0.0f; 1168 if (!parcel.ReadFloat(param)) { 1169 delete config; 1170 return nullptr; 1171 } else { 1172 config->curveParams_.push_back(param); 1173 } 1174 } 1175 } 1176 1177 if (!parcel.ReadUint32(config->duration_)) { 1178 delete config; 1179 return nullptr; 1180 } 1181 return config; 1182 } 1183 1184 std::string curveType_ = ""; 1185 std::vector<float> curveParams_ = {}; 1186 uint32_t duration_ = 0; 1187}; 1188 1189struct KeyboardAnimationConfig { 1190 KeyboardAnimationCurve curveIn; 1191 KeyboardAnimationCurve curveOut; 1192}; 1193 1194enum class CaseType { 1195 CASE_WINDOW_MANAGER = 0, 1196 CASE_WINDOW, 1197 CASE_STAGE 1198}; 1199 1200enum class MaximizePresentation { 1201 FOLLOW_APP_IMMERSIVE_SETTING = 0, // follow app set imersiveStateEnable 1202 EXIT_IMMERSIVE = 1, // imersiveStateEnable will be set as false 1203 ENTER_IMMERSIVE = 2, // imersiveStateEnable will be set as true 1204 // imersiveStateEnable will be set as true, titleHoverShowEnabled and dockHoverShowEnabled will be set as false 1205 ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER = 3, 1206}; 1207 1208enum ForceHideState : uint32_t { 1209 NOT_HIDDEN = 0, 1210 HIDDEN_WHEN_FOCUSED, 1211 HIDDEN_WHEN_UNFOCUSED 1212}; 1213 1214enum class ExtensionWindowAttribute : int32_t { 1215 SYSTEM_WINDOW = 0, 1216 SUB_WINDOW = 1, 1217 UNKNOWN = 2 1218}; 1219 1220struct SystemWindowOptions { 1221 int32_t windowType = -1; 1222}; 1223 1224enum class ModalityType : uint8_t { 1225 WINDOW_MODALITY, 1226 APPLICATION_MODALITY, 1227}; 1228 1229struct SubWindowOptions { 1230 std::string title; 1231 bool decorEnabled = false; 1232 bool isModal = false; 1233 bool isTopmost = false; 1234 ModalityType modalityType = ModalityType::WINDOW_MODALITY; 1235}; 1236 1237struct ExtensionWindowConfig { 1238 std::string windowName; 1239 ExtensionWindowAttribute windowAttribute = ExtensionWindowAttribute::UNKNOWN; 1240 Rect windowRect; 1241 SubWindowOptions subWindowOptions; 1242 SystemWindowOptions systemWindowOptions; 1243}; 1244 1245/** 1246 * @class KeyboardLayoutParams 1247 * 1248 * @brief Keyboard need adjust layout 1249 */ 1250class KeyboardLayoutParams : public Parcelable { 1251public: 1252 WindowGravity gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM; 1253 Rect LandscapeKeyboardRect_ { 0, 0, 0, 0 }; 1254 Rect PortraitKeyboardRect_ { 0, 0, 0, 0 }; 1255 Rect LandscapePanelRect_ { 0, 0, 0, 0 }; 1256 Rect PortraitPanelRect_ { 0, 0, 0, 0 }; 1257 1258 bool operator==(const KeyboardLayoutParams& params) const 1259 { 1260 return (gravity_ == params.gravity_ && LandscapeKeyboardRect_ == params.LandscapeKeyboardRect_ && 1261 PortraitKeyboardRect_ == params.PortraitKeyboardRect_ && 1262 LandscapePanelRect_ == params.LandscapePanelRect_ && 1263 PortraitPanelRect_ == params.PortraitPanelRect_); 1264 } 1265 1266 bool operator!=(const KeyboardLayoutParams& params) const 1267 { 1268 return !this->operator==(params); 1269 } 1270 1271 bool isEmpty() const 1272 { 1273 return LandscapeKeyboardRect_.IsUninitializedRect() && PortraitKeyboardRect_.IsUninitializedRect() && 1274 LandscapePanelRect_.IsUninitializedRect() && PortraitPanelRect_.IsUninitializedRect(); 1275 } 1276 1277 static inline bool WriteParcel(Parcel& parcel, const Rect& rect) 1278 { 1279 return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) && 1280 parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_); 1281 } 1282 1283 static inline bool ReadParcel(Parcel& parcel, Rect& rect) 1284 { 1285 return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) && 1286 parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_); 1287 } 1288 1289 virtual bool Marshalling(Parcel& parcel) const override 1290 { 1291 return (parcel.WriteUint32(static_cast<uint32_t>(gravity_)) && 1292 WriteParcel(parcel, LandscapeKeyboardRect_) && 1293 WriteParcel(parcel, PortraitKeyboardRect_) && 1294 WriteParcel(parcel, LandscapePanelRect_) && 1295 WriteParcel(parcel, PortraitPanelRect_)); 1296 } 1297 1298 static KeyboardLayoutParams* Unmarshalling(Parcel& parcel) 1299 { 1300 KeyboardLayoutParams *params = new(std::nothrow) KeyboardLayoutParams(); 1301 if (params == nullptr) { 1302 return nullptr; 1303 } 1304 params->gravity_ = static_cast<WindowGravity>(parcel.ReadUint32()); 1305 if (ReadParcel(parcel, params->LandscapeKeyboardRect_) && 1306 ReadParcel(parcel, params->PortraitKeyboardRect_) && 1307 ReadParcel(parcel, params->LandscapePanelRect_) && 1308 ReadParcel(parcel, params->PortraitPanelRect_)) { 1309 return params; 1310 } 1311 delete params; 1312 return nullptr; 1313 } 1314}; 1315} 1316} 1317#endif // OHOS_ROSEN_WM_COMMON_H 1318