Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Improve window close behavior and camera selection
Richie McIlroyad419eaf5ad3
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex e2b2f9509..83aa85a44 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -3419,16 +3419,45 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {});}CapWindowId::Main => {+ api.prevent_close();+ let _ = window.hide();+let state = app.state::<ArcLock<App>>();let is_recording = state.try_read().map(|s| s.is_recording_active_or_pending()).unwrap_or(true);- if !is_recording- && let Some(camera_window) = CapWindowId::Camera.get(app)- {- let _ = camera_window.hide();+ if !is_recording {+ if let Some(camera_window) = CapWindowId::Camera.get(app) {+ let _ = camera_window.hide();+ }++ for (id, overlay_window) in app.webview_windows() {+ if let Ok(CapWindowId::TargetSelectOverlay { .. }) =+ CapWindowId::from_str(&id)+ {+ let _ = overlay_window.hide();+ }+ }++ let app = app.clone();+ tokio::spawn(async move {+ let state = app.state::<ArcLock<App>>();+ let app_state = &mut *state.write().await;++ app_state.camera_preview.pause();++ let _ =+ app_state.mic_feed.ask(microphone::RemoveInput).await;+ let _ = app_state+ .camera_feed+ .ask(feeds::camera::RemoveInput)+ .await;++ app_state.selected_mic_label = None;+ app_state.camera_in_use = false;+ });}}_ => {}diff --git a/apps/desktop/src/components/titlebar/controls/CaptionControlsMacOS.tsx b/apps/desktop/src/components/titlebar/controls/CaptionControlsMacOS.tsxindex a8459fa55..dd745fe0a 100644--- a/apps/desktop/src/components/titlebar/controls/CaptionControlsMacOS.tsx+++ b/apps/desktop/src/components/titlebar/controls/CaptionControlsMacOS.tsx@@ -32,12 +32,8 @@ export default function CaptionControlsMacOS(const showMinimize = () => local.showMinimize ?? true;const showZoom = () => local.showZoom ?? true;- const handleClose = () => {- if (currentWindow.label === "main") {- currentWindow.hide();- } else {- currentWindow.close();- }+ const handleClose = async () => {+ currentWindow.close();};return (diff --git a/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsx b/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsxindex fe8dfe364..667e92b90 100644--- a/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsx+++ b/apps/desktop/src/components/titlebar/controls/CaptionControlsWindows11.tsx@@ -27,12 +27,8 @@ export default function (});onCleanup(() => unlisten?.());- const handleClose = () => {- if (currentWindow.label === "main") {- currentWindow.hide();- } else {- currentWindow.close();- }+ const handleClose = async () => {+ currentWindow.close();};return (diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsxindex 6ddf328bc..559002ea7 100644--- a/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsx+++ b/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsx@@ -12,6 +12,7 @@ import { createCurrentRecordingQuery } from "~/utils/queries";import {type CameraInfo,commands,+ type DeviceOrModelID,type OSPermissionsCheck,} from "~/utils/tauri";import InfoPill from "./InfoPill";@@ -61,7 +62,14 @@ export default function CameraSelect(props: {const openCameraWindow = async (e: MouseEvent) => {e.stopPropagation();- await commands.showWindow({ Camera: { centered: false } });+ if (props.value) {+ const id: DeviceOrModelID = props.value.model_id+ ? { ModelID: props.value.model_id }+ : { DeviceID: props.value.device_id };+ await commands.setCameraInput(id, false);+ } else {+ await commands.showWindow({ Camera: { centered: false } });+ }await refreshCameraWindowState();};@@ -171,7 +179,14 @@ export function CameraSelectBase(props: {const openCameraWindow = async (e: MouseEvent) => {e.stopPropagation();- await commands.showWindow({ Camera: { centered: false } });+ if (props.value) {+ const id: DeviceOrModelID = props.value.model_id+ ? { ModelID: props.value.model_id }+ : { DeviceID: props.value.device_id };+ await commands.setCameraInput(id, false);+ } else {+ await commands.showWindow({ Camera: { centered: false } });+ }await refreshCameraWindowState();};