Loading include/input/Input.h +5 −2 Original line number Diff line number Diff line Loading @@ -577,6 +577,8 @@ public: void setCursorPosition(float x, float y); uint32_t getDisplayOrientation() const { return mDisplayOrientation; } int2 getDisplaySize() const { return {mDisplayWidth, mDisplayHeight}; } static inline bool isValidCursorPosition(float x, float y) { return !isnan(x) && !isnan(y); } Loading Loading @@ -753,8 +755,8 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, float rawYCursorPosition, uint32_t displayOrientation, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); void copyFrom(const MotionEvent* other, bool keepHistory); Loading Loading @@ -812,6 +814,7 @@ protected: float mYPrecision; float mRawXCursorPosition; float mRawYCursorPosition; uint32_t mDisplayOrientation; int32_t mDisplayWidth; int32_t mDisplayHeight; nsecs_t mDownTime; Loading include/input/InputTransport.h +4 −3 Original line number Diff line number Diff line Loading @@ -136,10 +136,10 @@ struct InputMessage { float yPrecision; float xCursorPosition; float yCursorPosition; uint32_t displayOrientation; int32_t displayWidth; int32_t displayHeight; uint32_t pointerCount; uint32_t empty3; /** * The "pointers" field must be the last field of the struct InputMessage. * When we send the struct InputMessage across the socket, we are not Loading Loading @@ -355,8 +355,9 @@ public: int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float xCursorPosition, float yCursorPosition, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, uint32_t pointerCount, float yCursorPosition, uint32_t displayOrientation, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, uint32_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); Loading libs/gui/include/gui/WindowInfo.h +3 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,9 @@ struct WindowInfo : public Parcelable { // Transform applied to individual windows. ui::Transform transform; // Display orientation. Used for compatibility raw coordinates. uint32_t displayOrientation = ui::Transform::ROT_0; // Display size in its natural rotation. Used to rotate raw coordinates for compatibility. int32_t displayWidth = 0; int32_t displayHeight = 0; Loading libs/gui/tests/WindowInfo_test.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ TEST(WindowInfo, Parcelling) { i.globalScaleFactor = 0.3; i.alpha = 0.7; i.transform.set({0.4, -1, 100, 0.5, 0, 40, 0, 0, 1}); i.displayOrientation = ui::Transform::ROT_0; i.displayWidth = 1000; i.displayHeight = 2000; i.visible = false; Loading libs/input/Input.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -66,14 +66,11 @@ float transformAngle(const ui::Transform& transform, float angleRadians) { return result; } // Rotates the given point to the transform's orientation. If the display width and height are // Rotates the given point to the specified orientation. If the display width and height are // provided, the point is rotated in the screen space. Otherwise, the point is rotated about the // origin. This helper is used to avoid the extra overhead of creating new Transforms. vec2 rotatePoint(const ui::Transform& transform, float x, float y, int32_t displayWidth = 0, vec2 rotatePoint(uint32_t orientation, float x, float y, int32_t displayWidth = 0, int32_t displayHeight = 0) { // 0x7 encapsulates all 3 rotations (see ui::Transform::RotationFlags) static const int ALL_ROTATIONS_MASK = 0x7; const uint32_t orientation = (transform.getOrientation() & ALL_ROTATIONS_MASK); if (orientation == ui::Transform::ROT_0) { return {x, y}; } Loading Loading @@ -425,9 +422,9 @@ void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source, int3 int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, uint32_t displayOrientation, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords) { InputEvent::initialize(id, deviceId, source, displayId, hmac); mAction = action; Loading @@ -442,6 +439,7 @@ void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source, int3 mYPrecision = yPrecision; mRawXCursorPosition = rawXCursorPosition; mRawYCursorPosition = rawYCursorPosition; mDisplayOrientation = displayOrientation; mDisplayWidth = displayWidth; mDisplayHeight = displayHeight; mDownTime = downTime; Loading @@ -467,6 +465,7 @@ void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) { mYPrecision = other->mYPrecision; mRawXCursorPosition = other->mRawXCursorPosition; mRawYCursorPosition = other->mRawYCursorPosition; mDisplayOrientation = other->mDisplayOrientation; mDisplayWidth = other->mDisplayWidth; mDisplayHeight = other->mDisplayHeight; mDownTime = other->mDownTime; Loading Loading @@ -535,8 +534,8 @@ float MotionEvent::getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex, // For compatibility, convert raw coordinates into "oriented screen space". Once app // developers are educated about getRaw, we can consider removing this. const vec2 xy = shouldDisregardWindowTranslation(mSource) ? rotatePoint(mTransform, coords->getX(), coords->getY()) : rotatePoint(mTransform, coords->getX(), coords->getY(), mDisplayWidth, ? rotatePoint(mDisplayOrientation, coords->getX(), coords->getY()) : rotatePoint(mDisplayOrientation, coords->getX(), coords->getY(), mDisplayWidth, mDisplayHeight); static_assert(AMOTION_EVENT_AXIS_X == 0 && AMOTION_EVENT_AXIS_Y == 1); return xy[axis]; Loading @@ -545,8 +544,8 @@ float MotionEvent::getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex, if (axis == AMOTION_EVENT_AXIS_RELATIVE_X || axis == AMOTION_EVENT_AXIS_RELATIVE_Y) { // For compatibility, since we convert raw coordinates into "oriented screen space", we // need to convert the relative axes into the same orientation for consistency. const vec2 relativeXy = rotatePoint(mTransform, coords->getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), const vec2 relativeXy = rotatePoint(mDisplayOrientation, coords->getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), coords->getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y)); return axis == AMOTION_EVENT_AXIS_RELATIVE_X ? relativeXy.x : relativeXy.y; } Loading Loading @@ -698,6 +697,7 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { mYPrecision = parcel->readFloat(); mRawXCursorPosition = parcel->readFloat(); mRawYCursorPosition = parcel->readFloat(); mDisplayOrientation = parcel->readUint32(); mDisplayWidth = parcel->readInt32(); mDisplayHeight = parcel->readInt32(); mDownTime = parcel->readInt64(); Loading Loading @@ -759,6 +759,7 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeFloat(mYPrecision); parcel->writeFloat(mRawXCursorPosition); parcel->writeFloat(mRawYCursorPosition); parcel->writeUint32(mDisplayOrientation); parcel->writeInt32(mDisplayWidth); parcel->writeInt32(mDisplayHeight); parcel->writeInt64(mDownTime); Loading Loading
include/input/Input.h +5 −2 Original line number Diff line number Diff line Loading @@ -577,6 +577,8 @@ public: void setCursorPosition(float x, float y); uint32_t getDisplayOrientation() const { return mDisplayOrientation; } int2 getDisplaySize() const { return {mDisplayWidth, mDisplayHeight}; } static inline bool isValidCursorPosition(float x, float y) { return !isnan(x) && !isnan(y); } Loading Loading @@ -753,8 +755,8 @@ public: int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, float rawYCursorPosition, uint32_t displayOrientation, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); void copyFrom(const MotionEvent* other, bool keepHistory); Loading Loading @@ -812,6 +814,7 @@ protected: float mYPrecision; float mRawXCursorPosition; float mRawYCursorPosition; uint32_t mDisplayOrientation; int32_t mDisplayWidth; int32_t mDisplayHeight; nsecs_t mDownTime; Loading
include/input/InputTransport.h +4 −3 Original line number Diff line number Diff line Loading @@ -136,10 +136,10 @@ struct InputMessage { float yPrecision; float xCursorPosition; float yCursorPosition; uint32_t displayOrientation; int32_t displayWidth; int32_t displayHeight; uint32_t pointerCount; uint32_t empty3; /** * The "pointers" field must be the last field of the struct InputMessage. * When we send the struct InputMessage across the socket, we are not Loading Loading @@ -355,8 +355,9 @@ public: int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float xCursorPosition, float yCursorPosition, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, uint32_t pointerCount, float yCursorPosition, uint32_t displayOrientation, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, uint32_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); Loading
libs/gui/include/gui/WindowInfo.h +3 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,9 @@ struct WindowInfo : public Parcelable { // Transform applied to individual windows. ui::Transform transform; // Display orientation. Used for compatibility raw coordinates. uint32_t displayOrientation = ui::Transform::ROT_0; // Display size in its natural rotation. Used to rotate raw coordinates for compatibility. int32_t displayWidth = 0; int32_t displayHeight = 0; Loading
libs/gui/tests/WindowInfo_test.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ TEST(WindowInfo, Parcelling) { i.globalScaleFactor = 0.3; i.alpha = 0.7; i.transform.set({0.4, -1, 100, 0.5, 0, 40, 0, 0, 1}); i.displayOrientation = ui::Transform::ROT_0; i.displayWidth = 1000; i.displayHeight = 2000; i.visible = false; Loading
libs/input/Input.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -66,14 +66,11 @@ float transformAngle(const ui::Transform& transform, float angleRadians) { return result; } // Rotates the given point to the transform's orientation. If the display width and height are // Rotates the given point to the specified orientation. If the display width and height are // provided, the point is rotated in the screen space. Otherwise, the point is rotated about the // origin. This helper is used to avoid the extra overhead of creating new Transforms. vec2 rotatePoint(const ui::Transform& transform, float x, float y, int32_t displayWidth = 0, vec2 rotatePoint(uint32_t orientation, float x, float y, int32_t displayWidth = 0, int32_t displayHeight = 0) { // 0x7 encapsulates all 3 rotations (see ui::Transform::RotationFlags) static const int ALL_ROTATIONS_MASK = 0x7; const uint32_t orientation = (transform.getOrientation() & ALL_ROTATIONS_MASK); if (orientation == ui::Transform::ROT_0) { return {x, y}; } Loading Loading @@ -425,9 +422,9 @@ void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source, int3 int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, uint32_t displayOrientation, int32_t displayWidth, int32_t displayHeight, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords) { InputEvent::initialize(id, deviceId, source, displayId, hmac); mAction = action; Loading @@ -442,6 +439,7 @@ void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source, int3 mYPrecision = yPrecision; mRawXCursorPosition = rawXCursorPosition; mRawYCursorPosition = rawYCursorPosition; mDisplayOrientation = displayOrientation; mDisplayWidth = displayWidth; mDisplayHeight = displayHeight; mDownTime = downTime; Loading @@ -467,6 +465,7 @@ void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) { mYPrecision = other->mYPrecision; mRawXCursorPosition = other->mRawXCursorPosition; mRawYCursorPosition = other->mRawYCursorPosition; mDisplayOrientation = other->mDisplayOrientation; mDisplayWidth = other->mDisplayWidth; mDisplayHeight = other->mDisplayHeight; mDownTime = other->mDownTime; Loading Loading @@ -535,8 +534,8 @@ float MotionEvent::getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex, // For compatibility, convert raw coordinates into "oriented screen space". Once app // developers are educated about getRaw, we can consider removing this. const vec2 xy = shouldDisregardWindowTranslation(mSource) ? rotatePoint(mTransform, coords->getX(), coords->getY()) : rotatePoint(mTransform, coords->getX(), coords->getY(), mDisplayWidth, ? rotatePoint(mDisplayOrientation, coords->getX(), coords->getY()) : rotatePoint(mDisplayOrientation, coords->getX(), coords->getY(), mDisplayWidth, mDisplayHeight); static_assert(AMOTION_EVENT_AXIS_X == 0 && AMOTION_EVENT_AXIS_Y == 1); return xy[axis]; Loading @@ -545,8 +544,8 @@ float MotionEvent::getHistoricalRawAxisValue(int32_t axis, size_t pointerIndex, if (axis == AMOTION_EVENT_AXIS_RELATIVE_X || axis == AMOTION_EVENT_AXIS_RELATIVE_Y) { // For compatibility, since we convert raw coordinates into "oriented screen space", we // need to convert the relative axes into the same orientation for consistency. const vec2 relativeXy = rotatePoint(mTransform, coords->getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), const vec2 relativeXy = rotatePoint(mDisplayOrientation, coords->getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), coords->getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y)); return axis == AMOTION_EVENT_AXIS_RELATIVE_X ? relativeXy.x : relativeXy.y; } Loading Loading @@ -698,6 +697,7 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) { mYPrecision = parcel->readFloat(); mRawXCursorPosition = parcel->readFloat(); mRawYCursorPosition = parcel->readFloat(); mDisplayOrientation = parcel->readUint32(); mDisplayWidth = parcel->readInt32(); mDisplayHeight = parcel->readInt32(); mDownTime = parcel->readInt64(); Loading Loading @@ -759,6 +759,7 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const { parcel->writeFloat(mYPrecision); parcel->writeFloat(mRawXCursorPosition); parcel->writeFloat(mRawYCursorPosition); parcel->writeUint32(mDisplayOrientation); parcel->writeInt32(mDisplayWidth); parcel->writeInt32(mDisplayHeight); parcel->writeInt64(mDownTime); Loading