1 /* 2 * Copyright (c) 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_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 "wm_common.h" 26 #include "window_node.h" 27 #include "wm_single_instance.h" 28 29 enum class InnerWMRunningState { 30 STATE_NOT_START, 31 STATE_RUNNING, 32 }; 33 namespace OHOS { 34 namespace Rosen { 35 using InnerTask = std::function<void()>; 36 using EventRunner = OHOS::AppExecFwk::EventRunner; 37 using EventHandler = OHOS::AppExecFwk::EventHandler; 38 using EventPriority = OHOS::AppExecFwk::EventQueue::Priority; 39 class WindowInnerManager : public RefBase { 40 WM_DECLARE_SINGLE_INSTANCE_BASE(WindowInnerManager); 41 public: 42 void Start(bool enableRecentholder); 43 void Stop(); 44 void CreateInnerWindow(std::string name, DisplayId displayId, Rect rect, WindowType type, WindowMode mode); 45 void DestroyInnerWindow(DisplayId displayId, WindowType type); 46 void UpdateInnerWindow(DisplayId displayId, WindowType type, uint32_t width, uint32_t height); 47 void PostTask(InnerTask &&callback, std::string name = "WindowInnerManagerTask", 48 EventPriority priority = EventPriority::LOW); 49 50 // asynchronously calls the functions of AbilityManager 51 void MinimizeAbility(const wptr<WindowNode> &node, bool isFromUser); 52 void TerminateAbility(const wptr<WindowNode> &node); 53 void CloseAbility(const wptr<WindowNode> &node); 54 void CompleteFirstFrameDrawing(const wptr<WindowNode> &node); 55 56 void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent); 57 void NotifyDisplayChange(const std::map<DisplayId, Rect>& displayRectMap); 58 bool NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty, 59 sptr<MoveDragProperty>& moveDragProperty); 60 void NotifyWindowEndUpMovingOrDragging(uint32_t windowId); 61 void NotifyWindowRemovedOrDestroyed(uint32_t windowId); 62 pid_t GetPid(); 63 void SetInputEventConsumer(); 64 65 protected: 66 WindowInnerManager(); 67 ~WindowInnerManager(); 68 69 private: 70 bool Init(); 71 72 pid_t pid_ = INVALID_PID; 73 bool isRecentHolderEnable_ = false; 74 sptr<MoveDragController> moveDragController_; 75 // event handle for inner window 76 std::shared_ptr<EventHandler> eventHandler_; 77 std::shared_ptr<EventRunner> eventLoop_; 78 InnerWMRunningState state_; 79 const std::string INNER_WM_THREAD_NAME = "InnerWindowManager"; 80 }; 81 } // namespace Rosen 82 } // namespace OHOS 83 #endif // OHOS_ROSEN_WINDOW_INNER_MANAGER_H