Fix some bugs in input rotation

Set deviceWidth/Height properly when setting displayviewport

Remove unnecessary rotation from pointerlocationview (which was
double rotating PointerEventDispatcher).

Fixed PointerEventDispatcher to use "real" size.

Bug: 179308296
Test: enable input rotation, rotate, and touch things
Change-Id: I156b6b3e0bf6d71996901c6e616c5710b12e3f0c
This commit is contained in:
Evan Rosky
2021-02-24 17:53:15 -08:00
parent cc8370b542
commit ba7e1a521f
3 changed files with 13 additions and 28 deletions

View File

@@ -36,7 +36,6 @@ import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
import android.view.Surface;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
@@ -60,9 +59,6 @@ public class PointerLocationView extends View implements InputDeviceListener,
*/
private static final String GESTURE_EXCLUSION_PROP = "debug.pointerlocation.showexclusion";
private static final boolean ENABLE_PER_WINDOW_INPUT_ROTATION =
SystemProperties.getBoolean("persist.debug.per_window_input_rotation", false);
public static class PointerState {
// Trace of previous points.
private float[] mTraceX = new float[32];
@@ -356,21 +352,6 @@ public class PointerLocationView extends View implements InputDeviceListener,
.toString(), 1 + itemW * 6, base, mTextPaint);
}
int saveId = canvas.save();
if (ENABLE_PER_WINDOW_INPUT_ROTATION) {
// Rotate negative (since we're rotating the drawing canvas vs the output).
canvas.rotate(-90.0f * mContext.getDisplay().getRotation());
switch (mContext.getDisplay().getRotation()) {
case Surface.ROTATION_90:
canvas.translate(-canvas.getHeight(), 0);
break;
case Surface.ROTATION_180:
canvas.translate(-canvas.getWidth(), -canvas.getHeight());
break;
case Surface.ROTATION_270:
canvas.translate(0, -canvas.getWidth());
}
}
// Pointer trace.
for (int p = 0; p < NP; p++) {
final PointerState ps = mPointers.get(p);
@@ -480,7 +461,6 @@ public class PointerLocationView extends View implements InputDeviceListener,
}
}
}
canvas.restoreToCount(saveId);
}
private void logMotionEvent(String type, MotionEvent event) {