node-mac-recorder 2.20.9 → 2.20.11
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/.claude/settings.local.json +2 -1
- package/index.js +6 -6
- package/package.json +1 -1
- package/src/cursor_tracker.mm +102 -114
- package/src/mac_recorder.mm +8 -8
package/index.js
CHANGED
|
@@ -217,7 +217,7 @@ class MacRecorder extends EventEmitter {
|
|
|
217
217
|
adjustedX = targetWindow.x - display.x;
|
|
218
218
|
adjustedY = targetWindow.y - display.y;
|
|
219
219
|
|
|
220
|
-
console.log(`🔧 macOS 14/13 coordinate fix: Global (${targetWindow.x},${targetWindow.y}) -> Display-relative (${adjustedX},${adjustedY})`);
|
|
220
|
+
// console.log(`🔧 macOS 14/13 coordinate fix: Global (${targetWindow.x},${targetWindow.y}) -> Display-relative (${adjustedX},${adjustedY})`);
|
|
221
221
|
break;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -271,9 +271,9 @@ class MacRecorder extends EventEmitter {
|
|
|
271
271
|
height: targetWindow.height,
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
-
console.log(
|
|
275
|
-
|
|
276
|
-
);
|
|
274
|
+
// console.log(
|
|
275
|
+
// `Window ${targetWindow.appName}: display=${targetDisplayId}, coords=${targetWindow.x},${targetWindow.y} -> ${adjustedX},${adjustedY}`
|
|
276
|
+
// );
|
|
277
277
|
}
|
|
278
278
|
} catch (error) {
|
|
279
279
|
console.warn(
|
|
@@ -357,7 +357,7 @@ class MacRecorder extends EventEmitter {
|
|
|
357
357
|
recordingOptions
|
|
358
358
|
);
|
|
359
359
|
} catch (error) {
|
|
360
|
-
console.log('Native recording failed, trying alternative method');
|
|
360
|
+
// console.log('Native recording failed, trying alternative method');
|
|
361
361
|
success = false;
|
|
362
362
|
}
|
|
363
363
|
|
|
@@ -466,7 +466,7 @@ class MacRecorder extends EventEmitter {
|
|
|
466
466
|
try {
|
|
467
467
|
success = nativeBinding.stopRecording();
|
|
468
468
|
} catch (nativeError) {
|
|
469
|
-
console.log('Native stop failed:', nativeError.message);
|
|
469
|
+
// console.log('Native stop failed:', nativeError.message);
|
|
470
470
|
success = true; // Assume success to avoid throwing
|
|
471
471
|
}
|
|
472
472
|
|
package/package.json
CHANGED
package/src/cursor_tracker.mm
CHANGED
|
@@ -525,7 +525,7 @@ static NSString* cursorTypeFromNSCursor(NSCursor *cursor) {
|
|
|
525
525
|
return @"default";
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
// Standard macOS
|
|
528
|
+
// PRIORITY: Standard macOS cursor pointer equality (most reliable)
|
|
529
529
|
if (cursor == [NSCursor arrowCursor]) {
|
|
530
530
|
return @"default";
|
|
531
531
|
}
|
|
@@ -602,23 +602,28 @@ static NSString* cursorTypeFromNSCursor(NSCursor *cursor) {
|
|
|
602
602
|
NSString *className = NSStringFromClass([cursor class]);
|
|
603
603
|
NSString *description = [cursor description];
|
|
604
604
|
|
|
605
|
-
|
|
605
|
+
// Debug: Check for pointer cursor patterns
|
|
606
|
+
if (className && ([className containsString:@"pointing"] || [className containsString:@"Hand"])) {
|
|
607
|
+
NSLog(@"🔍 POINTER CLASS: %@", className);
|
|
608
|
+
return @"pointer";
|
|
609
|
+
}
|
|
610
|
+
if (description && ([description containsString:@"pointing"] || [description containsString:@"hand"])) {
|
|
611
|
+
NSLog(@"🔍 POINTER DESC: %@", description);
|
|
612
|
+
return @"pointer";
|
|
613
|
+
}
|
|
606
614
|
|
|
607
615
|
// Try name-based detection
|
|
608
616
|
NSString *derived = cursorTypeFromCursorName(className);
|
|
609
617
|
if (derived) {
|
|
610
|
-
MRLog(@"🎯 Cursor type from class name: %@", derived);
|
|
611
618
|
return derived;
|
|
612
619
|
}
|
|
613
620
|
|
|
614
621
|
derived = cursorTypeFromCursorName(description);
|
|
615
622
|
if (derived) {
|
|
616
|
-
MRLog(@"🎯 Cursor type from description: %@", derived);
|
|
617
623
|
return derived;
|
|
618
624
|
}
|
|
619
625
|
|
|
620
626
|
// Default fallback
|
|
621
|
-
MRLog(@"⚠️ Unknown cursor type, defaulting to 'default'");
|
|
622
627
|
return @"default";
|
|
623
628
|
}
|
|
624
629
|
|
|
@@ -631,53 +636,71 @@ static NSString* detectSystemCursorType(void) {
|
|
|
631
636
|
// Try different methods to get current cursor
|
|
632
637
|
if ([NSCursor respondsToSelector:@selector(currentSystemCursor)]) {
|
|
633
638
|
currentCursor = [NSCursor currentSystemCursor];
|
|
634
|
-
NSLog(@"🖱️ currentSystemCursor: %@", currentCursor ?: @"nil");
|
|
635
639
|
}
|
|
636
640
|
|
|
637
641
|
if (!currentCursor) {
|
|
638
642
|
currentCursor = [NSCursor currentCursor];
|
|
639
|
-
NSLog(@"🖱️ currentCursor: %@", currentCursor ?: @"nil");
|
|
640
643
|
}
|
|
641
644
|
|
|
642
645
|
if (currentCursor) {
|
|
643
646
|
NSString *className = NSStringFromClass([currentCursor class]);
|
|
644
647
|
NSString *description = [currentCursor description];
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
// Try to identify cursor by hotspot and size (more reliable than pointer equality)
|
|
648
|
+
// Use more direct cursor detection approach
|
|
649
|
+
NSImage *cursorImage = [currentCursor image];
|
|
648
650
|
NSPoint hotspot = [currentCursor hotSpot];
|
|
649
|
-
NSSize
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
651
|
+
NSSize imageSize = [cursorImage size];
|
|
652
|
+
|
|
653
|
+
// ROBUST cursor detection - works with any cursor size
|
|
654
|
+
CGFloat aspectRatio = imageSize.width / imageSize.height;
|
|
655
|
+
CGFloat relativeHotspotX = hotspot.x / imageSize.width;
|
|
656
|
+
CGFloat relativeHotspotY = hotspot.y / imageSize.height;
|
|
657
|
+
|
|
658
|
+
// Debug: Show proportional analysis
|
|
659
|
+
NSLog(@"🔍 CURSOR: %.1fx%.1f ratio=%.2f hotspot=(%.2f,%.2f)",
|
|
660
|
+
imageSize.width, imageSize.height, aspectRatio, relativeHotspotX, relativeHotspotY);
|
|
661
|
+
|
|
662
|
+
// UPDATED with real cursor data:
|
|
663
|
+
// Arrow: 17x23 ratio=0.74 hotspot=(0.24,0.17)
|
|
664
|
+
// Text: 9x18 ratio=0.50 hotspot=(0.44,0.50)
|
|
665
|
+
// Pointer: 32x32 ratio=1.00 hotspot=(0.41,0.25)
|
|
666
|
+
|
|
667
|
+
// 1. TEXT/I-BEAM CURSOR - narrow ratio, center hotspot
|
|
668
|
+
if (aspectRatio >= 0.45 && aspectRatio <= 0.60 && // Narrow (0.50 typical)
|
|
669
|
+
relativeHotspotX >= 0.35 && relativeHotspotX <= 0.55 && // Center X (0.44 typical)
|
|
670
|
+
relativeHotspotY >= 0.40 && relativeHotspotY <= 0.60) { // Center Y (0.50 typical)
|
|
661
671
|
cursorType = @"text";
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
672
|
+
}
|
|
673
|
+
// 2. ARROW CURSOR - medium ratio, top-left hotspot
|
|
674
|
+
else if (aspectRatio >= 0.65 && aspectRatio <= 0.85 && // Medium (0.74 typical)
|
|
675
|
+
relativeHotspotX >= 0.15 && relativeHotspotX <= 0.35 && // Left side (0.24 typical)
|
|
676
|
+
relativeHotspotY >= 0.10 && relativeHotspotY <= 0.25) { // Top area (0.17 typical)
|
|
677
|
+
cursorType = @"default";
|
|
678
|
+
}
|
|
679
|
+
// 3. POINTER CURSOR - square ratio, left-center hotspot
|
|
680
|
+
else if (aspectRatio >= 0.90 && aspectRatio <= 1.10 && // Square (1.00 typical)
|
|
681
|
+
relativeHotspotX >= 0.30 && relativeHotspotX <= 0.50 && // Left-center (0.41 typical)
|
|
682
|
+
relativeHotspotY >= 0.15 && relativeHotspotY <= 0.35) { // Upper area (0.25 typical)
|
|
665
683
|
cursorType = @"pointer";
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
684
|
+
}
|
|
685
|
+
// 4. GRAB CURSOR - square, center hotspot
|
|
686
|
+
else if (aspectRatio >= 0.90 && aspectRatio <= 1.10 && // Square
|
|
687
|
+
relativeHotspotX >= 0.40 && relativeHotspotX <= 0.60 && // Center X
|
|
688
|
+
relativeHotspotY >= 0.40 && relativeHotspotY <= 0.60) { // Center Y
|
|
689
|
+
cursorType = @"grab";
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
// Try to use a different approach - cursor name introspection
|
|
693
|
+
NSString *derived = cursorTypeFromNSCursor(currentCursor);
|
|
694
|
+
if (derived && ![derived isEqualToString:@"default"]) {
|
|
695
|
+
cursorType = derived;
|
|
696
|
+
// NSLog(@"🎯 DERIVED FROM ANALYSIS: %@", cursorType);
|
|
673
697
|
} else {
|
|
674
|
-
// Use accessibility detection if system cursor is generic
|
|
675
698
|
cursorType = @"default";
|
|
676
|
-
NSLog(@"🎯
|
|
699
|
+
// NSLog(@"🎯 FALLBACK TO DEFAULT (will check AX)");
|
|
677
700
|
}
|
|
678
701
|
}
|
|
679
702
|
} else {
|
|
680
|
-
NSLog(@"🖱️ No current cursor found");
|
|
703
|
+
// NSLog(@"🖱️ No current cursor found");
|
|
681
704
|
cursorType = @"default";
|
|
682
705
|
}
|
|
683
706
|
};
|
|
@@ -730,25 +753,33 @@ NSString* getCursorType() {
|
|
|
730
753
|
|
|
731
754
|
NSString *finalType = @"default";
|
|
732
755
|
|
|
733
|
-
//
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
// Use system cursor if available (it's more accurate for visual appearance)
|
|
756
|
+
// SYSTEM CURSOR FIRST - more reliable for visual state
|
|
757
|
+
// Always trust system cursor first, only use AX for very specific cases
|
|
737
758
|
if (systemCursorType && [systemCursorType length] > 0) {
|
|
738
|
-
|
|
739
|
-
|
|
759
|
+
// Only override system cursor with AX if system is "default" AND AX gives us text/resize
|
|
760
|
+
if ([systemCursorType isEqualToString:@"default"] && axCursorType &&
|
|
761
|
+
([axCursorType isEqualToString:@"text"] ||
|
|
762
|
+
[axCursorType containsString:@"resize"] ||
|
|
763
|
+
[axCursorType isEqualToString:@"crosshair"])) {
|
|
764
|
+
finalType = axCursorType;
|
|
765
|
+
} else {
|
|
766
|
+
finalType = systemCursorType;
|
|
767
|
+
}
|
|
740
768
|
}
|
|
741
|
-
//
|
|
769
|
+
// Only if system completely fails, use AX
|
|
742
770
|
else if (axCursorType && [axCursorType length] > 0) {
|
|
743
771
|
finalType = axCursorType;
|
|
744
|
-
NSLog(@"🎯 Using AX cursor (fallback): %@", finalType);
|
|
745
772
|
}
|
|
746
|
-
// Final fallback
|
|
747
773
|
else {
|
|
748
|
-
|
|
774
|
+
finalType = @"default";
|
|
749
775
|
}
|
|
750
776
|
|
|
751
|
-
|
|
777
|
+
// Only log when cursor type changes
|
|
778
|
+
static NSString *lastLoggedType = nil;
|
|
779
|
+
if (![finalType isEqualToString:lastLoggedType]) {
|
|
780
|
+
NSLog(@"🎯 %@", finalType);
|
|
781
|
+
lastLoggedType = [finalType copy];
|
|
782
|
+
}
|
|
752
783
|
return finalType;
|
|
753
784
|
}
|
|
754
785
|
}
|
|
@@ -1047,80 +1078,58 @@ NSDictionary* getDisplayScalingInfo(CGPoint globalPoint) {
|
|
|
1047
1078
|
uint32_t displayCount;
|
|
1048
1079
|
CGDirectDisplayID displayIDs[32];
|
|
1049
1080
|
CGGetActiveDisplayList(32, displayIDs, &displayCount);
|
|
1050
|
-
|
|
1081
|
+
|
|
1051
1082
|
// Find which display contains this point
|
|
1052
1083
|
for (uint32_t i = 0; i < displayCount; i++) {
|
|
1053
1084
|
CGDirectDisplayID displayID = displayIDs[i];
|
|
1054
1085
|
CGRect displayBounds = CGDisplayBounds(displayID);
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
displayID, displayBounds.origin.x, displayBounds.origin.y,
|
|
1058
|
-
displayBounds.size.width, displayBounds.size.height,
|
|
1059
|
-
globalPoint.x, globalPoint.y);
|
|
1060
|
-
|
|
1061
|
-
// CRITICAL FIX: Manual bounds check for better coordinate system compatibility
|
|
1062
|
-
BOOL isInBounds = (globalPoint.x >= displayBounds.origin.x &&
|
|
1086
|
+
|
|
1087
|
+
BOOL isInBounds = (globalPoint.x >= displayBounds.origin.x &&
|
|
1063
1088
|
globalPoint.x < displayBounds.origin.x + displayBounds.size.width &&
|
|
1064
|
-
globalPoint.y >= displayBounds.origin.y &&
|
|
1089
|
+
globalPoint.y >= displayBounds.origin.y &&
|
|
1065
1090
|
globalPoint.y < displayBounds.origin.y + displayBounds.size.height);
|
|
1066
|
-
|
|
1067
|
-
NSLog(@"🔍 Manual bounds check: %s", isInBounds ? "INSIDE" : "OUTSIDE");
|
|
1068
|
-
|
|
1091
|
+
|
|
1069
1092
|
// Check if point is within this display
|
|
1070
1093
|
if (isInBounds) {
|
|
1071
|
-
//
|
|
1072
|
-
// Method 1: CGDisplayCreateImage (may be scaled on some systems)
|
|
1094
|
+
// Get physical dimensions
|
|
1073
1095
|
CGImageRef testImage = CGDisplayCreateImage(displayID);
|
|
1074
1096
|
CGSize imageSize = CGSizeMake(CGImageGetWidth(testImage), CGImageGetHeight(testImage));
|
|
1075
1097
|
CGImageRelease(testImage);
|
|
1076
|
-
|
|
1077
|
-
// Method 2: Native display mode detection for true physical resolution
|
|
1098
|
+
|
|
1078
1099
|
CGSize actualPhysicalSize = imageSize;
|
|
1079
1100
|
CFArrayRef displayModes = CGDisplayCopyAllDisplayModes(displayID, NULL);
|
|
1080
1101
|
if (displayModes) {
|
|
1081
1102
|
CFIndex modeCount = CFArrayGetCount(displayModes);
|
|
1082
1103
|
CGSize maxResolution = CGSizeMake(0, 0);
|
|
1083
|
-
|
|
1084
|
-
// Find the highest resolution mode (native resolution)
|
|
1104
|
+
|
|
1085
1105
|
for (CFIndex i = 0; i < modeCount; i++) {
|
|
1086
1106
|
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(displayModes, i);
|
|
1087
1107
|
CGSize modeSize = CGSizeMake(CGDisplayModeGetWidth(mode), CGDisplayModeGetHeight(mode));
|
|
1088
|
-
|
|
1089
|
-
if (modeSize.width > maxResolution.width ||
|
|
1108
|
+
|
|
1109
|
+
if (modeSize.width > maxResolution.width ||
|
|
1090
1110
|
(modeSize.width == maxResolution.width && modeSize.height > maxResolution.height)) {
|
|
1091
1111
|
maxResolution = modeSize;
|
|
1092
1112
|
}
|
|
1093
1113
|
}
|
|
1094
|
-
|
|
1095
|
-
// Use the max resolution if it's significantly higher than image size
|
|
1114
|
+
|
|
1096
1115
|
if (maxResolution.width > imageSize.width * 1.5 || maxResolution.height > imageSize.height * 1.5) {
|
|
1097
1116
|
actualPhysicalSize = maxResolution;
|
|
1098
|
-
NSLog(@"🔍 Using display mode detection: %.0fx%.0f (was %.0fx%.0f)",
|
|
1099
|
-
maxResolution.width, maxResolution.height, imageSize.width, imageSize.height);
|
|
1100
1117
|
} else {
|
|
1101
1118
|
actualPhysicalSize = imageSize;
|
|
1102
|
-
NSLog(@"🔍 Using image size detection: %.0fx%.0f", imageSize.width, imageSize.height);
|
|
1103
1119
|
}
|
|
1104
|
-
|
|
1120
|
+
|
|
1105
1121
|
CFRelease(displayModes);
|
|
1106
1122
|
} else {
|
|
1107
1123
|
actualPhysicalSize = imageSize;
|
|
1108
1124
|
}
|
|
1109
|
-
|
|
1125
|
+
|
|
1110
1126
|
CGSize logicalSize = displayBounds.size;
|
|
1111
1127
|
CGSize reportedPhysicalSize = CGSizeMake(CGDisplayPixelsWide(displayID), CGDisplayPixelsHigh(displayID));
|
|
1112
|
-
|
|
1113
|
-
NSLog(@"🔍 REAL scaling info:");
|
|
1114
|
-
NSLog(@" Logical: %.0fx%.0f", logicalSize.width, logicalSize.height);
|
|
1115
|
-
NSLog(@" Reported physical: %.0fx%.0f", reportedPhysicalSize.width, reportedPhysicalSize.height);
|
|
1116
|
-
NSLog(@" ACTUAL physical: %.0fx%.0f", actualPhysicalSize.width, actualPhysicalSize.height);
|
|
1117
|
-
|
|
1128
|
+
|
|
1118
1129
|
CGFloat scaleX = actualPhysicalSize.width / logicalSize.width;
|
|
1119
1130
|
CGFloat scaleY = actualPhysicalSize.height / logicalSize.height;
|
|
1120
1131
|
CGFloat scaleFactor = MAX(scaleX, scaleY);
|
|
1121
1132
|
|
|
1122
|
-
NSLog(@"🔍 REAL scale factors: X=%.2f, Y=%.2f, Final=%.2f", scaleX, scaleY, scaleFactor);
|
|
1123
|
-
|
|
1124
1133
|
return @{
|
|
1125
1134
|
@"displayID": @(displayID),
|
|
1126
1135
|
@"logicalSize": [NSValue valueWithSize:NSMakeSize(logicalSize.width, logicalSize.height)],
|
|
@@ -1131,39 +1140,37 @@ NSDictionary* getDisplayScalingInfo(CGPoint globalPoint) {
|
|
|
1131
1140
|
}
|
|
1132
1141
|
}
|
|
1133
1142
|
|
|
1134
|
-
// Fallback to main display
|
|
1143
|
+
// Fallback to main display
|
|
1135
1144
|
CGDirectDisplayID mainDisplay = CGMainDisplayID();
|
|
1136
1145
|
CGRect displayBounds = CGDisplayBounds(mainDisplay);
|
|
1137
|
-
|
|
1138
|
-
// Get REAL physical dimensions using multiple detection methods
|
|
1146
|
+
|
|
1139
1147
|
CGImageRef testImage = CGDisplayCreateImage(mainDisplay);
|
|
1140
1148
|
CGSize imageSize = CGSizeMake(CGImageGetWidth(testImage), CGImageGetHeight(testImage));
|
|
1141
1149
|
CGImageRelease(testImage);
|
|
1142
|
-
|
|
1143
|
-
// Try display mode detection for true native resolution
|
|
1150
|
+
|
|
1144
1151
|
CGSize actualPhysicalSize = imageSize;
|
|
1145
1152
|
CFArrayRef displayModes = CGDisplayCopyAllDisplayModes(mainDisplay, NULL);
|
|
1146
1153
|
if (displayModes) {
|
|
1147
1154
|
CFIndex modeCount = CFArrayGetCount(displayModes);
|
|
1148
1155
|
CGSize maxResolution = CGSizeMake(0, 0);
|
|
1149
|
-
|
|
1156
|
+
|
|
1150
1157
|
for (CFIndex i = 0; i < modeCount; i++) {
|
|
1151
1158
|
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(displayModes, i);
|
|
1152
1159
|
CGSize modeSize = CGSizeMake(CGDisplayModeGetWidth(mode), CGDisplayModeGetHeight(mode));
|
|
1153
|
-
|
|
1154
|
-
if (modeSize.width > maxResolution.width ||
|
|
1160
|
+
|
|
1161
|
+
if (modeSize.width > maxResolution.width ||
|
|
1155
1162
|
(modeSize.width == maxResolution.width && modeSize.height > maxResolution.height)) {
|
|
1156
1163
|
maxResolution = modeSize;
|
|
1157
1164
|
}
|
|
1158
1165
|
}
|
|
1159
|
-
|
|
1166
|
+
|
|
1160
1167
|
if (maxResolution.width > imageSize.width * 1.5 || maxResolution.height > imageSize.height * 1.5) {
|
|
1161
1168
|
actualPhysicalSize = maxResolution;
|
|
1162
1169
|
}
|
|
1163
|
-
|
|
1170
|
+
|
|
1164
1171
|
CFRelease(displayModes);
|
|
1165
1172
|
}
|
|
1166
|
-
|
|
1173
|
+
|
|
1167
1174
|
CGSize logicalSize = displayBounds.size;
|
|
1168
1175
|
CGFloat scaleFactor = MAX(actualPhysicalSize.width / logicalSize.width, actualPhysicalSize.height / logicalSize.height);
|
|
1169
1176
|
|
|
@@ -1191,10 +1198,7 @@ Napi::Value GetCursorPosition(const Napi::CallbackInfo& info) {
|
|
|
1191
1198
|
CFRelease(event);
|
|
1192
1199
|
}
|
|
1193
1200
|
|
|
1194
|
-
// Get display scaling information
|
|
1195
|
-
NSDictionary *scalingInfo = getDisplayScalingInfo(rawLocation);
|
|
1196
1201
|
CGPoint logicalLocation = rawLocation;
|
|
1197
|
-
// CGEventGetLocation already returns logical coordinates; additional scaling happens in JS layer.
|
|
1198
1202
|
|
|
1199
1203
|
NSString *cursorType = getCursorType();
|
|
1200
1204
|
|
|
@@ -1232,27 +1236,11 @@ Napi::Value GetCursorPosition(const Napi::CallbackInfo& info) {
|
|
|
1232
1236
|
result.Set("cursorType", Napi::String::New(env, [cursorType UTF8String]));
|
|
1233
1237
|
result.Set("eventType", Napi::String::New(env, [eventType UTF8String]));
|
|
1234
1238
|
|
|
1235
|
-
//
|
|
1239
|
+
// Basic display info
|
|
1240
|
+
NSDictionary *scalingInfo = getDisplayScalingInfo(rawLocation);
|
|
1236
1241
|
if (scalingInfo) {
|
|
1237
1242
|
CGFloat scaleFactor = [[scalingInfo objectForKey:@"scaleFactor"] doubleValue];
|
|
1238
|
-
NSSize logicalSize = [[scalingInfo objectForKey:@"logicalSize"] sizeValue];
|
|
1239
|
-
NSSize physicalSize = [[scalingInfo objectForKey:@"physicalSize"] sizeValue];
|
|
1240
|
-
NSRect displayBounds = [[scalingInfo objectForKey:@"displayBounds"] rectValue];
|
|
1241
|
-
|
|
1242
1243
|
result.Set("scaleFactor", Napi::Number::New(env, scaleFactor));
|
|
1243
|
-
result.Set("rawX", Napi::Number::New(env, (int)rawLocation.x));
|
|
1244
|
-
result.Set("rawY", Napi::Number::New(env, (int)rawLocation.y));
|
|
1245
|
-
|
|
1246
|
-
// Add display dimension info for JS coordinate transformation
|
|
1247
|
-
Napi::Object displayInfo = Napi::Object::New(env);
|
|
1248
|
-
displayInfo.Set("logicalWidth", Napi::Number::New(env, logicalSize.width));
|
|
1249
|
-
displayInfo.Set("logicalHeight", Napi::Number::New(env, logicalSize.height));
|
|
1250
|
-
displayInfo.Set("physicalWidth", Napi::Number::New(env, physicalSize.width));
|
|
1251
|
-
displayInfo.Set("physicalHeight", Napi::Number::New(env, physicalSize.height));
|
|
1252
|
-
displayInfo.Set("displayX", Napi::Number::New(env, displayBounds.origin.x));
|
|
1253
|
-
displayInfo.Set("displayY", Napi::Number::New(env, displayBounds.origin.y));
|
|
1254
|
-
|
|
1255
|
-
result.Set("displayInfo", displayInfo);
|
|
1256
1244
|
}
|
|
1257
1245
|
|
|
1258
1246
|
return result;
|
package/src/mac_recorder.mm
CHANGED
|
@@ -591,16 +591,16 @@ Napi::Value GetDisplays(const Napi::CallbackInfo& info) {
|
|
|
591
591
|
}
|
|
592
592
|
Napi::Array result = Napi::Array::New(env, displays.count);
|
|
593
593
|
|
|
594
|
-
NSLog(@"Found %lu displays", (unsigned long)displays.count);
|
|
595
|
-
|
|
594
|
+
// NSLog(@"Found %lu displays", (unsigned long)displays.count);
|
|
595
|
+
|
|
596
596
|
for (NSUInteger i = 0; i < displays.count; i++) {
|
|
597
597
|
NSDictionary *display = displays[i];
|
|
598
|
-
NSLog(@"Display %lu: ID=%u, Name=%@, Size=%@x%@",
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
598
|
+
// NSLog(@"Display %lu: ID=%u, Name=%@, Size=%@x%@",
|
|
599
|
+
// (unsigned long)i,
|
|
600
|
+
// [display[@"id"] unsignedIntValue],
|
|
601
|
+
// display[@"name"],
|
|
602
|
+
// display[@"width"],
|
|
603
|
+
// display[@"height"]);
|
|
604
604
|
|
|
605
605
|
Napi::Object displayObj = Napi::Object::New(env);
|
|
606
606
|
displayObj.Set("id", Napi::Number::New(env, [display[@"id"] unsignedIntValue]));
|