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 UnreliableWindowInfo 244 * 245 * @brief Unreliable Window Info. 246 */ 247 class UnreliableWindowInfo : public Parcelable { 248 public: 249 /** 250 * @brief Default construct of UnreliableWindowInfo. 251 */ 252 UnreliableWindowInfo() = default; 253 /** 254 * @brief Default deconstruct of UnreliableWindowInfo. 255 */ 256 ~UnreliableWindowInfo() = default; 257 258 /** 259 * @brief Marshalling UnreliableWindowInfo. 260 * 261 * @param parcel Package of UnreliableWindowInfo. 262 * @return True means marshall success, false means marshall failed. 263 */ 264 virtual bool Marshalling(Parcel& parcel) const override; 265 /** 266 * @brief Unmarshalling UnreliableWindowInfo. 267 * 268 * @param parcel Package of UnreliableWindowInfo. 269 * @return UnreliableWindowInfo object. 270 */ 271 static UnreliableWindowInfo* Unmarshalling(Parcel& parcel); 272 273 int32_t windowId_ { 0 }; 274 Rect windowRect_; 275 uint32_t zOrder_ { 0 }; 276 float floatingScale_ { 1.0f }; 277 float scaleX_ { 1.0f }; 278 float scaleY_ { 1.0f }; 279 }; 280 281 /** 282 * @class IWindowUpdateListener 283 * 284 * @brief Listener to observe window update. 285 */ 286 class IWindowUpdateListener : virtual public RefBase { 287 public: 288 /** 289 * @brief Notify caller when AccessibilityWindowInfo update. 290 * 291 * @param infos Window info used for Accessibility. 292 * @param type Type for window update. 293 */ 294 virtual void OnWindowUpdate(const std::vector<sptr<AccessibilityWindowInfo>>& infos, WindowUpdateType type) = 0; 295 }; 296 297 /** 298 * @class IWaterMarkFlagChangedListener 299 * 300 * @brief Listener to observe water mark flag changed. 301 */ 302 class IWaterMarkFlagChangedListener : virtual public RefBase { 303 public: 304 /** 305 * @brief Notify caller when water mark flag changed. 306 * 307 * @param showWaterMark True means show water mark, false means the opposite. 308 */ 309 virtual void OnWaterMarkFlagUpdate(bool showWaterMark) = 0; 310 }; 311 312 /** 313 * @class IVisibleWindowNumChangedListener 314 * 315 * @brief Listener to observe visible main window num changed. 316 */ 317 class IVisibleWindowNumChangedListener : virtual public RefBase { 318 public: 319 /** 320 * @brief Notify caller when visible window num changed 321 * 322 * @param visibleWindowNum visible window num . 323 */ 324 virtual void OnVisibleWindowNumChange(const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo) = 0; 325 }; 326 327 /** 328 * @class ICameraFloatWindowChangedListener 329 * 330 * @brief Listener to observe camera window changed. 331 */ 332 class ICameraFloatWindowChangedListener : virtual public RefBase { 333 public: 334 /** 335 * @brief Notify caller when camera window changed. 336 * 337 * @param accessTokenId Token id of camera window. 338 * @param isShowing True means camera is shown, false means the opposite. 339 */ 340 virtual void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) = 0; 341 }; 342 343 /** 344 * @class ICameraWindowChangedListener 345 * 346 * @brief Listener to observe camera window changed. 347 */ 348 class ICameraWindowChangedListener : virtual public RefBase { 349 public: 350 /** 351 * @brief Notify caller when camera window changed. 352 * 353 * @param accessTokenId Token id of camera window. 354 * @param isShowing True means camera is shown, false means the opposite. 355 */ 356 virtual void OnCameraWindowChange(uint32_t accessTokenId, bool isShowing) = 0; 357 }; 358 359 /** 360 * @class IDisplayInfoChangedListener 361 * 362 * @brief Listener to observe display information changed. 363 */ 364 class IDisplayInfoChangedListener : virtual public RefBase { 365 public: 366 /** 367 * @brief Notify caller when display information changed. 368 * 369 * @param token token of ability. 370 * @param displayId ID of the display where the main window of the ability is located. 371 * @param density density of the display where the main window of the ability is located. 372 * @param orientation orientation of the display where the main window of the ability is located. 373 */ 374 virtual void OnDisplayInfoChange(const sptr<IRemoteObject>& token, 375 DisplayId displayId, float density, DisplayOrientation orientation) = 0; 376 }; 377 378 /** 379 * @class IPiPStateChangedListener 380 * 381 * @brief Listener to observe PiP State changed. 382 */ 383 class IPiPStateChangedListener : virtual public RefBase { 384 public: 385 /** 386 * @brief Notify caller when PiP State changed. 387 * 388 * @param bundleName the name of the bundle in PiP state changed. 389 * @param isForeground the state of the bundle in PiP State. 390 */ 391 virtual void OnPiPStateChanged(const std::string& bundleName, bool isForeground) = 0; 392 }; 393 394 /** 395 * @class WindowManager 396 * 397 * @brief WindowManager used to manage window. 398 */ 399 class WindowManager { 400 WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManager); 401 friend class WindowManagerAgent; 402 friend class WMSDeathRecipient; 403 friend class SSMDeathRecipient; 404 public: 405 /** 406 * @brief Register WMS connection status changed listener. 407 * @attention Callable only by u0 system user. A process only supports successful registration once. 408 * When the foundation service restarts, you need to re-register the listener. 409 * If you want to re-register, please call UnregisterWMSConnectionChangedListener first. 410 * 411 * @param listener IWMSConnectionChangedListener. 412 * @return WM_OK means register success, others means register failed. 413 */ 414 WMError RegisterWMSConnectionChangedListener(const sptr<IWMSConnectionChangedListener>& listener); 415 /** 416 * @brief Unregister WMS connection status changed listener. 417 * @attention Callable only by u0 system user. 418 * 419 * @return WM_OK means unregister success, others means unregister failed. 420 */ 421 WMError UnregisterWMSConnectionChangedListener(); 422 /** 423 * @brief Register focus changed listener. 424 * 425 * @param listener IFocusChangedListener. 426 * @return WM_OK means register success, others means register failed. 427 */ 428 WMError RegisterFocusChangedListener(const sptr<IFocusChangedListener>& listener); 429 /** 430 * @brief Unregister focus changed listener. 431 * 432 * @param listener IFocusChangedListener. 433 * @return WM_OK means unregister success, others means unregister failed. 434 */ 435 WMError UnregisterFocusChangedListener(const sptr<IFocusChangedListener>& listener); 436 /** 437 * @brief Register window mode listener. 438 * 439 * @param listener IWindowModeChangedListener. 440 * @return WM_OK means register success, others means register failed. 441 */ 442 WMError RegisterWindowModeChangedListener(const sptr<IWindowModeChangedListener>& listener); 443 /** 444 * @brief Unregister window mode listener. 445 * 446 * @param listener IWindowModeChangedListener. 447 * @return WM_OK means unregister success, others means unregister failed. 448 */ 449 WMError UnregisterWindowModeChangedListener(const sptr<IWindowModeChangedListener>& listener); 450 /** 451 * @brief Get window mode type. 452 * 453 * @param void 454 * @return WM_OK means get success, others means get failed. 455 */ 456 WMError GetWindowModeType(WindowModeType& windowModeType) const; 457 /** 458 * @brief Register system bar changed listener. 459 * 460 * @param listener ISystemBarChangedListener. 461 * @return WM_OK means register success, others means register failed. 462 */ 463 WMError RegisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener); 464 /** 465 * @brief Unregister system bar changed listener. 466 * 467 * @param listener ISystemBarChangedListener. 468 * @return WM_OK means unregister success, others means unregister failed. 469 */ 470 WMError UnregisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener); 471 /** 472 * @brief Register window updated listener. 473 * 474 * @param listener IWindowUpdateListener. 475 * @return WM_OK means register success, others means register failed. 476 */ 477 WMError RegisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener); 478 /** 479 * @brief Unregister window updated listener. 480 * 481 * @param listener IWindowUpdateListener. 482 * @return WM_OK means unregister success, others means unregister failed. 483 */ 484 WMError UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener); 485 /** 486 * @brief Register visibility changed listener. 487 * 488 * @param listener IVisibilityChangedListener. 489 * @return WM_OK means register success, others means register failed. 490 */ 491 WMError RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener); 492 /** 493 * @brief Unregister visibility changed listener. 494 * 495 * @param listener IVisibilityChangedListener. 496 * @return WM_OK means unregister success, others means unregister failed. 497 */ 498 WMError UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener); 499 /** 500 * @brief Register drawingcontent changed listener. 501 * 502 * @param listener IDrawingContentChangedListener. 503 * @return WM_OK means register success, others means register failed. 504 */ 505 WMError RegisterDrawingContentChangedListener(const sptr<IDrawingContentChangedListener>& listener); 506 507 /** 508 * @brief Unregister drawingcontent changed listener. 509 * 510 * @param listener IDrawingContentChangedListener. 511 * @return WM_OK means unregister success, others means unregister failed. 512 */ 513 WMError UnregisterDrawingContentChangedListener(const sptr<IDrawingContentChangedListener>& listener); 514 515 /** 516 * @brief Register camera float window changed listener. 517 * 518 * @param listener ICameraFloatWindowChangedListener. 519 * @return WM_OK means register success, others means register failed. 520 */ 521 WMError RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener); 522 /** 523 * @brief Unregister camera float window changed listener. 524 * 525 * @param listener ICameraFloatWindowChangedListener. 526 * @return WM_OK means unregister success, others means unregister failed. 527 */ 528 WMError UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener); 529 /** 530 * @brief Register water mark flag changed listener. 531 * 532 * @param listener IWaterMarkFlagChangedListener. 533 * @return WM_OK means register success, others means register failed. 534 */ 535 WMError RegisterWaterMarkFlagChangedListener(const sptr<IWaterMarkFlagChangedListener>& listener); 536 /** 537 * @brief Unregister water mark flag changed listener. 538 * 539 * @param listener IWaterMarkFlagChangedListener. 540 * @return WM_OK means unregister success, others means unregister failed. 541 */ 542 WMError UnregisterWaterMarkFlagChangedListener(const sptr<IWaterMarkFlagChangedListener>& listener); 543 /** 544 * @brief Register gesture navigation enabled changed listener. 545 * 546 * @param listener IGestureNavigationEnabledChangedListener. 547 * @return WM_OK means register success, others means register failed. 548 */ 549 WMError RegisterGestureNavigationEnabledChangedListener( 550 const sptr<IGestureNavigationEnabledChangedListener>& listener); 551 /** 552 * @brief Unregister gesture navigation enabled changed listener. 553 * 554 * @param listener IGestureNavigationEnabledChangedListener. 555 * @return WM_OK means unregister success, others means unregister failed. 556 */ 557 WMError UnregisterGestureNavigationEnabledChangedListener( 558 const sptr<IGestureNavigationEnabledChangedListener>& listener); 559 560 /** 561 * @brief register display information changed listener. 562 * 563 * @param token token of ability. 564 * @param listener IDisplayInfoChangedListener. 565 * @return WM_OK means register success, others means register failed. 566 */ 567 WMError RegisterDisplayInfoChangedListener(const sptr<IRemoteObject>& token, 568 const sptr<IDisplayInfoChangedListener>& listener); 569 570 /** 571 * @brief unregister display info changed listener.Before the ability is destroyed, the 572 * UnregisterDisplayInfoChangedListener interface must be invoked. 573 * Otherwise, the sptr token may be destroyed abnormally. 574 * 575 * @param token token of ability. 576 * @param listener IDisplayInfoChangedListener. 577 * @return WM_OK means unregister success, others means unregister failed. 578 */ 579 WMError UnregisterDisplayInfoChangedListener(const sptr<IRemoteObject>& token, 580 const sptr<IDisplayInfoChangedListener>& listener); 581 582 /** 583 * @brief notify display information change. 584 * 585 * @param token ability token. 586 * @param displayid ID of the display where the main window of the ability is located 587 * @param density density of the display where the main window of the ability is located. 588 * @param orientation orientation of the display where the main window of the ability is located. 589 * @return WM_OK means notify success, others means notify failed. 590 */ 591 WMError NotifyDisplayInfoChange(const sptr<IRemoteObject>& token, DisplayId displayId, 592 float density, DisplayOrientation orientation); 593 594 /** 595 * @brief Minimize all app window. 596 * 597 * @param displayId Display id. 598 * @return WM_OK means minimize success, others means minimize failed. 599 */ 600 WMError MinimizeAllAppWindows(DisplayId displayId); 601 /** 602 * @brief Toggle all app windows to the foreground. 603 * 604 * @return WM_OK means toggle success, others means toggle failed. 605 */ 606 WMError ToggleShownStateForAllAppWindows(); 607 /** 608 * @brief Set window layout mode. 609 * 610 * @param mode Window layout mode. 611 * @return WM_OK means set success, others means set failed. 612 */ 613 WMError SetWindowLayoutMode(WindowLayoutMode mode); 614 /** 615 * @brief Get accessibility window info. 616 * 617 * @param infos WindowInfos used for Accessibility. 618 * @return WM_OK means get success, others means get failed. 619 */ 620 WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) const; 621 /** 622 * @brief Get unreliable window info. 623 * 624 * @param infos Unreliable Window Info. 625 * @return WM_OK means get success, others means get failed. 626 */ 627 WMError GetUnreliableWindowInfo(int32_t windowId, 628 std::vector<sptr<UnreliableWindowInfo>>& infos) const; 629 /** 630 * @brief Get visibility window info. 631 * 632 * @param infos Visible window infos 633 * @return WM_OK means get success, others means get failed. 634 */ 635 WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) const; 636 /** 637 * @brief Set gesture navigaion enabled. 638 * 639 * @param enable True means set gesture on, false means set gesture off. 640 * @return WM_OK means set success, others means set failed. 641 */ 642 WMError SetGestureNavigaionEnabled(bool enable) const; 643 644 /** 645 * @brief Get focus window. 646 * 647 * @param focusInfo Focus window info. 648 * @return FocusChangeInfo object about focus window. 649 */ 650 void GetFocusWindowInfo(FocusChangeInfo& focusInfo); 651 652 /** 653 * @brief Dump all session info 654 * 655 * @param infos session infos 656 * @return WM_OK means set success, others means set failed. 657 */ 658 WMError DumpSessionAll(std::vector<std::string> &infos); 659 660 /** 661 * @brief Dump session info with id 662 * 663 * @param infos session infos 664 * @return WM_OK means set success, others means set failed. 665 */ 666 WMError DumpSessionWithId(int32_t persistentId, std::vector<std::string> &infos); 667 668 /** 669 * @brief Get uiContent remote object 670 * 671 * @param windowId windowId 672 * @param uiContentRemoteObj uiContentRemoteObj 673 * @return WM_OK if successfully retrieved uiContentRemoteObj 674 */ 675 WMError GetUIContentRemoteObj(int32_t windowId, sptr<IRemoteObject>& uiContentRemoteObj); 676 677 /** 678 * @brief raise window to top by windowId 679 * 680 * @param persistentId this window to raise 681 * @return WM_OK if raise success 682 */ 683 WMError RaiseWindowToTop(int32_t persistentId); 684 685 /** 686 * @brief notify window extension visibility change 687 * 688 * @param pid process id 689 * @param uid user id 690 * @param visible visibility 691 * @return WM_OK means notify success, others means notify failed. 692 */ 693 WMError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible); 694 695 /** 696 * @brief Shift window focus within the same application. Only main window and subwindow. 697 * 698 * @param sourcePersistentId Window id which the focus shift from 699 * @param targetPersistentId Window id which the focus shift to 700 * @return WM_OK means shift window focus success, others means failed. 701 */ 702 WMError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId); 703 704 /** 705 * @brief Get snapshot by window id. 706 * 707 * @param windowId Window id which want to snapshot. 708 * @param pixelMap Snapshot output pixel map. 709 * @return WM_OK means get snapshot success, others means failed. 710 */ 711 WMError GetSnapshotByWindowId(int32_t windowId, std::shared_ptr<Media::PixelMap>& pixelMap); 712 713 /** 714 * @brief Register visible main window num changed listener. 715 * 716 * @param listener IVisibleWindowNumChangedListener. 717 * @return WM_OK means register success, others means register failed. 718 */ 719 WMError RegisterVisibleWindowNumChangedListener(const sptr<IVisibleWindowNumChangedListener>& listener); 720 /** 721 * @brief Unregister visible main window num changed listener. 722 * 723 * @param listener IVisibleWindowNumChangedListener. 724 * @return WM_OK means unregister success, others means unregister failed. 725 */ 726 WMError UnregisterVisibleWindowNumChangedListener(const sptr<IVisibleWindowNumChangedListener>& listener); 727 728 /** 729 * @brief Register WindowStyle changed listener. 730 * 731 * @param listener IWindowStyleChangedListener 732 * @return WM_OK means register success, others means unregister failed. 733 */ 734 WMError RegisterWindowStyleChangedListener(const sptr<IWindowStyleChangedListener>& listener); 735 736 /** 737 * @brief Unregister WindowStyle changed listener. 738 * 739 * @param listener IWindowStyleChangedListener 740 * @return WM_OK means unregister success, others means unregister failed. 741 */ 742 WMError UnregisterWindowStyleChangedListener(const sptr<IWindowStyleChangedListener>& listener); 743 744 /** 745 * @brief Get window style type. 746 * 747 * @param windowStyleType WindowType 748 * @return @return WM_OK means get window style success, others means failed. 749 */ 750 WindowStyleType GetWindowStyleType(); 751 752 /** 753 * @brief Release screen lock of foreground sessions. 754 * 755 * @return WM_OK means release success, others means failed. 756 */ 757 WMError ReleaseForegroundSessionScreenLock(); 758 759 /** 760 * @brief Get displayId by windowId. 761 * 762 * @param windowIds list of window ids that need to get screen ids 763 * @param windowDisplayIdMap map of windows and displayIds 764 * @return WM_OK means get success, others means failed. 765 */ 766 WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds, 767 std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap); 768 769 private: 770 WindowManager(); 771 ~WindowManager(); 772 std::recursive_mutex mutex_; 773 class Impl; 774 std::unique_ptr<Impl> pImpl_; 775 bool destroyed_ = false; 776 777 void OnWMSConnectionChanged(int32_t userId, int32_t screenId, bool isConnected) const; 778 void UpdateFocusStatus(uint32_t windowId, const sptr<IRemoteObject>& abilityToken, WindowType windowType, 779 DisplayId displayId, bool focused) const; 780 void UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused) const; 781 void UpdateWindowModeTypeInfo(WindowModeType type) const; 782 void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) const; 783 void NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>>& infos, 784 WindowUpdateType type) const; 785 void UpdateWindowVisibilityInfo( 786 const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos) const; 787 void UpdateWindowDrawingContentInfo( 788 const std::vector<sptr<WindowDrawingContentInfo>>& windowDrawingContentInfos) const; 789 void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const; 790 void NotifyWaterMarkFlagChangedResult(bool showWaterMark) const; 791 void NotifyGestureNavigationEnabledResult(bool enable) const; 792 void UpdateVisibleWindowNum(const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo); 793 WMError NotifyWindowStyleChange(WindowStyleType type); 794 }; 795 } // namespace Rosen 796 } // namespace OHOS 797 798 #endif // OHOS_ROSEN_WINDOW_MANAGER_H 799