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

Commit 26627094 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "PointerChoreographer: Starting stylus hover gesture should fade mouse" into main

parents f4fb3287 fac4d252
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -476,6 +476,14 @@ void PointerChoreographer::processStylusHoverEventLocked(const NotifyMotionArgs&
                     << args.dump();
    }

    // Fade the mouse pointer on the display if there is one when the stylus starts hovering.
    if (args.action == AMOTION_EVENT_ACTION_HOVER_ENTER) {
        if (const auto it = mMousePointersByDisplay.find(args.displayId);
            it != mMousePointersByDisplay.end()) {
            it->second->fade(PointerControllerInterface::Transition::GRADUAL);
        }
    }

    // Get the stylus pointer controller for the device, or create one if it doesn't exist.
    auto [it, controllerAdded] =
            mStylusPointersByDevice.try_emplace(args.deviceId,
+28 −0
Original line number Diff line number Diff line
@@ -1008,6 +1008,34 @@ TEST_F(PointerChoreographerTest, ShowTouchesOverridesUnspecifiedStylusIcon) {
    pc->assertPointerIconSet(PointerIconStyle::TYPE_SPOT_HOVER);
}

TEST_F(PointerChoreographerTest, StylusHoverEnterFadesMouseOnDisplay) {
    // Make sure there are PointerControllers for a mouse and a stylus.
    mChoreographer.setStylusPointerIconEnabled(true);
    mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID);
    mChoreographer.notifyInputDevicesChanged(
            {/*id=*/0,
             {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID),
              generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_STYLUS, DISPLAY_ID)}});
    mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID}));
    mChoreographer.notifyMotion(
            MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
                    .pointer(MOUSE_POINTER)
                    .deviceId(DEVICE_ID)
                    .displayId(ui::LogicalDisplayId::INVALID)
                    .build());
    auto mousePc = assertPointerControllerCreated(ControllerType::MOUSE);
    ASSERT_TRUE(mousePc->isPointerShown());

    // Start hovering with a stylus. This should fade the mouse cursor.
    mChoreographer.notifyMotion(
            MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
                    .pointer(STYLUS_POINTER)
                    .deviceId(SECOND_DEVICE_ID)
                    .displayId(DISPLAY_ID)
                    .build());
    ASSERT_FALSE(mousePc->isPointerShown());
}

using StylusFixtureParam =
        std::tuple</*name*/ std::string_view, /*source*/ uint32_t, ControllerType>;