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

Commit f61c6dd7 authored by Arpit Singh's avatar Arpit Singh
Browse files

Disable density based scaling on pointer capture

Disable display density based mouse scaling on pointer capture request.

Test: atest inputflinger_tests
Bug: 367662715
Flag: com.android.input.flags.scale_cursor_speed_with_dpi
Change-Id: I028435d51be10760407ac675e267b25d535594ce
parent 7c5fb4b2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -510,6 +510,7 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura
        mPointerVelocityControl.setAccelerationEnabled(false);
        mWheelXVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
        mWheelYVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
        mXScale = mYScale = 1.0;
        return;
    }

+26 −0
Original line number Diff line number Diff line
@@ -1293,6 +1293,32 @@ TEST_F(DensityDependentCursorUnitTest,
                              WithRelativeMotion(rawRelativeX, rawRelativeY)))));
}

TEST_F(DensityDependentCursorUnitTest, DoesNotScaleCursorMoveWithPointerCaptureEnabled) {
    // Create a medium density viewport, that should have scaling enabled by default.
    DisplayViewport mediumDensityViewport =
            createPrimaryViewport(ui::Rotation::Rotation0, ACONFIGURATION_DENSITY_MEDIUM);
    mReaderConfiguration.setDisplayViewports({mediumDensityViewport});
    EXPECT_CALL((*mDevice), getAssociatedViewport).WillRepeatedly(Return(mediumDensityViewport));
    mMapper = createInputMapper<CursorInputMapper>(*mDeviceContext, mReaderConfiguration);

    // Request pointer capture after the mapper has been configured.
    setPointerCapture(true);

    // Verify pointer capture has been enabled.
    const int32_t rawRelativeX = 10;
    const int32_t rawRelativeY = 20;
    std::list<NotifyArgs> args;
    args += processRelativeMove(rawRelativeX, rawRelativeY);
    ASSERT_THAT(args,
                ElementsAre(VariantWith<NotifyMotionArgs>(
                        AllOf(WithMotionAction(ACTION_MOVE),
                              WithSource(AINPUT_SOURCE_MOUSE_RELATIVE),
                              WithCoords(rawRelativeX, rawRelativeY),
                              WithRelativeMotion(rawRelativeX, rawRelativeY),
                              WithCursorPosition(INVALID_CURSOR_POSITION,
                                                 INVALID_CURSOR_POSITION)))));
}

namespace {

// Minimum timestamp separation between subsequent input events from a Bluetooth device.