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 | |
| 17 | #ifndef _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H |
| 18 | #define _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H |
| 19 | |
| 20 | #include "Monitor.h" |
| 21 | #include "TouchedWindow.h" |
| 22 | |
| 23 | namespace android { |
| 24 | |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 25 | namespace gui { |
| 26 | class WindowInfoHandle; |
| 27 | } |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 28 | |
| 29 | namespace inputdispatcher { |
| 30 | |
| 31 | struct TouchState { |
Prabir Pradhan | e680f9b | 2022-02-04 04:24:00 -0800 | [diff] [blame] | 32 | bool down = false; |
| 33 | bool split = false; |
Prabir Pradhan | e680f9b | 2022-02-04 04:24:00 -0800 | [diff] [blame] | 34 | |
| 35 | // id of the device that is currently down, others are rejected |
| 36 | int32_t deviceId = -1; |
| 37 | // source of the device that is current down, others are rejected |
| 38 | uint32_t source = 0; |
| 39 | // id to the display that currently has a touch, others are rejected |
| 40 | int32_t displayId = ADISPLAY_ID_NONE; |
| 41 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 42 | std::vector<TouchedWindow> windows; |
| 43 | |
Prabir Pradhan | e680f9b | 2022-02-04 04:24:00 -0800 | [diff] [blame] | 44 | TouchState() = default; |
| 45 | ~TouchState() = default; |
| 46 | TouchState& operator=(const TouchState&) = default; |
| 47 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 48 | void reset(); |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 49 | void addOrUpdateWindow(const sp<android::gui::WindowInfoHandle>& windowHandle, |
| 50 | int32_t targetFlags, BitSet32 pointerIds); |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 51 | void removeWindowByToken(const sp<IBinder>& token); |
| 52 | void filterNonAsIsTouchWindows(); |
Prabir Pradhan | 07e05b6 | 2021-11-19 03:57:24 -0800 | [diff] [blame] | 53 | void filterWindowsExcept(const sp<IBinder>& token); |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame^] | 54 | |
| 55 | // Cancel pointers for current set of windows except the window with particular binder token. |
| 56 | void cancelPointersForWindowsExcept(const BitSet32 pointerIds, const sp<IBinder>& token); |
| 57 | // Cancel pointers for current set of non-pilfering windows i.e. windows with isPilferingWindow |
| 58 | // set to false. |
| 59 | void cancelPointersForNonPilferingWindows(const BitSet32 pointerIds); |
| 60 | |
chaviw | 98318de | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 61 | sp<android::gui::WindowInfoHandle> getFirstForegroundWindowHandle() const; |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 62 | bool isSlippery() const; |
Siarhei Vishniakou | ca20550 | 2021-07-16 21:31:58 +0000 | [diff] [blame] | 63 | sp<android::gui::WindowInfoHandle> getWallpaperWindow() const; |
Prabir Pradhan | 07e05b6 | 2021-11-19 03:57:24 -0800 | [diff] [blame] | 64 | sp<android::gui::WindowInfoHandle> getWindow(const sp<IBinder>&) const; |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace inputdispatcher |
| 68 | } // namespace android |
| 69 | |
| 70 | #endif // _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H |