Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25615477 authored by Nergi Rahardi's avatar Nergi Rahardi Committed by Android (Google) Code Review
Browse files

Merge "[CD Cursor] Fix invalid displayId set when topology is not yet set" into main

parents 515b2e4a 1396c8ff
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -677,7 +677,13 @@ ui::LogicalDisplayId PointerChoreographer::getTargetMouseDisplayLocked(
        mTopology.graph.find(associatedDisplayId) == mTopology.graph.end()) {
        return associatedDisplayId;
    }
    return mCurrentMouseDisplayId.isValid() ? mCurrentMouseDisplayId : mTopology.primaryDisplayId;
    if (mCurrentMouseDisplayId.isValid()) {
        return mCurrentMouseDisplayId;
    }
    if (mTopology.primaryDisplayId.isValid()) {
        return mTopology.primaryDisplayId;
    }
    return ui::LogicalDisplayId::DEFAULT;
}

std::pair<ui::LogicalDisplayId, PointerControllerInterface&>
@@ -786,7 +792,8 @@ PointerChoreographer::PointerDisplayChange
PointerChoreographer::calculatePointerDisplayChangeToNotify() {
    ui::LogicalDisplayId displayIdToNotify = ui::LogicalDisplayId::INVALID;
    vec2 cursorPosition = {0, 0};
    if (const auto it = mMousePointersByDisplay.find(mCurrentMouseDisplayId);
    if (const auto it =
                mMousePointersByDisplay.find(getTargetMouseDisplayLocked(mCurrentMouseDisplayId));
        it != mMousePointersByDisplay.end()) {
        const auto& pointerController = it->second;
        // Use the displayId from the pointerController, because it accurately reflects whether
+11 −0
Original line number Diff line number Diff line
@@ -361,6 +361,17 @@ TEST_F(PointerChoreographerTest, CallsNotifyPointerDisplayIdChanged) {
    assertPointerDisplayIdNotified(DISPLAY_ID);
}

TEST_F(PointerChoreographerTest, NoDefaultMouseSetFallbackToDefaultDisplayId) {
    mChoreographer.setDisplayViewports(createViewports({ui::LogicalDisplayId::DEFAULT}));
    mChoreographer.notifyInputDevicesChanged(
            {/*id=*/0,
             {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE,
                                     ui::LogicalDisplayId::INVALID)}});
    assertPointerControllerCreated(ControllerType::MOUSE);

    assertPointerDisplayIdNotified(ui::LogicalDisplayId::DEFAULT);
}

TEST_F(PointerChoreographerTest, WhenViewportIsSetLaterCallsNotifyPointerDisplayIdChanged) {
    setDefaultMouseDisplayId(DISPLAY_ID);
    mChoreographer.notifyInputDevicesChanged(