Unverified Commit f70f0ae9 authored by Callum Moffat's avatar Callum Moffat Committed by GitHub

PointerDeviceKind and ui.PointerChange forwards-compatibility (#97350)

* PointerDeviceKind and ui.PointerChange forwards-compatibility

* Add link to trackpad gestures issue

* Add TODO
parent 29fd0469
...@@ -21,6 +21,8 @@ int _synthesiseDownButtons(int buttons, PointerDeviceKind kind) { ...@@ -21,6 +21,8 @@ int _synthesiseDownButtons(int buttons, PointerDeviceKind kind) {
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
return buttons == 0 ? kPrimaryButton : buttons; return buttons == 0 ? kPrimaryButton : buttons;
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
// We have no information about the device but we know we never want // We have no information about the device but we know we never want
// buttons to be 0 when the pointer is down. // buttons to be 0 when the pointer is down.
return buttons == 0 ? kPrimaryButton : buttons; return buttons == 0 ? kPrimaryButton : buttons;
...@@ -207,6 +209,9 @@ class PointerEventConverter { ...@@ -207,6 +209,9 @@ class PointerEventConverter {
radiusMax: radiusMax, radiusMax: radiusMax,
embedderId: datum.embedderId, embedderId: datum.embedderId,
); );
default: // ignore: no_default_cases, to allow adding new pointer events to [ui.PointerChange]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
throw StateError('Unreachable');
} }
case ui.PointerSignalKind.scroll: case ui.PointerSignalKind.scroll:
final Offset scrollDelta = final Offset scrollDelta =
......
...@@ -2108,6 +2108,8 @@ double computeHitSlop(PointerDeviceKind kind, DeviceGestureSettings? settings) { ...@@ -2108,6 +2108,8 @@ double computeHitSlop(PointerDeviceKind kind, DeviceGestureSettings? settings) {
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
case PointerDeviceKind.touch: case PointerDeviceKind.touch:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
return settings?.touchSlop ?? kTouchSlop; return settings?.touchSlop ?? kTouchSlop;
} }
} }
...@@ -2121,6 +2123,8 @@ double computePanSlop(PointerDeviceKind kind, DeviceGestureSettings? settings) { ...@@ -2121,6 +2123,8 @@ double computePanSlop(PointerDeviceKind kind, DeviceGestureSettings? settings) {
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
case PointerDeviceKind.touch: case PointerDeviceKind.touch:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
return settings?.panSlop ?? kPanSlop; return settings?.panSlop ?? kPanSlop;
} }
} }
...@@ -2134,6 +2138,8 @@ double computeScaleSlop(PointerDeviceKind kind) { ...@@ -2134,6 +2138,8 @@ double computeScaleSlop(PointerDeviceKind kind) {
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
case PointerDeviceKind.touch: case PointerDeviceKind.touch:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
return kScaleSlop; return kScaleSlop;
} }
} }
......
...@@ -653,6 +653,8 @@ class _AndroidMotionEventConverter { ...@@ -653,6 +653,8 @@ class _AndroidMotionEventConverter {
toolType = AndroidPointerProperties.kToolTypeEraser; toolType = AndroidPointerProperties.kToolTypeEraser;
break; break;
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
toolType = AndroidPointerProperties.kToolTypeUnknown; toolType = AndroidPointerProperties.kToolTypeUnknown;
break; break;
} }
......
...@@ -1649,6 +1649,8 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier { ...@@ -1649,6 +1649,8 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
break; break;
case PointerDeviceKind.mouse: case PointerDeviceKind.mouse:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
_lastInteractionWasTouch = false; _lastInteractionWasTouch = false;
expectedMode = FocusHighlightMode.traditional; expectedMode = FocusHighlightMode.traditional;
break; break;
......
...@@ -668,6 +668,8 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -668,6 +668,8 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
case PointerDeviceKind.stylus: case PointerDeviceKind.stylus:
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
return interactiveRect.contains(position); return interactiveRect.contains(position);
} }
} }
...@@ -700,6 +702,8 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { ...@@ -700,6 +702,8 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
case PointerDeviceKind.stylus: case PointerDeviceKind.stylus:
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
return _thumbRect!.contains(position); return _thumbRect!.contains(position);
} }
} }
...@@ -1936,6 +1940,8 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv ...@@ -1936,6 +1940,8 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
case PointerDeviceKind.touch: case PointerDeviceKind.touch:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
break; break;
} }
}, },
...@@ -1949,6 +1955,8 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv ...@@ -1949,6 +1955,8 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.invertedStylus:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
case PointerDeviceKind.touch: case PointerDeviceKind.touch:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
break; break;
} }
}, },
......
...@@ -1145,6 +1145,8 @@ class TextSelectionGestureDetectorBuilder { ...@@ -1145,6 +1145,8 @@ class TextSelectionGestureDetectorBuilder {
break; break;
case PointerDeviceKind.touch: case PointerDeviceKind.touch:
case PointerDeviceKind.unknown: case PointerDeviceKind.unknown:
default: // ignore: no_default_cases, to allow adding new device types to [PointerDeviceKind]
// TODO(moffatman): Remove after landing https://github.com/flutter/flutter/issues/23604
// On macOS/iOS/iPadOS a touch tap places the cursor at the edge // On macOS/iOS/iPadOS a touch tap places the cursor at the edge
// of the word. // of the word.
renderEditable.selectWordEdge(cause: SelectionChangedCause.tap); renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
......
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