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

Commit a3980a52 authored by nergi's avatar nergi
Browse files

Fix xScale and yScale not reset when scaling is disabled

Bug: 367662715
Test: atest inputflinger_tests
Flag: com.android.input.flags.scale_cursor_speed_with_dpi

Change-Id: Iebdc2bcb74c9426492a647dc0c59ce81c49e1e6d
parent 7214597d
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -517,11 +517,11 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura
    bool disableAllScaling = config.displaysWithMouseScalingDisabled.count(
    bool disableAllScaling = config.displaysWithMouseScalingDisabled.count(
                                     mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) != 0;
                                     mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) != 0;


    if (InputFlags::scaleCursorSpeedWithDisplayDensity() &&
    if (mParameters.mode == Parameters::Mode::POINTER) {
        mParameters.mode == Parameters::Mode::POINTER && !disableAllScaling) {
        // TODO(b/408170793): We use ACONFIGURATION_DENSITY_XHIGH as baseline for scale due to
        // TODO(b/408170793): We use ACONFIGURATION_DENSITY_XHIGH as baseline for scale due to
        // legacy reasons, this need to be tuned with further UX testing.
        // legacy reasons, this need to be tuned with further UX testing.
        mXScale = mYScale = isDensityValueSupportedForScaling(mViewportDensityDpi)
        mXScale = mYScale = InputFlags::scaleCursorSpeedWithDisplayDensity() &&
                        !disableAllScaling && isDensityValueSupportedForScaling(mViewportDensityDpi)
                ? static_cast<float>(mViewportDensityDpi) /
                ? static_cast<float>(mViewportDensityDpi) /
                        static_cast<float>(ACONFIGURATION_DENSITY_XHIGH)
                        static_cast<float>(ACONFIGURATION_DENSITY_XHIGH)
                : 1.0;
                : 1.0;
+25 −0
Original line number Original line Diff line number Diff line
@@ -1293,6 +1293,31 @@ TEST_F(DensityDependentCursorUnitTest,
                              WithRelativeMotion(rawRelativeX, rawRelativeY)))));
                              WithRelativeMotion(rawRelativeX, rawRelativeY)))));
}
}


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

    std::list<NotifyArgs> args;
    // Disables scaling
    mReaderConfiguration.displaysWithMouseScalingDisabled.emplace(DISPLAY_ID);
    args += mMapper->reconfigure(ARBITRARY_TIME, mReaderConfiguration,
                                 InputReaderConfiguration::Change::POINTER_SPEED);
    args.clear();

    const int32_t rawRelativeX = 10;
    const int32_t rawRelativeY = 20;
    args += processRelativeMove(rawRelativeX, rawRelativeY);
    ASSERT_THAT(args,
                ElementsAre(VariantWith<NotifyMotionArgs>(
                        AllOf(WithMotionAction(HOVER_MOVE),
                              WithRelativeMotion(rawRelativeX, rawRelativeY)))));
}

TEST_F(DensityDependentCursorUnitTest, DoesNotScaleCursorMoveWithPointerCaptureEnabled) {
TEST_F(DensityDependentCursorUnitTest, DoesNotScaleCursorMoveWithPointerCaptureEnabled) {
    // Create a medium density viewport, that should have scaling enabled by default.
    // Create a medium density viewport, that should have scaling enabled by default.
    DisplayViewport mediumDensityViewport =
    DisplayViewport mediumDensityViewport =