node-mac-recorder 2.10.8 → 2.10.9
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 +60 -28
package/package.json
CHANGED
package/src/window_selector.mm
CHANGED
|
@@ -494,25 +494,47 @@ void updateOverlay() {
|
|
|
494
494
|
// Find window under cursor
|
|
495
495
|
NSDictionary *windowUnderCursor = getWindowUnderCursor(globalPoint);
|
|
496
496
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
497
|
+
// Decide which window to track (cursor or toggled)
|
|
498
|
+
NSDictionary *targetWindow = nil;
|
|
499
|
+
|
|
500
|
+
if (g_hasToggledWindow && g_currentWindowUnderCursor) {
|
|
501
|
+
// Use current toggled window, but get fresh position data
|
|
502
|
+
int windowId = [[g_currentWindowUnderCursor objectForKey:@"id"] intValue];
|
|
503
|
+
NSArray *allWindows = getAllSelectableWindows();
|
|
504
|
+
targetWindow = allWindows != nil ?
|
|
505
|
+
[[allWindows filteredArrayUsingPredicate:
|
|
506
|
+
[NSPredicate predicateWithFormat:@"id == %d", windowId]] firstObject] : nil;
|
|
507
|
+
|
|
508
|
+
if (!targetWindow) {
|
|
509
|
+
NSLog(@"⚠️ Toggled window no longer exists - resetting toggle");
|
|
510
|
+
g_hasToggledWindow = false;
|
|
511
|
+
targetWindow = windowUnderCursor;
|
|
512
|
+
}
|
|
513
|
+
} else {
|
|
514
|
+
targetWindow = windowUnderCursor;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (targetWindow) {
|
|
518
|
+
// Update current window if different or if we need fresh position data
|
|
519
|
+
BOOL shouldUpdate = !g_currentWindowUnderCursor ||
|
|
520
|
+
![targetWindow isEqualToDictionary:g_currentWindowUnderCursor] ||
|
|
521
|
+
g_hasToggledWindow; // Always update position for toggled windows
|
|
522
|
+
|
|
523
|
+
if (shouldUpdate && !g_hasToggledWindow) {
|
|
524
|
+
// Only switch windows if not toggled
|
|
525
|
+
[g_currentWindowUnderCursor release];
|
|
526
|
+
g_currentWindowUnderCursor = [targetWindow retain];
|
|
527
|
+
} else if (g_hasToggledWindow) {
|
|
528
|
+
// Update position data for toggled window
|
|
529
|
+
[g_currentWindowUnderCursor release];
|
|
530
|
+
g_currentWindowUnderCursor = [targetWindow retain];
|
|
506
531
|
}
|
|
507
|
-
// Update current window
|
|
508
|
-
[g_currentWindowUnderCursor release];
|
|
509
|
-
g_currentWindowUnderCursor = [windowUnderCursor retain];
|
|
510
532
|
|
|
511
|
-
// Update overlay position and size
|
|
512
|
-
int x = [[
|
|
513
|
-
int y = [[
|
|
514
|
-
int width = [[
|
|
515
|
-
int height = [[
|
|
533
|
+
// Update overlay position and size with fresh data
|
|
534
|
+
int x = [[targetWindow objectForKey:@"x"] intValue];
|
|
535
|
+
int y = [[targetWindow objectForKey:@"y"] intValue];
|
|
536
|
+
int width = [[targetWindow objectForKey:@"width"] intValue];
|
|
537
|
+
int height = [[targetWindow objectForKey:@"height"] intValue];
|
|
516
538
|
|
|
517
539
|
// Find which screen contains the window center
|
|
518
540
|
NSArray *screens = [NSScreen screens];
|
|
@@ -548,8 +570,8 @@ void updateOverlay() {
|
|
|
548
570
|
// Only convert Y from top-left to bottom-left coordinate system
|
|
549
571
|
NSRect overlayFrame = NSMakeRect(x, adjustedY, width, height);
|
|
550
572
|
|
|
551
|
-
NSString *windowTitle = [
|
|
552
|
-
NSString *appName = [
|
|
573
|
+
NSString *windowTitle = [targetWindow objectForKey:@"title"] ?: @"Untitled";
|
|
574
|
+
NSString *appName = [targetWindow objectForKey:@"appName"] ?: @"Unknown";
|
|
553
575
|
|
|
554
576
|
NSLog(@"🎯 WINDOW DETECTED: %@ - \"%@\"", appName, windowTitle);
|
|
555
577
|
NSLog(@" 📍 Position: (%d, %d) 📏 Size: %d × %d", x, y, width, height);
|
|
@@ -560,7 +582,7 @@ void updateOverlay() {
|
|
|
560
582
|
|
|
561
583
|
// Bring window to front if enabled
|
|
562
584
|
if (g_bringToFrontEnabled) {
|
|
563
|
-
int windowId = [[
|
|
585
|
+
int windowId = [[targetWindow objectForKey:@"id"] intValue];
|
|
564
586
|
if (windowId > 0) {
|
|
565
587
|
bool success = bringWindowToFront(windowId);
|
|
566
588
|
if (!success) {
|
|
@@ -572,10 +594,14 @@ void updateOverlay() {
|
|
|
572
594
|
// Ensure overlay is on the correct screen
|
|
573
595
|
[g_overlayWindow setFrame:overlayFrame display:YES];
|
|
574
596
|
|
|
575
|
-
// Update overlay view window info
|
|
576
|
-
[(WindowSelectorOverlayView *)g_overlayView setWindowInfo:
|
|
577
|
-
|
|
578
|
-
|
|
597
|
+
// Update overlay view window info
|
|
598
|
+
[(WindowSelectorOverlayView *)g_overlayView setWindowInfo:targetWindow];
|
|
599
|
+
|
|
600
|
+
// Only reset toggle state when switching to a different window (not for position updates)
|
|
601
|
+
if (shouldUpdate && !g_hasToggledWindow) {
|
|
602
|
+
[(WindowSelectorOverlayView *)g_overlayView setIsToggled:NO];
|
|
603
|
+
g_hasToggledWindow = NO; // Reset global toggle state when switching windows
|
|
604
|
+
}
|
|
579
605
|
|
|
580
606
|
// Add/update info label above button
|
|
581
607
|
NSTextField *infoLabel = nil;
|
|
@@ -727,8 +753,11 @@ void updateOverlay() {
|
|
|
727
753
|
[g_overlayWindow orderFront:nil];
|
|
728
754
|
[g_overlayWindow makeKeyAndOrderFront:nil];
|
|
729
755
|
|
|
730
|
-
// Ensure
|
|
756
|
+
// Ensure subviews (except overlay view itself) have no borders after positioning
|
|
731
757
|
for (NSView *subview in [g_overlayWindow.contentView subviews]) {
|
|
758
|
+
// Skip the main overlay view - it handles its own borders
|
|
759
|
+
if ([subview isKindOfClass:[WindowSelectorOverlayView class]]) continue;
|
|
760
|
+
|
|
732
761
|
if ([subview respondsToSelector:@selector(setWantsLayer:)]) {
|
|
733
762
|
[subview setWantsLayer:YES];
|
|
734
763
|
if (subview.layer) {
|
|
@@ -745,8 +774,8 @@ void updateOverlay() {
|
|
|
745
774
|
NSLog(@" ✅ Overlay Status: Level=%ld, Alpha=%.1f, Visible=%s, Frame Set=YES",
|
|
746
775
|
[g_overlayWindow level], [g_overlayWindow alphaValue],
|
|
747
776
|
[g_overlayWindow isVisible] ? "YES" : "NO");
|
|
748
|
-
} else if (!
|
|
749
|
-
// No window under cursor, hide overlay
|
|
777
|
+
} else if (!targetWindow && g_currentWindowUnderCursor && !g_hasToggledWindow) {
|
|
778
|
+
// No window under cursor and no toggle active, hide overlay
|
|
750
779
|
NSString *leftWindowTitle = [g_currentWindowUnderCursor objectForKey:@"title"] ?: @"Untitled";
|
|
751
780
|
NSString *leftAppName = [g_currentWindowUnderCursor objectForKey:@"appName"] ?: @"Unknown";
|
|
752
781
|
|
|
@@ -1604,8 +1633,11 @@ Napi::Value StartWindowSelection(const Napi::CallbackInfo& info) {
|
|
|
1604
1633
|
// Add cancel button to window
|
|
1605
1634
|
[g_overlayWindow.contentView addSubview:cancelButton];
|
|
1606
1635
|
|
|
1607
|
-
// Force
|
|
1636
|
+
// Force subviews (except overlay view itself) to have no borders
|
|
1608
1637
|
for (NSView *subview in [g_overlayWindow.contentView subviews]) {
|
|
1638
|
+
// Skip the main overlay view - it handles its own borders
|
|
1639
|
+
if ([subview isKindOfClass:[WindowSelectorOverlayView class]]) continue;
|
|
1640
|
+
|
|
1609
1641
|
if ([subview respondsToSelector:@selector(setWantsLayer:)]) {
|
|
1610
1642
|
[subview setWantsLayer:YES];
|
|
1611
1643
|
if (subview.layer) {
|