diff options
| author | 2023-05-19 16:56:44 +0000 | |
|---|---|---|
| committer | 2023-05-19 16:56:44 +0000 | |
| commit | caf8fcaad2cdde7e2dc48df5f5fef1441d562e0e (patch) | |
| tree | 3fd85ec5a2c71a58b683cff17647819f88675f6c | |
| parent | 00e2961eb9740acaf41c9f82c4b6a110a56bcce0 (diff) | |
| parent | 1e7cda2e88650854a1fbed3c631839f50f217591 (diff) | |
Merge "Create new input targets for hover events" into udc-dev am: 1d810c5129 am: 1e7cda2e88
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/23249463
Change-Id: I81c1586c483d5b48f012ff711c300faaecf9cfe9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 14 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputDispatcher_test.cpp | 23 |
2 files changed, 34 insertions, 3 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 9125fe49e0..bdd45dc9b4 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -2561,9 +2561,17 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked( std::vector<TouchedWindow> hoveringWindows = getHoveringWindowsLocked(oldState, tempTouchState, entry); for (const TouchedWindow& touchedWindow : hoveringWindows) { - addWindowTargetLocked(touchedWindow.windowHandle, touchedWindow.targetFlags, - touchedWindow.pointerIds, touchedWindow.firstDownTimeInTarget, - targets); + std::optional<InputTarget> target = + createInputTargetLocked(touchedWindow.windowHandle, touchedWindow.targetFlags, + touchedWindow.firstDownTimeInTarget); + if (!target) { + continue; + } + // Hardcode to single hovering pointer for now. + std::bitset<MAX_POINTER_ID + 1> pointerIds; + pointerIds.set(entry.pointerProperties[0].id); + target->addPointers(pointerIds, touchedWindow.windowHandle->getInfo()->transform); + targets.push_back(*target); } } diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp index 3f2658a71d..017f10baf8 100644 --- a/services/inputflinger/tests/InputDispatcher_test.cpp +++ b/services/inputflinger/tests/InputDispatcher_test.cpp @@ -6592,6 +6592,29 @@ TEST_F(InputDispatcherMultiWindowSameTokenTests, TouchDoesNotSlipEvenIfSlippery) consumeMotionEvent(mWindow1, ACTION_MOVE, {{150, 150}}); } +/** + * When hover starts in one window and continues into the other, there should be a HOVER_EXIT and + * a HOVER_ENTER generated, even if the windows have the same token. This is because the new window + * that the pointer is hovering over may have a different transform. + */ +TEST_F(InputDispatcherMultiWindowSameTokenTests, HoverIntoClone) { + mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mWindow1, mWindow2}}}); + + // Start hover in window 1 + mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_ENTER, AINPUT_SOURCE_TOUCHSCREEN, + ADISPLAY_ID_DEFAULT, {{50, 50}})); + consumeMotionEvent(mWindow1, ACTION_HOVER_ENTER, + {getPointInWindow(mWindow1->getInfo(), PointF{50, 50})}); + + // Move hover to window 2. + mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_TOUCHSCREEN, + ADISPLAY_ID_DEFAULT, {{150, 150}})); + + consumeMotionEvent(mWindow1, ACTION_HOVER_EXIT, {{50, 50}}); + consumeMotionEvent(mWindow1, ACTION_HOVER_ENTER, + {getPointInWindow(mWindow2->getInfo(), PointF{150, 150})}); +} + class InputDispatcherSingleWindowAnr : public InputDispatcherTest { virtual void SetUp() override { InputDispatcherTest::SetUp(); |