Unverified Commit 1269863d authored by amirh's avatar amirh Committed by GitHub

Fix touch event conversion bugs. (#19780)

These are bugs uncovered by the integration test for embedded Android
views:

  * Some PointerEvents were constructed with radiusMinor set to
  radiusMajor.
  * Some PointerEvents were missing radiusMajor/radiusMinor.
  * The pressure parameter was not passed to PointerUpEvent.
  * radiusMin, radiusMax, radiusMinor, and radiusMajor were not
  converted from physical pixels to logical.

Sending the fixes without a test as the bugs are covered by the integration
test that is going to land soon.
parent eb23d83b
......@@ -63,6 +63,10 @@ class PointerEventConverter {
static Iterable<PointerEvent> expand(Iterable<ui.PointerData> data, double devicePixelRatio) sync* {
for (ui.PointerData datum in data) {
final Offset position = new Offset(datum.physicalX, datum.physicalY) / devicePixelRatio;
final double radiusMinor = _toLogicalPixels(datum.radiusMinor, devicePixelRatio);
final double radiusMajor = _toLogicalPixels(datum.radiusMajor, devicePixelRatio);
final double radiusMin = _toLogicalPixels(datum.radiusMin, devicePixelRatio);
final double radiusMax = _toLogicalPixels(datum.radiusMax, devicePixelRatio);
final Duration timeStamp = datum.timeStamp;
final PointerDeviceKind kind = datum.kind;
assert(datum.change != null);
......@@ -81,8 +85,8 @@ class PointerEventConverter {
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -103,8 +107,8 @@ class PointerEventConverter {
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -123,10 +127,10 @@ class PointerEventConverter {
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMajor: datum.radiusMajor,
radiusMinor: datum.radiusMajor,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -148,8 +152,8 @@ class PointerEventConverter {
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -172,10 +176,10 @@ class PointerEventConverter {
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMajor: datum.radiusMajor,
radiusMinor: datum.radiusMajor,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt,
synthesized: true,
......@@ -196,10 +200,10 @@ class PointerEventConverter {
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distanceMax: datum.distanceMax,
radiusMajor: datum.radiusMajor,
radiusMinor: datum.radiusMajor,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -226,10 +230,10 @@ class PointerEventConverter {
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distanceMax: datum.distanceMax,
radiusMajor: datum.radiusMajor,
radiusMinor: datum.radiusMajor,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -260,10 +264,10 @@ class PointerEventConverter {
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distanceMax: datum.distanceMax,
radiusMajor: datum.radiusMajor,
radiusMinor: datum.radiusMajor,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt,
synthesized: true,
......@@ -281,11 +285,15 @@ class PointerEventConverter {
position: position,
buttons: datum.buttons,
obscured: datum.obscured,
pressure: datum.pressure,
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -302,8 +310,10 @@ class PointerEventConverter {
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -325,8 +335,10 @@ class PointerEventConverter {
pressureMax: datum.pressureMax,
distance: datum.distance,
distanceMax: datum.distanceMax,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: datum.orientation,
tilt: datum.tilt
);
......@@ -340,11 +352,14 @@ class PointerEventConverter {
pressureMin: datum.pressureMin,
pressureMax: datum.pressureMax,
distanceMax: datum.distanceMax,
radiusMin: datum.radiusMin,
radiusMax: datum.radiusMax
radiusMin: radiusMin,
radiusMax: radiusMax
);
break;
}
}
}
static double _toLogicalPixels(double physicalPixels, double devicePixelRatio) =>
physicalPixels == null ? null : physicalPixels / devicePixelRatio;
}
......@@ -519,10 +519,13 @@ class PointerUpEvent extends PointerEvent {
Offset position = Offset.zero,
int buttons = 0,
bool obscured = false,
double pressure = 1.0,
double pressureMin = 1.0,
double pressureMax = 1.0,
double distance = 0.0,
double distanceMax = 0.0,
double radiusMajor = 0.0,
double radiusMinor = 0.0,
double radiusMin = 0.0,
double radiusMax = 0.0,
double orientation = 0.0,
......@@ -536,10 +539,13 @@ class PointerUpEvent extends PointerEvent {
buttons: buttons,
down: false,
obscured: obscured,
pressure: pressure,
pressureMin: pressureMin,
pressureMax: pressureMax,
distance: distance,
distanceMax: distanceMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: orientation,
......@@ -564,6 +570,8 @@ class PointerCancelEvent extends PointerEvent {
double pressureMax = 1.0,
double distance = 0.0,
double distanceMax = 0.0,
double radiusMajor = 0.0,
double radiusMinor = 0.0,
double radiusMin = 0.0,
double radiusMax = 0.0,
double orientation = 0.0,
......@@ -581,6 +589,8 @@ class PointerCancelEvent extends PointerEvent {
pressureMax: pressureMax,
distance: distance,
distanceMax: distanceMax,
radiusMajor: radiusMajor,
radiusMinor: radiusMinor,
radiusMin: radiusMin,
radiusMax: radiusMax,
orientation: orientation,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment