OSDN Git Service

mouse: fix cursor movements after rotations
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 10 Nov 2010 07:38:46 +0000 (15:38 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 10 Nov 2010 07:38:46 +0000 (15:38 +0800)
services/java/com/android/server/InputDevice.java
services/java/com/android/server/KeyInputQueue.java

index 8a6097a..891cda8 100644 (file)
@@ -846,11 +846,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;
@@ -883,7 +882,8 @@ public class InputDevice {
                             ((reportData[j + MotionEvent.SAMPLE_SIZE]-absSize.minValue)
                                 / (float)absSize.range);
                 }
-                
+                if (isMouse)
+                    continue;
                 switch (orientation) {
                     case Surface.ROTATION_90: {
                         final float temp = reportData[j + MotionEvent.SAMPLE_X];
index 9c6483c..a31fd5c 100644 (file)
@@ -742,15 +742,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) {