Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Make sure camera and in-progress-recording windows stay on top of occluder (#335)
Brendan Allan7bd327e0758e
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex 44e9d206c..58b577634 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -15,8 +15,8 @@ use crate::{RecordingStarted, RecordingStopped, UploadMode,};use cap_flags::FLAGS;-use cap_media::feeds::CameraFeed;use cap_media::sources::{CaptureScreen, CaptureWindow};+use cap_media::{feeds::CameraFeed, sources::ScreenCaptureTarget};use cap_project::{Content, ProjectConfiguration, TimelineConfiguration, TimelineSegment, ZoomSegment, XY,};@@ -96,6 +96,14 @@ pub async fn start_recording(}}}++ if matches!(+ state.start_recording_options.capture_target,+ ScreenCaptureTarget::Window(_) | ScreenCaptureTarget::Area(_)+ ) {+ let _ = ShowCapWindow::WindowCaptureOccluder.show(&app);+ }+let (actor, actor_done_rx) = cap_recording::spawn_recording_actor(id,recording_dir,@@ -127,8 +135,7 @@ pub async fn start_recording(}if let Some(window) = CapWindowId::InProgressRecording.get(&app) {- window.eval("window.location.reload()").unwrap();- window.show().unwrap();+ window.eval("window.location.reload()").ok();} else {ShowCapWindow::InProgressRecording { position: None }.show(&app)diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rsindex 364ea9b40..488fefb4c 100644--- a/apps/desktop/src-tauri/src/windows.rs+++ b/apps/desktop/src-tauri/src/windows.rs@@ -241,7 +241,14 @@ impl ShowCapWindow {)).transparent(true);- window_builder.build()?+ let window = window_builder.build()?;++ #[cfg(target_os = "macos")]+ {+ crate::platform::set_window_level(window.as_ref().window(), 1000);+ }++ window}Self::WindowCaptureOccluder => {let mut window_builder = self@@ -267,10 +274,7 @@ impl ShowCapWindow {#[cfg(target_os = "macos")]{- crate::platform::set_window_level(- window.as_ref().window(),- objc2_app_kit::NSScreenSaverWindowLevel,- );+ crate::platform::set_window_level(window.as_ref().window(), 900);}window@@ -334,7 +338,8 @@ impl ShowCapWindow {let height = 40.0;- self.window_builder(app, "/in-progress-recording")+ let window = self+ .window_builder(app, "/in-progress-recording").maximized(false).resizable(false).fullscreen(false)@@ -349,7 +354,14 @@ impl ShowCapWindow {(monitor.size().height as f64) / monitor.scale_factor() - height - 120.0,).skip_taskbar(true)- .build()?+ .build()?;++ #[cfg(target_os = "macos")]+ {+ crate::platform::set_window_level(window.as_ref().window(), 1000);+ }++ window}Self::PrevRecordings => {let window = selfdiff --git a/apps/desktop/src/components/CropAreaRenderer.tsx b/apps/desktop/src/components/CropAreaRenderer.tsxindex bc55567a1..3de37c0e4 100644--- a/apps/desktop/src/components/CropAreaRenderer.tsx+++ b/apps/desktop/src/components/CropAreaRenderer.tsx@@ -282,7 +282,7 @@ export default function CropAreaRenderer(});return (- <div class="*:h-full *:w-full">+ <div class="*:h-full *:w-full animate-in fade-in"><canvas ref={canvasRef} class="pointer-events-none absolute" /><div>{props.children}</div></div>diff --git a/apps/desktop/src/routes/window-capture-occluder.tsx b/apps/desktop/src/routes/window-capture-occluder.tsxindex 5d297fe0b..b13c547d7 100644--- a/apps/desktop/src/routes/window-capture-occluder.tsx+++ b/apps/desktop/src/routes/window-capture-occluder.tsx@@ -1,11 +1,19 @@+import { getAllWindows } from "@tauri-apps/api/window";import { type as ostype } from "@tauri-apps/plugin-os";-import { Show, Suspense } from "solid-js";+import { onMount, Show, Suspense } from "solid-js";import CropAreaRenderer from "~/components/CropAreaRenderer";import { createCurrentRecordingQuery } from "~/utils/queries";export default function () {const currentRecording = createCurrentRecordingQuery();+ getAllWindows().then((w) =>+ w.forEach((w) => {+ if (w.label === "camera" || w.label === "in-progress-recording")+ w.setFocus();+ })+ );+return (<Suspense><Show@@ -15,12 +23,21 @@ export default function () {currentRecording.data.captureTarget.bounds}>- {(bounds) => (- <CropAreaRenderer- bounds={bounds()}- borderRadius={ostype() === "macos" ? 9 : 7}- />- )}+ {(bounds) => {+ getAllWindows().then((w) =>+ w.forEach((w) => {+ if (w.label === "camera" || w.label === "in-progress-recording")+ w.setFocus();+ })+ );++ return (+ <CropAreaRenderer+ bounds={bounds()}+ borderRadius={ostype() === "macos" ? 9 : 7}+ />+ );+ }}</Show></Suspense>);