Check display id of the last hover window before it is cleared
The display id of the last hover window must be checked before
it is cleared when a window changes for a display.
If display id of the last hover window is not checked, then the
last hover window is cleared every time a window changes on a
different display which is faulty.
The last hover window should only be cleared when the window
is removed from the same display as the display of last
hover window.
Add test that ensure that only one hover enter is generated
followed by several hover move when the mouse is moved in
a window on primary display when windows on second display
are removed.
The CTS test, VirtualMouseTest, must also be updated.
Reference patch:
Correct CTS test VirtualMouseTest#sendRelativeEvent
Ie4a54ee3469ed0b7c88abea946f32f66203da38f
Bug: 239687726
Test: atest VirtualMouseTest
Change-Id: I70ebcb994ebc31327b85303110753ce3d40329be
Merged-In: I70ebcb994ebc31327b85303110753ce3d40329be
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 564acc0..f634ce7 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4721,10 +4721,13 @@
updateWindowHandlesForDisplayLocked(windowInfoHandles, displayId);
const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(displayId);
- if (mLastHoverWindowHandle &&
- std::find(windowHandles.begin(), windowHandles.end(), mLastHoverWindowHandle) ==
- windowHandles.end()) {
- mLastHoverWindowHandle = nullptr;
+ if (mLastHoverWindowHandle) {
+ const WindowInfo* lastHoverWindowInfo = mLastHoverWindowHandle->getInfo();
+ if (lastHoverWindowInfo->displayId == displayId &&
+ std::find(windowHandles.begin(), windowHandles.end(), mLastHoverWindowHandle) ==
+ windowHandles.end()) {
+ mLastHoverWindowHandle = nullptr;
+ }
}
std::optional<FocusResolver::FocusChanges> changes =