diff --git a/electron/native/NativeCursorMonitor.swift b/electron/native/NativeCursorMonitor.swift index 581a595d..18c64415 100644 --- a/electron/native/NativeCursorMonitor.swift +++ b/electron/native/NativeCursorMonitor.swift @@ -428,9 +428,15 @@ func mouseInteractionCallback( action = "mouseup" button = 2 case .otherMouseDown: + guard event.getIntegerValueField(.mouseEventButtonNumber) == 2 else { + return Unmanaged.passUnretained(event) + } action = "mousedown" button = 3 case .otherMouseUp: + guard event.getIntegerValueField(.mouseEventButtonNumber) == 2 else { + return Unmanaged.passUnretained(event) + } action = "mouseup" button = 3 default: diff --git a/electron/native/ScreenCaptureKitRecorder.swift b/electron/native/ScreenCaptureKitRecorder.swift index 285f0dd1..65320fde 100644 --- a/electron/native/ScreenCaptureKitRecorder.swift +++ b/electron/native/ScreenCaptureKitRecorder.swift @@ -653,19 +653,27 @@ final class ScreenCaptureRecorder: NSObject, SCStreamOutput, SCStreamDelegate { if Task.isCancelled { return } guard self.isRecording else { return } + let availableContent: SCShareableContent do { - let availableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: true) - let windowStillAvailable = availableContent.windows.contains(where: { $0.windowID == trackedWindowId }) - if !windowStillAvailable { - print("WINDOW_UNAVAILABLE") - fflush(stdout) + availableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: true) + } catch { + continue + } + + let windowStillAvailable = availableContent.windows.contains(where: { $0.windowID == trackedWindowId }) + if !windowStillAvailable { + print("WINDOW_UNAVAILABLE") + fflush(stdout) + do { let outputPath = try await self.finishCapture() print("Recording stopped. Output path: \(outputPath)") fflush(stdout) exit(0) + } catch { + fputs("Error stopping capture: \(error.localizedDescription)\n", stderr) + fflush(stderr) + exit(1) } - } catch { - continue } } } diff --git a/electron/native/bin/darwin-arm64/recordly-native-cursor-monitor b/electron/native/bin/darwin-arm64/recordly-native-cursor-monitor index 9e309c37..962161c1 100755 Binary files a/electron/native/bin/darwin-arm64/recordly-native-cursor-monitor and b/electron/native/bin/darwin-arm64/recordly-native-cursor-monitor differ diff --git a/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper b/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper index 609b045d..242bf20e 100755 Binary files a/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper and b/electron/native/bin/darwin-arm64/recordly-screencapturekit-helper differ diff --git a/electron/native/bin/darwin-x64/recordly-native-cursor-monitor b/electron/native/bin/darwin-x64/recordly-native-cursor-monitor index 9c592b78..3e55919f 100755 Binary files a/electron/native/bin/darwin-x64/recordly-native-cursor-monitor and b/electron/native/bin/darwin-x64/recordly-native-cursor-monitor differ diff --git a/electron/native/bin/darwin-x64/recordly-screencapturekit-helper b/electron/native/bin/darwin-x64/recordly-screencapturekit-helper index 08a2f749..7a4ce312 100755 Binary files a/electron/native/bin/darwin-x64/recordly-screencapturekit-helper and b/electron/native/bin/darwin-x64/recordly-screencapturekit-helper differ diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts index 251f31b5..1c2c1acf 100644 --- a/src/hooks/useScreenRecorder.ts +++ b/src/hooks/useScreenRecorder.ts @@ -903,6 +903,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn { webcamStopPromise.current = null; pendingWebcamPathPromise.current = null; resolvedWebcamPath.current = result ?? null; + webcamRecorder.current = null; return result ?? null; }, []);