Skip to content

Commit 2ed31c0

Browse files
Priyanka Advani (xWF)Android (Google) Code Review
authored andcommitted
Merge "Revert "[3/n CD Cursor] Enable cross-display mouse gestures"" into main
2 parents 0635155 + a6a2ac9 commit 2ed31c0

4 files changed

Lines changed: 15 additions & 141 deletions

File tree

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,7 @@ InputDispatcher::DispatcherTouchState::findTouchedWindowTargets(
23982398
// Copy current touch state into tempTouchState.
23992399
// This state will be used to update saved touch state at the end of this function.
24002400
// If no state for the specified display exists, then our initial state will be empty.
2401-
const TouchState* oldState = getTouchStateForMotionEntry(entry, windowInfos);
2401+
const TouchState* oldState = getTouchStateForMotionEntry(entry);
24022402
TouchState tempTouchState;
24032403
if (oldState != nullptr) {
24042404
tempTouchState = *oldState;
@@ -2787,9 +2787,9 @@ InputDispatcher::DispatcherTouchState::findTouchedWindowTargets(
27872787
if (maskedAction != AMOTION_EVENT_ACTION_SCROLL) {
27882788
if (displayId >= ui::LogicalDisplayId::DEFAULT) {
27892789
tempTouchState.clearWindowsWithoutPointers();
2790-
saveTouchStateForMotionEntry(entry, std::move(tempTouchState), windowInfos);
2790+
saveTouchStateForMotionEntry(entry, std::move(tempTouchState));
27912791
} else {
2792-
eraseTouchStateForMotionEntry(entry, windowInfos);
2792+
eraseTouchStateForMotionEntry(entry);
27932793
}
27942794
}
27952795

@@ -5182,14 +5182,6 @@ ui::Transform InputDispatcher::DispatcherWindowInfo::getRawTransform(
51825182
: getDisplayTransform(windowInfo.displayId);
51835183
}
51845184

5185-
ui::LogicalDisplayId InputDispatcher::DispatcherWindowInfo::getPrimaryDisplayId(
5186-
ui::LogicalDisplayId displayId) const {
5187-
if (mTopology.graph.contains(displayId)) {
5188-
return mTopology.primaryDisplayId;
5189-
}
5190-
return displayId;
5191-
}
5192-
51935185
std::string InputDispatcher::DispatcherWindowInfo::dumpDisplayAndWindowInfo() const {
51945186
std::string dump;
51955187
if (!mWindowHandlesByDisplay.empty()) {
@@ -7483,37 +7475,32 @@ void InputDispatcher::DispatcherTouchState::clear() {
74837475

74847476
void InputDispatcher::DispatcherTouchState::saveTouchStateForMotionEntry(
74857477
const android::inputdispatcher::MotionEntry& entry,
7486-
android::inputdispatcher::TouchState&& touchState,
7487-
const DispatcherWindowInfo& windowInfos) {
7478+
android::inputdispatcher::TouchState&& touchState) {
74887479
if (touchState.windows.empty()) {
7489-
eraseTouchStateForMotionEntry(entry, windowInfos);
7480+
eraseTouchStateForMotionEntry(entry);
74907481
return;
74917482
}
74927483

74937484
if (USE_TOPOLOGY && isMouseOrTouchpad(entry.source)) {
7494-
mCursorStateByDisplay[windowInfos.getPrimaryDisplayId(entry.displayId)] =
7495-
std::move(touchState);
7485+
mCursorStateByDisplay[entry.displayId] = std::move(touchState);
74967486
} else {
74977487
mTouchStatesByDisplay[entry.displayId] = std::move(touchState);
74987488
}
74997489
}
75007490

75017491
void InputDispatcher::DispatcherTouchState::eraseTouchStateForMotionEntry(
7502-
const android::inputdispatcher::MotionEntry& entry,
7503-
const DispatcherWindowInfo& windowInfos) {
7492+
const android::inputdispatcher::MotionEntry& entry) {
75047493
if (USE_TOPOLOGY && isMouseOrTouchpad(entry.source)) {
7505-
mCursorStateByDisplay.erase(windowInfos.getPrimaryDisplayId(entry.displayId));
7494+
mCursorStateByDisplay.erase(entry.displayId);
75067495
} else {
75077496
mTouchStatesByDisplay.erase(entry.displayId);
75087497
}
75097498
}
75107499

75117500
const TouchState* InputDispatcher::DispatcherTouchState::getTouchStateForMotionEntry(
7512-
const android::inputdispatcher::MotionEntry& entry,
7513-
const DispatcherWindowInfo& windowInfos) const {
7501+
const android::inputdispatcher::MotionEntry& entry) const {
75147502
if (USE_TOPOLOGY && isMouseOrTouchpad(entry.source)) {
7515-
auto touchStateIt =
7516-
mCursorStateByDisplay.find(windowInfos.getPrimaryDisplayId(entry.displayId));
7503+
auto touchStateIt = mCursorStateByDisplay.find(entry.displayId);
75177504
if (touchStateIt != mCursorStateByDisplay.end()) {
75187505
return &touchStateIt->second;
75197506
}

services/inputflinger/dispatcher/InputDispatcher.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ class InputDispatcher : public android::InputDispatcherInterface {
336336

337337
bool isTouchTrusted(const TouchOcclusionInfo& occlusionInfo) const;
338338

339-
// Returns topology's primary display if the display belongs to it, otherwise the
340-
// same displayId.
341-
ui::LogicalDisplayId getPrimaryDisplayId(ui::LogicalDisplayId displayId) const;
342-
343339
std::string dumpDisplayAndWindowInfo() const;
344340

345341
private:
@@ -470,15 +466,12 @@ class InputDispatcher : public android::InputDispatcherInterface {
470466
ftl::Flags<InputTarget::Flags> newTargetFlags,
471467
const DispatcherWindowInfo& windowInfos, const ConnectionManager& connections);
472468

473-
void saveTouchStateForMotionEntry(const MotionEntry& entry, TouchState&& touchState,
474-
const DispatcherWindowInfo& windowInfos);
469+
void saveTouchStateForMotionEntry(const MotionEntry& entry, TouchState&& touchState);
475470

476-
void eraseTouchStateForMotionEntry(const MotionEntry& entry,
477-
const DispatcherWindowInfo& windowInfos);
471+
void eraseTouchStateForMotionEntry(const MotionEntry& entry);
478472

479473
const TouchState* getTouchStateForMotionEntry(
480-
const android::inputdispatcher::MotionEntry& entry,
481-
const DispatcherWindowInfo& windowInfos) const;
474+
const android::inputdispatcher::MotionEntry& entry) const;
482475

483476
bool canWindowReceiveMotion(const sp<gui::WindowInfoHandle>& window,
484477
const MotionEntry& motionEntry,

services/inputflinger/dispatcher/InputState.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@
2424

2525
namespace android::inputdispatcher {
2626

27-
namespace {
28-
29-
const bool USE_TOPOLOGY = com::android::input::flags::connected_displays_cursor();
30-
31-
bool isMouseOrTouchpad(uint32_t sources) {
32-
// Check if this is a mouse or touchpad, but not a drawing tablet.
33-
return isFromSource(sources, AINPUT_SOURCE_MOUSE_RELATIVE) ||
34-
(isFromSource(sources, AINPUT_SOURCE_MOUSE) &&
35-
!isFromSource(sources, AINPUT_SOURCE_STYLUS));
36-
}
37-
38-
} // namespace
39-
4027
InputState::InputState(const IdGenerator& idGenerator) : mIdGenerator(idGenerator) {}
4128

4229
InputState::~InputState() {}
@@ -234,14 +221,10 @@ ssize_t InputState::findKeyMemento(const KeyEntry& entry) const {
234221
}
235222

236223
ssize_t InputState::findMotionMemento(const MotionEntry& entry, bool hovering) const {
237-
// If we have connected displays a mouse can move between displays and displayId may change
238-
// while a gesture is in-progress.
239-
const bool skipDisplayCheck = USE_TOPOLOGY && isMouseOrTouchpad(entry.source);
240224
for (size_t i = 0; i < mMotionMementos.size(); i++) {
241225
const MotionMemento& memento = mMotionMementos[i];
242226
if (memento.deviceId == entry.deviceId && memento.source == entry.source &&
243-
memento.hovering == hovering &&
244-
(skipDisplayCheck || memento.displayId == entry.displayId)) {
227+
memento.displayId == entry.displayId && memento.hovering == hovering) {
245228
return i;
246229
}
247230
}
@@ -355,9 +338,7 @@ bool InputState::shouldCancelPreviousStream(const MotionEntry& motionEntry) cons
355338
// would receive different events from each display. Since the TouchStates are per-display,
356339
// it's unlikely that those two streams would be consistent with each other. Therefore,
357340
// cancel the previous gesture if the display id changes.
358-
// Except when we have connected-displays where a mouse may move across display boundaries.
359-
const bool skipDisplayCheck = (USE_TOPOLOGY && isMouseOrTouchpad(motionEntry.source));
360-
if (!skipDisplayCheck && motionEntry.displayId != lastMemento.displayId) {
341+
if (motionEntry.displayId != lastMemento.displayId) {
361342
LOG(INFO) << "Canceling stream: last displayId was " << lastMemento.displayId
362343
<< " and new event is " << motionEntry;
363344
return true;

services/inputflinger/tests/InputDispatcher_test.cpp

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -15185,91 +15185,4 @@ TEST_P(TransferOrDontTransferFixture, MouseAndTouchTransferSimultaneousMultiDevi
1518515185

1518615186
INSTANTIATE_TEST_SUITE_P(WithAndWithoutTransfer, TransferOrDontTransferFixture, testing::Bool());
1518715187

15188-
class InputDispatcherConnectedDisplayTest : public InputDispatcherTest {
15189-
constexpr static int DENSITY_MEDIUM = 160;
15190-
15191-
const DisplayTopologyGraph
15192-
mTopology{.primaryDisplayId = DISPLAY_ID,
15193-
.graph = {{DISPLAY_ID,
15194-
{{SECOND_DISPLAY_ID, DisplayTopologyPosition::TOP, 0.0f}}},
15195-
{SECOND_DISPLAY_ID,
15196-
{{DISPLAY_ID, DisplayTopologyPosition::BOTTOM, 0.0f}}}},
15197-
.displaysDensity = {{DISPLAY_ID, DENSITY_MEDIUM},
15198-
{SECOND_DISPLAY_ID, DENSITY_MEDIUM}}};
15199-
15200-
protected:
15201-
sp<FakeWindowHandle> mWindow;
15202-
15203-
void SetUp() override {
15204-
InputDispatcherTest::SetUp();
15205-
mDispatcher->setDisplayTopology(mTopology);
15206-
mWindow = sp<FakeWindowHandle>::make(std::make_shared<FakeApplicationHandle>(), mDispatcher,
15207-
"Window", DISPLAY_ID);
15208-
mWindow->setFrame({0, 0, 100, 100});
15209-
15210-
mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
15211-
}
15212-
};
15213-
15214-
TEST_F(InputDispatcherConnectedDisplayTest, MultiDisplayMouseGesture) {
15215-
SCOPED_FLAG_OVERRIDE(connected_displays_cursor, true);
15216-
15217-
// pointer-down
15218-
mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE)
15219-
.displayId(DISPLAY_ID)
15220-
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15221-
.pointer(PointerBuilder(0, ToolType::MOUSE).x(60).y(60))
15222-
.build());
15223-
mWindow->consumeMotionEvent(
15224-
AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(DISPLAY_ID), WithRawCoords(60, 60)));
15225-
15226-
mDispatcher->notifyMotion(
15227-
MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
15228-
.displayId(DISPLAY_ID)
15229-
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15230-
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
15231-
.pointer(PointerBuilder(0, ToolType::MOUSE).x(60).y(60))
15232-
.build());
15233-
mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
15234-
WithDisplayId(DISPLAY_ID), WithRawCoords(60, 60)));
15235-
15236-
// pointer-move
15237-
mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_MOUSE)
15238-
.displayId(DISPLAY_ID)
15239-
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15240-
.pointer(PointerBuilder(0, ToolType::MOUSE).x(60).y(60))
15241-
.build());
15242-
mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
15243-
WithDisplayId(DISPLAY_ID), WithRawCoords(60, 60)));
15244-
15245-
// pointer-move with different display
15246-
// TODO (b/383092013): by default windows will not be topology aware and receive events as it
15247-
// was in the same display. This behaviour has not been implemented yet.
15248-
mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_MOUSE)
15249-
.displayId(SECOND_DISPLAY_ID)
15250-
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15251-
.pointer(PointerBuilder(0, ToolType::MOUSE).x(70).y(70))
15252-
.build());
15253-
mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
15254-
WithDisplayId(SECOND_DISPLAY_ID), WithRawCoords(70, 70)));
15255-
15256-
// pointer-up
15257-
mDispatcher->notifyMotion(
15258-
MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_RELEASE, AINPUT_SOURCE_MOUSE)
15259-
.displayId(SECOND_DISPLAY_ID)
15260-
.buttonState(0)
15261-
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
15262-
.pointer(PointerBuilder(0, ToolType::MOUSE).x(70).y(70))
15263-
.build());
15264-
mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
15265-
WithDisplayId(SECOND_DISPLAY_ID), WithRawCoords(70, 70)));
15266-
15267-
mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_MOUSE)
15268-
.displayId(SECOND_DISPLAY_ID)
15269-
.buttonState(0)
15270-
.pointer(PointerBuilder(0, ToolType::MOUSE).x(70).y(70))
15271-
.build());
15272-
mWindow->consumeMotionUp(SECOND_DISPLAY_ID);
15273-
}
15274-
1527515188
} // namespace android::inputdispatcher

0 commit comments

Comments
 (0)