Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
- (int)unregisterTouch:(RNGHUITouch *)touch
{
for (int index = 0; index < MAX_POINTERS_COUNT; index++) {
#if TARGET_OS_OSX
// A macOS mouse sequence delivers a fresh NSEvent per event, so identity matching
// (valid on iOS, where a UITouch is one stable object for the whole touch) never
// matches. There is only one mouse pointer — match the tracked slot instead.
if (_trackedPointers[index] != nil) {
#else
if (_trackedPointers[index] == touch) {
#endif
_trackedPointers[index] = nil;
return index;
}
Expand All @@ -51,7 +58,12 @@
- (int)findTouchIndex:(RNGHUITouch *)touch
{
for (int index = 0; index < MAX_POINTERS_COUNT; index++) {
#if TARGET_OS_OSX
// See unregisterTouch: — identity matching cannot work for NSEvents.
if (_trackedPointers[index] != nil) {
#else
if (_trackedPointers[index] == touch) {
#endif
return index;
}
}
Expand Down Expand Up @@ -94,7 +106,7 @@
{
int registeredTouches = [self registeredTouchesCount];

NSDictionary *data[registeredTouches];

Check warning on line 109 in packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm

View workflow job for this annotation

GitHub Actions / build (apps/basic-example)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
int nextIndex = 0;

for (int i = 0; i < MAX_POINTERS_COUNT; i++) {
Expand All @@ -115,7 +127,7 @@

_eventType = RNGHTouchEventTypePointerDown;

NSDictionary *data[touches.count];

Check warning on line 130 in packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm

View workflow job for this annotation

GitHub Actions / build (apps/basic-example)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
int changedCount = 0;

for (int i = 0; i < [touches count]; i++) {
Expand Down Expand Up @@ -148,7 +160,7 @@

_eventType = RNGHTouchEventTypePointerMove;

NSDictionary *data[touches.count];

Check warning on line 163 in packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm

View workflow job for this annotation

GitHub Actions / build (apps/basic-example)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
int changedCount = 0;

for (int i = 0; i < [touches count]; i++) {
Expand All @@ -159,6 +171,12 @@
continue;
}

#if TARGET_OS_OSX
// Replace the stored mouse-down event with the latest one so extractAllTouches
// reads the pointer's current position, not where the sequence started.
_trackedPointers[index] = touch;
#endif

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
data[changedCount++] = [self extractPointerData:index forTouch:touch];
}

Expand All @@ -177,12 +195,24 @@
return;
}

#if TARGET_OS_OSX
// Refresh the tracked slot with the ending event so extractAllTouches below reports
// the pointer's final position. On iOS the stored UITouch is a live object that
// always reads its current location; a stored NSEvent is a stale snapshot.
for (RNGHUITouch *touch in touches) {
int index = [self findTouchIndex:touch];
if (index >= 0) {
_trackedPointers[index] = touch;
}
}
#endif

// extract all touches first to include the ones that were just lifted
[self extractAllTouches];

_eventType = RNGHTouchEventTypePointerUp;

NSDictionary *data[touches.count];

Check warning on line 215 in packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm

View workflow job for this annotation

GitHub Actions / build (apps/basic-example)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
int changedCount = 0;

for (int i = 0; i < [touches count]; i++) {
Expand Down Expand Up @@ -242,7 +272,7 @@

if (registeredTouches > 0) {
int nextIndex = 0;
NSDictionary *data[registeredTouches];

Check warning on line 275 in packages/react-native-gesture-handler/apple/RNGestureHandlerPointerTracker.mm

View workflow job for this annotation

GitHub Actions / build (apps/basic-example)

variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]

for (int i = 0; i < MAX_POINTERS_COUNT; i++) {
RNGHUITouch *touch = _trackedPointers[i];
Expand Down
Loading