• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #ifndef INTERCEPTOR_MANAGER_GLOBAL_H
16 #define INTERCEPTOR_MANAGER_GLOBAL_H
17 
18 #include <list>
19 #include "pointer_event.h"
20 #include "singleton.h"
21 #include "uds_session.h"
22 #include "key_event.h"
23 #include "nocopyable.h"
24 
25 namespace OHOS {
26 namespace MMI {
27 class InterceptorManagerGlobal {
28 public:
29     InterceptorManagerGlobal();
30     DISALLOW_COPY_AND_MOVE(InterceptorManagerGlobal);
31     ~InterceptorManagerGlobal();
32     void OnAddInterceptor(int32_t sourceType, int32_t id, SessionPtr session);
33     void OnRemoveInterceptor(int32_t id);
34     bool OnPointerEvent(std::shared_ptr<PointerEvent> pointerEvent);
35     bool OnKeyEvent(std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent);
36 private:
37     struct InterceptorItem {
38         int32_t sourceType;
39         int32_t id;
40         SessionPtr session = nullptr;
41         bool operator == (const InterceptorItem& item)
42         {
43             return id == item.id;
44         }
45     };
46 private:
47     std::mutex mu_;
48     std::list<InterceptorItem> interceptors_;
49 };
50 } // namespace MMI
51 } // namespace OHOS
52 
53 #define InterceptorMgrGbl OHOS::Singleton<OHOS::MMI::InterceptorManagerGlobal>::GetInstance()
54 #endif // INTERCEPTOR_MANAGER_GLOBAL_H