Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c4f51bc

Browse files
author
Jonah Williams
authored
Revert "Add support for double tap action from Apple Pencil 2 (#39267)" (#39607)
This reverts commit 99a81a8.
1 parent c2e165e commit c4f51bc

File tree

12 files changed

+37
-230
lines changed

12 files changed

+37
-230
lines changed

lib/ui/platform_dispatcher.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class PlatformDispatcher {
371371
// * pointer_data.cc
372372
// * pointer.dart
373373
// * AndroidTouchProcessor.java
374-
static const int _kPointerDataFieldCount = 36;
374+
static const int _kPointerDataFieldCount = 35;
375375

376376
static PointerDataPacket _unpackPointerDataPacket(ByteData packet) {
377377
const int kStride = Int64List.bytesPerElement;
@@ -417,7 +417,6 @@ class PlatformDispatcher {
417417
panDeltaY: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
418418
scale: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
419419
rotation: packet.getFloat64(kStride * offset++, _kFakeHostEndian),
420-
preferredStylusAuxiliaryAction: PointerPreferredStylusAuxiliaryAction.values[packet.getInt64(kStride * offset++, _kFakeHostEndian)],
421420
));
422421
assert(offset == (i + 1) * _kPointerDataFieldCount);
423422
}

lib/ui/pointer.dart

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,10 @@ enum PointerSignalKind {
133133
/// A pointer-generated scale event (e.g. trackpad pinch).
134134
scale,
135135

136-
/// A stylus generated action (e.g. double tap on Apple Pencil 2)
137-
stylusAuxiliaryAction,
138-
139136
/// An unknown pointer signal kind.
140137
unknown
141138
}
142139

143-
/// The preferred action for stylus action
144-
enum PointerPreferredStylusAuxiliaryAction {
145-
/// Ignore pointer input
146-
ignore,
147-
148-
/// Show colour palette if available
149-
showColorPalette,
150-
151-
/// Switch to eraser if available
152-
switchEraser,
153-
154-
/// Switch to previous tool
155-
switchPrevious,
156-
157-
/// unknown preferred action
158-
unknown,
159-
}
160-
161140
/// Information about the state of a pointer.
162141
class PointerData {
163142
/// Creates an object that represents the state of a pointer.
@@ -197,7 +176,6 @@ class PointerData {
197176
this.panDeltaY = 0.0,
198177
this.scale = 0.0,
199178
this.rotation = 0.0,
200-
this.preferredStylusAuxiliaryAction = PointerPreferredStylusAuxiliaryAction.ignore,
201179
});
202180

203181
/// Unique identifier that ties the [PointerEvent] to embedder event created it.
@@ -396,11 +374,6 @@ class PointerData {
396374
/// The current angle of the pan/zoom in radians, with 0.0 as the initial angle.
397375
final double rotation;
398376

399-
/// For events with signal kind of stylusAuxiliaryAction
400-
///
401-
/// The current preferred action for stylusAuxiliaryAction, with ignore as the default.
402-
final PointerPreferredStylusAuxiliaryAction preferredStylusAuxiliaryAction;
403-
404377
@override
405378
String toString() => 'PointerData(x: $physicalX, y: $physicalY)';
406379

@@ -440,8 +413,7 @@ class PointerData {
440413
'panDeltaX: $panDeltaX, '
441414
'panDeltaY: $panDeltaY, '
442415
'scale: $scale, '
443-
'rotation: $rotation, '
444-
'preferredStylusAuxiliaryAction: $preferredStylusAuxiliaryAction'
416+
'rotation: $rotation'
445417
')';
446418
}
447419
}

lib/ui/window/pointer_data.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace flutter {
1111

1212
// If this value changes, update the pointer data unpacking code in
1313
// platform_dispatcher.dart.
14-
static constexpr int kPointerDataFieldCount = 36;
14+
static constexpr int kPointerDataFieldCount = 35;
1515
static constexpr int kBytesPerField = sizeof(int64_t);
1616
// Must match the button constants in events.dart.
1717
enum PointerButtonMouse : int64_t {
@@ -63,16 +63,6 @@ struct alignas(8) PointerData {
6363
kScroll,
6464
kScrollInertiaCancel,
6565
kScale,
66-
kStylusAuxiliaryAction,
67-
};
68-
69-
// Must match the PreferredStylusAuxiliaryAction enum in pointer.dart.
70-
enum class PreferredStylusAuxiliaryAction : int64_t {
71-
kIgnore,
72-
kShowColorPalette,
73-
kSwitchEraser,
74-
kSwitchPrevious,
75-
kUnknown
7666
};
7767

7868
int64_t embedder_id;
@@ -110,7 +100,6 @@ struct alignas(8) PointerData {
110100
double pan_delta_y;
111101
double scale;
112102
double rotation;
113-
PreferredStylusAuxiliaryAction preferred_auxiliary_stylus_action;
114103

115104
void Clear();
116105
};

lib/ui/window/pointer_data_packet_converter.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ void PointerDataPacketConverter::ConvertPointerData(
293293
switch (pointer_data.signal_kind) {
294294
case PointerData::SignalKind::kScroll:
295295
case PointerData::SignalKind::kScrollInertiaCancel:
296-
case PointerData::SignalKind::kStylusAuxiliaryAction:
297296
case PointerData::SignalKind::kScale: {
298297
// Makes sure we have an existing pointer
299298
auto iter = states_.find(pointer_data.device);

lib/ui/window/pointer_data_packet_converter_unittests.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ void CreateSimulatedPointerData(PointerData& data, // NOLINT
4545
data.platformData = 0;
4646
data.scroll_delta_x = 0.0;
4747
data.scroll_delta_y = 0.0;
48-
data.preferred_auxiliary_stylus_action =
49-
PointerData::PreferredStylusAuxiliaryAction::kIgnore;
5048
}
5149

5250
void CreateSimulatedMousePointerData(PointerData& data, // NOLINT
@@ -86,8 +84,6 @@ void CreateSimulatedMousePointerData(PointerData& data, // NOLINT
8684
data.platformData = 0;
8785
data.scroll_delta_x = scroll_delta_x;
8886
data.scroll_delta_y = scroll_delta_y;
89-
data.preferred_auxiliary_stylus_action =
90-
PointerData::PreferredStylusAuxiliaryAction::kIgnore;
9187
}
9288

9389
void CreateSimulatedTrackpadGestureData(PointerData& data, // NOLINT
@@ -133,8 +129,6 @@ void CreateSimulatedTrackpadGestureData(PointerData& data, // NOLINT
133129
data.pan_delta_y = 0.0;
134130
data.scale = scale;
135131
data.rotation = rotation;
136-
data.preferred_auxiliary_stylus_action =
137-
PointerData::PreferredStylusAuxiliaryAction::kIgnore;
138132
}
139133

140134
void UnpackPointerPacket(std::vector<PointerData>& output, // NOLINT

lib/web_ui/lib/pointer.dart

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,6 @@ enum PointerSignalKind {
3434
unknown
3535
}
3636

37-
/// The preferred action for stylus action
38-
enum PointerPreferredStylusAuxiliaryAction {
39-
/// Ignore pointer input
40-
ignore,
41-
42-
/// Show colour palette if available
43-
showColorPalette,
44-
45-
/// Switch to eraser if available
46-
switchEraser,
47-
48-
/// Switch to previous tool
49-
switchPrevious,
50-
51-
/// unknown preferred action
52-
unknown,
53-
}
54-
5537
class PointerData {
5638
const PointerData({
5739
this.embedderId = 0,
@@ -89,7 +71,6 @@ class PointerData {
8971
this.panDeltaY = 0.0,
9072
this.scale = 0.0,
9173
this.rotation = 0.0,
92-
this.preferredStylusAuxiliaryAction = PointerPreferredStylusAuxiliaryAction.ignore,
9374
});
9475
final int embedderId;
9576
final Duration timeStamp;
@@ -126,7 +107,6 @@ class PointerData {
126107
final double panDeltaY;
127108
final double scale;
128109
final double rotation;
129-
final PointerPreferredStylusAuxiliaryAction preferredStylusAuxiliaryAction;
130110

131111
@override
132112
String toString() => 'PointerData(x: $physicalX, y: $physicalY)';
@@ -165,8 +145,7 @@ class PointerData {
165145
'panDeltaX: $panDeltaX, '
166146
'panDeltaY: $panDeltaY, '
167147
'scale: $scale, '
168-
'rotation: $rotation, '
169-
'preferredStylusAuxiliaryAction: $preferredStylusAuxiliaryAction'
148+
'rotation: $rotation'
170149
')';
171150
}
172151
}

shell/common/input_events_unittests.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ void CreateSimulatedPointerData(PointerData& data,
176176
data.platformData = 0;
177177
data.scroll_delta_x = 0.0;
178178
data.scroll_delta_y = 0.0;
179-
data.preferred_auxiliary_stylus_action =
180-
PointerData::PreferredStylusAuxiliaryAction::kIgnore;
181179
}
182180

183181
TEST_F(ShellTest, MissAtMostOneFrameForIrregularInputEvents) {

shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,18 @@ public class AndroidTouchProcessor {
6666
PointerSignalKind.SCROLL,
6767
PointerSignalKind.SCROLL_INERTIA_CANCEL,
6868
PointerSignalKind.SCALE,
69-
PointerSignalKind.STYLUS_AUXILIARY_ACTION,
7069
PointerSignalKind.UNKNOWN
7170
})
7271
public @interface PointerSignalKind {
7372
int NONE = 0;
7473
int SCROLL = 1;
7574
int SCROLL_INERTIA_CANCEL = 2;
7675
int SCALE = 3;
77-
int STYLUS_AUXILIARY_ACTION = 4;
78-
int UNKNOWN = 5;
79-
}
80-
81-
// Must match the PointerPreferredStylusAuxiliaryAction enum in pointer.dart.
82-
@IntDef({
83-
PointerPreferredStylusAuxiliaryAction.IGNORE,
84-
PointerPreferredStylusAuxiliaryAction.SHOW_COLOR_PALETTE,
85-
PointerPreferredStylusAuxiliaryAction.SWITCH_ERASER,
86-
PointerPreferredStylusAuxiliaryAction.SWITCH_PREVIOUS,
87-
PointerPreferredStylusAuxiliaryAction.UNKNOWN
88-
})
89-
public @interface PointerPreferredStylusAuxiliaryAction {
90-
int IGNORE = 0;
91-
int SHOW_COLOR_PALETTE = 1;
92-
int SWITCH_ERASER = 2;
93-
int SWITCH_PREVIOUS = 3;
9476
int UNKNOWN = 4;
9577
}
9678

9779
// Must match the unpacking code in hooks.dart.
98-
private static final int POINTER_DATA_FIELD_COUNT = 36;
80+
private static final int POINTER_DATA_FIELD_COUNT = 35;
9981
@VisibleForTesting static final int BYTES_PER_FIELD = 8;
10082

10183
// This value must match the value in framework's platform_view.dart.
@@ -373,8 +355,6 @@ private void addPointerForIndex(
373355
packet.putDouble(1.0); // scale
374356
packet.putDouble(0.0); // rotation
375357

376-
packet.putLong(PointerPreferredStylusAuxiliaryAction.IGNORE); // preferred stylus action
377-
378358
if (isTrackpadPan && getPointerChangeForPanZoom(pointerChange) == PointerChange.PAN_ZOOM_END) {
379359
ongoingPans.remove(event.getPointerId(pointerIndex));
380360
}

shell/platform/darwin/ios/framework/Source/FlutterViewController.mm

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@
5656
// This is left a FlutterBinaryMessenger privately for now to give people a chance to notice the
5757
// change. Unfortunately unless you have Werror turned on, incompatible pointers as arguments are
5858
// just a warning.
59-
@interface FlutterViewController () <FlutterBinaryMessenger,
60-
UIScrollViewDelegate,
61-
UIPencilInteractionDelegate>
59+
@interface FlutterViewController () <FlutterBinaryMessenger, UIScrollViewDelegate>
6260
@property(nonatomic, readwrite, getter=isDisplayingFlutterUI) BOOL displayingFlutterUI;
6361
@property(nonatomic, assign) BOOL isHomeIndicatorHidden;
6462
@property(nonatomic, assign) BOOL isPresentingViewControllerAnimating;
@@ -99,7 +97,7 @@ @interface FlutterViewController () <FlutterBinaryMessenger,
9997
// Trackpad rotating
10098
@property(nonatomic, retain)
10199
UIRotationGestureRecognizer* rotationGestureRecognizer API_AVAILABLE(ios(13.4));
102-
@property(nonatomic, retain) UIPencilInteraction* pencilInteraction API_AVAILABLE(ios(13.4));
100+
103101
/**
104102
* Creates and registers plugins used by this view controller.
105103
*/
@@ -724,10 +722,6 @@ - (void)viewDidLoad {
724722
[self createTouchRateCorrectionVSyncClientIfNeeded];
725723

726724
if (@available(iOS 13.4, *)) {
727-
_pencilInteraction = [[UIPencilInteraction alloc] init];
728-
_pencilInteraction.delegate = self;
729-
[_flutterView addInteraction:_pencilInteraction];
730-
731725
_hoverGestureRecognizer =
732726
[[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(hoverEvent:)];
733727
_hoverGestureRecognizer.delegate = self;
@@ -901,8 +895,6 @@ - (void)dealloc {
901895
[_pinchGestureRecognizer release];
902896
_rotationGestureRecognizer.delegate = nil;
903897
[_rotationGestureRecognizer release];
904-
_pencilInteraction.delegate = nil;
905-
[_pencilInteraction release];
906898
[super dealloc];
907899
}
908900

@@ -977,7 +969,7 @@ - (void)goToApplicationLifecycle:(nonnull NSString*)state {
977969
case UITouchTypeDirect:
978970
case UITouchTypeIndirect:
979971
return flutter::PointerData::DeviceKind::kTouch;
980-
case UITouchTypePencil:
972+
case UITouchTypeStylus:
981973
return flutter::PointerData::DeviceKind::kStylus;
982974
case UITouchTypeIndirectPointer:
983975
return flutter::PointerData::DeviceKind::kMouse;
@@ -1232,50 +1224,6 @@ - (void)invalidateTouchRateCorrectionVSyncClient {
12321224
_touchRateCorrectionVSyncClient = nil;
12331225
}
12341226

1235-
#pragma mark - Stylus Events
1236-
1237-
- (void)pencilInteractionDidTap:(UIPencilInteraction*)interaction API_AVAILABLE(ios(13.4)) {
1238-
flutter::PointerData pointer_data = [self createAuxillaryStylusActionData];
1239-
1240-
auto packet = std::make_unique<flutter::PointerDataPacket>(1);
1241-
packet->SetPointerData(/*index=*/0, pointer_data);
1242-
[_engine.get() dispatchPointerDataPacket:std::move(packet)];
1243-
}
1244-
1245-
- (flutter::PointerData)createAuxillaryStylusActionData API_AVAILABLE(ios(13.4)) {
1246-
flutter::PointerData pointer_data;
1247-
pointer_data.Clear();
1248-
1249-
switch (UIPencilInteraction.preferredTapAction) {
1250-
case UIPencilPreferredActionIgnore:
1251-
pointer_data.preferred_auxiliary_stylus_action =
1252-
flutter::PointerData::PreferredStylusAuxiliaryAction::kIgnore;
1253-
break;
1254-
case UIPencilPreferredActionShowColorPalette:
1255-
pointer_data.preferred_auxiliary_stylus_action =
1256-
flutter::PointerData::PreferredStylusAuxiliaryAction::kShowColorPalette;
1257-
break;
1258-
case UIPencilPreferredActionSwitchEraser:
1259-
pointer_data.preferred_auxiliary_stylus_action =
1260-
flutter::PointerData::PreferredStylusAuxiliaryAction::kSwitchEraser;
1261-
break;
1262-
case UIPencilPreferredActionSwitchPrevious:
1263-
pointer_data.preferred_auxiliary_stylus_action =
1264-
flutter::PointerData::PreferredStylusAuxiliaryAction::kSwitchPrevious;
1265-
break;
1266-
default:
1267-
pointer_data.preferred_auxiliary_stylus_action =
1268-
flutter::PointerData::PreferredStylusAuxiliaryAction::kUnknown;
1269-
break;
1270-
}
1271-
1272-
pointer_data.time_stamp = [[NSProcessInfo processInfo] systemUptime] * kMicrosecondsPerSecond;
1273-
pointer_data.kind = flutter::PointerData::DeviceKind::kStylus;
1274-
pointer_data.signal_kind = flutter::PointerData::SignalKind::kStylusAuxiliaryAction;
1275-
1276-
return pointer_data;
1277-
}
1278-
12791227
#pragma mark - Handle view resizing
12801228

12811229
- (void)updateViewportMetrics {

0 commit comments

Comments
 (0)