Clean up after enabling per-window-input-rotation
The input feature of per-window-input-rotation is now enabled by
default. Since we don't want to maintain two pipelines for input
rotation, we remove the old code path and clean up accordingly.
Bug: 188939842
Test: presubmit
Test: manual, test that touch and mouse works with display rotated
Change-Id: I0478bb4933c739b2975cbd170cc5dfdaeea0fd57
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
index f3d7cdc..15ba459 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
@@ -193,28 +193,18 @@
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.
- if (!isOrientedDevice) {
- std::optional<DisplayViewport> internalViewport =
- config->getDisplayViewportByType(ViewportType::INTERNAL);
- if (internalViewport) {
- mOrientation = getInverseRotation(internalViewport->orientation);
- mDisplayWidth = internalViewport->deviceWidth;
- mDisplayHeight = internalViewport->deviceHeight;
- }
- }
- } else {
- if (isOrientedDevice) {
- std::optional<DisplayViewport> internalViewport =
- config->getDisplayViewportByType(ViewportType::INTERNAL);
- if (internalViewport) {
- mOrientation = internalViewport->orientation;
- }
+ // 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);
+ if (internalViewport) {
+ mOrientation = getInverseRotation(internalViewport->orientation);
+ mDisplayWidth = internalViewport->deviceWidth;
+ mDisplayHeight = internalViewport->deviceHeight;
}
}
@@ -347,12 +337,11 @@
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);
- }
+ // 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 @@
}
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);
- }
+ // 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);
diff --git a/services/inputflinger/reader/mapper/TouchCursorInputMapperCommon.h b/services/inputflinger/reader/mapper/TouchCursorInputMapperCommon.h
index 197be98..8c30e38 100644
--- a/services/inputflinger/reader/mapper/TouchCursorInputMapperCommon.h
+++ b/services/inputflinger/reader/mapper/TouchCursorInputMapperCommon.h
@@ -17,7 +17,6 @@
#ifndef _UI_INPUTREADER_TOUCH_CURSOR_INPUT_MAPPER_COMMON_H
#define _UI_INPUTREADER_TOUCH_CURSOR_INPUT_MAPPER_COMMON_H
-#include <InputFlingerProperties.sysprop.h>
#include <input/DisplayViewport.h>
#include <stdint.h>
@@ -29,13 +28,6 @@
// --- Static Definitions ---
-// When per-window input rotation is enabled, display transformations such as rotation and
-// projection are part of the input window's transform. This means InputReader should work in the
-// un-rotated coordinate space.
-static bool isPerWindowInputRotationEnabled() {
- return sysprop::InputFlingerProperties::per_window_input_rotation().value_or(true);
-}
-
static int32_t getInverseRotation(int32_t orientation) {
switch (orientation) {
case DISPLAY_ORIENTATION_90:
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index fd33df9..57f5225 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -749,43 +749,31 @@
mPhysicalLeft = naturalPhysicalLeft;
mPhysicalTop = naturalPhysicalTop;
- if (isPerWindowInputRotationEnabled()) {
- // When per-window input rotation is enabled, InputReader works in the display
- // space, so the surface bounds are the bounds of the display device.
- const int32_t oldSurfaceWidth = mRawSurfaceWidth;
- const int32_t oldSurfaceHeight = mRawSurfaceHeight;
- mRawSurfaceWidth = naturalDeviceWidth;
- mRawSurfaceHeight = naturalDeviceHeight;
- mSurfaceLeft = 0;
- mSurfaceTop = 0;
- mSurfaceRight = mRawSurfaceWidth;
- mSurfaceBottom = mRawSurfaceHeight;
- // 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.
- mSurfaceOrientation = mParameters.orientationAware
- ? DISPLAY_ORIENTATION_0
- : getInverseRotation(mViewport.orientation);
- // For orientation-aware devices that work in the un-rotated coordinate space, the
- // viewport update should be skipped if it is only a change in the orientation.
- skipViewportUpdate = mParameters.orientationAware &&
- mRawSurfaceWidth == oldSurfaceWidth &&
- mRawSurfaceHeight == oldSurfaceHeight && viewportOrientationChanged;
- } else {
- mRawSurfaceWidth = naturalLogicalWidth * naturalDeviceWidth / naturalPhysicalWidth;
- mRawSurfaceHeight =
- naturalLogicalHeight * naturalDeviceHeight / naturalPhysicalHeight;
- mSurfaceLeft = naturalPhysicalLeft * naturalLogicalWidth / naturalPhysicalWidth;
- mSurfaceTop = naturalPhysicalTop * naturalLogicalHeight / naturalPhysicalHeight;
- mSurfaceRight = mSurfaceLeft + naturalLogicalWidth;
- mSurfaceBottom = mSurfaceTop + naturalLogicalHeight;
+ // TODO(prabirmsp): Cleanup surface bounds.
+ // When per-window input rotation is enabled, InputReader works in the display
+ // space, so the surface bounds are the bounds of the display device.
+ const int32_t oldSurfaceWidth = mRawSurfaceWidth;
+ const int32_t oldSurfaceHeight = mRawSurfaceHeight;
+ mRawSurfaceWidth = naturalDeviceWidth;
+ mRawSurfaceHeight = naturalDeviceHeight;
+ mSurfaceLeft = 0;
+ mSurfaceTop = 0;
+ mSurfaceRight = mRawSurfaceWidth;
+ mSurfaceBottom = mRawSurfaceHeight;
- mSurfaceOrientation = mParameters.orientationAware ? mViewport.orientation
- : DISPLAY_ORIENTATION_0;
- }
+ // 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.
+ mSurfaceOrientation = mParameters.orientationAware
+ ? DISPLAY_ORIENTATION_0
+ : getInverseRotation(mViewport.orientation);
+ // For orientation-aware devices that work in the un-rotated coordinate space, the
+ // viewport update should be skipped if it is only a change in the orientation.
+ skipViewportUpdate = mParameters.orientationAware &&
+ mRawSurfaceWidth == oldSurfaceWidth && mRawSurfaceHeight == oldSurfaceHeight &&
+ viewportOrientationChanged;
// Apply the input device orientation for the device.
mSurfaceOrientation =
@@ -3781,16 +3769,10 @@
const float xScaled = (x - mRawPointerAxes.x.minValue) * mXScale;
const float yScaled = (y - mRawPointerAxes.y.minValue) * mYScale;
- if (isPerWindowInputRotationEnabled()) {
- return x >= mRawPointerAxes.x.minValue && x <= mRawPointerAxes.x.maxValue &&
- xScaled >= mPhysicalLeft && xScaled <= (mPhysicalLeft + mPhysicalWidth) &&
- y >= mRawPointerAxes.y.minValue && y <= mRawPointerAxes.y.maxValue &&
- yScaled >= mPhysicalTop && yScaled <= (mPhysicalTop + mPhysicalHeight);
- }
return x >= mRawPointerAxes.x.minValue && x <= mRawPointerAxes.x.maxValue &&
- xScaled >= mSurfaceLeft && xScaled <= mSurfaceRight &&
+ xScaled >= mPhysicalLeft && xScaled <= (mPhysicalLeft + mPhysicalWidth) &&
y >= mRawPointerAxes.y.minValue && y <= mRawPointerAxes.y.maxValue &&
- yScaled >= mSurfaceTop && yScaled <= mSurfaceBottom;
+ yScaled >= mPhysicalTop && yScaled <= (mPhysicalTop + mPhysicalHeight);
}
const TouchInputMapper::VirtualKey* TouchInputMapper::findVirtualKeyHit(int32_t x, int32_t y) {
@@ -4048,11 +4030,9 @@
}
void TouchInputMapper::moveMouseCursor(float dx, float dy) const {
- if (isPerWindowInputRotationEnabled()) {
- // Convert from InputReader's un-rotated coordinate space to PointerController's coordinate
- // space that is oriented with the viewport.
- rotateDelta(mViewport.orientation, &dx, &dy);
- }
+ // Convert from InputReader's un-rotated coordinate space to PointerController's coordinate
+ // space that is oriented with the viewport.
+ rotateDelta(mViewport.orientation, &dx, &dy);
mPointerController->move(dx, dy);
}
@@ -4062,7 +4042,6 @@
float y = 0;
mPointerController->getPosition(&x, &y);
- if (!isPerWindowInputRotationEnabled()) return {x, y};
if (!mViewport.isValid()) return {x, y};
// Convert from PointerController's rotated coordinate space that is oriented with the viewport
@@ -4073,11 +4052,9 @@
}
void TouchInputMapper::setMouseCursorPosition(float x, float y) const {
- if (isPerWindowInputRotationEnabled() && mViewport.isValid()) {
- // Convert from InputReader's un-rotated coordinate space to PointerController's rotated
- // coordinate space that is oriented with the viewport.
- rotatePoint(mViewport.orientation, x, y, mRawSurfaceWidth, mRawSurfaceHeight);
- }
+ // Convert from InputReader's un-rotated coordinate space to PointerController's rotated
+ // coordinate space that is oriented with the viewport.
+ rotatePoint(mViewport.orientation, x, y, mRawSurfaceWidth, mRawSurfaceHeight);
mPointerController->setPosition(x, y);
}
@@ -4092,11 +4069,9 @@
float y = spotCoords[index].getY();
float pressure = spotCoords[index].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE);
- if (isPerWindowInputRotationEnabled()) {
- // Convert from InputReader's un-rotated coordinate space to PointerController's rotated
- // coordinate space.
- rotatePoint(mViewport.orientation, x, y, mRawSurfaceWidth, mRawSurfaceHeight);
- }
+ // Convert from InputReader's un-rotated coordinate space to PointerController's rotated
+ // coordinate space.
+ rotatePoint(mViewport.orientation, x, y, mRawSurfaceWidth, mRawSurfaceHeight);
outSpotCoords[index].setAxisValue(AMOTION_EVENT_AXIS_X, x);
outSpotCoords[index].setAxisValue(AMOTION_EVENT_AXIS_Y, y);