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

Commit 9c3709a1 authored by Chih-Wei Huang's avatar Chih-Wei Huang Committed by Steve Kondik
Browse files

mouse: fix cursor movements after rotations

Change-Id: I3659587e4005f3fa0401981a2329744840f9ff10
parent 6d4022f4
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -843,11 +843,10 @@ public class InputDevice {
            final int dispH = display.getHeight()-1;
            int w = dispW;
            int h = dispH;
            if (orientation == Surface.ROTATION_90
                    || orientation == Surface.ROTATION_270) {
                int tmp = w;
                w = h;
                h = tmp;
            if (!isMouse && (orientation == Surface.ROTATION_90
                    || orientation == Surface.ROTATION_270)) {
                w = dispH;
                h = dispW;
            }

            final AbsoluteInfo absX = device.absX;
@@ -877,6 +876,8 @@ public class InputDevice {
                            ((reportData[j + MotionEvent.SAMPLE_SIZE]-absSize.minValue)
                                / (float)absSize.range);
                }
                if (isMouse)
                    continue;

                switch (orientation) {
                    case Surface.ROTATION_90: {
+16 −2
Original line number Diff line number Diff line
@@ -741,15 +741,29 @@ public abstract class KeyInputQueue {
                                    di.mRel.mNextData[MotionEvent.SAMPLE_Y] += ev.value;
                                }
                            } else if ((classes&RawInputEvent.CLASS_MOUSE) != 0) {
                                int dispW = mDisplayWidth, dispH = mDisplayHeight;
                                if (mDisplay != null) {
                                    if (mDisplay.getRotation() == Surface.ROTATION_90 ||
                                            mDisplay.getRotation() == Surface.ROTATION_270) {
                                        dispW = mDisplayHeight;
                                        dispH = mDisplayWidth;
                                    }
                                }
                                if (ev.scancode == RawInputEvent.REL_X) {
                                    di.mAbs.changed = true;
                                    mCx += (int)ev.value;
                                    mCx = ((mCx < 0) ? 0 : (mCx >= mDisplayWidth ? mDisplayWidth - 1 : mCx));
                                    if (mCx < 0)
                                        mCx = 0;
                                    else if (mCx >= dispW)
                                        mCx = dispW - 1;
                                    di.mAbs.mNextData[MotionEvent.SAMPLE_X] = mCx;
                                } else if (ev.scancode == RawInputEvent.REL_Y) {
                                    di.mAbs.changed = true;
                                    mCy += (int)ev.value;
                                    mCy = ((mCy < 0) ? 0 : (mCy >= mDisplayHeight ? mDisplayHeight - 1 : mCy));
                                    if (mCy < 0)
                                        mCy = 0;
                                    else if (mCy >= dispH)
                                        mCy = dispH - 1;
                                    di.mAbs.mNextData[MotionEvent.SAMPLE_Y] = mCy;
                                } else if (ev.scancode == RawInputEvent.REL_WHEEL &&
                                               (classes&RawInputEvent.CLASS_MOUSE) != 0) {