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