1 /* 2 * Copyright (c) 2024 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 WINDOW_REGISTER_MANAGER_H 17 #define WINDOW_REGISTER_MANAGER_H 18 19 #include <map> 20 #include <mutex> 21 #include <shared_mutex> 22 #include "window_listener.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class CjWindowRegisterManager { 27 public: 28 CjWindowRegisterManager(); ~CjWindowRegisterManager()29 ~CjWindowRegisterManager() {} 30 WmErrorCode RegisterListener(sptr<Window>, std::string type, 31 CaseType caseType, int64_t callbackObject); 32 WmErrorCode UnregisterListener(sptr<Window>, std::string type, 33 CaseType caseType, int64_t callbackObject); 34 private: 35 bool IsCallbackRegistered(std::string type, int64_t callbackObject); 36 WmErrorCode ProcessWindowChangeRegister(sptr<CjWindowListener> listener, sptr<Window> window, bool isRegister); 37 WmErrorCode ProcessSystemAvoidAreaChangeRegister(sptr<CjWindowListener> listener, sptr<Window> window, 38 bool isRegister); 39 WmErrorCode ProcessAvoidAreaChangeRegister(sptr<CjWindowListener> listener, sptr<Window> window, bool isRegister); 40 WmErrorCode ProcessLifeCycleEventRegister(sptr<CjWindowListener> listener, sptr<Window> window, bool isRegister); 41 WmErrorCode ProcessOccupiedAreaChangeRegister(sptr<CjWindowListener> listener, 42 sptr<Window> window, bool isRegister); 43 WmErrorCode ProcessSystemBarChangeRegister(sptr<CjWindowListener> listener, sptr<Window> window, bool isRegister); 44 WmErrorCode ProcessTouchOutsideRegister(sptr<CjWindowListener> listener, sptr<Window> window, bool isRegister); 45 WmErrorCode ProcessScreenshotRegister(sptr<CjWindowListener> listener, sptr<Window> window, bool isRegister); 46 WmErrorCode ProcessDialogTargetTouchRegister(sptr<CjWindowListener> listener, sptr<Window> window, bool isRegister); 47 WmErrorCode ProcessDialogDeathRecipientRegister(sptr<CjWindowListener> listener, sptr<Window> window, 48 bool isRegister); 49 WmErrorCode ProcessGestureNavigationEnabledChangeRegister(sptr<CjWindowListener> listener, 50 sptr<Window> window, bool isRegister); 51 WmErrorCode ProcessWaterMarkFlagChangeRegister(sptr<CjWindowListener> listener, 52 sptr<Window> window, bool isRegister); 53 WmErrorCode ProcessWindowVisibilityChangeRegister(sptr<CjWindowListener> listener, sptr<Window> window, 54 bool isRegister); 55 WmErrorCode ProcessDisplayIdChangeRegister(const sptr<CjWindowListener>& listener, const sptr<Window>& window, 56 bool isRegister); 57 WmErrorCode ProcessWindowStatusChangeRegister(sptr<CjWindowListener> listener, sptr<Window> window, 58 bool isRegister); 59 WmErrorCode ProcessWindowTitleButtonRectChangeRegister(sptr<CjWindowListener> listener, sptr<Window> window, 60 bool isRegister); 61 using Func = std::function<WmErrorCode(sptr<CjWindowListener>, sptr<Window>, bool)>; 62 std::map<std::string, std::map<int64_t, sptr<CjWindowListener>>> cjCbMap_; 63 mutable std::shared_mutex mtx_; 64 std::map<CaseType, std::map<std::string, Func>> listenerProcess_; 65 }; 66 } 67 } 68 #endif 69