• 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 "session/screen/include/screen_property.h"
26 #include "wm_common.h"
27 #include "wm_single_instance.h"
28 
29 namespace OHOS {
30 namespace Rosen {
31 class SceneSessionDirtyManager;
32 struct SecSurfaceInfo;
33 class SceneInputManager : public std::enable_shared_from_this<SceneInputManager> {
34 WM_DECLARE_SINGLE_INSTANCE_BASE(SceneInputManager)
35 public:
36     void Init();
37     void FlushDisplayInfoToMMI(std::vector<MMI::WindowInfo>&& windowInfoList,
38         std::vector<std::shared_ptr<Media::PixelMap>>&& pixelMapList, const bool forceFlush = false);
39     void NotifyWindowInfoChange(const sptr<SceneSession>& scenenSession, const WindowUpdateType& type);
40     void NotifyWindowInfoChangeFromSession(const sptr<SceneSession>& sceneSession);
41     void NotifyMMIWindowPidChange(const sptr<SceneSession>& sceneSession, const bool startMoving);
42     void UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap);
43     void UpdateConstrainedModalUIExtInfo(const std::map<uint64_t,
44         std::vector<SecSurfaceInfo>>& constrainedModalUIExtInfoMap);
45     std::optional<ExtensionWindowEventInfo> GetConstrainedModalExtWindowInfo(const sptr<SceneSession>& sceneSession);
46     using FlushWindowInfoCallback = std::function<void()>;
47     void RegisterFlushWindowInfoCallback(FlushWindowInfoCallback&& callback);
48     void ResetSessionDirty();
49     std::pair<std::vector<MMI::WindowInfo>, std::vector<std::shared_ptr<Media::PixelMap>>>
50         GetFullWindowInfoList();
51 
52     /*
53      * Multi User
54      */
55     void FlushEmptyInfoToMMI();
56     void SetUserBackground(bool userBackground);
57     void SetCurrentUserId(int32_t userId);
58 
59 protected:
60     SceneInputManager() = default;
61     virtual ~SceneInputManager() = default;
62 
63 private:
64     void UpdateFocusedSessionId(int32_t focusedSessionId);
65     void FlushFullInfoToMMI(const std::vector<MMI::ScreenInfo>& screenInfos,
66         std::map<DisplayGroupId, MMI::DisplayGroupInfo>& displayGroupMap,
67         const std::vector<MMI::WindowInfo>& windowInfoList, bool isOverBatchSize = false);
68     void FlushChangeInfoToMMI(const std::map<uint64_t, std::vector<MMI::WindowInfo>>& screenId2Windows);
69     std::vector<MMI::ScreenInfo> ConstructScreenInfos(std::map<ScreenId, ScreenProperty>& screensProperties);
70     void ConstructDisplayGroupInfos(std::map<ScreenId, ScreenProperty>& screensProperties,
71         std::map<DisplayGroupId, MMI::DisplayGroupInfo>& displayGroupMap);
72     bool CheckNeedUpdate(const std::vector<MMI::ScreenInfo>& screenInfos,
73         const std::vector<MMI::DisplayInfo>& displayInfos, const std::vector<MMI::WindowInfo>& windowInfoList);
74     void PrintScreenInfo(const std::vector<MMI::ScreenInfo>& screenInfos);
75     void PrintDisplayInfo(const std::vector<MMI::DisplayInfo>& displayInfos);
76     void PrintWindowInfo(const std::vector<MMI::WindowInfo>& windowInfoList);
77     void UpdateDisplayAndWindowInfo(const std::vector<MMI::ScreenInfo>& screenInfos,
78         std::map<DisplayGroupId, MMI::DisplayGroupInfo>& displayGroupMap,
79         std::vector<MMI::WindowInfo> windowInfoList);
80     void ConstructDumpDisplayInfo(const MMI::DisplayInfo& displayInfo,
81         std::ostringstream& dumpDisplayListStream);
82     void ConstructDumpWindowInfo(const MMI::WindowInfo& windowInfo,
83         std::ostringstream& dumpWindowListStream);
84     std::unordered_map<DisplayId, int32_t> GetFocusedSessionMap() const;
85     std::shared_ptr<SceneSessionDirtyManager> sceneSessionDirty_;
86     std::shared_ptr<AppExecFwk::EventRunner> eventLoop_;
87     std::shared_ptr<AppExecFwk::EventHandler> eventHandler_;
88     std::vector<MMI::ScreenInfo> lastScreenInfos_;
89     std::vector<MMI::DisplayInfo> lastDisplayInfos_;
90     std::vector<MMI::WindowInfo> lastWindowInfoList_;
91     int32_t lastFocusId_ { -1 };
92     int32_t focusedSessionId_ { -1 };
93 
94     /*
95      * Multi User
96      */
97     int32_t currentUserId_ = INVALID_USER_ID;
98     std::atomic<bool> isUserBackground_ { false };
99 };
100 }//Rosen
101 }//OHOS
102 #endif //OHOS_SESSION_MANAGER_SCENE_INPUT_MANAGER_H