diff options
| -rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index ff63967c2f..ff63a6f05f 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -2991,7 +2991,7 @@ void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime, ATRACE_NAME(message.c_str()); } - bool wasEmpty = connection->outboundQueue.empty(); + const bool wasEmpty = connection->outboundQueue.empty(); // Enqueue dispatch entries for the requested modes. enqueueDispatchEntryLocked(connection, eventEntry, inputTarget, @@ -3674,6 +3674,8 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( target.inputChannel = connection->inputChannel; target.flags = InputTarget::FLAG_DISPATCH_AS_IS; + const bool wasEmpty = connection->outboundQueue.empty(); + for (size_t i = 0; i < cancelationEvents.size(); i++) { std::unique_ptr<EventEntry> cancelationEventEntry = std::move(cancelationEvents[i]); switch (cancelationEventEntry->type) { @@ -3708,7 +3710,10 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( InputTarget::FLAG_DISPATCH_AS_IS); } - startDispatchCycleLocked(currentTime, connection); + // If the outbound queue was previously empty, start the dispatch cycle going. + if (wasEmpty && !connection->outboundQueue.empty()) { + startDispatchCycleLocked(currentTime, connection); + } } void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( @@ -3740,6 +3745,7 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( target.inputChannel = connection->inputChannel; target.flags = InputTarget::FLAG_DISPATCH_AS_IS; + const bool wasEmpty = connection->outboundQueue.empty(); for (std::unique_ptr<EventEntry>& downEventEntry : downEvents) { switch (downEventEntry->type) { case EventEntry::Type::MOTION: { @@ -3766,7 +3772,10 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( InputTarget::FLAG_DISPATCH_AS_IS); } - startDispatchCycleLocked(downTime, connection); + // If the outbound queue was previously empty, start the dispatch cycle going. + if (wasEmpty && !connection->outboundQueue.empty()) { + startDispatchCycleLocked(downTime, connection); + } } std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent( |