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

Commit b316c34a authored by Michael Wright's avatar Michael Wright Committed by Android (Google) Code Review
Browse files

Merge "Convert MotionEvent#getSurfaceRotation to ui::Rotation"

parents b8280a46 635422be
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -577,7 +577,7 @@ public:

    inline const ui::Transform& getTransform() const { return mTransform; }

    int32_t getSurfaceRotation() const;
    std::optional<ui::Rotation> getSurfaceRotation() const;

    inline float getXPrecision() const { return mXPrecision; }

+7 −6
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <cutils/compiler.h>
#include <inttypes.h>
#include <string.h>
#include <optional>

#include <android-base/file.h>
#include <android-base/logging.h>
@@ -552,21 +553,21 @@ void MotionEvent::addSample(
                                &pointerCoords[getPointerCount()]);
}

int32_t MotionEvent::getSurfaceRotation() const {
std::optional<ui::Rotation> MotionEvent::getSurfaceRotation() const {
    // The surface rotation is the rotation from the window's coordinate space to that of the
    // display. Since the event's transform takes display space coordinates to window space, the
    // returned surface rotation is the inverse of the rotation for the surface.
    switch (mTransform.getOrientation()) {
        case ui::Transform::ROT_0:
            return static_cast<int32_t>(ui::ROTATION_0);
            return ui::ROTATION_0;
        case ui::Transform::ROT_90:
            return static_cast<int32_t>(ui::ROTATION_270);
            return ui::ROTATION_270;
        case ui::Transform::ROT_180:
            return static_cast<int32_t>(ui::ROTATION_180);
            return ui::ROTATION_180;
        case ui::Transform::ROT_270:
            return static_cast<int32_t>(ui::ROTATION_90);
            return ui::ROTATION_90;
        default:
            return -1;
            return std::nullopt;
    }
}