Skip to content

Commit feca057

Browse files
committed
InputDispatcher: Ensure pointer down is generated for touched window
A precondition for synthesizing pointer down events is that the touch state must already be updated to reflect the new gesture going into the window. When generating the down event, it should be associated with the correct touched window, not just any window with the same token. This CL fixes the a bug where the down event would be synthesized for the top-most clone window that matches the token, rather than the touched window. Bug: 210460522 Test: atest inputflinger_tests Change-Id: I3bedc2c2c8e0f18dc8814d519ba7cf9449e10211
1 parent 73ba920 commit feca057

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4192,7 +4192,12 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked(
41924192
connection->getInputChannelName().c_str(), downEvents.size());
41934193
}
41944194

4195-
sp<WindowInfoHandle> windowHandle = getWindowHandleLocked(connection->getToken());
4195+
const auto [_, touchedWindowState, displayId] =
4196+
findTouchStateWindowAndDisplayLocked(connection->getToken());
4197+
if (touchedWindowState == nullptr) {
4198+
LOG(FATAL) << __func__ << ": Touch state is out of sync: No touched window for token";
4199+
}
4200+
const auto& windowHandle = touchedWindowState->windowHandle;
41964201

41974202
const bool wasEmpty = connection->outboundQueue.empty();
41984203
for (std::unique_ptr<EventEntry>& downEventEntry : downEvents) {

0 commit comments

Comments
 (0)