Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | #include "TouchedWindow.h" |
| 18 | |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 19 | #include <android-base/logging.h> |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 20 | #include <android-base/stringprintf.h> |
| 21 | #include <input/PrintTools.h> |
| 22 | |
Siarhei Vishniakou | e535f97 | 2024-03-29 14:55:21 -0700 | [diff] [blame^] | 23 | using android::base::Result; |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 24 | using android::base::StringPrintf; |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | namespace inputdispatcher { |
| 29 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 30 | namespace { |
| 31 | |
| 32 | bool hasPointerId(const std::vector<PointerProperties>& pointers, int32_t pointerId) { |
| 33 | return std::find_if(pointers.begin(), pointers.end(), |
| 34 | [&pointerId](const PointerProperties& properties) { |
| 35 | return properties.id == pointerId; |
| 36 | }) != pointers.end(); |
| 37 | } |
| 38 | |
| 39 | } // namespace |
| 40 | |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 41 | bool TouchedWindow::hasHoveringPointers() const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 42 | for (const auto& [_, state] : mDeviceStates) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 43 | if (!state.hoveringPointers.empty()) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 44 | return true; |
| 45 | } |
| 46 | } |
| 47 | return false; |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 50 | bool TouchedWindow::hasHoveringPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 51 | const auto stateIt = mDeviceStates.find(deviceId); |
| 52 | if (stateIt == mDeviceStates.end()) { |
| 53 | return false; |
| 54 | } |
| 55 | const DeviceState& state = stateIt->second; |
| 56 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 57 | return !state.hoveringPointers.empty(); |
Siarhei Vishniakou | e0431e4 | 2023-01-28 17:01:39 -0800 | [diff] [blame] | 58 | } |
| 59 | |
Siarhei Vishniakou | 2899c55 | 2023-07-10 18:20:46 -0700 | [diff] [blame] | 60 | void TouchedWindow::clearHoveringPointers(DeviceId deviceId) { |
| 61 | auto stateIt = mDeviceStates.find(deviceId); |
| 62 | if (stateIt == mDeviceStates.end()) { |
| 63 | return; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 64 | } |
Siarhei Vishniakou | 2899c55 | 2023-07-10 18:20:46 -0700 | [diff] [blame] | 65 | DeviceState& state = stateIt->second; |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 66 | state.hoveringPointers.clear(); |
Siarhei Vishniakou | 2899c55 | 2023-07-10 18:20:46 -0700 | [diff] [blame] | 67 | if (!state.hasPointers()) { |
| 68 | mDeviceStates.erase(stateIt); |
| 69 | } |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 72 | bool TouchedWindow::hasHoveringPointer(DeviceId deviceId, int32_t pointerId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 73 | const auto stateIt = mDeviceStates.find(deviceId); |
| 74 | if (stateIt == mDeviceStates.end()) { |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 75 | return false; |
| 76 | } |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 77 | const DeviceState& state = stateIt->second; |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 78 | return hasPointerId(state.hoveringPointers, pointerId); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 81 | void TouchedWindow::addHoveringPointer(DeviceId deviceId, const PointerProperties& pointer) { |
| 82 | std::vector<PointerProperties>& hoveringPointers = mDeviceStates[deviceId].hoveringPointers; |
| 83 | const size_t initialSize = hoveringPointers.size(); |
| 84 | std::erase_if(hoveringPointers, [&pointer](const PointerProperties& properties) { |
| 85 | return properties.id == pointer.id; |
| 86 | }); |
| 87 | if (hoveringPointers.size() != initialSize) { |
| 88 | LOG(ERROR) << __func__ << ": " << pointer << ", device " << deviceId << " was in " << *this; |
| 89 | } |
| 90 | hoveringPointers.push_back(pointer); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Siarhei Vishniakou | e535f97 | 2024-03-29 14:55:21 -0700 | [diff] [blame^] | 93 | Result<void> TouchedWindow::addTouchingPointers(DeviceId deviceId, |
| 94 | const std::vector<PointerProperties>& pointers) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 95 | std::vector<PointerProperties>& touchingPointers = mDeviceStates[deviceId].touchingPointers; |
| 96 | const size_t initialSize = touchingPointers.size(); |
| 97 | for (const PointerProperties& pointer : pointers) { |
| 98 | std::erase_if(touchingPointers, [&pointer](const PointerProperties& properties) { |
| 99 | return properties.id == pointer.id; |
| 100 | }); |
| 101 | } |
Siarhei Vishniakou | e535f97 | 2024-03-29 14:55:21 -0700 | [diff] [blame^] | 102 | const bool foundInconsistentState = touchingPointers.size() != initialSize; |
| 103 | touchingPointers.insert(touchingPointers.end(), pointers.begin(), pointers.end()); |
| 104 | if (foundInconsistentState) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 105 | LOG(ERROR) << __func__ << ": " << dumpVector(pointers, streamableToString) << ", device " |
| 106 | << deviceId << " already in " << *this; |
Siarhei Vishniakou | e535f97 | 2024-03-29 14:55:21 -0700 | [diff] [blame^] | 107 | return android::base::Error(); |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 108 | } |
Siarhei Vishniakou | e535f97 | 2024-03-29 14:55:21 -0700 | [diff] [blame^] | 109 | return {}; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | bool TouchedWindow::hasTouchingPointers() const { |
| 113 | for (const auto& [_, state] : mDeviceStates) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 114 | if (!state.touchingPointers.empty()) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 115 | return true; |
| 116 | } |
| 117 | } |
| 118 | return false; |
| 119 | } |
| 120 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 121 | bool TouchedWindow::hasTouchingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 122 | return !getTouchingPointers(deviceId).empty(); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 125 | bool TouchedWindow::hasTouchingPointer(DeviceId deviceId, int32_t pointerId) const { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 126 | const auto stateIt = mDeviceStates.find(deviceId); |
| 127 | if (stateIt == mDeviceStates.end()) { |
| 128 | return false; |
| 129 | } |
| 130 | const DeviceState& state = stateIt->second; |
| 131 | return hasPointerId(state.touchingPointers, pointerId); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 134 | std::vector<PointerProperties> TouchedWindow::getTouchingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 135 | const auto stateIt = mDeviceStates.find(deviceId); |
| 136 | if (stateIt == mDeviceStates.end()) { |
| 137 | return {}; |
| 138 | } |
| 139 | const DeviceState& state = stateIt->second; |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 140 | return state.touchingPointers; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 143 | void TouchedWindow::removeTouchingPointer(DeviceId deviceId, int32_t pointerId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 144 | std::bitset<MAX_POINTER_ID + 1> pointerIds; |
| 145 | pointerIds.set(pointerId, true); |
| 146 | |
| 147 | removeTouchingPointers(deviceId, pointerIds); |
| 148 | } |
| 149 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 150 | void TouchedWindow::removeTouchingPointers(DeviceId deviceId, |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 151 | std::bitset<MAX_POINTER_ID + 1> pointers) { |
| 152 | const auto stateIt = mDeviceStates.find(deviceId); |
| 153 | if (stateIt == mDeviceStates.end()) { |
| 154 | return; |
| 155 | } |
| 156 | DeviceState& state = stateIt->second; |
| 157 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 158 | std::erase_if(state.touchingPointers, [&pointers](const PointerProperties& properties) { |
| 159 | return pointers.test(properties.id); |
| 160 | }); |
| 161 | |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 162 | state.pilferingPointerIds &= ~pointers; |
| 163 | |
| 164 | if (!state.hasPointers()) { |
| 165 | mDeviceStates.erase(stateIt); |
Siarhei Vishniakou | 6464e46 | 2023-02-06 18:57:59 -0800 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
Siarhei Vishniakou | f77f60a | 2023-10-23 17:26:05 -0700 | [diff] [blame] | 169 | bool TouchedWindow::hasActiveStylus() const { |
| 170 | for (const auto& [_, state] : mDeviceStates) { |
| 171 | for (const PointerProperties& properties : state.touchingPointers) { |
| 172 | if (properties.toolType == ToolType::STYLUS) { |
| 173 | return true; |
| 174 | } |
| 175 | } |
| 176 | for (const PointerProperties& properties : state.hoveringPointers) { |
| 177 | if (properties.toolType == ToolType::STYLUS) { |
| 178 | return true; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | return false; |
| 183 | } |
| 184 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 185 | std::set<DeviceId> TouchedWindow::getTouchingDeviceIds() const { |
| 186 | std::set<DeviceId> deviceIds; |
Prabir Pradhan | 9cd9eb6 | 2023-11-22 17:58:06 +0000 | [diff] [blame] | 187 | for (const auto& [deviceId, deviceState] : mDeviceStates) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 188 | if (!deviceState.touchingPointers.empty()) { |
Prabir Pradhan | 9cd9eb6 | 2023-11-22 17:58:06 +0000 | [diff] [blame] | 189 | deviceIds.insert(deviceId); |
| 190 | } |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 191 | } |
| 192 | return deviceIds; |
| 193 | } |
| 194 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 195 | bool TouchedWindow::hasPilferingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 196 | const auto stateIt = mDeviceStates.find(deviceId); |
| 197 | if (stateIt == mDeviceStates.end()) { |
| 198 | return false; |
| 199 | } |
| 200 | const DeviceState& state = stateIt->second; |
| 201 | |
| 202 | return state.pilferingPointerIds.any(); |
| 203 | } |
| 204 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 205 | void TouchedWindow::addPilferingPointers(DeviceId deviceId, |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 206 | std::bitset<MAX_POINTER_ID + 1> pointerIds) { |
| 207 | mDeviceStates[deviceId].pilferingPointerIds |= pointerIds; |
| 208 | } |
| 209 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 210 | void TouchedWindow::addPilferingPointer(DeviceId deviceId, int32_t pointerId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 211 | mDeviceStates[deviceId].pilferingPointerIds.set(pointerId); |
| 212 | } |
| 213 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 214 | std::bitset<MAX_POINTER_ID + 1> TouchedWindow::getPilferingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 215 | const auto stateIt = mDeviceStates.find(deviceId); |
| 216 | if (stateIt == mDeviceStates.end()) { |
| 217 | return {}; |
| 218 | } |
| 219 | const DeviceState& state = stateIt->second; |
| 220 | |
| 221 | return state.pilferingPointerIds; |
| 222 | } |
| 223 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 224 | std::map<DeviceId, std::bitset<MAX_POINTER_ID + 1>> TouchedWindow::getPilferingPointers() const { |
| 225 | std::map<DeviceId, std::bitset<MAX_POINTER_ID + 1>> out; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 226 | for (const auto& [deviceId, state] : mDeviceStates) { |
| 227 | out.emplace(deviceId, state.pilferingPointerIds); |
| 228 | } |
| 229 | return out; |
| 230 | } |
| 231 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 232 | std::optional<nsecs_t> TouchedWindow::getDownTimeInTarget(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 233 | const auto stateIt = mDeviceStates.find(deviceId); |
| 234 | if (stateIt == mDeviceStates.end()) { |
| 235 | return {}; |
| 236 | } |
| 237 | const DeviceState& state = stateIt->second; |
| 238 | return state.downTimeInTarget; |
| 239 | } |
| 240 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 241 | void TouchedWindow::trySetDownTimeInTarget(DeviceId deviceId, nsecs_t downTime) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 242 | auto [stateIt, _] = mDeviceStates.try_emplace(deviceId); |
| 243 | DeviceState& state = stateIt->second; |
| 244 | |
| 245 | if (!state.downTimeInTarget) { |
| 246 | state.downTimeInTarget = downTime; |
| 247 | } |
| 248 | } |
| 249 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 250 | void TouchedWindow::removeAllTouchingPointersForDevice(DeviceId deviceId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 251 | const auto stateIt = mDeviceStates.find(deviceId); |
| 252 | if (stateIt == mDeviceStates.end()) { |
| 253 | return; |
| 254 | } |
| 255 | DeviceState& state = stateIt->second; |
| 256 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 257 | state.touchingPointers.clear(); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 258 | state.pilferingPointerIds.reset(); |
| 259 | state.downTimeInTarget.reset(); |
| 260 | |
| 261 | if (!state.hasPointers()) { |
| 262 | mDeviceStates.erase(stateIt); |
| 263 | } |
Siarhei Vishniakou | 0686f0c | 2023-05-02 11:56:15 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 266 | void TouchedWindow::removeHoveringPointer(DeviceId deviceId, int32_t pointerId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 267 | const auto stateIt = mDeviceStates.find(deviceId); |
| 268 | if (stateIt == mDeviceStates.end()) { |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 269 | return; |
| 270 | } |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 271 | DeviceState& state = stateIt->second; |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 272 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 273 | std::erase_if(state.hoveringPointers, [&pointerId](const PointerProperties& properties) { |
| 274 | return properties.id == pointerId; |
| 275 | }); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 276 | |
| 277 | if (!state.hasPointers()) { |
| 278 | mDeviceStates.erase(stateIt); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 282 | void TouchedWindow::removeAllHoveringPointersForDevice(DeviceId deviceId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 283 | const auto stateIt = mDeviceStates.find(deviceId); |
| 284 | if (stateIt == mDeviceStates.end()) { |
| 285 | return; |
| 286 | } |
| 287 | DeviceState& state = stateIt->second; |
| 288 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 289 | state.hoveringPointers.clear(); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 290 | |
| 291 | if (!state.hasPointers()) { |
| 292 | mDeviceStates.erase(stateIt); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | std::string TouchedWindow::deviceStateToString(const TouchedWindow::DeviceState& state) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 297 | return StringPrintf("[touchingPointers=%s, " |
| 298 | "downTimeInTarget=%s, hoveringPointers=%s, pilferingPointerIds=%s]", |
| 299 | dumpVector(state.touchingPointers, streamableToString).c_str(), |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 300 | toString(state.downTimeInTarget).c_str(), |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 301 | dumpVector(state.hoveringPointers, streamableToString).c_str(), |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 302 | bitsetToString(state.pilferingPointerIds).c_str()); |
Siarhei Vishniakou | 0686f0c | 2023-05-02 11:56:15 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 305 | std::string TouchedWindow::dump() const { |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 306 | std::string out; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 307 | std::string deviceStates = |
| 308 | dumpMap(mDeviceStates, constToString, TouchedWindow::deviceStateToString); |
| 309 | out += StringPrintf("name='%s', targetFlags=%s, mDeviceStates=%s\n", |
| 310 | windowHandle->getName().c_str(), targetFlags.string().c_str(), |
| 311 | deviceStates.c_str()); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 312 | return out; |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 313 | } |
| 314 | |
Siarhei Vishniakou | 72945a0 | 2023-09-18 18:30:25 -0700 | [diff] [blame] | 315 | std::ostream& operator<<(std::ostream& out, const TouchedWindow& window) { |
| 316 | out << window.dump(); |
| 317 | return out; |
| 318 | } |
| 319 | |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 320 | } // namespace inputdispatcher |
| 321 | } // namespace android |