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

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

Merge "Fix xScale and yScale not reset when scaling is disabled" into main

parents 2fe4e6f9 a3980a52
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -517,11 +517,11 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura
    bool disableAllScaling = config.displaysWithMouseScalingDisabled.count(
                                     mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) != 0;

    if (InputFlags::scaleCursorSpeedWithDisplayDensity() &&
        mParameters.mode == Parameters::Mode::POINTER && !disableAllScaling) {
    if (mParameters.mode == Parameters::Mode::POINTER) {
        // 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.
        mXScale = mYScale = isDensityValueSupportedForScaling(mViewportDensityDpi)
        mXScale = mYScale = InputFlags::scaleCursorSpeedWithDisplayDensity() &&
                        !disableAllScaling && isDensityValueSupportedForScaling(mViewportDensityDpi)
                ? static_cast<float>(mViewportDensityDpi) /
                        static_cast<float>(ACONFIGURATION_DENSITY_XHIGH)
                : 1.0;
+25 −0
Original line number Diff line number Diff line
@@ -1293,6 +1293,31 @@ TEST_F(DensityDependentCursorUnitTest,
                              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) {
    // Create a medium density viewport, that should have scaling enabled by default.
    DisplayViewport mediumDensityViewport =