Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

camera fixes

Richie McIlroy729ab3cf6571
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 4ca226ea7..6fc8d1128 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -2932,11 +2932,15 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
match event {
WindowEvent::CloseRequested { .. } => {
if let Ok(CapWindowId::Camera) = CapWindowId::from_str(label) {
+ tracing::warn!("Camera window CloseRequested event received!");
tokio::spawn(cleanup_camera_window(app.clone()));
}
}
WindowEvent::Destroyed => {
if let Ok(window_id) = CapWindowId::from_str(label) {
+ if matches!(window_id, CapWindowId::Camera) {
+ tracing::warn!("Camera window Destroyed event received!");
+ }
match window_id {
CapWindowId::Main => {
let app = app.clone();
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index c4471b56e..284d1f44e 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -607,10 +607,29 @@ pub async fn start_recording(
win.close().ok();
}
}
+ #[cfg(windows)]
+ let had_camera_window = CapWindowId::Camera.get(&app).is_some();
+ #[cfg(windows)]
+ if had_camera_window {
+ tracing::info!(
+ "Closing camera window BEFORE InProgressRecording show (will recreate after)"
+ );
+ if let Some(cam_win) = CapWindowId::Camera.get(&app) {
+ cam_win.close().ok();
+ }
+ }
+
let _ = ShowCapWindow::InProgressRecording { countdown }
.show(&app)
.await;
+ #[cfg(windows)]
+ if had_camera_window {
+ tracing::info!("Recreating camera window after InProgressRecording");
+ tokio::time::sleep(std::time::Duration::from_millis(150)).await;
+ ShowCapWindow::Camera.show(&app).await.ok();
+ }
+
if let Some(window) = CapWindowId::Main.get(&app) {
let _ = general_settings
.map(|v| v.main_window_recording_start_behaviour)
diff --git a/apps/desktop/src/routes/camera.tsx b/apps/desktop/src/routes/camera.tsx
index 3b72a1f1f..760a245ee 100644
--- a/apps/desktop/src/routes/camera.tsx
+++ b/apps/desktop/src/routes/camera.tsx
@@ -589,16 +589,6 @@ function LegacyCameraPreviewPage(props: { disconnected: Accessor<boolean> }) {
let cameraCanvasRef: HTMLCanvasElement | undefined;
- createEffect(
- on(
- () => rawOptions.cameraLabel,
- (label) => {
- if (label === null) getCurrentWindow().close();
- },
- { defer: true },
- ),
- );
-
onMount(() => getCurrentWindow().show());
return (