1 /* 2 * Copyright (c) 2021-2022 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_WINDOW_MANAGER_H 17 #define OHOS_ROSEN_WINDOW_MANAGER_H 18 19 #include <memory> 20 #include <mutex> 21 #include <refbase.h> 22 #include <vector> 23 #include <iremote_object.h> 24 #include "wm_single_instance.h" 25 #include "wm_common.h" 26 #include "dm_common.h" 27 #include "focus_change_info.h" 28 #include "window_visibility_info.h" 29 #include "window_drawing_content_info.h" 30 #include "window.h" 31 32 namespace OHOS { 33 namespace Rosen { 34 struct SystemBarRegionTint { 35 WindowType type_; 36 SystemBarProperty prop_; 37 Rect region_; SystemBarRegionTintSystemBarRegionTint38 SystemBarRegionTint() 39 : type_(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW), prop_(), region_{ 0, 0, 0, 0 } {} SystemBarRegionTintSystemBarRegionTint40 SystemBarRegionTint(WindowType type, SystemBarProperty prop, Rect region) 41 : type_(type), prop_(prop), region_(region) {} 42 }; 43 using SystemBarRegionTints = std::vector<SystemBarRegionTint>; 44 45 struct VisibleWindowNumInfo { 46 uint32_t displayId; 47 uint32_t visibleWindowNum; 48 }; 49 50 struct WindowSnapshotDataPack { 51 std::shared_ptr<Media::PixelMap> pixelMap = nullptr; 52 WMError result = WMError::WM_OK; 53 }; 54 55 /** 56 * @class IWMSConnectionChangedListener 57 * 58 * @brief Listener to observe WMS connection status. 59 */ 60 class IWMSConnectionChangedListener : virtual public RefBase { 61 public: 62 /** 63 * @brief Notify caller when WMS connected 64 * 65 * @param userId ID of the user who has connected to the WMS. 66 * 67 * @param screenId ID of the screen that is connected to the WMS, screenId is currently always 0. 68 */ 69 virtual void OnConnected(int32_t userId, int32_t screenId) = 0; 70 /** 71 * @brief Notify caller when WMS disconnected 72 * 73 * @param userId ID of the user who has disconnected to the WMS. 74 * 75 * @param screenId ID of the screen that is disconnected to the WMS, screenId is currently always 0. 76 */ 77 virtual void OnDisconnected(int32_t userId, int32_t screenId) = 0; 78 }; 79 80 /** 81 * @class IFocusChangedListener 82 * 83 * @brief Listener to observe focus changed. 84 */ 85 class IFocusChangedListener : virtual public RefBase { 86 public: 87 /** 88 * @brief Notify caller when window get focus 89 * 90 * @param focusChangeInfo Window info while its focus status changed. 91 */ 92 virtual void OnFocused(const sptr<FocusChangeInfo>& focusChangeInfo) = 0; 93 /** 94 * @brief Notify caller when window lose focus 95 * 96 * @param focusChangeInfo Window info while its focus status changed. 97 */ 98 virtual void OnUnfocused(const sptr<FocusChangeInfo>& focusChangeInfo) = 0; 99 }; 100 101 /** 102 * @class IWindowModeChangedListener 103 * 104 * @brief Listener to observe window mode change. 105 */ 106 class IWindowModeChangedListener : virtual public RefBase { 107 public: 108 /** 109 * @brief Notify caller when window mode update. 110 * 111 * @param mode Window mode. 112 */ 113 virtual void OnWindowModeUpdate(WindowModeType mode) = 0; 114 }; 115 116 117 /** 118 * @class ISystemBarChangedListener 119 * 120 * @brief Listener to observe systembar changed. 121 */ 122 class ISystemBarChangedListener : virtual public RefBase { 123 public: 124 /** 125 * @brief Notify caller when system bar property changed 126 * 127 * @param displayId ID of display. 128 * @param tints Tint of system bar region. 129 */ 130 virtual void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) = 0; 131 }; 132 133 /** 134 * @class IGestureNavigationEnabledChangedListener 135 * 136 * @brief Listener to observe GestureNavigationEnabled changed. 137 */ 138 class IGestureNavigationEnabledChangedListener : virtual public RefBase { 139 public: 140 /** 141 * @brief Notify caller when GestureNavigationEnabled changed. 142 * 143 * @param enable True means set Gesture on, false means set Gesture off. 144 */ 145 virtual void OnGestureNavigationEnabledUpdate(bool enable) = 0; 146 }; 147 148 /** 149 * @class IVisibilityChangedListener 150 * 151 * @brief Listener to observe visibility changed. 152 */ 153 class IVisibilityChangedListener : virtual public RefBase { 154 public: 155 /** 156 * @brief Notify caller when window visibility changed. 157 * 158 * @param windowVisibilityInfo Window visibility info. 159 */ 160 virtual void OnWindowVisibilityChanged(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfo) = 0; 161 }; 162 163 /** 164 * @class IDrawingContentChangedListener 165 * 166 * @brief Listener to observe drawing content changed. 167 */ 168 class IDrawingContentChangedListener : virtual public RefBase { 169 public: 170 /** 171 * @brief Notify caller when window DrawingContent changed. 172 * 173 * @param windowDrawingInfo Window DrawingContent info. 174 */ 175 virtual void OnWindowDrawingContentChanged(const std::vector<sptr<WindowDrawingContentInfo>>& 176 windowDrawingInfo) = 0; 177 }; 178 179 /** 180 * @class IWindowStyleChangedListener 181 * 182 * @brief Listener to observe windowStyle changed. 183 */ 184 class IWindowStyleChangedListener : virtual public RefBase { 185 public: 186 /** 187 * @brief Notify caller when window style changed. 188 * 189 * @param styleType 190 */ 191 virtual void OnWindowStyleUpdate(WindowStyleType styleType) = 0; 192 }; 193 194 /** 195 * @class AccessibilityWindowInfo 196 * 197 * @brief Window info used for Accessibility. 198 */ 199 class AccessibilityWindowInfo : public Parcelable { 200 public: 201 /** 202 * @brief Default construct of AccessibilityWindowInfo. 203 */ 204 AccessibilityWindowInfo() = default; 205 /** 206 * @brief Default deconstruct of AccessibilityWindowInfo. 207 */ 208 ~AccessibilityWindowInfo() = default; 209 210 /** 211 * @brief Marshalling AccessibilityWindowInfo. 212 * 213 * @param parcel Package of AccessibilityWindowInfo. 214 * @return True means marshall success, false means marshall failed. 215 */ 216 virtual bool Marshalling(Parcel& parcel) const override; 217 /** 218 * @brief Unmarshalling AccessibilityWindowInfo. 219 * 220 * @param parcel Package of AccessibilityWindowInfo. 221 * @return AccessibilityWindowInfo object. 222 */ 223 static AccessibilityWindowInfo* Unmarshalling(Parcel& parcel); 224 225 int32_t wid_; 226 int32_t innerWid_; 227 int32_t uiNodeId_; 228 Rect windowRect_; 229 bool focused_ { false }; 230 bool isDecorEnable_ { false }; 231 DisplayId displayId_; 232 uint32_t layer_; 233 WindowMode mode_; 234 WindowType type_; 235 float scaleVal_; 236 float scaleX_; 237 float scaleY_; 238 std::string bundleName_; 239 std::vector<Rect> touchHotAreas_; 240 }; 241 242 /** 243 * @class AppUseControlInfo 244 * 245 * @brief Window info used for AppUseControlInfo. 246 */ 247 struct AppUseControlInfo : public Parcelable { 248 /** 249 * @brief Marshalling AppUseControlInfo. 250 * 251 * @param parcel Package of AppUseControlInfo. 252 * @return True means marshall success, false means marshall failed. 253 */ MarshallingAppUseControlInfo254 virtual bool Marshalling(Parcel& parcel) const override 255 { 256 return parcel.WriteString(bundleName_) && 257 parcel.WriteInt32(appIndex_) && 258 parcel.WriteBool(isNeedControl_); 259 } 260 261 /** 262 * @brief Unmarshalling AppUseControlInfo. 263 * 264 * @param parcel Package of AppUseControlInfo. 265 * @return AppUseControlInfo object. 266 */ UnmarshallingAppUseControlInfo267 static AppUseControlInfo* Unmarshalling(Parcel& parcel) 268 { 269 auto info = new AppUseControlInfo(); 270 if (!parcel.ReadString(info->bundleName_) || 271 !parcel.ReadInt32(info->appIndex_) || 272 !parcel.ReadBool(info->isNeedControl_)) { 273 delete info; 274 return nullptr; 275 } 276 return info; 277 } 278 279 std::string bundleName_ = ""; 280 int32_t appIndex_ = 0; 281 bool isNeedControl_ = false; 282 }; 283 284 /** 285 * @struct AbilityInfoBase 286 * 287 * @brief ability info. 288 */ 289 struct AbilityInfoBase : public Parcelable { 290 /** 291 * @brief Marshalling AbilityInfoBase. 292 * 293 * @param parcel Package of AbilityInfoBase. 294 * @return True means marshall success, false means marshall failed. 295 */ MarshallingAbilityInfoBase296 bool Marshalling(Parcel& parcel) const override 297 { 298 return parcel.WriteString(bundleName) && 299 parcel.WriteString(moduleName) && 300 parcel.WriteString(abilityName) && 301 parcel.WriteInt32(appIndex); 302 } 303 304 /** 305 * @brief Unmarshalling AbilityInfoBase. 306 * 307 * @param parcel Package of AbilityInfoBase. 308 * @return AbilityInfoBase object. 309 */ UnmarshallingAbilityInfoBase310 static AbilityInfoBase* Unmarshalling(Parcel& parcel) 311 { 312 auto info = new AbilityInfoBase(); 313 if (!parcel.ReadString(info->bundleName) || 314 !parcel.ReadString(info->moduleName) || 315 !parcel.ReadString(info->abilityName) || 316 !parcel.ReadInt32(info->appIndex)) { 317 delete info; 318 return nullptr; 319 } 320 return info; 321 } 322 IsValidAbilityInfoBase323 bool IsValid() const 324 { 325 return !bundleName.empty() && !moduleName.empty() && !abilityName.empty() && appIndex >= 0; 326 } 327 ToKeyStringAbilityInfoBase328 std::string ToKeyString() const 329 { 330 return bundleName + "_" + moduleName + "_" + abilityName + "_" + std::to_string(appIndex); 331 } 332 333 std::string bundleName; 334 std::string moduleName; 335 std::string abilityName; 336 int32_t appIndex = 0; 337 }; 338 339 /** 340 * @class UnreliableWindowInfo 341 * 342 * @brief Unreliable Window Info. 343 */ 344 class UnreliableWindowInfo : public Parcelable { 345 public: 346 /** 347 * @brief Default construct of UnreliableWindowInfo. 348 */ 349 UnreliableWindowInfo() = default; 350 /** 351 * @brief Default deconstruct of UnreliableWindowInfo. 352 */ 353 ~UnreliableWindowInfo() = default; 354 355 /** 356 * @brief Marshalling UnreliableWindowInfo. 357 * 358 * @param parcel Package of UnreliableWindowInfo. 359 * @return True means marshall success, false means marshall failed. 360 */ 361 virtual bool Marshalling(Parcel& parcel) const override; 362 /** 363 * @brief Unmarshalling UnreliableWindowInfo. 364 * 365 * @param parcel Package of UnreliableWindowInfo. 366 * @return UnreliableWindowInfo object. 367 */ 368 static UnreliableWindowInfo* Unmarshalling(Parcel& parcel); 369 370 int32_t windowId_ { 0 }; 371 Rect windowRect_; 372 uint32_t zOrder_ { 0 }; 373 float floatingScale_ { 1.0f }; 374 float scaleX_ { 1.0f }; 375 float scaleY_ { 1.0f }; 376 }; 377 378 /** 379 * @class IWindowUpdateListener 380 * 381 * @brief Listener to observe window update. 382 */ 383 class IWindowUpdateListener : virtual public RefBase { 384 public: 385 /** 386 * @brief Notify caller when AccessibilityWindowInfo update. 387 * 388 * @param infos Window info used for Accessibility. 389 * @param type Type for window update. 390 */ 391 virtual void OnWindowUpdate(const std::vector<sptr<AccessibilityWindowInfo>>& infos, WindowUpdateType type) = 0; 392 }; 393 394 /** 395 * @class IWaterMarkFlagChangedListener 396 * 397 * @brief Listener to observe water mark flag changed. 398 */ 399 class IWaterMarkFlagChangedListener : virtual public RefBase { 400 public: 401 /** 402 * @brief Notify caller when water mark flag changed. 403 * 404 * @param showWaterMark True means show water mark, false means the opposite. 405 */ 406 virtual void OnWaterMarkFlagUpdate(bool showWaterMark) = 0; 407 }; 408 409 /** 410 * @class IVisibleWindowNumChangedListener 411 * 412 * @brief Listener to observe visible main window num changed. 413 */ 414 class IVisibleWindowNumChangedListener : virtual public RefBase { 415 public: 416 /** 417 * @brief Notify caller when visible window num changed 418 * 419 * @param visibleWindowNum visible window num . 420 */ 421 virtual void OnVisibleWindowNumChange(const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo) = 0; 422 }; 423 424 /** 425 * @class ICameraFloatWindowChangedListener 426 * 427 * @brief Listener to observe camera window changed. 428 */ 429 class ICameraFloatWindowChangedListener : virtual public RefBase { 430 public: 431 /** 432 * @brief Notify caller when camera window changed. 433 * 434 * @param accessTokenId Token id of camera window. 435 * @param isShowing True means camera is shown, false means the opposite. 436 */ 437 virtual void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) = 0; 438 }; 439 440 /** 441 * @class ICameraWindowChangedListener 442 * 443 * @brief Listener to observe camera window changed. 444 */ 445 class ICameraWindowChangedListener : virtual public RefBase { 446 public: 447 /** 448 * @brief Notify caller when camera window changed. 449 * 450 * @param accessTokenId Token id of camera window. 451 * @param isShowing True means camera is shown, false means the opposite. 452 */ 453 virtual void OnCameraWindowChange(uint32_t accessTokenId, bool isShowing) = 0; 454 }; 455 456 /** 457 * @class IDisplayInfoChangedListener 458 * 459 * @brief Listener to observe display information changed. 460 */ 461 class IDisplayInfoChangedListener : virtual public RefBase { 462 public: 463 /** 464 * @brief Notify caller when display information changed. 465 * 466 * @param token token of ability. 467 * @param displayId ID of the display where the main window of the ability is located. 468 * @param density density of the display where the main window of the ability is located. 469 * @param orientation orientation of the display where the main window of the ability is located. 470 */ 471 virtual void OnDisplayInfoChange(const sptr<IRemoteObject>& token, 472 DisplayId displayId, float density, DisplayOrientation orientation) = 0; 473 }; 474 475 /** 476 * @class IPiPStateChangedListener 477 * 478 * @brief Listener to observe PiP State changed. 479 */ 480 class IPiPStateChangedListener : virtual public RefBase { 481 public: 482 /** 483 * @brief Notify caller when PiP State changed. 484 * 485 * @param bundleName the name of the bundle in PiP state changed. 486 * @param isForeground the state of the bundle in PiP State. 487 */ 488 virtual void OnPiPStateChanged(const std::string& bundleName, bool isForeground) = 0; 489 }; 490 491 /** 492 * @class WindowManager 493 * 494 * @brief WindowManager used to manage window. 495 */ 496 class WindowManager { 497 WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManager); 498 friend class WindowManagerAgent; 499 friend class WMSDeathRecipient; 500 friend class SSMDeathRecipient; 501 public: 502 /** 503 * @brief Register WMS connection status changed listener. 504 * @attention Callable only by u0 system user. A process only supports successful registration once. 505 * When the foundation service restarts, you need to re-register the listener. 506 * If you want to re-register, please call UnregisterWMSConnectionChangedListener first. 507 * 508 * @param listener IWMSConnectionChangedListener. 509 * @return WM_OK means register success, others means register failed. 510 */ 511 WMError RegisterWMSConnectionChangedListener(const sptr<IWMSConnectionChangedListener>& listener); 512 /** 513 * @brief Unregister WMS connection status changed listener. 514 * @attention Callable only by u0 system user. 515 * 516 * @return WM_OK means unregister success, others means unregister failed. 517 */ 518 WMError UnregisterWMSConnectionChangedListener(); 519 /** 520 * @brief Register focus changed listener. 521 * 522 * @param listener IFocusChangedListener. 523 * @return WM_OK means register success, others means register failed. 524 */ 525 WMError RegisterFocusChangedListener(const sptr<IFocusChangedListener>& listener); 526 /** 527 * @brief Unregister focus changed listener. 528 * 529 * @param listener IFocusChangedListener. 530 * @return WM_OK means unregister success, others means unregister failed. 531 */ 532 WMError UnregisterFocusChangedListener(const sptr<IFocusChangedListener>& listener); 533 /** 534 * @brief Register window mode listener. 535 * 536 * @param listener IWindowModeChangedListener. 537 * @return WM_OK means register success, others means register failed. 538 */ 539 WMError RegisterWindowModeChangedListener(const sptr<IWindowModeChangedListener>& listener); 540 /** 541 * @brief Unregister window mode listener. 542 * 543 * @param listener IWindowModeChangedListener. 544 * @return WM_OK means unregister success, others means unregister failed. 545 */ 546 WMError UnregisterWindowModeChangedListener(const sptr<IWindowModeChangedListener>& listener); 547 /** 548 * @brief Get window mode type. 549 * 550 * @param void 551 * @return WM_OK means get success, others means get failed. 552 */ 553 WMError GetWindowModeType(WindowModeType& windowModeType) const; 554 /** 555 * @brief Register system bar changed listener. 556 * 557 * @param listener ISystemBarChangedListener. 558 * @return WM_OK means register success, others means register failed. 559 */ 560 WMError RegisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener); 561 /** 562 * @brief Unregister system bar changed listener. 563 * 564 * @param listener ISystemBarChangedListener. 565 * @return WM_OK means unregister success, others means unregister failed. 566 */ 567 WMError UnregisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener); 568 /** 569 * @brief Register window updated listener. 570 * 571 * @param listener IWindowUpdateListener. 572 * @return WM_OK means register success, others means register failed. 573 */ 574 WMError RegisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener); 575 /** 576 * @brief Unregister window updated listener. 577 * 578 * @param listener IWindowUpdateListener. 579 * @return WM_OK means unregister success, others means unregister failed. 580 */ 581 WMError UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener); 582 /** 583 * @brief Register visibility changed listener. 584 * 585 * @param listener IVisibilityChangedListener. 586 * @return WM_OK means register success, others means register failed. 587 */ 588 WMError RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener); 589 /** 590 * @brief Unregister visibility changed listener. 591 * 592 * @param listener IVisibilityChangedListener. 593 * @return WM_OK means unregister success, others means unregister failed. 594 */ 595 WMError UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener); 596 /** 597 * @brief Register drawingcontent changed listener. 598 * 599 * @param listener IDrawingContentChangedListener. 600 * @return WM_OK means register success, others means register failed. 601 */ 602 WMError RegisterDrawingContentChangedListener(const sptr<IDrawingContentChangedListener>& listener); 603 604 /** 605 * @brief Unregister drawingcontent changed listener. 606 * 607 * @param listener IDrawingContentChangedListener. 608 * @return WM_OK means unregister success, others means unregister failed. 609 */ 610 WMError UnregisterDrawingContentChangedListener(const sptr<IDrawingContentChangedListener>& listener); 611 612 /** 613 * @brief Register camera float window changed listener. 614 * 615 * @param listener ICameraFloatWindowChangedListener. 616 * @return WM_OK means register success, others means register failed. 617 */ 618 WMError RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener); 619 /** 620 * @brief Unregister camera float window changed listener. 621 * 622 * @param listener ICameraFloatWindowChangedListener. 623 * @return WM_OK means unregister success, others means unregister failed. 624 */ 625 WMError UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener); 626 /** 627 * @brief Register water mark flag changed listener. 628 * 629 * @param listener IWaterMarkFlagChangedListener. 630 * @return WM_OK means register success, others means register failed. 631 */ 632 WMError RegisterWaterMarkFlagChangedListener(const sptr<IWaterMarkFlagChangedListener>& listener); 633 /** 634 * @brief Unregister water mark flag changed listener. 635 * 636 * @param listener IWaterMarkFlagChangedListener. 637 * @return WM_OK means unregister success, others means unregister failed. 638 */ 639 WMError UnregisterWaterMarkFlagChangedListener(const sptr<IWaterMarkFlagChangedListener>& listener); 640 /** 641 * @brief Register gesture navigation enabled changed listener. 642 * 643 * @param listener IGestureNavigationEnabledChangedListener. 644 * @return WM_OK means register success, others means register failed. 645 */ 646 WMError RegisterGestureNavigationEnabledChangedListener( 647 const sptr<IGestureNavigationEnabledChangedListener>& listener); 648 /** 649 * @brief Unregister gesture navigation enabled changed listener. 650 * 651 * @param listener IGestureNavigationEnabledChangedListener. 652 * @return WM_OK means unregister success, others means unregister failed. 653 */ 654 WMError UnregisterGestureNavigationEnabledChangedListener( 655 const sptr<IGestureNavigationEnabledChangedListener>& listener); 656 657 /** 658 * @brief register display information changed listener. 659 * 660 * @param token token of ability. 661 * @param listener IDisplayInfoChangedListener. 662 * @return WM_OK means register success, others means register failed. 663 */ 664 WMError RegisterDisplayInfoChangedListener(const sptr<IRemoteObject>& token, 665 const sptr<IDisplayInfoChangedListener>& listener); 666 667 /** 668 * @brief unregister display info changed listener.Before the ability is destroyed, the 669 * UnregisterDisplayInfoChangedListener interface must be invoked. 670 * Otherwise, the sptr token may be destroyed abnormally. 671 * 672 * @param token token of ability. 673 * @param listener IDisplayInfoChangedListener. 674 * @return WM_OK means unregister success, others means unregister failed. 675 */ 676 WMError UnregisterDisplayInfoChangedListener(const sptr<IRemoteObject>& token, 677 const sptr<IDisplayInfoChangedListener>& listener); 678 679 /** 680 * @brief notify display information change. 681 * 682 * @param token ability token. 683 * @param displayid ID of the display where the main window of the ability is located 684 * @param density density of the display where the main window of the ability is located. 685 * @param orientation orientation of the display where the main window of the ability is located. 686 * @return WM_OK means notify success, others means notify failed. 687 */ 688 WMError NotifyDisplayInfoChange(const sptr<IRemoteObject>& token, DisplayId displayId, 689 float density, DisplayOrientation orientation); 690 691 /** 692 * @brief Minimize all app window. 693 * 694 * @param displayId Display id. 695 * @return WM_OK means minimize success, others means minimize failed. 696 */ 697 WMError MinimizeAllAppWindows(DisplayId displayId); 698 /** 699 * @brief Toggle all app windows to the foreground. 700 * 701 * @return WM_OK means toggle success, others means toggle failed. 702 */ 703 WMError ToggleShownStateForAllAppWindows(); 704 /** 705 * @brief Set window layout mode. 706 * 707 * @param mode Window layout mode. 708 * @return WM_OK means set success, others means set failed. 709 */ 710 WMError SetWindowLayoutMode(WindowLayoutMode mode); 711 /** 712 * @brief Get accessibility window info. 713 * 714 * @param infos WindowInfos used for Accessibility. 715 * @return WM_OK means get success, others means get failed. 716 */ 717 WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) const; 718 /** 719 * @brief Get unreliable window info. 720 * 721 * @param infos Unreliable Window Info. 722 * @return WM_OK means get success, others means get failed. 723 */ 724 WMError GetUnreliableWindowInfo(int32_t windowId, 725 std::vector<sptr<UnreliableWindowInfo>>& infos) const; 726 727 /** 728 * @brief Get window layout info. 729 * 730 * @param infos window layout infos 731 * @return WM_OK means get success, others means get failed. 732 */ 733 WMError GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos) const; 734 735 /** 736 * @brief Get visibility window info. 737 * 738 * @param infos Visible window infos 739 * @return WM_OK means get success, others means get failed. 740 */ 741 WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) const; 742 /** 743 * @brief Set gesture navigaion enabled. 744 * 745 * @param enable True means set gesture on, false means set gesture off. 746 * @return WM_OK means set success, others means set failed. 747 */ 748 WMError SetGestureNavigaionEnabled(bool enable) const; 749 750 /** 751 * @brief Get focus window. 752 * 753 * @param focusInfo Focus window info. 754 * @return FocusChangeInfo object about focus window. 755 */ 756 void GetFocusWindowInfo(FocusChangeInfo& focusInfo); 757 758 /** 759 * @brief Dump all session info 760 * 761 * @param infos session infos 762 * @return WM_OK means set success, others means set failed. 763 */ 764 WMError DumpSessionAll(std::vector<std::string> &infos); 765 766 /** 767 * @brief Dump session info with id 768 * 769 * @param infos session infos 770 * @return WM_OK means set success, others means set failed. 771 */ 772 WMError DumpSessionWithId(int32_t persistentId, std::vector<std::string> &infos); 773 774 /** 775 * @brief Get uiContent remote object 776 * 777 * @param windowId windowId 778 * @param uiContentRemoteObj uiContentRemoteObj 779 * @return WM_OK if successfully retrieved uiContentRemoteObj 780 */ 781 WMError GetUIContentRemoteObj(int32_t windowId, sptr<IRemoteObject>& uiContentRemoteObj); 782 783 /** 784 * @brief raise window to top by windowId 785 * 786 * @param persistentId this window to raise 787 * @return WM_OK if raise success 788 */ 789 WMError RaiseWindowToTop(int32_t persistentId); 790 791 /** 792 * @brief notify window extension visibility change 793 * 794 * @param pid process id 795 * @param uid user id 796 * @param visible visibility 797 * @return WM_OK means notify success, others means notify failed. 798 */ 799 WMError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible); 800 801 /** 802 * @brief Shift window focus within the same application. Only main window and subwindow. 803 * 804 * @param sourcePersistentId Window id which the focus shift from 805 * @param targetPersistentId Window id which the focus shift to 806 * @return WM_OK means shift window focus success, others means failed. 807 */ 808 WMError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId); 809 810 /** 811 * @brief Get snapshot by window id. 812 * 813 * @param windowId Window id which want to snapshot. 814 * @param pixelMap Snapshot output pixel map. 815 * @return WM_OK means get snapshot success, others means failed. 816 */ 817 WMError GetSnapshotByWindowId(int32_t windowId, std::shared_ptr<Media::PixelMap>& pixelMap); 818 819 /** 820 * @brief Register visible main window num changed listener. 821 * 822 * @param listener IVisibleWindowNumChangedListener. 823 * @return WM_OK means register success, others means register failed. 824 */ 825 WMError RegisterVisibleWindowNumChangedListener(const sptr<IVisibleWindowNumChangedListener>& listener); 826 /** 827 * @brief Unregister visible main window num changed listener. 828 * 829 * @param listener IVisibleWindowNumChangedListener. 830 * @return WM_OK means unregister success, others means unregister failed. 831 */ 832 WMError UnregisterVisibleWindowNumChangedListener(const sptr<IVisibleWindowNumChangedListener>& listener); 833 834 /** 835 * @brief Register WindowStyle changed listener. 836 * 837 * @param listener IWindowStyleChangedListener 838 * @return WM_OK means register success, others means unregister failed. 839 */ 840 WMError RegisterWindowStyleChangedListener(const sptr<IWindowStyleChangedListener>& listener); 841 842 /** 843 * @brief Unregister WindowStyle changed listener. 844 * 845 * @param listener IWindowStyleChangedListener 846 * @return WM_OK means unregister success, others means unregister failed. 847 */ 848 WMError UnregisterWindowStyleChangedListener(const sptr<IWindowStyleChangedListener>& listener); 849 850 /** 851 * @brief Get window style type. 852 * 853 * @param windowStyleType WindowType 854 * @return @return WM_OK means get window style success, others means failed. 855 */ 856 WindowStyleType GetWindowStyleType(); 857 858 /** 859 * @brief Get window ids by coordinate. 860 * 861 * @param displayId display id 862 * @param windowNumber indicates the number of query windows 863 * @param x x-coordinate of the window 864 * @param y y-coordinate of the window 865 * @param windowIds array of window id 866 * @return WM_OK means get success, others means get failed. 867 */ 868 WMError GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber, 869 int32_t x, int32_t y, std::vector<int32_t>& windowIds) const; 870 871 /** 872 * @brief Release screen lock of foreground sessions. 873 * 874 * @return WM_OK means release success, others means failed. 875 */ 876 WMError ReleaseForegroundSessionScreenLock(); 877 878 /** 879 * @brief Get displayId by windowId. 880 * 881 * @param windowIds list of window ids that need to get screen ids 882 * @param windowDisplayIdMap map of windows and displayIds 883 * @return WM_OK means get success, others means failed. 884 */ 885 WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds, 886 std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap); 887 888 /** 889 * @brief Set global drag resize type. 890 * this priority is highest. 891 * 892 * @param dragResizeType global drag resize type to set 893 * @return WM_OK means get success, others means failed. 894 */ 895 WMError SetGlobalDragResizeType(DragResizeType dragResizeType); 896 897 /** 898 * @brief Get global drag resize type. 899 * if it is RESIZE_TYPE_UNDEFINED, return default value. 900 * 901 * @param dragResizeType global drag resize type to get 902 * @return WM_OK means get success, others means failed. 903 */ 904 WMError GetGlobalDragResizeType(DragResizeType& dragResizeType); 905 906 /** 907 * @brief Set drag resize type of specific app. 908 * only when global value is RESIZE_TYPE_UNDEFINED, this value take effect. 909 * 910 * @param bundleName bundleName of specific app 911 * @param dragResizeType drag resize type to set 912 * @return WM_OK means get success, others means failed. 913 */ 914 WMError SetAppDragResizeType(const std::string& bundleName, DragResizeType dragResizeType); 915 916 /** 917 * @brief Get drag resize type of specific app. 918 * effective order: 919 * 1. global value 920 * 2. app value 921 * 3. default value 922 * 923 * @param bundleName bundleName of specific app 924 * @param dragResizeType drag resize type to get 925 * @return WM_OK means get success, others means failed. 926 */ 927 WMError GetAppDragResizeType(const std::string& bundleName, DragResizeType& dragResizeType); 928 929 /** 930 * @brief Shift window pointer event within the same application. Only main window and subwindow. 931 * 932 * @param sourceWindowId Window id which the pointer event shift from 933 * @param targetWindowId Window id which the pointer event shift to 934 * @return WM_OK means shift window pointer event success, others means failed. 935 */ 936 WMError ShiftAppWindowPointerEvent(int32_t sourceWindowId, int32_t targetWindowId); 937 938 private: 939 WindowManager(); 940 ~WindowManager(); 941 std::recursive_mutex mutex_; 942 class Impl; 943 std::unique_ptr<Impl> pImpl_; 944 bool destroyed_ = false; 945 946 void OnWMSConnectionChanged(int32_t userId, int32_t screenId, bool isConnected) const; 947 void UpdateFocusStatus(uint32_t windowId, const sptr<IRemoteObject>& abilityToken, WindowType windowType, 948 DisplayId displayId, bool focused) const; 949 void UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused) const; 950 void UpdateWindowModeTypeInfo(WindowModeType type) const; 951 void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) const; 952 void NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>>& infos, 953 WindowUpdateType type) const; 954 void UpdateWindowVisibilityInfo( 955 const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos) const; 956 void UpdateWindowDrawingContentInfo( 957 const std::vector<sptr<WindowDrawingContentInfo>>& windowDrawingContentInfos) const; 958 void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const; 959 void NotifyWaterMarkFlagChangedResult(bool showWaterMark) const; 960 void NotifyGestureNavigationEnabledResult(bool enable) const; 961 void UpdateVisibleWindowNum(const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo); 962 WMError NotifyWindowStyleChange(WindowStyleType type); 963 }; 964 } // namespace Rosen 965 } // namespace OHOS 966 967 #endif // OHOS_ROSEN_WINDOW_MANAGER_H 968