From 1a40ee953a4596ff693272cf7557ee90cb1aede7 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 14 Oct 2016 15:46:46 -0700 Subject: [PATCH] PointerChange.cancel should have a zero index (#3135) To make the default state all zeros. Fixes https://github.com/flutter/flutter/issues/6236 --- lib/ui/pointer.dart | 6 ++--- lib/ui/window/pointer_data.cc | 22 +++---------------- lib/ui/window/pointer_data.h | 2 +- .../android/io/flutter/view/FlutterView.java | 12 +++++----- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/lib/ui/pointer.dart b/lib/ui/pointer.dart index 794982581..c71c232ea 100644 --- a/lib/ui/pointer.dart +++ b/lib/ui/pointer.dart @@ -6,6 +6,9 @@ part of dart_ui; /// How the pointer has changed since the last report. enum PointerChange { + /// The input from the pointer is no longer directed towards this receiver. + cancel, + /// The device has started tracking the pointer. /// /// For example, the pointer might be hovering above the device, having not yet @@ -26,9 +29,6 @@ enum PointerChange { /// The pointer has stopped making contact with the device. up, - - /// The input from the pointer is no longer directed towards this receiver. - cancel, } /// The kind of pointer device. diff --git a/lib/ui/window/pointer_data.cc b/lib/ui/window/pointer_data.cc index e14156e50..c85a1a50b 100644 --- a/lib/ui/window/pointer_data.cc +++ b/lib/ui/window/pointer_data.cc @@ -4,6 +4,8 @@ #include "flutter/lib/ui/window/pointer_data.h" +#include + namespace blink { // If this value changes, update the pointer data unpacking code in hooks.dart. @@ -13,25 +15,7 @@ static_assert(sizeof(PointerData) == sizeof(int64_t) * kPointerDataFieldCount, "PointerData has the wrong size"); void PointerData::Clear() { - time_stamp = 0; - pointer = 0; - change = Change::kCancel; - kind = DeviceKind::kTouch; - physical_x = 0.0; - physical_y = 0.0; - buttons = 0; - obscured = 0; - pressure = 0.0; - pressure_min = 0.0; - pressure_max = 0.0; - distance = 0.0; - distance_max = 0.0; - radius_major = 0.0; - radius_minor = 0.0; - radius_min = 0.0; - radius_max = 0.0; - orientation = 0.0; - tilt = 0.0; + memset(this, 0, sizeof(PointerData)); } } // namespace blink diff --git a/lib/ui/window/pointer_data.h b/lib/ui/window/pointer_data.h index 61b901e6e..d2da6f707 100644 --- a/lib/ui/window/pointer_data.h +++ b/lib/ui/window/pointer_data.h @@ -13,12 +13,12 @@ namespace blink { struct alignas(8) PointerData { // Must match the PointerChange enum in pointer.dart. enum class Change : int64_t { + kCancel, kAdd, kRemove, kDown, kMove, kUp, - kCancel, }; // Must match the PointerDeviceKind enum in pointer.dart. diff --git a/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java index 8b102db24..c40081d8a 100644 --- a/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -261,12 +261,12 @@ public class FlutterView extends SurfaceView } // Must match the PointerChange enum in pointer.dart. - private static final int kPointerChangeAdd = 0; - private static final int kPointerChangeRemove = 1; - private static final int kPointerChangeDown = 2; - private static final int kPointerChangeMove = 3; - private static final int kPointerChangeUp = 4; - private static final int kPointerChangeCancel = 5; + private static final int kPointerChangeCancel = 0; + private static final int kPointerChangeAdd = 1; + private static final int kPointerChangeRemove = 2; + private static final int kPointerChangeDown = 3; + private static final int kPointerChangeMove = 4; + private static final int kPointerChangeUp = 5; // Must match the PointerDeviceKind enum in pointer.dart. private static final int kPointerDeviceKindTouch = 0; -- GitLab