node-mac-recorder 2.20.9 → 2.20.10
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 +48 -30
package/package.json
CHANGED
package/src/cursor_tracker.mm
CHANGED
|
@@ -644,36 +644,44 @@ static NSString* detectSystemCursorType(void) {
|
|
|
644
644
|
NSString *description = [currentCursor description];
|
|
645
645
|
NSLog(@"🖱️ Cursor class: %@, description: %@", className ?: @"nil", description ?: @"nil");
|
|
646
646
|
|
|
647
|
-
//
|
|
647
|
+
// Use more direct cursor detection approach
|
|
648
|
+
NSImage *cursorImage = [currentCursor image];
|
|
648
649
|
NSPoint hotspot = [currentCursor hotSpot];
|
|
649
|
-
NSSize
|
|
650
|
+
NSSize imageSize = [cursorImage size];
|
|
650
651
|
|
|
651
|
-
NSLog(@"🎯 Cursor
|
|
652
|
-
|
|
652
|
+
NSLog(@"🎯 Cursor analysis: size=%.1fx%.1f, hotspot=(%.1f,%.1f)",
|
|
653
|
+
imageSize.width, imageSize.height, hotspot.x, hotspot.y);
|
|
653
654
|
|
|
654
|
-
//
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
} else if ((hotspot.x >= 12.0 && hotspot.x <= 16.0) && (hotspot.y >= 6.0 && hotspot.y <= 10.0)) {
|
|
660
|
-
// I-beam cursor typically has hotspot around middle
|
|
655
|
+
// Updated pattern recognition based on observed values
|
|
656
|
+
if (imageSize.width >= 8.0 && imageSize.width <= 12.0 &&
|
|
657
|
+
imageSize.height >= 16.0 && imageSize.height <= 20.0 &&
|
|
658
|
+
hotspot.x >= 3.0 && hotspot.x <= 5.0 && hotspot.y >= 8.0 && hotspot.y <= 10.0) {
|
|
659
|
+
// I-beam cursor: narrow and tall, hotspot in middle
|
|
661
660
|
cursorType = @"text";
|
|
662
|
-
NSLog(@"🎯 IBEAM CURSOR
|
|
663
|
-
}
|
|
664
|
-
|
|
661
|
+
NSLog(@"🎯 DETECTED IBEAM CURSOR -> text");
|
|
662
|
+
}
|
|
663
|
+
else if (imageSize.width <= 20.0 && imageSize.height <= 25.0 &&
|
|
664
|
+
hotspot.x <= 5.0 && hotspot.y <= 5.0) {
|
|
665
|
+
// Arrow cursor: small size, hotspot at top-left
|
|
666
|
+
cursorType = @"default";
|
|
667
|
+
NSLog(@"🎯 DETECTED ARROW CURSOR -> default");
|
|
668
|
+
}
|
|
669
|
+
else if (imageSize.width >= 15.0 && imageSize.width <= 25.0 &&
|
|
670
|
+
imageSize.height >= 15.0 && imageSize.height <= 25.0 &&
|
|
671
|
+
hotspot.x >= 5.0 && hotspot.x <= 10.0 && hotspot.y <= 8.0) {
|
|
672
|
+
// Hand cursor: squarish, hotspot at fingertip
|
|
665
673
|
cursorType = @"pointer";
|
|
666
|
-
NSLog(@"🎯
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
674
|
+
NSLog(@"🎯 DETECTED HAND CURSOR -> pointer");
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
// Try to use a different approach - cursor name introspection
|
|
678
|
+
NSString *derived = cursorTypeFromNSCursor(currentCursor);
|
|
679
|
+
if (derived && ![derived isEqualToString:@"default"]) {
|
|
680
|
+
cursorType = derived;
|
|
681
|
+
NSLog(@"🎯 DERIVED FROM ANALYSIS: %@", cursorType);
|
|
673
682
|
} else {
|
|
674
|
-
// Use accessibility detection if system cursor is generic
|
|
675
683
|
cursorType = @"default";
|
|
676
|
-
NSLog(@"🎯
|
|
684
|
+
NSLog(@"🎯 FALLBACK TO DEFAULT (will check AX)");
|
|
677
685
|
}
|
|
678
686
|
}
|
|
679
687
|
} else {
|
|
@@ -730,22 +738,32 @@ NSString* getCursorType() {
|
|
|
730
738
|
|
|
731
739
|
NSString *finalType = @"default";
|
|
732
740
|
|
|
733
|
-
//
|
|
741
|
+
// Smart decision logic: AX for special cases, system for normal cases
|
|
734
742
|
NSLog(@"🎯 CURSOR DECISION: system='%@', ax='%@'", systemCursorType ?: @"nil", axCursorType ?: @"nil");
|
|
735
743
|
|
|
736
|
-
//
|
|
737
|
-
if (systemCursorType && [systemCursorType length] > 0) {
|
|
744
|
+
// If system cursor detected something specific (not default), use it
|
|
745
|
+
if (systemCursorType && [systemCursorType length] > 0 && ![systemCursorType isEqualToString:@"default"]) {
|
|
746
|
+
finalType = systemCursorType;
|
|
747
|
+
NSLog(@"🎯 Using SYSTEM cursor (specific): %@", finalType);
|
|
748
|
+
}
|
|
749
|
+
// If AX detected something specific and system is default, use AX
|
|
750
|
+
else if (axCursorType && [axCursorType length] > 0 && ![axCursorType isEqualToString:@"default"] &&
|
|
751
|
+
(!systemCursorType || [systemCursorType isEqualToString:@"default"])) {
|
|
752
|
+
finalType = axCursorType;
|
|
753
|
+
NSLog(@"🎯 Using AX cursor (specific over default): %@", finalType);
|
|
754
|
+
}
|
|
755
|
+
// Otherwise use system cursor (including default)
|
|
756
|
+
else if (systemCursorType && [systemCursorType length] > 0) {
|
|
738
757
|
finalType = systemCursorType;
|
|
739
758
|
NSLog(@"🎯 Using SYSTEM cursor: %@", finalType);
|
|
740
759
|
}
|
|
741
|
-
//
|
|
760
|
+
// Final fallback to AX or default
|
|
742
761
|
else if (axCursorType && [axCursorType length] > 0) {
|
|
743
762
|
finalType = axCursorType;
|
|
744
|
-
NSLog(@"🎯 Using AX cursor (fallback): %@", finalType);
|
|
763
|
+
NSLog(@"🎯 Using AX cursor (final fallback): %@", finalType);
|
|
745
764
|
}
|
|
746
|
-
// Final fallback
|
|
747
765
|
else {
|
|
748
|
-
NSLog(@"🎯
|
|
766
|
+
NSLog(@"🎯 Ultimate fallback to default");
|
|
749
767
|
}
|
|
750
768
|
|
|
751
769
|
NSLog(@"🎯 FINAL CURSOR TYPE: %@", finalType);
|