Loading services/inputflinger/PointerChoreographer.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -407,7 +407,8 @@ void PointerChoreographer::processStylusHoverEventLocked(const NotifyMotionArgs& // TODO(b/315815559): Do not fade and reset the icon if the hover exit will be followed // immediately by a DOWN event. pc.fade(PointerControllerInterface::Transition::IMMEDIATE); pc.updatePointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED); pc.updatePointerIcon(mShowTouchesEnabled ? PointerIconStyle::TYPE_SPOT_HOVER : PointerIconStyle::TYPE_NOT_SPECIFIED); } else if (canUnfadeOnDisplay(args.displayId)) { pc.unfade(PointerControllerInterface::Transition::IMMEDIATE); } Loading Loading @@ -792,6 +793,13 @@ bool PointerChoreographer::setPointerIcon( if (isFromSource(sources, AINPUT_SOURCE_STYLUS)) { auto it = mStylusPointersByDevice.find(deviceId); if (it != mStylusPointersByDevice.end()) { if (mShowTouchesEnabled) { // If an app doesn't override the icon for the hovering stylus, show the hover icon. auto* style = std::get_if<PointerIconStyle>(&icon); if (style != nullptr && *style == PointerIconStyle::TYPE_NOT_SPECIFIED) { *style = PointerIconStyle::TYPE_SPOT_HOVER; } } setIconForController(icon, *it->second); return true; } Loading services/inputflinger/tests/PointerChoreographer_test.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -978,6 +978,36 @@ TEST_F(PointerChoreographerTest, WhenTouchDeviceIsResetClearsSpots) { assertPointerControllerRemoved(pc); } /** * When both "show touches" and "stylus hover icons" are enabled, if the app doesn't specify an * icon for the hovering stylus, fall back to using the spot hover icon. */ TEST_F(PointerChoreographerTest, ShowTouchesOverridesUnspecifiedStylusIcon) { mChoreographer.setShowTouchesEnabled(true); mChoreographer.setStylusPointerIconEnabled(true); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS, DISPLAY_ID)}}); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); auto pc = assertPointerControllerCreated(ControllerType::STYLUS); mChoreographer.setPointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED, DISPLAY_ID, DEVICE_ID); pc->assertPointerIconSet(PointerIconStyle::TYPE_SPOT_HOVER); mChoreographer.setPointerIcon(PointerIconStyle::TYPE_ARROW, DISPLAY_ID, DEVICE_ID); pc->assertPointerIconSet(PointerIconStyle::TYPE_ARROW); mChoreographer.setPointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED, DISPLAY_ID, DEVICE_ID); pc->assertPointerIconSet(PointerIconStyle::TYPE_SPOT_HOVER); } using StylusFixtureParam = std::tuple</*name*/ std::string_view, /*source*/ uint32_t, ControllerType>; Loading Loading
services/inputflinger/PointerChoreographer.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -407,7 +407,8 @@ void PointerChoreographer::processStylusHoverEventLocked(const NotifyMotionArgs& // TODO(b/315815559): Do not fade and reset the icon if the hover exit will be followed // immediately by a DOWN event. pc.fade(PointerControllerInterface::Transition::IMMEDIATE); pc.updatePointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED); pc.updatePointerIcon(mShowTouchesEnabled ? PointerIconStyle::TYPE_SPOT_HOVER : PointerIconStyle::TYPE_NOT_SPECIFIED); } else if (canUnfadeOnDisplay(args.displayId)) { pc.unfade(PointerControllerInterface::Transition::IMMEDIATE); } Loading Loading @@ -792,6 +793,13 @@ bool PointerChoreographer::setPointerIcon( if (isFromSource(sources, AINPUT_SOURCE_STYLUS)) { auto it = mStylusPointersByDevice.find(deviceId); if (it != mStylusPointersByDevice.end()) { if (mShowTouchesEnabled) { // If an app doesn't override the icon for the hovering stylus, show the hover icon. auto* style = std::get_if<PointerIconStyle>(&icon); if (style != nullptr && *style == PointerIconStyle::TYPE_NOT_SPECIFIED) { *style = PointerIconStyle::TYPE_SPOT_HOVER; } } setIconForController(icon, *it->second); return true; } Loading
services/inputflinger/tests/PointerChoreographer_test.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -978,6 +978,36 @@ TEST_F(PointerChoreographerTest, WhenTouchDeviceIsResetClearsSpots) { assertPointerControllerRemoved(pc); } /** * When both "show touches" and "stylus hover icons" are enabled, if the app doesn't specify an * icon for the hovering stylus, fall back to using the spot hover icon. */ TEST_F(PointerChoreographerTest, ShowTouchesOverridesUnspecifiedStylusIcon) { mChoreographer.setShowTouchesEnabled(true); mChoreographer.setStylusPointerIconEnabled(true); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS, DISPLAY_ID)}}); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); auto pc = assertPointerControllerCreated(ControllerType::STYLUS); mChoreographer.setPointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED, DISPLAY_ID, DEVICE_ID); pc->assertPointerIconSet(PointerIconStyle::TYPE_SPOT_HOVER); mChoreographer.setPointerIcon(PointerIconStyle::TYPE_ARROW, DISPLAY_ID, DEVICE_ID); pc->assertPointerIconSet(PointerIconStyle::TYPE_ARROW); mChoreographer.setPointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED, DISPLAY_ID, DEVICE_ID); pc->assertPointerIconSet(PointerIconStyle::TYPE_SPOT_HOVER); } using StylusFixtureParam = std::tuple</*name*/ std::string_view, /*source*/ uint32_t, ControllerType>; Loading