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

Commit 036b105b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topics "cursor_type_hotspot", "set_viewport_in_input_reader" am: 43beafe0

Change-Id: Ib3930377b494bf7bafce339165dff428a30563b6
parents 555e4f25 43beafe0
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -99,6 +99,16 @@ std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewportByPor
    return std::nullopt;
}

std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewportById(
        int32_t displayId) const {
    for (const DisplayViewport& currentViewport : mDisplays) {
        if (currentViewport.displayId == displayId) {
            return std::make_optional(currentViewport);
        }
    }
    return std::nullopt;
}

void InputReaderConfiguration::setDisplayViewports(const std::vector<DisplayViewport>& viewports) {
    mDisplays = viewports;
}
+5 −1
Original line number Diff line number Diff line
@@ -172,6 +172,9 @@ struct InputReaderConfiguration {
    // Used to determine which DisplayViewport should be tied to which InputDevice.
    std::unordered_map<std::string, uint8_t> portAssociations;

    // The suggested display ID to show the cursor.
    int32_t defaultPointerDisplayId;

    // Velocity control parameters for mouse pointer movements.
    VelocityControlParameters pointerVelocityControlParameters;

@@ -274,6 +277,7 @@ struct InputReaderConfiguration {
    std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueDisplayId)
            const;
    std::optional<DisplayViewport> getDisplayViewportByPort(uint8_t physicalPort) const;
    std::optional<DisplayViewport> getDisplayViewportById(int32_t displayId) const;
    void setDisplayViewports(const std::vector<DisplayViewport>& viewports);


+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H
#define _INPUTFLINGER_POINTER_CONTROLLER_INTERFACE_H

#include <input/DisplayViewport.h>
#include <input/Input.h>
#include <utils/BitSet.h>
#include <utils/RefBase.h>
@@ -101,6 +102,9 @@ public:

    /* Gets the id of the display where the pointer should be shown. */
    virtual int32_t getDisplayId() const = 0;

    /* Sets the associated display of this pointer. Pointer should show on that display. */
    virtual void setDisplayViewport(const DisplayViewport& displayViewport) = 0;
};

} // namespace android
+21 −1
Original line number Diff line number Diff line
@@ -189,12 +189,32 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration*

        // Update the PointerController if viewports changed.
        if (mParameters.mode == Parameters::MODE_POINTER) {
            getPolicy()->obtainPointerController(getDeviceId());
            updatePointerControllerDisplayViewport(*config);
        }
        bumpGeneration();
    }
}

void CursorInputMapper::updatePointerControllerDisplayViewport(
        const InputReaderConfiguration& config) {
    std::optional<DisplayViewport> viewport =
            config.getDisplayViewportById(config.defaultPointerDisplayId);
    if (!viewport) {
        ALOGW("Can't find the designated viewport with ID %" PRId32 " to update cursor input "
              "mapper. Fall back to default display",
              config.defaultPointerDisplayId);
        viewport = config.getDisplayViewportById(ADISPLAY_ID_DEFAULT);
    }

    if (!viewport) {
        ALOGE("Still can't find a viable viewport to update cursor input mapper. Skip setting it to"
              " PointerController.");
        return;
    }

    mPointerController->setDisplayViewport(*viewport);
}

void CursorInputMapper::configureParameters() {
    mParameters.mode = Parameters::MODE_POINTER;
    String8 cursorModeString;
+2 −1
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ private:
    void dumpParameters(std::string& dump);

    void sync(nsecs_t when);
    void updatePointerControllerDisplayViewport(const InputReaderConfiguration& config);
};

} // namespace android
Loading