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(const bool forceFlush = false); 37 void FlushEmptyInfoToMMI(); 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 SetUserBackground(bool userBackground); 42 void SetCurrentUserId(int32_t userId); 43 void UpdateSecSurfaceInfo(const std::map<uint64_t, std::vector<SecSurfaceInfo>>& secSurfaceInfoMap); 44 45 protected: 46 SceneInputManager() = default; 47 virtual ~SceneInputManager() = default; 48 49 private: 50 void UpdateFocusedSessionId(int32_t focusedSessionId); 51 void FlushFullInfoToMMI(const std::vector<MMI::DisplayInfo>& displayInfos, 52 const std::vector<MMI::WindowInfo>& windowInfoList); 53 void FlushChangeInfoToMMI(const std::map<uint64_t, std::vector<MMI::WindowInfo>>& screenId2Windows); 54 void ConstructDisplayInfos(std::vector<MMI::DisplayInfo>& displayInfos); 55 bool CheckNeedUpdate(const std::vector<MMI::DisplayInfo>& displayInfos, 56 const std::vector<MMI::WindowInfo>& windowInfoList); 57 void PrintWindowInfo(const std::vector<MMI::WindowInfo>& windowInfoList); 58 void UpdateDisplayAndWindowInfo(const std::vector<MMI::DisplayInfo>& displayInfos, 59 std::vector<MMI::WindowInfo> windowInfoList); 60 std::shared_ptr<SceneSessionDirtyManager> sceneSessionDirty_; 61 std::shared_ptr<AppExecFwk::EventRunner> eventLoop_; 62 std::shared_ptr<AppExecFwk::EventHandler> eventHandler_; 63 std::vector<MMI::DisplayInfo> lastDisplayInfos_; 64 std::vector<MMI::WindowInfo> lastWindowInfoList_; 65 int32_t lastFocusId_ { -1 }; 66 int32_t currentUserId_ { -1 }; 67 int32_t focusedSessionId_ { -1 }; 68 std::atomic<bool> isUserBackground_ { false }; 69 }; 70 }//Rosen 71 }//OHOS 72 #endif //OHOS_SESSION_MANAGER_SCENE_INPUT_MANAGER_H