Skip to content

Commit

Permalink
Add discrete scale pointer signal (flutter#36342)
Browse files Browse the repository at this point in the history
  • Loading branch information
moffatman authored Sep 27, 2022
1 parent 700507f commit 9055e71
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/ui/pointer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ enum PointerSignalKind {
/// A pointer-generated scroll-inertia cancel.
scrollInertiaCancel,

/// A pointer-generated scale event (e.g. trackpad pinch).
scale,

/// An unknown pointer signal kind.
unknown
}
Expand Down
1 change: 1 addition & 0 deletions lib/ui/window/pointer_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct alignas(8) PointerData {
kNone,
kScroll,
kScrollInertiaCancel,
kScale,
};

int64_t embedder_id;
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/window/pointer_data_packet_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ void PointerDataPacketConverter::ConvertPointerData(
} else {
switch (pointer_data.signal_kind) {
case PointerData::SignalKind::kScroll:
case PointerData::SignalKind::kScrollInertiaCancel: {
case PointerData::SignalKind::kScrollInertiaCancel:
case PointerData::SignalKind::kScale: {
// Makes sure we have an existing pointer
auto iter = states_.find(pointer_data.device);
PointerState state;
Expand Down
1 change: 1 addition & 0 deletions lib/ui/window/pointer_data_packet_converter_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ TEST(PointerDataPacketConverterTest, CanConvertPointerSignals) {
PointerData::SignalKind signal_kinds[] = {
PointerData::SignalKind::kScroll,
PointerData::SignalKind::kScrollInertiaCancel,
PointerData::SignalKind::kScale,
};
for (const PointerData::SignalKind& kind : signal_kinds) {
PointerDataPacketConverter converter;
Expand Down
1 change: 1 addition & 0 deletions lib/web_ui/lib/pointer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum PointerSignalKind {
none,
scroll,
scrollInertiaCancel,
scale,
unknown
}

Expand Down
1 change: 1 addition & 0 deletions lib/web_ui/lib/src/engine/pointer_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ class PointerDataConverter {
switch (signalKind) {
case ui.PointerSignalKind.scroll:
case ui.PointerSignalKind.scrollInertiaCancel:
case ui.PointerSignalKind.scale:
final bool alreadyAdded = _pointers.containsKey(device);
_ensureStateForPointer(device, physicalX, physicalY);
if (!alreadyAdded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ public class AndroidTouchProcessor {
PointerSignalKind.NONE,
PointerSignalKind.SCROLL,
PointerSignalKind.SCROLL_INERTIA_CANCEL,
PointerSignalKind.SCALE,
PointerSignalKind.UNKNOWN
})
public @interface PointerSignalKind {
int NONE = 0;
int SCROLL = 1;
int SCROLL_INERTIA_CANCEL = 2;
int UNKNOWN = 3;
int SCALE = 3;
int UNKNOWN = 4;
}

// Must match the unpacking code in hooks.dart.
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,8 @@ inline flutter::PointerData::SignalKind ToPointerDataSignalKind(
return flutter::PointerData::SignalKind::kScroll;
case kFlutterPointerSignalKindScrollInertiaCancel:
return flutter::PointerData::SignalKind::kScrollInertiaCancel;
case kFlutterPointerSignalKindScale:
return flutter::PointerData::SignalKind::kScale;
}
return flutter::PointerData::SignalKind::kNone;
}
Expand Down
1 change: 1 addition & 0 deletions shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ typedef enum {
kFlutterPointerSignalKindNone,
kFlutterPointerSignalKindScroll,
kFlutterPointerSignalKindScrollInertiaCancel,
kFlutterPointerSignalKindScale,
} FlutterPointerSignalKind;

typedef struct {
Expand Down

0 comments on commit 9055e71

Please sign in to comment.