• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
68 protected:
69     WindowInnerManager();
70     ~WindowInnerManager();
71 
72 private:
73     bool Init();
74 
75     pid_t pid_ = INVALID_PID;
76     bool isRecentHolderEnable_ = false;
77     sptr<MoveDragController> moveDragController_;
78     // event handle for inner window
79     std::shared_ptr<EventHandler> eventHandler_;
80     std::shared_ptr<EventRunner> eventLoop_;
81     InnerWMRunningState state_;
82     const std::string INNER_WM_THREAD_NAME = "InnerWindowManager";
83     bool isReportTaskStart_ = false;
84 };
85 } // namespace Rosen
86 } // namespace OHOS
87 #endif // OHOS_ROSEN_WINDOW_INNER_MANAGER_H