• 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 #include "focus_change_listener.h"
17 #include "global.h"
18 #ifdef SCENE_BOARD_ENABLE
19 #include "window_manager_lite.h"
20 #else
21 #include "window_manager.h"
22 #endif
23 
24 namespace OHOS {
25 namespace MiscServices {
26 using namespace Rosen;
GetInstance()27 FocusMonitorManager &FocusMonitorManager::GetInstance()
28 {
29     static FocusMonitorManager focusMonitorManager;
30     return focusMonitorManager;
31 }
32 
RegisterFocusChangedListener(const FocusHandle & handle)33 void FocusMonitorManager::RegisterFocusChangedListener(const FocusHandle &handle)
34 {
35     sptr<IFocusChangedListener> listener = new (std::nothrow) FocusChangedListener(handle);
36     if (listener == nullptr) {
37         IMSA_HILOGE("failed to create listener");
38         return;
39     }
40 #ifdef SCENE_BOARD_ENABLE
41     WMError ret = WindowManagerLite::GetInstance().RegisterFocusChangedListener(listener);
42 #else
43     WMError ret = WindowManager::GetInstance().RegisterFocusChangedListener(listener);
44 #endif
45     IMSA_HILOGI("register focus changed listener ret: %{public}d", ret);
46 }
47 } // namespace MiscServices
48 } // namespace OHOS