1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "trace/EventTrackerInterface.h" 20 21 #include <input/Input.h> 22 #include <bitset> 23 #include <optional> 24 25 namespace android { 26 namespace inputdispatcher { 27 28 /* Specifies which events are to be canceled and why. */ 29 struct CancelationOptions { 30 enum class Mode { 31 CANCEL_ALL_EVENTS = 0, 32 CANCEL_POINTER_EVENTS = 1, 33 CANCEL_NON_POINTER_EVENTS = 2, 34 CANCEL_FALLBACK_EVENTS = 3, 35 CANCEL_HOVER_EVENTS = 4, 36 ftl_last = CANCEL_HOVER_EVENTS 37 }; 38 39 // The criterion to use to determine which events should be canceled. 40 Mode mode; 41 42 // Descriptive reason for the cancelation. 43 const char* reason; 44 45 // The specific keycode of the key event to cancel, or nullopt to cancel any key event. 46 std::optional<int32_t> keyCode = std::nullopt; 47 48 // The specific device id of events to cancel, or nullopt to cancel events from any device. 49 std::optional<int32_t> deviceId = std::nullopt; 50 51 // The specific display id of events to cancel, or nullopt to cancel events on any display. 52 std::optional<ui::LogicalDisplayId> displayId = std::nullopt; 53 54 // The specific pointers to cancel, or nullopt to cancel all pointer events 55 std::optional<std::bitset<MAX_POINTER_ID + 1>> pointerIds = std::nullopt; 56 57 const std::unique_ptr<trace::EventTrackerInterface>& traceTracker; 58 CancelationOptionsCancelationOptions59 explicit CancelationOptions(Mode mode, const char* reason, 60 const std::unique_ptr<trace::EventTrackerInterface>& traceTracker) 61 : mode(mode), reason(reason), traceTracker(traceTracker) {} 62 CancelationOptions(const CancelationOptions&) = delete; 63 CancelationOptions operator=(const CancelationOptions&) = delete; 64 }; 65 66 } // namespace inputdispatcher 67 } // namespace android 68