blob: 512cb6e692b57a5833494d51ff09b1b8fcba321a [file] [log] [blame]
Garfield Tane84e6f92019-08-29 17:28:41 -07001/*
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 Pradhan48108662022-09-09 21:22:04 +000017#pragma once
Garfield Tane84e6f92019-08-29 17:28:41 -070018
Vaibhav Devmurariff798f32022-05-09 23:45:04 +000019#include <utils/BitSet.h>
Garfield Tane84e6f92019-08-29 17:28:41 -070020#include <optional>
21
Vaibhav Devmurariff798f32022-05-09 23:45:04 +000022namespace android {
23namespace inputdispatcher {
Garfield Tane84e6f92019-08-29 17:28:41 -070024
25/* Specifies which events are to be canceled and why. */
26struct CancelationOptions {
Michael Wrightfb04fd52022-11-24 22:31:11 +000027 enum class Mode {
Garfield Tane84e6f92019-08-29 17:28:41 -070028 CANCEL_ALL_EVENTS = 0,
29 CANCEL_POINTER_EVENTS = 1,
30 CANCEL_NON_POINTER_EVENTS = 2,
31 CANCEL_FALLBACK_EVENTS = 3,
32 };
33
34 // The criterion to use to determine which events should be canceled.
35 Mode mode;
36
37 // Descriptive reason for the cancelation.
38 const char* reason;
39
40 // The specific keycode of the key event to cancel, or nullopt to cancel any key event.
41 std::optional<int32_t> keyCode = std::nullopt;
42
43 // The specific device id of events to cancel, or nullopt to cancel events from any device.
44 std::optional<int32_t> deviceId = std::nullopt;
45
46 // The specific display id of events to cancel, or nullopt to cancel events on any display.
47 std::optional<int32_t> displayId = std::nullopt;
48
Vaibhav Devmurariff798f32022-05-09 23:45:04 +000049 // The specific pointers to cancel, or nullopt to cancel all pointer events
50 std::optional<BitSet32> pointerIds = std::nullopt;
51
Garfield Tane84e6f92019-08-29 17:28:41 -070052 CancelationOptions(Mode mode, const char* reason) : mode(mode), reason(reason) {}
53};
54
Vaibhav Devmurariff798f32022-05-09 23:45:04 +000055} // namespace inputdispatcher
56} // namespace android