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

Commit c1240726 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge "Touchpad: Cleanup after PointerChoreographer refactor" into main

parents 077c4fb8 8b053510
Loading
Loading
Loading
Loading
+5 −40
Original line number Diff line number Diff line
@@ -47,8 +47,6 @@ namespace android {

namespace {

static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer();

/**
 * Log details of each gesture output by the gestures library.
 * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires
@@ -237,20 +235,13 @@ private:

TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
                                         const InputReaderConfiguration& readerConfig)
      : TouchpadInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {}

TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
                                         const InputReaderConfiguration& readerConfig,
                                         bool enablePointerChoreographer)
      : InputMapper(deviceContext, readerConfig),
        mGestureInterpreter(NewGestureInterpreter(), DeleteGestureInterpreter),
        mPointerController(getContext()->getPointerController(getDeviceId())),
        mTimerProvider(*getContext()),
        mStateConverter(deviceContext, mMotionAccumulator),
        mGestureConverter(*getContext(), deviceContext, getDeviceId()),
        mCapturedEventConverter(*getContext(), deviceContext, mMotionAccumulator, getDeviceId()),
        mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())),
        mEnablePointerChoreographer(enablePointerChoreographer) {
        mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())) {
    RawAbsoluteAxisInfo slotAxisInfo;
    deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT, &slotAxisInfo);
    if (!slotAxisInfo.valid || slotAxisInfo.maxValue <= 0) {
@@ -277,10 +268,6 @@ TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
}

TouchpadInputMapper::~TouchpadInputMapper() {
    if (mPointerController != nullptr) {
        mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
    }

    // The gesture interpreter's destructor will try to free its property and timer providers,
    // calling PropertyProvider::freeProperty and TimerProvider::freeTimer using a raw pointers.
    // Depending on the declaration order in TouchpadInputMapper.h, those providers may have already
@@ -342,33 +329,12 @@ std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when,
            // Only generate events for the associated display.
            mDisplayId = assocViewport->displayId;
            resolvedViewport = *assocViewport;
            if (!mEnablePointerChoreographer) {
                const bool mismatchedPointerDisplay =
                        (assocViewport->displayId != mPointerController->getDisplayId());
                if (mismatchedPointerDisplay) {
                    ALOGW("Touchpad \"%s\" associated viewport display does not match pointer "
                          "controller",
                          mDeviceContext.getName().c_str());
                    mDisplayId.reset();
                }
            }
        } else {
            // The InputDevice is not associated with a viewport, but it controls the mouse pointer.
            if (mEnablePointerChoreographer) {
            // Always use DISPLAY_ID_NONE for touchpad events.
            // PointerChoreographer will make it target the correct the displayId later.
                resolvedViewport =
                        getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
            resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
            mDisplayId = resolvedViewport ? std::make_optional(ADISPLAY_ID_NONE) : std::nullopt;
            } else {
                mDisplayId = mPointerController->getDisplayId();
                if (auto v = config.getDisplayViewportById(*mDisplayId); v) {
                    resolvedViewport = *v;
                }
                if (auto bounds = mPointerController->getBounds(); bounds) {
                    boundsInLogicalDisplay = *bounds;
                }
            }
        }

        mGestureConverter.setDisplayId(mDisplayId);
@@ -422,7 +388,6 @@ std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when,
            // The touchpad is being captured, so we need to tidy up any fake fingers etc. that are
            // still being reported for a gesture in progress.
            out += reset(when);
            mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
        } else {
            // We're transitioning from captured to uncaptured.
            mCapturedEventConverter.reset();
+0 −7
Original line number Diff line number Diff line
@@ -72,10 +72,6 @@ private:
    void resetGestureInterpreter(nsecs_t when);
    explicit TouchpadInputMapper(InputDeviceContext& deviceContext,
                                 const InputReaderConfiguration& readerConfig);
    // Constructor for testing.
    explicit TouchpadInputMapper(InputDeviceContext& deviceContext,
                                 const InputReaderConfiguration& readerConfig,
                                 bool enablePointerChoreographer);
    void updatePalmDetectionMetrics();
    [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime,
                                                          SelfContainedHardwareState schs);
@@ -83,7 +79,6 @@ private:

    std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)>
            mGestureInterpreter;
    std::shared_ptr<PointerControllerInterface> mPointerController;

    PropertyProvider mPropertyProvider;
    TimerProvider mTimerProvider;
@@ -111,8 +106,6 @@ private:
    // Tracking IDs for touches that have at some point been reported as palms by the touchpad.
    std::set<int32_t> mPalmTrackingIds;

    const bool mEnablePointerChoreographer;

    // The display that events generated by this mapper should target. This can be set to
    // ADISPLAY_ID_NONE to target the focused display. If there is no display target (i.e.
    // std::nullopt), all events will be ignored.
+57 −111

File changed.

Preview size limit exceeded, changes collapsed.

+5 −12
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include <list>
#include <memory>

#include <PointerControllerInterface.h>
#include <android/input.h>
#include <utils/Timers.h>

@@ -41,8 +40,7 @@ using std::chrono_literals::operator""ms;
 */
constexpr std::chrono::nanoseconds TAP_ENABLE_DELAY_NANOS = 400ms;

// Converts Gesture structs from the gestures library into NotifyArgs and the appropriate
// PointerController calls.
// Converts Gesture structs from the gestures library into NotifyArgs.
class GestureConverter {
public:
    GestureConverter(InputReaderContext& readerContext, const InputDeviceContext& deviceContext,
@@ -85,18 +83,14 @@ private:
                                                    const Gesture& gesture);
    [[nodiscard]] std::list<NotifyArgs> endPinch(nsecs_t when, nsecs_t readTime);

    [[nodiscard]] std::list<NotifyArgs> enterHover(nsecs_t when, nsecs_t readTime,
                                                   float xCursorPosition, float yCursorPosition);
    [[nodiscard]] std::list<NotifyArgs> exitHover(nsecs_t when, nsecs_t readTime,
                                                  float xCursorPosition, float yCursorPosition);
    [[nodiscard]] std::list<NotifyArgs> enterHover(nsecs_t when, nsecs_t readTime);
    [[nodiscard]] std::list<NotifyArgs> exitHover(nsecs_t when, nsecs_t readTime);

    NotifyMotionArgs makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action,
                                    float xCursorPosition, float yCursorPosition);
    NotifyMotionArgs makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action);

    NotifyMotionArgs makeMotionArgs(nsecs_t when, nsecs_t readTime, int32_t action,
                                    int32_t actionButton, int32_t buttonState,
                                    uint32_t pointerCount, const PointerCoords* pointerCoords,
                                    float xCursorPosition, float yCursorPosition);
                                    uint32_t pointerCount, const PointerCoords* pointerCoords);

    void enableTapToClick(nsecs_t when);
    bool mIsHoverCancelled{false};
@@ -104,7 +98,6 @@ private:

    const int32_t mDeviceId;
    InputReaderContext& mReaderContext;
    std::shared_ptr<PointerControllerInterface> mPointerController;
    const bool mEnableFlingStop;

    std::optional<int32_t> mDisplayId;
+52 −1516

File changed.

Preview size limit exceeded, changes collapsed.

Loading