node-mac-recorder 2.7.2 → 2.7.3

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.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -68,7 +68,7 @@ void updateScreenOverlays();
68
68
  if (self) {
69
69
  // Use layer for background instead of custom drawing
70
70
  self.wantsLayer = YES;
71
- self.isActiveWindow = NO; // Default to inactive (no mouse highlighting)
71
+ self.isActiveWindow = NO; // Default to inactive (will be set by updateOverlay)
72
72
  self.isSelectedWindow = NO; // Default to not selected
73
73
 
74
74
  // Set initial appearance
@@ -87,10 +87,10 @@ void updateScreenOverlays();
87
87
  self.layer.borderWidth = 3.0; // Thick border for selected window
88
88
  // Selected window appearance set
89
89
  } else if (self.isActiveWindow) {
90
- // Active window: brighter background with thin border
90
+ // Active window (highlighted): brighter background with thin border
91
91
  self.layer.backgroundColor = [[NSColor colorWithRed:0.6 green:0.4 blue:0.9 alpha:0.4] CGColor];
92
92
  self.layer.borderColor = [[NSColor colorWithRed:0.6 green:0.4 blue:0.9 alpha:0.8] CGColor];
93
- self.layer.borderWidth = 1.0; // Thin border for active window
93
+ self.layer.borderWidth = 1.0; // Thin border for highlighted window
94
94
  // Active window appearance set
95
95
  } else {
96
96
  // Inactive window: dimmer background with no border
@@ -123,26 +123,46 @@ void updateScreenOverlays();
123
123
  }
124
124
 
125
125
  - (void)mouseDown:(NSEvent *)event {
126
- // Handle mouse click to select this window
126
+ // Handle mouse click to toggle window selection
127
127
  if (self.windowInfo) {
128
- // Set this overlay as selected
129
- self.isSelectedWindow = YES;
130
-
131
- // Update global selected window info
132
- if (g_selectedWindowInfo) {
133
- [g_selectedWindowInfo release];
128
+ // Check if this window is already selected
129
+ BOOL wasSelected = (g_selectedWindowInfo &&
130
+ [g_selectedWindowInfo isEqualToDictionary:self.windowInfo]);
131
+
132
+ if (wasSelected) {
133
+ // Deselect this window
134
+ self.isSelectedWindow = NO;
135
+
136
+ // Clear global selection
137
+ if (g_selectedWindowInfo) {
138
+ [g_selectedWindowInfo release];
139
+ g_selectedWindowInfo = nil;
140
+ }
141
+ g_selectedOverlayView = nil;
142
+
143
+ NSLog(@"🚫 WINDOW DESELECTED VIA CLICK: %@ - \"%@\"",
144
+ [self.windowInfo objectForKey:@"appName"] ?: @"Unknown",
145
+ [self.windowInfo objectForKey:@"title"] ?: @"Untitled");
146
+ } else {
147
+ // Select this window
148
+ self.isSelectedWindow = YES;
149
+
150
+ // Update global selected window info
151
+ if (g_selectedWindowInfo) {
152
+ [g_selectedWindowInfo release];
153
+ }
154
+ g_selectedWindowInfo = [self.windowInfo retain];
155
+
156
+ // Update global selected overlay reference
157
+ g_selectedOverlayView = self;
158
+
159
+ NSLog(@"🎯 WINDOW SELECTED VIA CLICK: %@ - \"%@\"",
160
+ [self.windowInfo objectForKey:@"appName"] ?: @"Unknown",
161
+ [self.windowInfo objectForKey:@"title"] ?: @"Untitled");
134
162
  }
135
- g_selectedWindowInfo = [self.windowInfo retain];
136
-
137
- // Update global selected overlay reference
138
- g_selectedOverlayView = self;
139
163
 
140
164
  // Update overlay appearance
141
165
  [self updateAppearance];
142
-
143
- NSLog(@"🎯 WINDOW SELECTED VIA CLICK: %@ - \"%@\"",
144
- [self.windowInfo objectForKey:@"appName"] ?: @"Unknown",
145
- [self.windowInfo objectForKey:@"title"] ?: @"Untitled");
146
166
  }
147
167
  }
148
168
 
@@ -494,23 +514,33 @@ NSDictionary* getWindowUnderCursor(CGPoint point) {
494
514
  }
495
515
  }
496
516
 
497
- // Update overlay to show selected window (no more mouse-based highlighting)
517
+ // Update overlay to show window under cursor with highlighting (but no auto-bring-to-front)
498
518
  void updateOverlay() {
499
519
  @autoreleasepool {
500
520
  if (!g_isWindowSelecting || !g_overlayWindow) return;
501
521
 
502
- // Check if we have a selected window or if we should show overlay for selection
503
- NSDictionary *windowUnderCursor = nil;
504
- if (!g_selectedWindowInfo) {
505
- // No window selected yet - show overlay for the first available window
522
+ // Get current cursor position for highlighting
523
+ NSPoint mouseLocation = [NSEvent mouseLocation];
524
+ NSScreen *mainScreen = [NSScreen mainScreen];
525
+ CGFloat screenHeight = [mainScreen frame].size.height;
526
+ CGPoint globalPoint = CGPointMake(mouseLocation.x, screenHeight - mouseLocation.y);
527
+
528
+ // Find window under cursor for highlighting
529
+ NSDictionary *windowUnderCursor = getWindowUnderCursor(globalPoint);
530
+
531
+ // Update current window under cursor for highlighting
532
+ if (windowUnderCursor && ![windowUnderCursor isEqualToDictionary:g_currentWindowUnderCursor]) {
533
+ [g_currentWindowUnderCursor release];
534
+ g_currentWindowUnderCursor = [windowUnderCursor retain];
535
+ }
536
+
537
+ // If no window under cursor, show first available window
538
+ if (!windowUnderCursor) {
506
539
  if (g_allWindows && [g_allWindows count] > 0) {
507
540
  windowUnderCursor = [g_allWindows objectAtIndex:0];
508
541
  } else {
509
542
  return; // No windows available
510
543
  }
511
- } else {
512
- // Use selected window info
513
- windowUnderCursor = g_selectedWindowInfo;
514
544
  }
515
545
 
516
546
  // Update overlay position and size
@@ -545,8 +575,8 @@ void updateOverlay() {
545
575
 
546
576
  // Convert coordinates from CGWindow (top-left) to NSWindow (bottom-left) for the specific screen
547
577
  NSRect screenFrame = [windowScreen frame];
548
- CGFloat screenHeight = screenFrame.size.height;
549
- CGFloat adjustedY = screenHeight - y - height;
578
+ CGFloat windowScreenHeight = screenFrame.size.height;
579
+ CGFloat adjustedY = windowScreenHeight - y - height;
550
580
 
551
581
  // Window coordinates are in global space, overlay frame should be screen-relative
552
582
  // Keep X coordinate as-is (already in global space which is what we want)
@@ -754,18 +784,24 @@ void updateOverlay() {
754
784
  [g_overlayWindow level], [g_overlayWindow alphaValue],
755
785
  [g_overlayWindow isVisible] ? "YES" : "NO");
756
786
 
757
- // Update overlay view states - check if this window is selected
787
+ // Update overlay view states - highlight window under cursor and check selection
758
788
  if (g_overlayView && [g_overlayView isKindOfClass:[WindowSelectorOverlayView class]]) {
759
789
  WindowSelectorOverlayView *overlayView = (WindowSelectorOverlayView *)g_overlayView;
760
790
 
761
- // Check if this is the selected window (true if we have selected window info)
762
- BOOL isSelected = (g_selectedWindowInfo != nil);
791
+ // Check if this window is under cursor (highlight)
792
+ BOOL isUnderCursor = (windowUnderCursor &&
793
+ [g_currentWindowUnderCursor isEqualToDictionary:windowUnderCursor]);
794
+
795
+ // Check if this is the selected window
796
+ BOOL isSelected = (g_selectedWindowInfo &&
797
+ [g_selectedWindowInfo isEqualToDictionary:windowUnderCursor]);
763
798
 
764
799
  // Update states
765
- overlayView.isActiveWindow = NO; // No more mouse-based highlighting
800
+ overlayView.isActiveWindow = isUnderCursor; // Highlight if under cursor
766
801
  overlayView.isSelectedWindow = isSelected;
767
802
 
768
- NSLog(@"🎯 Overlay State Updated: Active=NO, Selected=%s", isSelected ? "YES" : "NO");
803
+ NSLog(@"🎯 Overlay State Updated: Active=%s, Selected=%s",
804
+ isUnderCursor ? "YES" : "NO", isSelected ? "YES" : "NO");
769
805
  }
770
806
  }
771
807
  }
@@ -1540,6 +1576,11 @@ Napi::Value StartWindowSelection(const Napi::CallbackInfo& info) {
1540
1576
  [(WindowSelectorOverlayView *)g_overlayView setIsActiveWindow:NO];
1541
1577
  [(WindowSelectorOverlayView *)g_overlayView setIsSelectedWindow:NO];
1542
1578
 
1579
+ // Set initial window under cursor for highlighting
1580
+ if (g_allWindows && [g_allWindows count] > 0) {
1581
+ g_currentWindowUnderCursor = [[g_allWindows objectAtIndex:0] retain];
1582
+ }
1583
+
1543
1584
  // Note: NSWindow doesn't have setWantsLayer method, only NSView does
1544
1585
 
1545
1586
  // Force content view to have no borders