• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_SESSION_MANAGER_SCENE_INPUT_MANAGER_H
17 #define OHOS_SESSION_MANAGER_SCENE_INPUT_MANAGER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include <ui_content.h>
23 #include "input_manager.h"
24 #include "session/host/include/scene_session.h"
25 #include "wm_common.h"
26 #include "wm_single_instance.h"
27 
28 namespace OHOS {
29 namespace Rosen {
30 class SceneSessionDirtyManager;
31 struct SecSurfaceInfo;
32 class SceneInputManager : public std::enable_shared_from_this<SceneInputManager> {
33 WM_DECLARE_SINGLE_INSTANCE_BASE(SceneInputManager)
34 public:
35     void Init();
36     void FlushDisplayInfoToMMI(std::vector<MMI::WindowInfo>&& windowInfoList,
37         std::vector<std::shared_ptr<Media::PixelMap>>&& pixelMapList, const bool forceFlush = false);
38     void NotifyWindowInfoChange(const sptr<SceneSession>& scenenSession, const WindowUpdateType& type);
39     void NotifyWindowInfoChangeFromSession(const sptr<SceneSession>& sceneSession);
40     void NotifyMMIWindowPidChange(const sptr<SceneSession>& sceneSession, const bool startMoving);
41     void UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap);
42     void UpdateConstrainedModalUIExtInfo(const std::map<uint64_t,
43         std::vector<SecSurfaceInfo>>& constrainedModalUIExtInfoMap);
44     std::optional<ExtensionWindowEventInfo> GetConstrainedModalExtWindowInfo(const sptr<SceneSession>& sceneSession);
45     using FlushWindowInfoCallback = std::function<void()>;
46     void RegisterFlushWindowInfoCallback(FlushWindowInfoCallback&& callback);
47     void ResetSessionDirty();
48     std::pair<std::vector<MMI::WindowInfo>, std::vector<std::shared_ptr<Media::PixelMap>>>
49         GetFullWindowInfoList();
50 
51     /*
52      * Multi User
53      */
54     void FlushEmptyInfoToMMI();
55     void SetUserBackground(bool userBackground);
56     void SetCurrentUserId(int32_t userId);
57 
58 protected:
59     SceneInputManager() = default;
60     virtual ~SceneInputManager() = default;
61 
62 private:
63     void UpdateFocusedSessionId(int32_t focusedSessionId);
64     void FlushFullInfoToMMI(const std::vector<MMI::DisplayInfo>& displayInfos,
65         const std::vector<MMI::WindowInfo>& windowInfoList);
66     void FlushChangeInfoToMMI(const std::map<uint64_t, std::vector<MMI::WindowInfo>>& screenId2Windows);
67     void ConstructDisplayInfos(std::vector<MMI::DisplayInfo>& displayInfos);
68     bool CheckNeedUpdate(const std::vector<MMI::DisplayInfo>& displayInfos,
69         const std::vector<MMI::WindowInfo>& windowInfoList);
70     void PrintDisplayInfo(const std::vector<MMI::DisplayInfo>& displayInfos);
71     void PrintWindowInfo(const std::vector<MMI::WindowInfo>& windowInfoList);
72     void UpdateDisplayAndWindowInfo(const std::vector<MMI::DisplayInfo>& displayInfos,
73         std::vector<MMI::WindowInfo> windowInfoList);
74     std::shared_ptr<SceneSessionDirtyManager> sceneSessionDirty_;
75     std::shared_ptr<AppExecFwk::EventRunner> eventLoop_;
76     std::shared_ptr<AppExecFwk::EventHandler> eventHandler_;
77     std::vector<MMI::DisplayInfo> lastDisplayInfos_;
78     std::vector<MMI::WindowInfo> lastWindowInfoList_;
79     int32_t lastFocusId_ { -1 };
80     int32_t focusedSessionId_ { -1 };
81 
82     /*
83      * Multi User
84      */
85     int32_t currentUserId_ = INVALID_USER_ID;
86     std::atomic<bool> isUserBackground_ { false };
87 };
88 }//Rosen
89 }//OHOS
90 #endif //OHOS_SESSION_MANAGER_SCENE_INPUT_MANAGER_H