Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 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 | |
Prabir Pradhan | 4810866 | 2022-09-09 21:22:04 +0000 | [diff] [blame] | 17 | #pragma once |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 18 | |
Prabir Pradhan | d6b2b05 | 2024-02-21 23:25:15 +0000 | [diff] [blame] | 19 | #include "trace/EventTrackerInterface.h" |
| 20 | |
Siarhei Vishniakou | 8a87835 | 2023-01-30 14:05:01 -0800 | [diff] [blame] | 21 | #include <input/Input.h> |
| 22 | #include <bitset> |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 23 | #include <optional> |
| 24 | |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 25 | namespace android { |
| 26 | namespace inputdispatcher { |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 27 | |
| 28 | /* Specifies which events are to be canceled and why. */ |
| 29 | struct CancelationOptions { |
Michael Wright | fb04fd5 | 2022-11-24 22:31:11 +0000 | [diff] [blame] | 30 | enum class Mode { |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 31 | CANCEL_ALL_EVENTS = 0, |
| 32 | CANCEL_POINTER_EVENTS = 1, |
| 33 | CANCEL_NON_POINTER_EVENTS = 2, |
| 34 | CANCEL_FALLBACK_EVENTS = 3, |
Siarhei Vishniakou | 2e3e443 | 2023-02-09 18:34:11 -0800 | [diff] [blame] | 35 | ftl_last = CANCEL_FALLBACK_EVENTS, |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | // The criterion to use to determine which events should be canceled. |
| 39 | Mode mode; |
| 40 | |
| 41 | // Descriptive reason for the cancelation. |
| 42 | const char* reason; |
| 43 | |
| 44 | // The specific keycode of the key event to cancel, or nullopt to cancel any key event. |
| 45 | std::optional<int32_t> keyCode = std::nullopt; |
| 46 | |
| 47 | // The specific device id of events to cancel, or nullopt to cancel events from any device. |
| 48 | std::optional<int32_t> deviceId = std::nullopt; |
| 49 | |
| 50 | // The specific display id of events to cancel, or nullopt to cancel events on any display. |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame^] | 51 | std::optional<ui::LogicalDisplayId> displayId = std::nullopt; |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 52 | |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 53 | // The specific pointers to cancel, or nullopt to cancel all pointer events |
Siarhei Vishniakou | 8a87835 | 2023-01-30 14:05:01 -0800 | [diff] [blame] | 54 | std::optional<std::bitset<MAX_POINTER_ID + 1>> pointerIds = std::nullopt; |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 55 | |
Prabir Pradhan | d6b2b05 | 2024-02-21 23:25:15 +0000 | [diff] [blame] | 56 | const std::unique_ptr<trace::EventTrackerInterface>& traceTracker; |
| 57 | |
| 58 | explicit CancelationOptions(Mode mode, const char* reason, |
| 59 | const std::unique_ptr<trace::EventTrackerInterface>& traceTracker) |
| 60 | : mode(mode), reason(reason), traceTracker(traceTracker) {} |
| 61 | CancelationOptions(const CancelationOptions&) = delete; |
| 62 | CancelationOptions operator=(const CancelationOptions&) = delete; |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 65 | } // namespace inputdispatcher |
| 66 | } // namespace android |