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 #include "event_filter_wrap.h" 17 #include "mmi_log.h" 18 19 namespace OHOS { 20 namespace MMI { 21 namespace { 22 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "EventFilterWrap" }; 23 } // namespace 24 EventFilterWrap()25EventFilterWrap::EventFilterWrap() 26 { 27 MMI_LOGD("enter"); 28 } 29 ~EventFilterWrap()30EventFilterWrap::~EventFilterWrap() 31 { 32 MMI_LOGD("enter"); 33 } 34 AddInputEventFilter(sptr<IEventFilter> filter)35int32_t EventFilterWrap::AddInputEventFilter(sptr<IEventFilter> filter) 36 { 37 MMI_LOGD("enter"); 38 std::lock_guard<std::mutex> guard(lockInputEventFilter_); 39 filter_ = filter; 40 MMI_LOGD("leave"); 41 return RET_OK; 42 } 43 HandlePointerEventFilter(std::shared_ptr<PointerEvent> point)44bool EventFilterWrap::HandlePointerEventFilter(std::shared_ptr<PointerEvent> point) 45 { 46 MMI_LOGD("enter"); 47 CHKPF(point); 48 std::lock_guard<std::mutex> guard(lockInputEventFilter_); 49 CHKPF(filter_); 50 if (filter_->HandlePointerEvent(point)) { 51 MMI_LOGD("call HandlePointerEvent return true"); 52 return true; 53 } 54 MMI_LOGD("leave"); 55 return false; 56 } 57 } // namespace MMI 58 } // namespace OHOS 59