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

Commit 51282e86 authored by Byoungho Jung's avatar Byoungho Jung Committed by Prabir Pradhan
Browse files

Pointer icon refactor for touch (base)

When PointerChoreographer is enabled, PointerChoreographer can
create multiple TouchPointerControllers for each touch device
when 'Show taps' is enabled. A TouchPointerController is
reponsible for one touch device and it can show touch spots
on the associated display.

Test: atest libinputservice_test
Bug: 293587049
Change-Id: I1a624a6a50023c530e709cc5fc0704b0b997125b
parent e35a7ead
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -74,6 +74,10 @@ std::shared_ptr<PointerController> PointerController::create(
            controller = std::shared_ptr<PointerController>(
                    new MousePointerController(policy, looper, spriteController, enabled));
            break;
        case ControllerType::TOUCH:
            controller = std::shared_ptr<PointerController>(
                    new TouchPointerController(policy, looper, spriteController, enabled));
            break;
        case ControllerType::LEGACY:
        default:
            controller = std::shared_ptr<PointerController>(
@@ -397,4 +401,13 @@ MousePointerController::MousePointerController(const sp<PointerControllerPolicyI
    PointerController::setPresentation(Presentation::POINTER);
}

// --- TouchPointerController ---

TouchPointerController::TouchPointerController(const sp<PointerControllerPolicyInterface>& policy,
                                               const sp<Looper>& looper,
                                               SpriteController& spriteController, bool enabled)
      : PointerController(policy, looper, spriteController, enabled) {
    PointerController::setPresentation(Presentation::SPOT);
}

} // namespace android
+45 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public:

    void updatePointerIcon(PointerIconStyle iconId);
    void setCustomPointerIcon(const SpriteIcon& icon);
    void setInactivityTimeout(InactivityTimeout inactivityTimeout);
    virtual void setInactivityTimeout(InactivityTimeout inactivityTimeout);
    void doInactivityTimeout();
    void reloadPointerResources();
    void onDisplayViewportsUpdated(const std::vector<DisplayViewport>& viewports);
@@ -154,6 +154,50 @@ public:
    }
};

class TouchPointerController : public PointerController {
public:
    /** A version of PointerController that controls touch spots. */
    TouchPointerController(const sp<PointerControllerPolicyInterface>& policy,
                           const sp<Looper>& looper, SpriteController& spriteController,
                           bool enabled);

    std::optional<FloatRect> getBounds() const override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void move(float, float) override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void setPosition(float, float) override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    FloatPoint getPosition() const override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    int32_t getDisplayId() const override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void fade(Transition) override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void unfade(Transition) override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void setDisplayViewport(const DisplayViewport&) override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void setPresentation(Presentation) override {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void updatePointerIcon(PointerIconStyle) {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    void setCustomPointerIcon(const SpriteIcon&) {
        LOG_ALWAYS_FATAL("Should not be called");
    }
    // fade() should not be called by inactivity timeout. Do nothing.
    void setInactivityTimeout(InactivityTimeout) override {}
};

} // namespace android

#endif // _UI_POINTER_CONTROLLER_H
+5 −0
Original line number Diff line number Diff line
@@ -1293,6 +1293,11 @@ void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled)
}

void NativeInputManager::setShowTouches(bool enabled) {
    if (ENABLE_POINTER_CHOREOGRAPHER) {
        mInputManager->getChoreographer().setShowTouchesEnabled(enabled);
        return;
    }

    { // acquire lock
        std::scoped_lock _l(mLock);