node-mac-recorder 2.4.12 → 2.4.14

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.4.12",
3
+ "version": "2.4.14",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -467,19 +467,36 @@ void updateOverlay() {
467
467
  int width = [[windowUnderCursor objectForKey:@"width"] intValue];
468
468
  int height = [[windowUnderCursor objectForKey:@"height"] intValue];
469
469
 
470
- // Convert coordinates from CGWindow (top-left) to NSWindow (bottom-left)
471
- NSScreen *mainScreen = [NSScreen mainScreen];
472
- CGFloat screenHeight = [mainScreen frame].size.height;
473
- CGFloat adjustedY = screenHeight - y - height;
470
+ // Find which screen contains the window center
471
+ NSArray *screens = [NSScreen screens];
472
+ NSScreen *windowScreen = nil;
473
+ CGFloat windowCenterX = x + width / 2;
474
+ CGFloat windowCenterY = y + height / 2;
475
+
476
+ for (NSScreen *screen in screens) {
477
+ NSRect screenFrame = [screen frame];
478
+ // Convert screen frame to CGWindow coordinates
479
+ CGFloat screenTop = screenFrame.origin.y + screenFrame.size.height;
480
+ CGFloat screenBottom = screenFrame.origin.y;
481
+ CGFloat screenLeft = screenFrame.origin.x;
482
+ CGFloat screenRight = screenFrame.origin.x + screenFrame.size.width;
483
+
484
+ if (windowCenterX >= screenLeft && windowCenterX <= screenRight &&
485
+ windowCenterY >= screenBottom && windowCenterY <= screenTop) {
486
+ windowScreen = screen;
487
+ break;
488
+ }
489
+ }
490
+
491
+ // Use main screen if no specific screen found
492
+ if (!windowScreen) windowScreen = [NSScreen mainScreen];
474
493
 
475
- // Clamp overlay to screen bounds to avoid partial off-screen issues
476
- NSRect screenFrame = [mainScreen frame];
477
- CGFloat clampedX = MAX(screenFrame.origin.x, MIN(x, screenFrame.origin.x + screenFrame.size.width - width));
478
- CGFloat clampedY = MAX(screenFrame.origin.y, MIN(adjustedY, screenFrame.origin.y + screenFrame.size.height - height));
479
- CGFloat clampedWidth = MIN(width, screenFrame.size.width - (clampedX - screenFrame.origin.x));
480
- CGFloat clampedHeight = MIN(height, screenFrame.size.height - (clampedY - screenFrame.origin.y));
494
+ // Convert coordinates from CGWindow (top-left) to NSWindow (bottom-left) for the specific screen
495
+ CGFloat screenHeight = [windowScreen frame].size.height;
496
+ CGFloat adjustedY = screenHeight - y - height;
481
497
 
482
- NSRect overlayFrame = NSMakeRect(clampedX, clampedY, clampedWidth, clampedHeight);
498
+ // Use actual window coordinates without clamping to preserve overlay accuracy
499
+ NSRect overlayFrame = NSMakeRect(x, adjustedY, width, height);
483
500
 
484
501
  NSString *windowTitle = [windowUnderCursor objectForKey:@"title"] ?: @"Untitled";
485
502
  NSString *appName = [windowUnderCursor objectForKey:@"appName"] ?: @"Unknown";
@@ -501,6 +518,8 @@ void updateOverlay() {
501
518
  }
502
519
  }
503
520
  }
521
+
522
+ // Ensure overlay is on the correct screen
504
523
  [g_overlayWindow setFrame:overlayFrame display:YES];
505
524
 
506
525
  // Update overlay view window info
@@ -757,16 +776,15 @@ bool startScreenSelection() {
757
776
  NSButton *selectButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 180, 60)];
758
777
  [selectButton setTitle:@"Start Record"];
759
778
  [selectButton setButtonType:NSButtonTypeMomentaryPushIn];
760
- [selectButton setBezelStyle:NSBezelStyleRounded];
779
+ [selectButton setBezelStyle:NSBezelStyleRegularSquare];
761
780
  [selectButton setFont:[NSFont systemFontOfSize:16 weight:NSFontWeightSemibold]];
762
781
  [selectButton setTag:i]; // Set screen index as tag
763
782
 
764
783
  // Blue background with white text
765
784
  [selectButton setWantsLayer:YES];
766
- [selectButton.layer setBackgroundColor:[[NSColor colorWithRed:0.0 green:0.4 blue:0.8 alpha:0.9] CGColor]];
767
- [selectButton.layer setCornerRadius:8.0];
768
- [selectButton.layer setBorderColor:[[NSColor colorWithRed:0.0 green:0.3 blue:0.7 alpha:1.0] CGColor]];
769
- [selectButton.layer setBorderWidth:2.0];
785
+ [selectButton.layer setBackgroundColor:[[NSColor colorWithRed:0.2 green:0.6 blue:1.0 alpha:0.95] CGColor]];
786
+ [selectButton.layer setCornerRadius:12.0];
787
+ [selectButton.layer setBorderWidth:0.0];
770
788
 
771
789
  // White text color
772
790
  NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc]
@@ -793,15 +811,14 @@ bool startScreenSelection() {
793
811
  NSButton *screenCancelButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 120, 40)];
794
812
  [screenCancelButton setTitle:@"Cancel"];
795
813
  [screenCancelButton setButtonType:NSButtonTypeMomentaryPushIn];
796
- [screenCancelButton setBezelStyle:NSBezelStyleRounded];
814
+ [screenCancelButton setBezelStyle:NSBezelStyleRegularSquare];
797
815
  [screenCancelButton setFont:[NSFont systemFontOfSize:14 weight:NSFontWeightMedium]];
798
816
 
799
817
  // Gray cancel button styling
800
818
  [screenCancelButton setWantsLayer:YES];
801
- [screenCancelButton.layer setBackgroundColor:[[NSColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.8] CGColor]];
802
- [screenCancelButton.layer setCornerRadius:6.0];
803
- [screenCancelButton.layer setBorderColor:[[NSColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:1.0] CGColor]];
804
- [screenCancelButton.layer setBorderWidth:1.0];
819
+ [screenCancelButton.layer setBackgroundColor:[[NSColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.9] CGColor]];
820
+ [screenCancelButton.layer setCornerRadius:10.0];
821
+ [screenCancelButton.layer setBorderWidth:0.0];
805
822
 
806
823
  // White text for cancel button
807
824
  NSMutableAttributedString *screenCancelTitleString = [[NSMutableAttributedString alloc]
@@ -992,15 +1009,14 @@ Napi::Value StartWindowSelection(const Napi::CallbackInfo& info) {
992
1009
  g_selectButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 160, 60)];
993
1010
  [g_selectButton setTitle:@"Start Record"];
994
1011
  [g_selectButton setButtonType:NSButtonTypeMomentaryPushIn];
995
- [g_selectButton setBezelStyle:NSBezelStyleRounded];
1012
+ [g_selectButton setBezelStyle:NSBezelStyleRegularSquare];
996
1013
  [g_selectButton setFont:[NSFont systemFontOfSize:16 weight:NSFontWeightSemibold]];
997
1014
 
998
1015
  // Blue background with white text
999
1016
  [g_selectButton setWantsLayer:YES];
1000
- [g_selectButton.layer setBackgroundColor:[[NSColor colorWithRed:0.0 green:0.4 blue:0.8 alpha:0.9] CGColor]];
1001
- [g_selectButton.layer setCornerRadius:8.0];
1002
- [g_selectButton.layer setBorderColor:[[NSColor colorWithRed:0.0 green:0.3 blue:0.7 alpha:1.0] CGColor]];
1003
- [g_selectButton.layer setBorderWidth:2.0];
1017
+ [g_selectButton.layer setBackgroundColor:[[NSColor colorWithRed:0.2 green:0.6 blue:1.0 alpha:0.95] CGColor]];
1018
+ [g_selectButton.layer setCornerRadius:12.0];
1019
+ [g_selectButton.layer setBorderWidth:0.0];
1004
1020
 
1005
1021
  // White text color
1006
1022
  NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc]
@@ -1028,15 +1044,14 @@ Napi::Value StartWindowSelection(const Napi::CallbackInfo& info) {
1028
1044
  NSButton *cancelButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 120, 40)];
1029
1045
  [cancelButton setTitle:@"Cancel"];
1030
1046
  [cancelButton setButtonType:NSButtonTypeMomentaryPushIn];
1031
- [cancelButton setBezelStyle:NSBezelStyleRounded];
1047
+ [cancelButton setBezelStyle:NSBezelStyleRegularSquare];
1032
1048
  [cancelButton setFont:[NSFont systemFontOfSize:14 weight:NSFontWeightMedium]];
1033
1049
 
1034
1050
  // Gray cancel button styling
1035
1051
  [cancelButton setWantsLayer:YES];
1036
- [cancelButton.layer setBackgroundColor:[[NSColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.8] CGColor]];
1037
- [cancelButton.layer setCornerRadius:6.0];
1038
- [cancelButton.layer setBorderColor:[[NSColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:1.0] CGColor]];
1039
- [cancelButton.layer setBorderWidth:1.0];
1052
+ [cancelButton.layer setBackgroundColor:[[NSColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.9] CGColor]];
1053
+ [cancelButton.layer setCornerRadius:10.0];
1054
+ [cancelButton.layer setBorderWidth:0.0];
1040
1055
 
1041
1056
  // White text for cancel button
1042
1057
  NSMutableAttributedString *cancelTitleString = [[NSMutableAttributedString alloc]