summaryrefslogtreecommitdiff
path: root/include/input/Input.h
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2024-03-05 22:18:09 +0000
committer Prabir Pradhan <prabirmsp@google.com> 2024-03-05 22:18:09 +0000
commitadd8a4a9c3abd2c2b8d75b41bb99b7fb607e549a (patch)
tree727affec2e7716ec3cb2f6e0bba594f47f12e410 /include/input/Input.h
parent9180f87bfaac7d0f063d1f59fa572e4751899af6 (diff)
MotionEvent: Get offsets in raw coordinate space
MotionEvents store the underlying axis values in the coordinate space of the physical display, or "untransformed" space. The MotionEvent's mRawTransform takes those coordinates into the coordinate space of the logical display, or "raw" coordinates. The MotionEvent's mTransform takes those coordinates into the window/View's local coordinates. Previously, getting the motion event offset would return the offset with respect to the origin of the "untransformed" space. This is of little value to callers, since they are expecting the offset in "raw" coordinates, which is the offset with respect to the logical display's origin. To calculate the raw offset, we calculate where the raw point (0, 0) would map to in untransformed coordinates by applying the inverse raw transform, and then apply the window transform. Bug: 249340921 Test: atest libinput_tests Test: atest inputflinger_tests Change-Id: Iadbdde4dd45b5527b73be863b198b4c9a9e713cc
Diffstat (limited to 'include/input/Input.h')
-rw-r--r--include/input/Input.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/include/input/Input.h b/include/input/Input.h
index a84dcfc63c..027e4a5bdc 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -662,10 +662,6 @@ public:
inline void setActionButton(int32_t button) { mActionButton = button; }
- inline float getXOffset() const { return mTransform.tx(); }
-
- inline float getYOffset() const { return mTransform.ty(); }
-
inline const ui::Transform& getTransform() const { return mTransform; }
std::optional<ui::Rotation> getSurfaceRotation() const;
@@ -876,6 +872,22 @@ public:
void offsetLocation(float xOffset, float yOffset);
+ /**
+ * Get the X offset of this motion event relative to the origin of the raw coordinate space.
+ *
+ * In practice, this is the delta that was added to the raw screen coordinates (i.e. in logical
+ * display space) to adjust for the absolute position of the containing windows and views.
+ */
+ float getRawXOffset() const;
+
+ /**
+ * Get the Y offset of this motion event relative to the origin of the raw coordinate space.
+ *
+ * In practice, this is the delta that was added to the raw screen coordinates (i.e. in logical
+ * display space) to adjust for the absolute position of the containing windows and views.
+ */
+ float getRawYOffset() const;
+
void scale(float globalScaleFactor);
// Set 3x3 perspective matrix transformation.