node-mac-recorder 2.16.24 → 2.16.25

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.16.24",
3
+ "version": "2.16.25",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -567,50 +567,24 @@ Napi::Value GetDisplays(const Napi::CallbackInfo& info) {
567
567
  Napi::Env env = info.Env();
568
568
 
569
569
  @try {
570
- // Get displays using NSScreen instead of ScreenCapture
571
- NSArray *screens = [NSScreen screens];
570
+ // Get active displays directly using CGDirectDisplayID
572
571
  NSMutableArray *displays = [NSMutableArray array];
573
-
574
- // Get real CGDirectDisplayIDs first
575
572
  CGDirectDisplayID activeDisplays[32];
576
573
  uint32_t displayCount;
577
574
  CGGetActiveDisplayList(32, activeDisplays, &displayCount);
578
575
 
579
- for (NSUInteger i = 0; i < [screens count]; i++) {
580
- NSScreen *screen = [screens objectAtIndex:i];
581
- NSRect frame = [screen frame];
582
-
583
- // Find matching CGDirectDisplayID
584
- CGDirectDisplayID displayID = 0;
585
- bool isPrimary = false;
586
-
587
- for (uint32_t j = 0; j < displayCount; j++) {
588
- CGDirectDisplayID candidateID = activeDisplays[j];
589
- CGRect displayBounds = CGDisplayBounds(candidateID);
590
-
591
- if (fabs(frame.origin.x - displayBounds.origin.x) < 1.0 &&
592
- fabs(frame.origin.y - displayBounds.origin.y) < 1.0 &&
593
- fabs(frame.size.width - displayBounds.size.width) < 1.0 &&
594
- fabs(frame.size.height - displayBounds.size.height) < 1.0) {
595
- displayID = candidateID;
596
- isPrimary = (candidateID == CGMainDisplayID());
597
- break;
598
- }
599
- }
600
-
601
- // Fallback if no match found
602
- if (displayID == 0 && i < displayCount) {
603
- displayID = activeDisplays[i];
604
- isPrimary = (displayID == CGMainDisplayID());
605
- }
576
+ for (uint32_t i = 0; i < displayCount; i++) {
577
+ CGDirectDisplayID displayID = activeDisplays[i];
578
+ CGRect displayBounds = CGDisplayBounds(displayID);
579
+ bool isPrimary = (displayID == CGMainDisplayID());
606
580
 
607
581
  NSDictionary *displayInfo = @{
608
- @"id": @(displayID), // Use real display ID
609
- @"name": [NSString stringWithFormat:@"Display %lu", (unsigned long)(i + 1)],
610
- @"width": @((int)frame.size.width),
611
- @"height": @((int)frame.size.height),
612
- @"x": @((int)frame.origin.x),
613
- @"y": @((int)frame.origin.y),
582
+ @"id": @(displayID), // Direct CGDirectDisplayID
583
+ @"name": [NSString stringWithFormat:@"Display %u", (unsigned int)(i + 1)],
584
+ @"width": @((int)displayBounds.size.width),
585
+ @"height": @((int)displayBounds.size.height),
586
+ @"x": @((int)displayBounds.origin.x),
587
+ @"y": @((int)displayBounds.origin.y),
614
588
  @"isPrimary": @(isPrimary)
615
589
  };
616
590
  [displays addObject:displayInfo];
@@ -2360,33 +2360,15 @@ Napi::Value GetSelectedWindowInfo(const Napi::CallbackInfo& info) {
2360
2360
  windowScreen = mainScreen;
2361
2361
  }
2362
2362
 
2363
- // CRITICAL FIX: Add screen information using real CGDirectDisplayID
2363
+ // Simple screen information - no complex mapping
2364
2364
  NSRect screenFrame = [windowScreen frame];
2365
+ NSNumber *screenNumber = [windowScreen deviceDescription][@"NSScreenNumber"];
2365
2366
 
2366
- // Find real CGDirectDisplayID for this screen (matching GetDisplays logic)
2367
- CGDirectDisplayID realDisplayID = 0;
2368
- CGDirectDisplayID activeDisplays[32];
2369
- uint32_t displayCount;
2370
- CGGetActiveDisplayList(32, activeDisplays, &displayCount);
2371
-
2372
- for (uint32_t j = 0; j < displayCount; j++) {
2373
- CGDirectDisplayID candidateID = activeDisplays[j];
2374
- CGRect displayBounds = CGDisplayBounds(candidateID);
2375
-
2376
- if (fabs(screenFrame.origin.x - displayBounds.origin.x) < 1.0 &&
2377
- fabs(screenFrame.origin.y - displayBounds.origin.y) < 1.0 &&
2378
- fabs(screenFrame.size.width - displayBounds.size.width) < 1.0 &&
2379
- fabs(screenFrame.size.height - displayBounds.size.height) < 1.0) {
2380
- realDisplayID = candidateID;
2381
- break;
2382
- }
2383
- }
2384
-
2385
- NSLog(@"🔍 Window screen mapping: Frame=(%.0f,%.0f,%.0fx%.0f) → CGDirectDisplayID=%u",
2367
+ NSLog(@"🔍 Window screen: Frame=(%.0f,%.0f,%.0fx%.0f) ScreenNumber=%@",
2386
2368
  screenFrame.origin.x, screenFrame.origin.y,
2387
- screenFrame.size.width, screenFrame.size.height, realDisplayID);
2369
+ screenFrame.size.width, screenFrame.size.height, screenNumber);
2388
2370
 
2389
- result.Set("screenId", Napi::Number::New(env, realDisplayID));
2371
+ result.Set("screenId", Napi::Number::New(env, [screenNumber unsignedIntValue]));
2390
2372
  result.Set("screenX", Napi::Number::New(env, (int)screenFrame.origin.x));
2391
2373
  result.Set("screenY", Napi::Number::New(env, (int)screenFrame.origin.y));
2392
2374
  result.Set("screenWidth", Napi::Number::New(env, (int)screenFrame.size.width));