node-mac-recorder 2.20.4 → 2.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cursor_tracker.mm +47 -32
package/package.json
CHANGED
package/src/cursor_tracker.mm
CHANGED
|
@@ -248,13 +248,7 @@ static NSString* CursorTypeFromAccessibilityElement(AXUIElementRef element, CGPo
|
|
|
248
248
|
CFRelease(valueAttribute);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
|
|
252
|
-
return @"progress";
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (StringEqualsAny(role, @[@"AXHelpTag", @"AXTooltip"])) {
|
|
256
|
-
return @"help";
|
|
257
|
-
}
|
|
251
|
+
// Leave progress/help to system cursor; don't force via AX
|
|
258
252
|
|
|
259
253
|
if ([role isEqualToString:@"AXSplitter"]) {
|
|
260
254
|
NSString *orientation = CopyAttributeString(element, CFSTR("AXOrientation"));
|
|
@@ -273,11 +267,11 @@ static NSString* CursorTypeFromAccessibilityElement(AXUIElementRef element, CGPo
|
|
|
273
267
|
}
|
|
274
268
|
}
|
|
275
269
|
|
|
276
|
-
|
|
270
|
+
// Pointer (hand) only for actual links; buttons remain default arrow on macOS
|
|
271
|
+
if (StringEqualsAny(role, @[@"AXLink"])) {
|
|
277
272
|
return @"pointer";
|
|
278
273
|
}
|
|
279
|
-
|
|
280
|
-
if (StringEqualsAny(subrole, @[@"AXLink", @"AXToolbarButton", @"AXFileDrop", @"AXDropTarget"])) {
|
|
274
|
+
if (StringEqualsAny(subrole, @[@"AXLink"])) {
|
|
281
275
|
return @"pointer";
|
|
282
276
|
}
|
|
283
277
|
|
|
@@ -295,11 +289,7 @@ static NSString* CursorTypeFromAccessibilityElement(AXUIElementRef element, CGPo
|
|
|
295
289
|
}
|
|
296
290
|
}
|
|
297
291
|
|
|
298
|
-
|
|
299
|
-
ElementHasAction(element, kAXShowMenuAction) ||
|
|
300
|
-
ElementHasAction(element, CFSTR("AXConfirm"))) {
|
|
301
|
-
return @"pointer";
|
|
302
|
-
}
|
|
292
|
+
// Actions alone do not imply pointer hand on macOS; ignore
|
|
303
293
|
|
|
304
294
|
CFTypeRef urlValue = NULL;
|
|
305
295
|
if (AXUIElementCopyAttributeValue(element, kAXURLAttribute, &urlValue) == kAXErrorSuccess && urlValue) {
|
|
@@ -310,23 +300,37 @@ static NSString* CursorTypeFromAccessibilityElement(AXUIElementRef element, CGPo
|
|
|
310
300
|
CFRelease(urlValue);
|
|
311
301
|
}
|
|
312
302
|
|
|
313
|
-
|
|
314
|
-
if (CopyAttributeBoolean(element, CFSTR("AXDraggable"), &isDraggable) && isDraggable) {
|
|
315
|
-
return @"grab";
|
|
316
|
-
}
|
|
303
|
+
// Grab/open-hand often comes from system cursor; avoid forcing via AX
|
|
317
304
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
305
|
+
// Zoom is rare; prefer system cursor unless explicitly needed
|
|
306
|
+
|
|
307
|
+
return nil;
|
|
308
|
+
}
|
|
322
309
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (
|
|
327
|
-
return
|
|
310
|
+
static AXUIElementRef CopyParent(AXUIElementRef element) {
|
|
311
|
+
if (!element) return NULL;
|
|
312
|
+
AXUIElementRef parent = NULL;
|
|
313
|
+
if (AXUIElementCopyAttributeValue(element, kAXParentAttribute, (CFTypeRef *)&parent) == kAXErrorSuccess && parent) {
|
|
314
|
+
return parent; // retained
|
|
328
315
|
}
|
|
316
|
+
if (parent) CFRelease(parent);
|
|
317
|
+
return NULL;
|
|
318
|
+
}
|
|
329
319
|
|
|
320
|
+
static NSString* CursorTypeFromElementOrAncestors(AXUIElementRef element, CGPoint cursorPos, int maxDepth) {
|
|
321
|
+
AXUIElementRef current = element;
|
|
322
|
+
int depth = 0;
|
|
323
|
+
while (current && depth < maxDepth) {
|
|
324
|
+
NSString *t = CursorTypeFromAccessibilityElement(current, cursorPos);
|
|
325
|
+
if (t && [t length] > 0) {
|
|
326
|
+
return t;
|
|
327
|
+
}
|
|
328
|
+
AXUIElementRef parent = CopyParent(current);
|
|
329
|
+
if (current != element) CFRelease(current);
|
|
330
|
+
current = parent;
|
|
331
|
+
depth++;
|
|
332
|
+
}
|
|
333
|
+
if (current && current != element) CFRelease(current);
|
|
330
334
|
return nil;
|
|
331
335
|
}
|
|
332
336
|
|
|
@@ -348,7 +352,7 @@ static NSString* detectCursorTypeUsingAccessibility(CGPoint cursorPos) {
|
|
|
348
352
|
AXUIElementRef elementAtPosition = NULL;
|
|
349
353
|
AXError error = AXUIElementCopyElementAtPosition(systemWide, cursorPos.x, cursorPos.y, &elementAtPosition);
|
|
350
354
|
if (error == kAXErrorSuccess && elementAtPosition) {
|
|
351
|
-
cursorType =
|
|
355
|
+
cursorType = CursorTypeFromElementOrAncestors(elementAtPosition, cursorPos, 6);
|
|
352
356
|
CFRelease(elementAtPosition);
|
|
353
357
|
}
|
|
354
358
|
|
|
@@ -359,7 +363,7 @@ static NSString* detectCursorTypeUsingAccessibility(CGPoint cursorPos) {
|
|
|
359
363
|
AXError hitError = AXUIElementCopyParameterizedAttributeValue(systemWide, kAXHitTestParameterizedAttribute, pointValue, (CFTypeRef *)&hitElement);
|
|
360
364
|
CFRelease(pointValue);
|
|
361
365
|
if (hitError == kAXErrorSuccess && hitElement) {
|
|
362
|
-
cursorType =
|
|
366
|
+
cursorType = CursorTypeFromElementOrAncestors(hitElement, cursorPos, 6);
|
|
363
367
|
CFRelease(hitElement);
|
|
364
368
|
}
|
|
365
369
|
}
|
|
@@ -658,6 +662,10 @@ CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef eve
|
|
|
658
662
|
NSTimeInterval timestamp = [currentDate timeIntervalSinceDate:g_trackingStartTime] * 1000; // milliseconds
|
|
659
663
|
NSTimeInterval unixTimeMs = [currentDate timeIntervalSince1970] * 1000; // unix timestamp in milliseconds
|
|
660
664
|
NSString *cursorType = getCursorType();
|
|
665
|
+
// Debug fields: capture raw AX and system cursor types
|
|
666
|
+
NSString *axTypeDbg = detectCursorTypeUsingAccessibility(location);
|
|
667
|
+
NSString *sysTypeDbg = detectSystemCursorType();
|
|
668
|
+
// (already captured above)
|
|
661
669
|
NSString *eventType = @"move";
|
|
662
670
|
|
|
663
671
|
// Event tipini belirle
|
|
@@ -690,7 +698,9 @@ CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef eve
|
|
|
690
698
|
@"timestamp": @(timestamp),
|
|
691
699
|
@"unixTimeMs": @(unixTimeMs),
|
|
692
700
|
@"cursorType": cursorType,
|
|
693
|
-
@"type": eventType
|
|
701
|
+
@"type": eventType,
|
|
702
|
+
@"axCursorType": axTypeDbg ? axTypeDbg : @"",
|
|
703
|
+
@"systemCursorType": sysTypeDbg ? sysTypeDbg : @""
|
|
694
704
|
};
|
|
695
705
|
|
|
696
706
|
// Direkt dosyaya yaz
|
|
@@ -723,6 +733,9 @@ void cursorTimerCallback() {
|
|
|
723
733
|
NSTimeInterval timestamp = [currentDate timeIntervalSinceDate:g_trackingStartTime] * 1000; // milliseconds
|
|
724
734
|
NSTimeInterval unixTimeMs = [currentDate timeIntervalSince1970] * 1000; // unix timestamp in milliseconds
|
|
725
735
|
NSString *cursorType = getCursorType();
|
|
736
|
+
// Debug fields: capture raw AX and system cursor types
|
|
737
|
+
NSString *axTypeDbg = detectCursorTypeUsingAccessibility(location);
|
|
738
|
+
NSString *sysTypeDbg = detectSystemCursorType();
|
|
726
739
|
|
|
727
740
|
// Cursor data oluştur
|
|
728
741
|
NSDictionary *cursorInfo = @{
|
|
@@ -731,7 +744,9 @@ void cursorTimerCallback() {
|
|
|
731
744
|
@"timestamp": @(timestamp),
|
|
732
745
|
@"unixTimeMs": @(unixTimeMs),
|
|
733
746
|
@"cursorType": cursorType,
|
|
734
|
-
@"type": @"move"
|
|
747
|
+
@"type": @"move",
|
|
748
|
+
@"axCursorType": axTypeDbg ? axTypeDbg : @"",
|
|
749
|
+
@"systemCursorType": sysTypeDbg ? sysTypeDbg : @""
|
|
735
750
|
};
|
|
736
751
|
|
|
737
752
|
// Direkt dosyaya yaz
|