1 /* 2 * Copyright (c) 2022-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_WINDOW_INNER_MANAGER_H 17 #define OHOS_ROSEN_WINDOW_INNER_MANAGER_H 18 19 #include <refbase.h> 20 #include "event_handler.h" 21 #include "event_runner.h" 22 23 #include "drag_controller.h" 24 #include "inner_window.h" 25 #include "pixel_map.h" 26 #include "wm_common.h" 27 #include "window_node.h" 28 #include "wm_single_instance.h" 29 30 enum class InnerWMRunningState { 31 STATE_NOT_START, 32 STATE_RUNNING, 33 }; 34 namespace OHOS { 35 namespace Rosen { 36 class RSUIContext; 37 class RSUIDirector; 38 39 using InnerTask = std::function<void()>; 40 using EventRunner = OHOS::AppExecFwk::EventRunner; 41 using EventHandler = OHOS::AppExecFwk::EventHandler; 42 using EventPriority = OHOS::AppExecFwk::EventQueue::Priority; 43 class WindowInnerManager : public RefBase { 44 WM_DECLARE_SINGLE_INSTANCE_BASE(WindowInnerManager); 45 public: 46 void Start(bool enableRecentholder); 47 void Stop(); 48 void CreateInnerWindow(std::string name, DisplayId displayId, Rect rect, WindowType type, WindowMode mode); 49 void DestroyInnerWindow(DisplayId displayId, WindowType type); 50 void UpdateInnerWindow(DisplayId displayId, WindowType type, uint32_t width, uint32_t height); 51 void PostTask(InnerTask &&callback, std::string name = "WindowInnerManagerTask", 52 EventPriority priority = EventPriority::LOW); 53 54 // asynchronously calls the functions of AbilityManager 55 void MinimizeAbility(const wptr<WindowNode>& node, bool isFromUser); 56 void TerminateAbility(const wptr<WindowNode>& node); 57 void CloseAbility(const wptr<WindowNode>& node); 58 void CompleteFirstFrameDrawing(const wptr<WindowNode>& node); 59 void UpdateMissionSnapShot(const wptr<WindowNode>& node, std::shared_ptr<Media::PixelMap> pixelMap); 60 61 void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent); 62 void NotifyDisplayLimitRectChange(const std::map<DisplayId, Rect>& limitRectMap); 63 bool NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty, 64 sptr<MoveDragProperty>& moveDragProperty); 65 void NotifyWindowEndUpMovingOrDragging(uint32_t windowId); 66 void NotifyWindowRemovedOrDestroyed(uint32_t windowId); 67 pid_t GetPid(); 68 void SetInputEventConsumer(); 69 void StartWindowInfoReportLoop(); 70 void SetWindowRoot(const sptr<WindowRoot>& windowRoot); 71 72 /* 73 * RS Client Multi Instance 74 */ 75 void SetRSUIDirector(std::shared_ptr<RSUIDirector>& rsUIDirector); 76 std::shared_ptr<RSUIDirector> GetRSUIDirector() const; 77 std::shared_ptr<RSUIContext> GetRSUIContext() const; 78 79 protected: 80 WindowInnerManager(); 81 ~WindowInnerManager(); 82 83 private: 84 bool Init(); 85 86 pid_t pid_ = INVALID_PID; 87 bool isRecentHolderEnable_ = false; 88 sptr<MoveDragController> moveDragController_; 89 // event handle for inner window 90 std::shared_ptr<EventHandler> eventHandler_; 91 std::shared_ptr<EventRunner> eventLoop_; 92 InnerWMRunningState state_; 93 const std::string INNER_WM_THREAD_NAME = "InnerWindowManager"; 94 bool isReportTaskStart_ = false; 95 96 /* 97 * RS Client Multi Instance 98 */ 99 std::shared_ptr<RSUIDirector> rsUIDirector_; 100 }; 101 } // namespace Rosen 102 } // namespace OHOS 103 #endif // OHOS_ROSEN_WINDOW_INNER_MANAGER_H