Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: Hide in progress recording window from recorder
Richie McIlroy3477ff0e555f
diff --git a/Cargo.lock b/Cargo.lockindex 6f0e86ec2..ecc91dcdd 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1400,7 +1400,7 @@ dependencies = [[[package]]name = "desktop"-version = "0.3.0-alpha.9"+version = "0.3.0-alpha.10"dependencies = ["anyhow","axum",diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.tomlindex 0234c4432..dff05dd3d 100644--- a/apps/desktop/src-tauri/Cargo.toml+++ b/apps/desktop/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "desktop"-version = "0.3.0-alpha.9"+version = "0.3.0-alpha.10"description = "Effortless, instant screen sharing. Open source and cross-platform."authors = ["you"]edition = "2021"diff --git a/apps/desktop/src-tauri/src/display.rs b/apps/desktop/src-tauri/src/display.rsindex 6efadca3c..03f595742 100644--- a/apps/desktop/src-tauri/src/display.rs+++ b/apps/desktop/src-tauri/src/display.rs@@ -7,9 +7,7 @@ use scap::{};use serde::{Deserialize, Serialize};use specta::Type;-use tokio::{- sync::{oneshot, watch},-};+use tokio::sync::{oneshot, watch};use crate::macos;use cap_ffmpeg::NamedPipeCapture;@@ -89,8 +87,14 @@ pub async fn start_capturing(_ => None,};- let excluded_titles = ["Cap", "Cap Camera", "Cap Recordings", "Cap In Progress Recording"];+ let excluded_titles = [+ "Cap",+ "Cap Camera",+ "Cap Recordings",+ "Cap In Progress Recording",+ ];let excluded_targets: Vec<scap::Target> = targets+ .clone().into_iter().filter(|target| match target {Target::Window(scap_window)@@ -159,8 +163,8 @@ pub async fn start_capturing(loop {if frame_rx.changed().await.is_err() {- println!("Closing display pipe writer");- return;+ println!("Closing display pipe writer");+ return;}let frame = frame_rx.borrow();diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 2cda2830c..c8e541c22 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -259,7 +259,11 @@ async fn start_recording(app: AppHandle, state: MutableState<'_, App>) -> Resultwindow.minimize().ok();}- create_in_progress_recording_window(&app);+ let window = app+ .get_webview_window(IN_PROGRESS_RECORDINGS_LABEL)+ .unwrap();+ window.eval("window.location.reload()").unwrap();+ window.show().unwrap();RecordingStarted.emit(&app).ok();@@ -277,7 +281,7 @@ fn create_in_progress_recording_window(app: &AppHandle) {IN_PROGRESS_RECORDINGS_LABEL,tauri::WebviewUrl::App("/in-progress-recording".into()),)- .title("Cap")+ .title("Cap In Progress Recording").maximized(false).resizable(false).fullscreen(false)@@ -293,6 +297,7 @@ fn create_in_progress_recording_window(app: &AppHandle) {((monitor.size().width as f64) / monitor.scale_factor() - width) / 2.0,(monitor.size().height as f64) / monitor.scale_factor() - height - 120.0,)+ .visible(false).build().ok();}@@ -308,9 +313,10 @@ async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Result<current_recording.stop().await;- if let Some(window) = app.get_webview_window(IN_PROGRESS_RECORDINGS_LABEL) {- window.close().ok();- }+ let window = app+ .get_webview_window(IN_PROGRESS_RECORDINGS_LABEL)+ .unwrap();+ window.hide().unwrap();if let Some(window) = app.get_webview_window("main") {window.unminimize().ok();@@ -1322,6 +1328,8 @@ pub fn run() {tray::create_tray(&app_handle).unwrap();+ let _window = create_in_progress_recording_window(&app.app_handle());+RequestStopRecording::listen_any(app, move |_| {let app_handle = app_handle.clone();tauri::async_runtime::spawn(async move {diff --git a/apps/desktop/src/routes/in-progress-recording.tsx b/apps/desktop/src/routes/in-progress-recording.tsxindex e7a3d4634..da95014ec 100644--- a/apps/desktop/src/routes/in-progress-recording.tsx+++ b/apps/desktop/src/routes/in-progress-recording.tsx@@ -1,4 +1,4 @@-import { createSignal, type ComponentProps } from "solid-js";+import { createEffect, createSignal, type ComponentProps } from "solid-js";import { commands } from "../utils/tauri";import { createTimer } from "@solid-primitives/timer";@@ -18,6 +18,11 @@ export default function () {setInterval);+ createEffect(() => {+ stopped = false;+ setTime(Date.now());+ });+const stopRecording = createMutation(() => ({mutationFn: async () => {stopped = true;diff --git a/apps/desktop/src/routes/permissions.tsx b/apps/desktop/src/routes/permissions.tsxindex 3378f464b..60c818304 100644--- a/apps/desktop/src/routes/permissions.tsx+++ b/apps/desktop/src/routes/permissions.tsx@@ -2,7 +2,12 @@ import { cx } from "cva";import { Button } from "@cap/ui-solid";import { exit } from "@tauri-apps/plugin-process";-import { commands, OSPermission, OSPermissionStatus, OSPermissionsCheck } from "../utils/tauri";+import {+ commands,+ OSPermission,+ OSPermissionStatus,+ OSPermissionsCheck,+} from "../utils/tauri";import {createEffect,createResource,@@ -38,7 +43,7 @@ export default function () {if (!initialCheck()) {createTimer(() => checkActions.refetch(), 100, setInterval);}- })+ });createEffect(() => {const c = check.latest;@@ -49,27 +54,24 @@ export default function () {commands.openMainWindow();const window = getCurrentWindow();window.close();- }- else {+ } else {setCurrentStepIndex(neededStep);}});const requestPermission = () => {- // After this, we will get "denied" instead of "empty" values for screen recording permissiontry {commands.requestPermission(currentStep().key);- }- catch (err) {+ } catch (err) {console.error(`Error occurred while requesting permission: ${err}`);}setInitialCheck(false);- }+ };const openSettings = () => {commands.openPermissionSettings(currentStep().key);setInitialCheck(false);- }+ };return (<div class="flex flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] flex-1 bg-gray-100 border rounded-lg border-gray-200 w-screen h-screen">@@ -84,25 +86,29 @@ export default function () {</div><Suspense fallback={<div class="w-full flex-1" />}><div class="flex flex-col items-start gap-1">- <h4 class="font-[500] text-[0.875rem]">- {currentStep().name} Permission- </h4>- <div class="w-full flex gap-2">- <Show- when={currentStepStatus() !== "denied"}- fallback={<Button onClick={openSettings} class="flex-1">Open Settings</Button>}- >- <Button- onClick={requestPermission}- disabled={currentStepStatus() !== "empty"}- class="flex-1"- >- Grant+ <h4 class="font-[500] text-[0.875rem]">+ {currentStep().name} Permission+ </h4>+ <div class="w-full flex gap-2">+ <Show+ when={currentStepStatus() !== "denied"}+ fallback={+ <Button onClick={openSettings} class="flex-1">+ Open Settings</Button>- </Show>- <Button variant="secondary" class="flex-1" onClick={() => exit()}>- Quit+ }+ >+ <Button+ onClick={requestPermission}+ disabled={currentStepStatus() !== "empty"}+ class="flex-1"+ >+ Grant</Button>+ </Show>+ <Button variant="secondary" class="flex-1" onClick={() => exit()}>+ Quit+ </Button></div></div></Suspense>diff --git a/apps/desktop/src/routes/prev-recordings.tsx b/apps/desktop/src/routes/prev-recordings.tsxindex 8358ce219..71c669ff9 100644--- a/apps/desktop/src/routes/prev-recordings.tsx+++ b/apps/desktop/src/routes/prev-recordings.tsx@@ -156,11 +156,6 @@ export default function () {const [imageExists, setImageExists] = createSignal(true);- onCleanup(() => {- if (recordings.length === 0)- commands.closePreviousRecordingsWindow();- });-const isLoading = () =>copyVideo.isPending || saveVideo.isPending;