InputDispatcher: Send cancellations from losing focus windows
An input channel must have at least one focusable window to gain focus.
When focus changes, we send cancellations for all of the non-pointer
event streams going to the previously focused window. Send these
cancellations to a window instead of directly to the channel so that
events are always associated with a window.
We track focus by token, and there can be more than one window for a
token/input channel. For such cases, we pick the first window (i.e. the
top-most window) with the focused token as the target, for convenience.
Bug: 210460522
Test: atest inputflinger_tests
Change-Id: I63990ccfca1f5ef013f6f08ce6336b4a961c20d6
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index dcd1566..90a5250 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -653,7 +653,9 @@
bool handled, nsecs_t consumeTime) REQUIRES(mLock);
void doInterceptKeyBeforeDispatchingCommand(const sp<IBinder>& focusedWindowToken,
const KeyEntry& entry) REQUIRES(mLock);
- void onFocusChangedLocked(const FocusResolver::FocusChanges& changes) REQUIRES(mLock);
+ void onFocusChangedLocked(const FocusResolver::FocusChanges& changes,
+ const sp<gui::WindowInfoHandle> removedFocusedWindowHandle = nullptr)
+ REQUIRES(mLock);
void sendFocusChangedCommandLocked(const sp<IBinder>& oldToken, const sp<IBinder>& newToken)
REQUIRES(mLock);
void sendDropWindowCommandLocked(const sp<IBinder>& token, float x, float y) REQUIRES(mLock);