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 using InnerTask = std::function<void()>; 37 using EventRunner = OHOS::AppExecFwk::EventRunner; 38 using EventHandler = OHOS::AppExecFwk::EventHandler; 39 using EventPriority = OHOS::AppExecFwk::EventQueue::Priority; 40 class WindowInnerManager : public RefBase { 41 WM_DECLARE_SINGLE_INSTANCE_BASE(WindowInnerManager); 42 public: 43 void Start(bool enableRecentholder); 44 void Stop(); 45 void CreateInnerWindow(std::string name, DisplayId displayId, Rect rect, WindowType type, WindowMode mode); 46 void DestroyInnerWindow(DisplayId displayId, WindowType type); 47 void UpdateInnerWindow(DisplayId displayId, WindowType type, uint32_t width, uint32_t height); 48 void PostTask(InnerTask &&callback, std::string name = "WindowInnerManagerTask", 49 EventPriority priority = EventPriority::LOW); 50 51 // asynchronously calls the functions of AbilityManager 52 void MinimizeAbility(const wptr<WindowNode> &node, bool isFromUser); 53 void TerminateAbility(const wptr<WindowNode> &node); 54 void CloseAbility(const wptr<WindowNode> &node); 55 void CompleteFirstFrameDrawing(const wptr<WindowNode> &node); 56 void UpdateMissionSnapShot(const wptr<WindowNode> &node, std::shared_ptr<Media::PixelMap> pixelMap); 57 58 void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent); 59 void NotifyDisplayLimitRectChange(const std::map<DisplayId, Rect>& limitRectMap); 60 bool NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty, 61 sptr<MoveDragProperty>& moveDragProperty); 62 void NotifyWindowEndUpMovingOrDragging(uint32_t windowId); 63 void NotifyWindowRemovedOrDestroyed(uint32_t windowId); 64 pid_t GetPid(); 65 void SetInputEventConsumer(); 66 void StartWindowInfoReportLoop(); 67 void SetWindowRoot(const sptr<WindowRoot>& windowRoot); 68 69 protected: 70 WindowInnerManager(); 71 ~WindowInnerManager(); 72 73 private: 74 bool Init(); 75 76 pid_t pid_ = INVALID_PID; 77 bool isRecentHolderEnable_ = false; 78 sptr<MoveDragController> moveDragController_; 79 // event handle for inner window 80 std::shared_ptr<EventHandler> eventHandler_; 81 std::shared_ptr<EventRunner> eventLoop_; 82 InnerWMRunningState state_; 83 const std::string INNER_WM_THREAD_NAME = "InnerWindowManager"; 84 bool isReportTaskStart_ = false; 85 }; 86 } // namespace Rosen 87 } // namespace OHOS 88 #endif // OHOS_ROSEN_WINDOW_INNER_MANAGER_H