node-mac-recorder 2.4.3 → 2.4.5
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 +1 -1
- package/src/window_selector.mm +43 -16
package/package.json
CHANGED
package/src/window_selector.mm
CHANGED
|
@@ -221,8 +221,10 @@ bool hideScreenRecordingPreview();
|
|
|
221
221
|
@implementation WindowSelectorDelegate
|
|
222
222
|
- (void)selectButtonClicked:(id)sender {
|
|
223
223
|
if (g_currentWindowUnderCursor) {
|
|
224
|
-
g_selectedWindowInfo = g_currentWindowUnderCursor;
|
|
225
|
-
|
|
224
|
+
g_selectedWindowInfo = [g_currentWindowUnderCursor copy];
|
|
225
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
226
|
+
cleanupWindowSelector();
|
|
227
|
+
});
|
|
226
228
|
}
|
|
227
229
|
}
|
|
228
230
|
|
|
@@ -233,23 +235,22 @@ bool hideScreenRecordingPreview();
|
|
|
233
235
|
// Get screen info from global array using button tag
|
|
234
236
|
if (g_allScreens && screenIndex >= 0 && screenIndex < [g_allScreens count]) {
|
|
235
237
|
NSDictionary *screenInfo = [g_allScreens objectAtIndex:screenIndex];
|
|
236
|
-
g_selectedScreenInfo = screenInfo;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
[screenInfo objectForKey:@"resolution"]);
|
|
241
|
-
|
|
242
|
-
cleanupScreenSelector();
|
|
238
|
+
g_selectedScreenInfo = [screenInfo copy];
|
|
239
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
240
|
+
cleanupScreenSelector();
|
|
241
|
+
});
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
|
|
246
245
|
- (void)cancelButtonClicked:(id)sender {
|
|
247
|
-
NSLog(@"🚫 CANCEL BUTTON CLICKED: Selection cancelled");
|
|
248
|
-
// Clean up without selecting anything
|
|
249
246
|
if (g_isScreenSelecting) {
|
|
250
|
-
|
|
247
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
248
|
+
cleanupScreenSelector();
|
|
249
|
+
});
|
|
251
250
|
} else {
|
|
252
|
-
|
|
251
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
252
|
+
cleanupWindowSelector();
|
|
253
|
+
});
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
|
|
@@ -443,6 +444,11 @@ NSDictionary* getWindowUnderCursor(CGPoint point) {
|
|
|
443
444
|
|
|
444
445
|
// Update overlay to highlight window under cursor
|
|
445
446
|
void updateOverlay() {
|
|
447
|
+
// Ensure AppKit usage on main thread
|
|
448
|
+
if (![NSThread isMainThread]) {
|
|
449
|
+
dispatch_async(dispatch_get_main_queue(), ^{ updateOverlay(); });
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
446
452
|
@autoreleasepool {
|
|
447
453
|
if (!g_isWindowSelecting || !g_overlayWindow) return;
|
|
448
454
|
|
|
@@ -556,6 +562,10 @@ void updateOverlay() {
|
|
|
556
562
|
|
|
557
563
|
// Cleanup function
|
|
558
564
|
void cleanupWindowSelector() {
|
|
565
|
+
if (![NSThread isMainThread]) {
|
|
566
|
+
dispatch_async(dispatch_get_main_queue(), ^{ cleanupWindowSelector(); });
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
559
569
|
g_isWindowSelecting = false;
|
|
560
570
|
|
|
561
571
|
// Stop tracking timer
|
|
@@ -595,6 +605,10 @@ void cleanupWindowSelector() {
|
|
|
595
605
|
|
|
596
606
|
// Recording preview functions
|
|
597
607
|
void cleanupRecordingPreview() {
|
|
608
|
+
if (![NSThread isMainThread]) {
|
|
609
|
+
dispatch_async(dispatch_get_main_queue(), ^{ cleanupRecordingPreview(); });
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
598
612
|
if (g_recordingPreviewWindow) {
|
|
599
613
|
[g_recordingPreviewWindow close];
|
|
600
614
|
g_recordingPreviewWindow = nil;
|
|
@@ -674,6 +688,10 @@ bool hideRecordingPreview() {
|
|
|
674
688
|
|
|
675
689
|
// Screen selection functions
|
|
676
690
|
void cleanupScreenSelector() {
|
|
691
|
+
if (![NSThread isMainThread]) {
|
|
692
|
+
dispatch_async(dispatch_get_main_queue(), ^{ cleanupScreenSelector(); });
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
677
695
|
g_isScreenSelecting = false;
|
|
678
696
|
|
|
679
697
|
// Remove key event monitor
|
|
@@ -699,7 +717,13 @@ void cleanupScreenSelector() {
|
|
|
699
717
|
bool startScreenSelection() {
|
|
700
718
|
@try {
|
|
701
719
|
if (g_isScreenSelecting) return false;
|
|
702
|
-
|
|
720
|
+
// Force to main thread
|
|
721
|
+
if (![NSThread isMainThread]) {
|
|
722
|
+
__block BOOL ok = NO;
|
|
723
|
+
dispatch_sync(dispatch_get_main_queue(), ^{ ok = startScreenSelection(); });
|
|
724
|
+
return ok;
|
|
725
|
+
}
|
|
726
|
+
|
|
703
727
|
// Get all available screens
|
|
704
728
|
NSArray *screens = [NSScreen screens];
|
|
705
729
|
if (!screens || [screens count] == 0) return false;
|
|
@@ -861,9 +885,12 @@ bool startScreenSelection() {
|
|
|
861
885
|
bool stopScreenSelection() {
|
|
862
886
|
@try {
|
|
863
887
|
if (!g_isScreenSelecting) return false;
|
|
864
|
-
|
|
888
|
+
if (![NSThread isMainThread]) {
|
|
889
|
+
__block BOOL ok = NO;
|
|
890
|
+
dispatch_sync(dispatch_get_main_queue(), ^{ ok = stopScreenSelection(); });
|
|
891
|
+
return ok;
|
|
892
|
+
}
|
|
865
893
|
cleanupScreenSelector();
|
|
866
|
-
NSLog(@"🖥️ SCREEN SELECTION: Stopped");
|
|
867
894
|
return true;
|
|
868
895
|
|
|
869
896
|
} @catch (NSException *exception) {
|