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

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

Merge "Move PointerController enums to enum classes."

parents 1aefc1fd ca5bede6
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -59,11 +59,11 @@ public:
    /* Gets the absolute location of the pointer. */
    virtual void getPosition(float* outX, float* outY) const = 0;

    enum Transition {
    enum class Transition {
        // Fade/unfade immediately.
        TRANSITION_IMMEDIATE,
        IMMEDIATE,
        // Fade/unfade gradually.
        TRANSITION_GRADUAL,
        GRADUAL,
    };

    /* Fades the pointer out now. */
@@ -75,11 +75,11 @@ public:
     * wants to ensure that the pointer becomes visible again. */
    virtual void unfade(Transition transition) = 0;

    enum Presentation {
    enum class Presentation {
        // Show the mouse pointer.
        PRESENTATION_POINTER,
        POINTER,
        // Show spots and a spot anchor in place of the mouse pointer.
        PRESENTATION_SPOT,
        SPOT,
    };

    /* Sets the mode of the pointer controller. */
+1 −1
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ void InputReader::updatePointerDisplayLocked() {
void InputReader::fadePointerLocked() {
    std::shared_ptr<PointerControllerInterface> controller = mPointerController.lock();
    if (controller != nullptr) {
        controller->fade(PointerControllerInterface::TRANSITION_GRADUAL);
        controller->fade(PointerControllerInterface::Transition::GRADUAL);
    }
}

+4 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include "CursorButtonAccumulator.h"
#include "CursorScrollAccumulator.h"
#include "PointerControllerInterface.h"
#include "TouchCursorInputMapperCommon.h"

namespace android {
@@ -154,7 +155,7 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration*
                mParameters.mode = Parameters::MODE_POINTER_RELATIVE;
                mSource = AINPUT_SOURCE_MOUSE_RELATIVE;
                // Keep PointerController around in order to preserve the pointer position.
                mPointerController->fade(PointerControllerInterface::TRANSITION_IMMEDIATE);
                mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
            } else {
                ALOGE("Cannot request pointer capture, device is not in MODE_POINTER");
            }
@@ -316,7 +317,7 @@ void CursorInputMapper::sync(nsecs_t when) {
    float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
    if (mSource == AINPUT_SOURCE_MOUSE) {
        if (moved || scrolled || buttonsChanged) {
            mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER);
            mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);

            if (moved) {
                mPointerController->move(deltaX, deltaY);
@@ -326,7 +327,7 @@ void CursorInputMapper::sync(nsecs_t when) {
                mPointerController->setButtonState(currentButtonState);
            }

            mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
            mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
        }

        mPointerController->getPosition(&xCursorPosition, &yCursorPosition);
+13 −13
Original line number Diff line number Diff line
@@ -1383,7 +1383,7 @@ void TouchInputMapper::reset(nsecs_t when) {
    resetExternalStylus();

    if (mPointerController != nullptr) {
        mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
        mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
        mPointerController->clearSpots();
    }

@@ -1589,8 +1589,8 @@ void TouchInputMapper::cookAndDispatch(nsecs_t when) {
    } else {
        if (mDeviceMode == DEVICE_MODE_DIRECT && mConfig.showTouches &&
            mPointerController != nullptr) {
            mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_SPOT);
            mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
            mPointerController->setPresentation(PointerControllerInterface::Presentation::SPOT);
            mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);

            mPointerController->setButtonState(mCurrentRawState.buttonState);
            mPointerController->setSpots(mCurrentCookedState.cookedPointerData.pointerCoords,
@@ -2327,7 +2327,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag

    // Update the pointer presentation and spots.
    if (mParameters.gestureMode == Parameters::GESTURE_MODE_MULTI_TOUCH) {
        mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER);
        mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
        if (finishPreviousGesture || cancelPreviousGesture) {
            mPointerController->clearSpots();
        }
@@ -2339,7 +2339,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
                                         mPointerController->getDisplayId());
        }
    } else {
        mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER);
        mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
    }

    // Show or hide the pointer if needed.
@@ -2349,7 +2349,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
            if (mParameters.gestureMode == Parameters::GESTURE_MODE_MULTI_TOUCH &&
                mPointerGesture.lastGestureMode == PointerGesture::FREEFORM) {
                // Remind the user of where the pointer is after finishing a gesture with spots.
                mPointerController->unfade(PointerControllerInterface::TRANSITION_GRADUAL);
                mPointerController->unfade(PointerControllerInterface::Transition::GRADUAL);
            }
            break;
        case PointerGesture::TAP:
@@ -2360,15 +2360,15 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
        case PointerGesture::SWIPE:
            // Unfade the pointer when the current gesture manipulates the
            // area directly under the pointer.
            mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
            mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
            break;
        case PointerGesture::FREEFORM:
            // Fade the pointer when the current gesture manipulates a different
            // area and there are spots to guide the user experience.
            if (mParameters.gestureMode == Parameters::GESTURE_MODE_MULTI_TOUCH) {
                mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
                mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
            } else {
                mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
                mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
            }
            break;
    }
@@ -2537,7 +2537,7 @@ void TouchInputMapper::abortPointerGestures(nsecs_t when, uint32_t policyFlags)

    // Remove any current spots.
    if (mPointerController != nullptr) {
        mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
        mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
        mPointerController->clearSpots();
    }
}
@@ -3396,12 +3396,12 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
    int32_t displayId = mViewport.displayId;

    if (down || hovering) {
        mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER);
        mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
        mPointerController->clearSpots();
        mPointerController->setButtonState(mCurrentRawState.buttonState);
        mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
        mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
    } else if (!down && !hovering && (mPointerSimple.down || mPointerSimple.hovering)) {
        mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
        mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
    }
    displayId = mPointerController->getDisplayId();