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 16 #ifndef EVENT_FILTER_HANDLER_H 17 #define EVENT_FILTER_HANDLER_H 18 19 #include <mutex> 20 #include "nocopyable.h" 21 22 #include "i_event_filter.h" 23 #include "i_input_event_handler.h" 24 25 namespace OHOS { 26 namespace MMI { 27 class EventFilterHandler : public IInputEventHandler { 28 public: 29 EventFilterHandler(); 30 DISALLOW_COPY_AND_MOVE(EventFilterHandler); 31 ~EventFilterHandler(); 32 #ifdef OHOS_BUILD_ENABLE_KEYBOARD 33 void HandleKeyEvent(const std::shared_ptr<KeyEvent> keyEvent) override; 34 #endif // OHOS_BUILD_ENABLE_KEYBOARD 35 #ifdef OHOS_BUILD_ENABLE_POINTER 36 void HandlePointerEvent(const std::shared_ptr<PointerEvent> pointerEvent) override; 37 #endif // OHOS_BUILD_ENABLE_POINTER 38 #ifdef OHOS_BUILD_ENABLE_TOUCH 39 void HandleTouchEvent(const std::shared_ptr<PointerEvent> pointerEvent) override; 40 #endif // OHOS_BUILD_ENABLE_TOUCH 41 int32_t AddInputEventFilter(sptr<IEventFilter> filter); 42 bool HandlePointerEventFilter(std::shared_ptr<PointerEvent> point); 43 private: 44 std::mutex lockFilter_; 45 sptr<IEventFilter> filter_ {nullptr}; 46 }; 47 } // namespace MMI 48 } // namespace OHOS 49 #endif // EVENT_FILTER_HANDLER_H