Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): resolve camera window via helper in overlay flows
Richie McIlroyd78b33f9ad4a
diff --git a/apps/desktop/src/routes/in-progress-recording.tsx b/apps/desktop/src/routes/in-progress-recording.tsxindex 309bbf702..4fa431574 100644--- a/apps/desktop/src/routes/in-progress-recording.tsx+++ b/apps/desktop/src/routes/in-progress-recording.tsx@@ -7,7 +7,6 @@ import {MenuItem,PredefinedMenuItem,} from "@tauri-apps/api/menu";-import { WebviewWindow } from "@tauri-apps/api/webviewWindow";import { getCurrentWindow } from "@tauri-apps/api/window";import * as dialog from "@tauri-apps/plugin-dialog";import { type as ostype } from "@tauri-apps/plugin-os";@@ -25,6 +24,7 @@ import {import { createStore, produce } from "solid-js/store";import { TransitionGroup } from "solid-transition-group";import { authStore } from "~/store";+import { getCameraWindow } from "~/utils/camera-window";import { createTauriEventListener } from "~/utils/createEventListener";import {createCurrentRecordingQuery,@@ -445,7 +445,7 @@ function InProgressRecordingInner() {const toggleCameraPreview = createMutation(() => ({mutationFn: async () => {if (cameraWindowOpen()) {- const cameraWindow = await WebviewWindow.getByLabel("camera");+ const cameraWindow = await getCameraWindow();if (cameraWindow) await cameraWindow.close();} else {await commands.showWindow({ Camera: { centered: false } });@@ -489,7 +489,7 @@ function InProgressRecordingInner() {try {await commands.setCameraInput(next, null);if (!next && cameraWindowOpen()) {- const cameraWindow = await WebviewWindow.getByLabel("camera");+ const cameraWindow = await getCameraWindow();if (cameraWindow) await cameraWindow.close();await refreshCameraWindowState();}diff --git a/apps/desktop/src/routes/target-select-overlay.tsx b/apps/desktop/src/routes/target-select-overlay.tsxindex ff2881c7a..5e8ae287c 100644--- a/apps/desktop/src/routes/target-select-overlay.tsx+++ b/apps/desktop/src/routes/target-select-overlay.tsx@@ -43,6 +43,7 @@ import {import ModeSelect from "~/components/ModeSelect";import SelectionHint from "~/components/selection-hint";import { authStore, generalSettingsStore } from "~/store";+import { getCameraWindow } from "~/utils/camera-window";import { createDevicesQuery } from "~/utils/devices";import {createCameraMutation,@@ -86,7 +87,7 @@ async function repositionCameraForWindow(windowBounds: { x: number; y: number; width: number; height: number },displayId: DisplayId,) {- const win = await WebviewWindow.getByLabel("camera");+ const win = await getCameraWindow();if (!win) return;const [physSize, scaleFactor] = await Promise.all([@@ -281,7 +282,7 @@ function Inner() {reconcile({ variant: "cameraOnly" } as ScreenCaptureTarget),);setOptions("captureSystemAudio", false);- WebviewWindow.getByLabel("camera").then((win) => {+ getCameraWindow().then((win) => {if (win) win.close();});}@@ -415,7 +416,7 @@ function Inner() {onMount(async () => {try {- const win = await WebviewWindow.getByLabel("camera");+ const win = await getCameraWindow();if (!win) return;const [pos, factor] = await Promise.all([win.outerPosition(),@@ -462,7 +463,7 @@ function Inner() {const original = originalCameraBounds();if (!original) return;try {- const win = await WebviewWindow.getByLabel("camera");+ const win = await getCameraWindow();if (!win) return;await win.setPosition(new LogicalPosition(original.x, original.y),@@ -686,7 +687,7 @@ function Inner() {>(null);onMount(async () => {- const win = await WebviewWindow.getByLabel("camera");+ const win = await getCameraWindow();if (win) setCameraWindow(win);});@@ -787,12 +788,7 @@ function Inner() {if (!win) {// Try to find ittry {- win = await WebviewWindow.getByLabel("camera");- if (!win) {- // Fallback: check all windows- const all = await WebviewWindow.getAll();- win = all.find((w) => w.label.includes("camera")) ?? null;- }+ win = await getCameraWindow();if (win) setCameraWindow(win);} catch (e) {console.error("Failed to find camera window", e);@@ -1589,7 +1585,7 @@ function RecordingControls(props: {});if (isCameraOnly) {- const win = await WebviewWindow.getByLabel("camera");+ const win = await getCameraWindow();if (win) win.close();}});diff --git a/apps/desktop/src/routes/window-capture-occluder.tsx b/apps/desktop/src/routes/window-capture-occluder.tsxindex f5b486089..a67f95202 100644--- a/apps/desktop/src/routes/window-capture-occluder.tsx+++ b/apps/desktop/src/routes/window-capture-occluder.tsx@@ -1,5 +1,6 @@import { getAllWindows } from "@tauri-apps/api/window";import { Show, Suspense } from "solid-js";+import { isCameraWindowLabel } from "~/utils/camera-window";import { createCurrentRecordingQuery } from "~/utils/queries";export default function () {@@ -7,7 +8,7 @@ export default function () {getAllWindows().then((w) =>w.forEach((w) => {- if (w.label === "camera" || w.label === "in-progress-recording")+ if (isCameraWindowLabel(w.label) || w.label === "in-progress-recording")w.setFocus();}),);@@ -29,7 +30,10 @@ export default function () {{(bounds) => {getAllWindows().then((w) =>w.forEach((w) => {- if (w.label === "camera" || w.label === "in-progress-recording")+ if (+ isCameraWindowLabel(w.label) ||+ w.label === "in-progress-recording"+ )w.setFocus();}),);