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

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

Merge "Clean up after enabling per-window-input-rotation"

parents 72e31500 8b89c2f2
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ cc_defaults {
        "libui",
        "lib-platform-compat-native-api",
        "server_configurable_flags",
        "InputFlingerProperties",
    ],
    static_libs: [
        "libattestation",
@@ -125,7 +124,7 @@ filegroup {
        "InputListener.cpp",
        "InputReaderBase.cpp",
        "InputThread.cpp",
        "VibrationElement.cpp"
        "VibrationElement.cpp",
    ],
}

+0 −1
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ cc_defaults {
        "libutils",
        "lib-platform-compat-native-api",
        "server_configurable_flags",
        "InputFlingerProperties",
    ],
    static_libs: [
        "libattestation",
+14 −27
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#define LOG_NDEBUG 1

#include <InputFlingerProperties.sysprop.h>
#include <android-base/chrono_utils.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
@@ -112,15 +111,6 @@ private:
    std::mutex& mMutex;
};

// When per-window-input-rotation is enabled, InputFlinger works in the un-rotated display
// coordinates and SurfaceFlinger includes the display rotation in the input window transforms.
bool isPerWindowInputRotationEnabled() {
    static const bool PER_WINDOW_INPUT_ROTATION =
            sysprop::InputFlingerProperties::per_window_input_rotation().value_or(true);

    return PER_WINDOW_INPUT_ROTATION;
}

// Default input dispatching timeout if there is no focused application or paused window
// from which to determine an appropriate dispatching timeout.
const std::chrono::duration DEFAULT_INPUT_DISPATCHING_TIMEOUT = std::chrono::milliseconds(
@@ -2519,8 +2509,7 @@ void InputDispatcher::addWindowTargetLocked(const sp<WindowInfoHandle>& windowHa
        if (displayInfoIt != mDisplayInfos.end()) {
            inputTarget.displayTransform = displayInfoIt->second.transform;
        } else {
            ALOGI_IF(isPerWindowInputRotationEnabled(),
                     "DisplayInfo not found for window on display: %d", windowInfo->displayId);
            ALOGE("DisplayInfo not found for window on display: %d", windowInfo->displayId);
        }
        inputTargets.push_back(inputTarget);
        it = inputTargets.end() - 1;
@@ -4725,7 +4714,6 @@ void InputDispatcher::setInputWindowsLocked(
        }
    }

    if (isPerWindowInputRotationEnabled()) {
    // Determine if the orientation of any of the input windows have changed, and cancel all
    // pointer events if necessary.
    for (const sp<WindowInfoHandle>& oldWindowHandle : oldWindowHandles) {
@@ -4742,7 +4730,6 @@ void InputDispatcher::setInputWindowsLocked(
            }
        }
    }
    }

    // Release information for windows that are no longer present.
    // This ensures that unused input channels are released promptly.
+2 −3
Original line number Diff line number Diff line
@@ -71,7 +71,6 @@ cc_defaults {
        "libstatslog",
        "libui",
        "libutils",
        "InputFlingerProperties",
    ],
    static_libs: [
        "libc++fs",
@@ -86,7 +85,7 @@ cc_library_shared {
    name: "libinputreader",
    defaults: [
        "inputflinger_defaults",
        "libinputreader_defaults"
        "libinputreader_defaults",
    ],
    srcs: [
        "InputReaderFactory.cpp",
@@ -100,6 +99,6 @@ cc_library_shared {
        "libinputreader_headers",
    ],
    static_libs: [
        "libc++fs"
        "libc++fs",
    ],
}
+22 −34
Original line number Diff line number Diff line
@@ -193,12 +193,11 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration*
        const bool isOrientedDevice =
                (mParameters.orientationAware && mParameters.hasAssociatedDisplay);

        if (isPerWindowInputRotationEnabled()) {
            // When per-window input rotation is enabled, InputReader works in the un-rotated
            // coordinate space, so we don't need to do anything if the device is already
            // orientation-aware. If the device is not orientation-aware, then we need to apply the
            // inverse rotation of the display so that when the display rotation is applied later
            // as a part of the per-window transform, we get the expected screen coordinates.
        // InputReader works in the un-rotated display coordinate space, so we don't need to do
        // anything if the device is already orientation-aware. If the device is not
        // orientation-aware, then we need to apply the inverse rotation of the display so that
        // when the display rotation is applied later as a part of the per-window transform, we
        // get the expected screen coordinates.
        if (!isOrientedDevice) {
            std::optional<DisplayViewport> internalViewport =
                    config->getDisplayViewportByType(ViewportType::INTERNAL);
@@ -208,15 +207,6 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration*
                mDisplayHeight = internalViewport->deviceHeight;
            }
        }
        } else {
            if (isOrientedDevice) {
                std::optional<DisplayViewport> internalViewport =
                        config->getDisplayViewportByType(ViewportType::INTERNAL);
                if (internalViewport) {
                    mOrientation = internalViewport->orientation;
                }
            }
        }

        bumpGeneration();
    }
@@ -347,12 +337,11 @@ void CursorInputMapper::sync(nsecs_t when, nsecs_t readTime) {
            if (moved) {
                float dx = deltaX;
                float dy = deltaY;
                if (isPerWindowInputRotationEnabled()) {
                // Rotate the delta from InputReader's un-rotated coordinate space to
                // PointerController's rotated coordinate space that is oriented with the
                // viewport.
                rotateDelta(getInverseRotation(mOrientation), &dx, &dy);
                }

                mPointerController->move(dx, dy);
            }

@@ -364,12 +353,11 @@ void CursorInputMapper::sync(nsecs_t when, nsecs_t readTime) {
        }

        mPointerController->getPosition(&xCursorPosition, &yCursorPosition);
        if (isPerWindowInputRotationEnabled()) {
        // Rotate the cursor position that is in PointerController's rotated coordinate space
        // to InputReader's un-rotated coordinate space.
        rotatePoint(mOrientation, xCursorPosition /*byRef*/, yCursorPosition /*byRef*/,
                    mDisplayWidth, mDisplayHeight);
        }

        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
        pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
Loading