node-mac-recorder 2.24.13 → 2.24.15
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/index.js +2 -1
- package/package.json +1 -1
- package/src/cursor_tracker.mm +7 -26
package/index.js
CHANGED
|
@@ -2007,7 +2007,8 @@ class MacRecorder extends EventEmitter {
|
|
|
2007
2007
|
this.cursorCaptureInterval = setInterval(() => {
|
|
2008
2008
|
try {
|
|
2009
2009
|
if (this.cursorCapturePaused) return;
|
|
2010
|
-
|
|
2010
|
+
// Geometry was resolved at capture start; scaleFactor is not used here.
|
|
2011
|
+
const position = nativeBinding.getCursorPosition(false);
|
|
2011
2012
|
const timestamp = Date.now() - this.cursorCaptureStartTime - this.cursorPausedDurationMs;
|
|
2012
2013
|
|
|
2013
2014
|
// Video-relative coordinate transformation for all recording types
|
package/package.json
CHANGED
package/src/cursor_tracker.mm
CHANGED
|
@@ -1929,31 +1929,7 @@ NSString* getCursorType() {
|
|
|
1929
1929
|
@autoreleasepool {
|
|
1930
1930
|
g_cursorTypeCounter++;
|
|
1931
1931
|
|
|
1932
|
-
//
|
|
1933
|
-
BOOL hasCursorPosition = NO;
|
|
1934
|
-
CGPoint cursorPos = CGPointZero;
|
|
1935
|
-
|
|
1936
|
-
CGEventRef event = CGEventCreate(NULL);
|
|
1937
|
-
if (event) {
|
|
1938
|
-
cursorPos = CGEventGetLocation(event);
|
|
1939
|
-
hasCursorPosition = YES;
|
|
1940
|
-
CFRelease(event);
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1943
|
-
if (!hasCursorPosition) {
|
|
1944
|
-
if ([NSThread isMainThread]) {
|
|
1945
|
-
cursorPos = [NSEvent mouseLocation];
|
|
1946
|
-
hasCursorPosition = YES;
|
|
1947
|
-
} else {
|
|
1948
|
-
__block CGPoint fallbackPos = CGPointZero;
|
|
1949
|
-
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
1950
|
-
fallbackPos = [NSEvent mouseLocation];
|
|
1951
|
-
});
|
|
1952
|
-
cursorPos = fallbackPos;
|
|
1953
|
-
hasCursorPosition = YES;
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1932
|
+
// Position is sampled by the caller; cursor type detection does not use it.
|
|
1957
1933
|
// Get seed and save to global variable for getCursorPosition()
|
|
1958
1934
|
int currentSeed = SafeCGSCurrentCursorSeed();
|
|
1959
1935
|
g_lastCursorSeed = currentSeed; // Save for getCursorPosition()
|
|
@@ -2390,7 +2366,11 @@ NSDictionary* getDisplayScalingInfo(CGPoint globalPoint) {
|
|
|
2390
2366
|
|
|
2391
2367
|
// NAPI Function: Get Current Cursor Position
|
|
2392
2368
|
Napi::Value GetCursorPosition(const Napi::CallbackInfo& info) {
|
|
2369
|
+
@autoreleasepool {
|
|
2393
2370
|
Napi::Env env = info.Env();
|
|
2371
|
+
// Recording already has display-relative geometry. Public callers retain
|
|
2372
|
+
// the full result unless they explicitly opt out of the display query.
|
|
2373
|
+
const bool includeDisplayInfo = !(info.Length() > 0 && info[0].IsBoolean() && !info[0].As<Napi::Boolean>().Value());
|
|
2394
2374
|
|
|
2395
2375
|
@try {
|
|
2396
2376
|
// Get raw cursor position (may be scaled on Retina displays)
|
|
@@ -2454,7 +2434,7 @@ Napi::Value GetCursorPosition(const Napi::CallbackInfo& info) {
|
|
|
2454
2434
|
result.Set("seed", Napi::Number::New(env, g_lastCursorSeed));
|
|
2455
2435
|
|
|
2456
2436
|
// Basic display info
|
|
2457
|
-
NSDictionary *scalingInfo = getDisplayScalingInfo(rawLocation);
|
|
2437
|
+
NSDictionary *scalingInfo = includeDisplayInfo ? getDisplayScalingInfo(rawLocation) : nil;
|
|
2458
2438
|
if (scalingInfo) {
|
|
2459
2439
|
CGFloat scaleFactor = [[scalingInfo objectForKey:@"scaleFactor"] doubleValue];
|
|
2460
2440
|
result.Set("scaleFactor", Napi::Number::New(env, scaleFactor));
|
|
@@ -2466,6 +2446,7 @@ Napi::Value GetCursorPosition(const Napi::CallbackInfo& info) {
|
|
|
2466
2446
|
return env.Null();
|
|
2467
2447
|
}
|
|
2468
2448
|
}
|
|
2449
|
+
}
|
|
2469
2450
|
|
|
2470
2451
|
// NAPI Function: Get Cursor Tracking Status
|
|
2471
2452
|
Napi::Value GetCursorTrackingStatus(const Napi::CallbackInfo& info) {
|