Loading services/inputflinger/reader/mapper/CursorInputMapper.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading services/inputflinger/tests/CursorInputMapper_test.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -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 = Loading Loading
services/inputflinger/reader/mapper/CursorInputMapper.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading
services/inputflinger/tests/CursorInputMapper_test.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -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 = Loading