node-mac-recorder 2.10.4 → 2.10.6

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.10.4",
3
+ "version": "2.10.6",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -16,7 +16,8 @@ static NSTimer *g_trackingTimer = nil;
16
16
  static NSDictionary *g_selectedWindowInfo = nil;
17
17
  static NSMutableArray *g_allWindows = nil;
18
18
  static NSDictionary *g_currentWindowUnderCursor = nil;
19
- static bool g_bringToFrontEnabled = true; // Default enabled
19
+ static bool g_bringToFrontEnabled = false; // Default disabled for overlay-only highlighting
20
+ static bool g_hasToggledWindow = false; // Track if any window is currently toggled
20
21
  static id g_windowKeyEventMonitor = nil;
21
22
 
22
23
  // Recording preview overlay state
@@ -54,6 +55,7 @@ void updateScreenOverlays();
54
55
  @interface WindowSelectorOverlayView : NSView
55
56
  @property (nonatomic, strong) NSDictionary *windowInfo;
56
57
  @property (nonatomic) BOOL isActiveWindow;
58
+ @property (nonatomic) BOOL isToggled;
57
59
  @end
58
60
 
59
61
  @implementation WindowSelectorOverlayView
@@ -74,24 +76,28 @@ void updateScreenOverlays();
74
76
  }
75
77
 
76
78
  - (void)updateAppearance {
77
- if (self.isActiveWindow) {
78
- // Active window: brighter background
79
+ if (self.isToggled) {
80
+ // Toggled window: same background, thick border
79
81
  self.layer.backgroundColor = [[NSColor colorWithRed:0.6 green:0.4 blue:0.9 alpha:0.4] CGColor];
80
- // Active window appearance set
82
+ self.layer.borderColor = [[NSColor whiteColor] CGColor];
83
+ self.layer.borderWidth = 3.0;
84
+ } else if (self.isActiveWindow) {
85
+ // Active window: brighter background, no border
86
+ self.layer.backgroundColor = [[NSColor colorWithRed:0.6 green:0.4 blue:0.9 alpha:0.4] CGColor];
87
+ self.layer.borderColor = [[NSColor clearColor] CGColor];
88
+ self.layer.borderWidth = 0.0;
81
89
  } else {
82
- // Inactive window: dimmer background
90
+ // Inactive window: dimmer background, no border
83
91
  self.layer.backgroundColor = [[NSColor colorWithRed:0.4 green:0.2 blue:0.6 alpha:0.25] CGColor];
84
- // Inactive window appearance set
92
+ self.layer.borderColor = [[NSColor clearColor] CGColor];
93
+ self.layer.borderWidth = 0.0;
85
94
  }
86
95
 
87
- // 1px border for window highlight
88
- self.layer.borderColor = [[NSColor whiteColor] CGColor];
89
- self.layer.borderWidth = 1.0;
90
- self.layer.cornerRadius = 8.0;
91
- self.layer.masksToBounds = YES;
92
- self.layer.shadowOpacity = 0.0;
93
- self.layer.shadowRadius = 0.0;
94
- self.layer.shadowOffset = NSMakeSize(0, 0);
96
+ self.layer.cornerRadius = 8.0;
97
+ self.layer.masksToBounds = YES;
98
+ self.layer.shadowOpacity = 0.0;
99
+ self.layer.shadowRadius = 0.0;
100
+ self.layer.shadowOffset = NSMakeSize(0, 0);
95
101
  }
96
102
 
97
103
  - (void)setIsActiveWindow:(BOOL)isActiveWindow {
@@ -101,6 +107,35 @@ void updateScreenOverlays();
101
107
  }
102
108
  }
103
109
 
110
+ - (void)setIsToggled:(BOOL)isToggled {
111
+ if (_isToggled != isToggled) {
112
+ _isToggled = isToggled;
113
+ [self updateAppearance];
114
+ }
115
+ }
116
+
117
+ // Handle mouse clicks for toggle functionality
118
+ - (void)mouseDown:(NSEvent *)event {
119
+ [super mouseDown:event];
120
+
121
+ // Toggle the window state
122
+ self.isToggled = !self.isToggled;
123
+
124
+ // Update global toggle state
125
+ g_hasToggledWindow = self.isToggled;
126
+
127
+ // Bring window to front if toggled
128
+ if (self.isToggled && self.windowInfo) {
129
+ int windowId = [[self.windowInfo objectForKey:@"id"] intValue];
130
+ if (windowId > 0) {
131
+ bringWindowToFront(windowId);
132
+ NSLog(@"🔄 TOGGLED: Window brought to front - %@", [self.windowInfo objectForKey:@"title"]);
133
+ }
134
+ }
135
+
136
+ NSLog(@"🎯 Global toggle state: %s", g_hasToggledWindow ? "HAS_TOGGLED" : "NO_TOGGLE");
137
+ }
138
+
104
139
  // Layer-based approach, no custom drawing needed
105
140
 
106
141
  @end
@@ -460,6 +495,15 @@ void updateOverlay() {
460
495
  NSDictionary *windowUnderCursor = getWindowUnderCursor(globalPoint);
461
496
 
462
497
  if (windowUnderCursor && ![windowUnderCursor isEqualToDictionary:g_currentWindowUnderCursor]) {
498
+ // If there's a toggled window, don't switch to a different window
499
+ if (g_hasToggledWindow && g_currentWindowUnderCursor) {
500
+ // Check if current toggled window is different from window under cursor
501
+ BOOL isSameWindow = [[g_currentWindowUnderCursor objectForKey:@"id"] isEqual:[windowUnderCursor objectForKey:@"id"]];
502
+ if (!isSameWindow) {
503
+ NSLog(@"🔒 BLOCKED: Not switching overlay - current window is toggled");
504
+ return; // Don't update overlay for different window
505
+ }
506
+ }
463
507
  // Update current window
464
508
  [g_currentWindowUnderCursor release];
465
509
  g_currentWindowUnderCursor = [windowUnderCursor retain];
@@ -528,8 +572,10 @@ void updateOverlay() {
528
572
  // Ensure overlay is on the correct screen
529
573
  [g_overlayWindow setFrame:overlayFrame display:YES];
530
574
 
531
- // Update overlay view window info
575
+ // Update overlay view window info and reset toggle state for new window
532
576
  [(WindowSelectorOverlayView *)g_overlayView setWindowInfo:windowUnderCursor];
577
+ [(WindowSelectorOverlayView *)g_overlayView setIsToggled:NO];
578
+ g_hasToggledWindow = NO; // Reset global toggle state when switching windows
533
579
 
534
580
  // Add/update info label above button
535
581
  NSTextField *infoLabel = nil;
@@ -716,6 +762,7 @@ void updateOverlay() {
716
762
  // Cleanup function
717
763
  void cleanupWindowSelector() {
718
764
  g_isWindowSelecting = false;
765
+ g_hasToggledWindow = false; // Reset toggle state
719
766
 
720
767
  // Stop tracking timer
721
768
  if (g_trackingTimer) {
@@ -1574,10 +1621,15 @@ Napi::Value StartWindowSelection(const Napi::CallbackInfo& info) {
1574
1621
 
1575
1622
  // Cancel button reference will be found dynamically in positioning code
1576
1623
 
1577
- // Timer approach doesn't work well with Node.js
1578
- // Instead, we'll use JavaScript polling via getWindowSelectionStatus
1579
- // The JS side will call this function repeatedly to trigger overlay updates
1580
- g_trackingTimer = nil; // No timer for now
1624
+ // Start tracking timer for real-time window detection
1625
+ if (!g_delegate) {
1626
+ g_delegate = [[WindowSelectorDelegate alloc] init];
1627
+ }
1628
+ g_trackingTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 // 20 FPS
1629
+ target:g_delegate
1630
+ selector:@selector(timerUpdate:)
1631
+ userInfo:nil
1632
+ repeats:YES];
1581
1633
 
1582
1634
  // Add ESC key event monitor to cancel selection
1583
1635
  g_windowKeyEventMonitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSEventMaskKeyDown