Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: Improved notifications on action complete
Richie McIlroy3457c1d7e755
diff --git a/Cargo.lock b/Cargo.lockindex 21f1f82e9..82e59e6f5 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -712,6 +712,7 @@ name = "cap-media"version = "0.1.0"dependencies = ["anyhow",+ "cap-flags","cap-project","cocoa 0.26.0","core-foundation 0.10.0",diff --git a/apps/desktop/src-tauri/sounds/action.ogg b/apps/desktop/src-tauri/sounds/action.oggnew file mode 100644index 000000000..3f2752c46Binary files /dev/null and b/apps/desktop/src-tauri/sounds/action.ogg differdiff --git a/apps/desktop/src-tauri/src/audio.rs b/apps/desktop/src-tauri/src/audio.rsindex 051a13745..354436a80 100644--- a/apps/desktop/src-tauri/src/audio.rs+++ b/apps/desktop/src-tauri/src/audio.rs@@ -17,16 +17,21 @@ pub enum AppSounds {StartRecording,StopRecording,Screenshot,+ Notification,}impl AppSounds {- pub fn play(self) {- play_audio(match self {- AppSounds::StartRecording => {- include_bytes!("../sounds/start-recording.ogg")- }+ pub fn play(&self) {+ let bytes = self.get_sound_bytes();+ play_audio(bytes);+ }++ fn get_sound_bytes(&self) -> &'static [u8] {+ match self {+ AppSounds::StartRecording => include_bytes!("../sounds/start-recording.ogg"),AppSounds::StopRecording => include_bytes!("../sounds/stop-recording.ogg"),AppSounds::Screenshot => include_bytes!("../sounds/screenshot.ogg"),- })+ AppSounds::Notification => include_bytes!("../sounds/action.ogg"),+ }}}diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 783de7799..7e4317370 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -240,6 +240,7 @@ pub struct RequestOpenSettings {pub struct NewNotification {title: String,body: String,+ is_error: bool,}type MutableState<'a, T> = State<'a, Arc<RwLock<T>>>;@@ -749,18 +750,39 @@ async fn get_rendered_video_impl(#[tauri::command]#[specta::specta]-async fn copy_file_to_path(src: String, dst: String) -> Result<(), String> {+async fn copy_file_to_path(app: AppHandle, src: String, dst: String) -> Result<(), String> {println!("Attempting to copy file from {} to {}", src, dst);++ // Determine if this is a screenshot based on the path+ let is_screenshot = src.contains("screenshots/");+match tokio::fs::copy(&src, &dst).await {Ok(bytes) => {println!("Successfully copied {} bytes from {} to {}",bytes, src, dst);+ // Send appropriate success notification+ notifications::send_notification(+ &app,+ if is_screenshot {+ notifications::NotificationType::ScreenshotSaved+ } else {+ notifications::NotificationType::VideoSaved+ },+ );Ok(())}Err(e) => {eprintln!("Failed to copy file from {} to {}: {}", src, dst, e);+ notifications::send_notification(+ &app,+ if is_screenshot {+ notifications::NotificationType::ScreenshotSaveFailed+ } else {+ notifications::NotificationType::VideoSaveFailed+ },+ );Err(e.to_string())}}@@ -775,6 +797,10 @@ async fn copy_screenshot_to_clipboard(app: AppHandle, path: PathBuf) -> Result<(Ok(data) => data,Err(e) => {println!("Failed to read screenshot file: {}", e);+ notifications::send_notification(+ &app,+ notifications::NotificationType::ScreenshotCopyFailed,+ );return Err(format!("Failed to read screenshot file: {}", e));}};@@ -786,7 +812,7 @@ async fn copy_screenshot_to_clipboard(app: AppHandle, path: PathBuf) -> Result<(use cocoa::foundation::{NSArray, NSData};use objc::rc::autoreleasepool;- unsafe {+ let result = unsafe {autoreleasepool(|| {let pasteboard: id = NSPasteboard::generalPasteboard(nil);NSPasteboard::clearContents(pasteboard);@@ -805,13 +831,32 @@ async fn copy_screenshot_to_clipboard(app: AppHandle, path: PathBuf) -> Result<(Err("Failed to create NSImage from data".to_string())}})+ };++ if let Err(e) = result {+ notifications::send_notification(+ &app,+ notifications::NotificationType::ScreenshotCopyFailed,+ );+ return Err(e);}++ notifications::send_notification(+ &app,+ notifications::NotificationType::ScreenshotCopiedToClipboard,+ );}#[cfg(not(target_os = "macos"))]{- Err("Clipboard operations are only supported on macOS".to_string())+ notifications::send_notification(+ &app,+ notifications::NotificationType::ScreenshotCopyFailed,+ );+ return Err("Clipboard operations are only supported on macOS".to_string());}++ Ok(())}#[tauri::command]@@ -1209,19 +1254,16 @@ async fn copy_rendered_video_to_clipboard(}Err(e) => {println!("Failed to get rendered video: {}", e);+ notifications::send_notification(+ &app,+ notifications::NotificationType::VideoCopyFailed,+ );return Err(format!("Failed to get rendered video: {}", e));}};let output_path_str = output_path.to_str().unwrap();- println!("Copying to clipboard: {:?}", output_path_str);-- notifications::send_notification(- &app,- notifications::NotificationType::VideoCopiedToClipboard,- );-#[cfg(target_os = "macos")]{use cocoa::appkit::NSPasteboard;@@ -1229,7 +1271,7 @@ async fn copy_rendered_video_to_clipboard(use cocoa::foundation::{NSArray, NSString, NSURL};use objc::rc::autoreleasepool;- unsafe {+ let result: Result<(), String> = unsafe {autoreleasepool(|| {let pasteboard: id = NSPasteboard::generalPasteboard(nil);NSPasteboard::clearContents(pasteboard);@@ -1239,11 +1281,28 @@ async fn copy_rendered_video_to_clipboard(let objects: id = NSArray::arrayWithObject(nil, url);- NSPasteboard::writeObjects(pasteboard, objects);- });+ if !NSPasteboard::writeObjects(pasteboard, objects) {+ Err("Failed to write to clipboard".to_string())+ } else {+ Ok(())+ }+ })+ };++ if let Err(e) = result {+ notifications::send_notification(+ &app,+ notifications::NotificationType::VideoCopyFailed,+ );+ return Err(e);}}+ notifications::send_notification(+ &app,+ notifications::NotificationType::VideoCopiedToClipboard,+ );+Ok(())}@@ -1622,8 +1681,6 @@ async fn upload_rendered_video(return Ok(UploadResult::NotAuthenticated);};- notifications::send_notification(&app, notifications::NotificationType::ShareableLinkCopied);-// Check if user has an upgraded planif !auth.is_upgraded() {// Fetch and update plan information@@ -1637,14 +1694,13 @@ async fn upload_rendered_video(// Re-check upgraded status after refreshif !auth.is_upgraded() {- // Open upgrade window instead of returning an error+ println!("User plan still not upgraded after refresh.");open_upgrade_window(app).await;return Ok(UploadResult::UpgradeRequired);}}let editor_instance = upsert_editor_instance(&app, video_id.clone()).await;-let mut meta = editor_instance.meta();let share_link = if let Some(sharing) = meta.sharing {@@ -1656,98 +1712,68 @@ async fn upload_rendered_video(Err(e) => return Err(format!("Failed to get rendered video: {}", e)),};- upload_video(+ match upload_video(&app,video_id.clone(),output_path,false,Some(pre_created.config),)- .await?;-- meta.sharing = Some(SharingMeta {- link: pre_created.link.clone(),- id: pre_created.id.clone(),- });- meta.save_for_project();- RecordingMetaChanged { id: video_id }.emit(&app).ok();+ .await+ {+ Ok(_) => {+ meta.sharing = Some(SharingMeta {+ link: pre_created.link.clone(),+ id: pre_created.id.clone(),+ });+ meta.save_for_project();+ RecordingMetaChanged { id: video_id }.emit(&app).ok();- pre_created.link+ pre_created.link+ }+ Err(e) => {+ notifications::send_notification(+ &app,+ notifications::NotificationType::UploadFailed,+ );+ return Err(e);+ }+ }} else {let output_path = match get_rendered_video_impl(editor_instance.clone(), project).await {- Ok(path) => {- println!("Successfully retrieved rendered video path: {:?}", path);- path- }+ Ok(path) => path,Err(e) => {- println!("Failed to get rendered video: {}", e);+ notifications::send_notification(+ &app,+ notifications::NotificationType::UploadFailed,+ );return Err(format!("Failed to get rendered video: {}", e));}};- let uploaded_video = upload_video(&app, video_id.clone(), output_path, false, None).await?;-- let general_settings = GeneralSettingsStore::get(&app)?;- if let Some(settings) = general_settings {- if settings.upload_individual_files {- let video_dir = app- .path()- .app_data_dir()- .unwrap()- .join("recordings")- .join(format!("{}.cap", video_id));-- let files_to_upload = vec![- (video_dir.join("content/audio-input.mp3"), true),- (video_dir.join("content/camera.mp4"), false),- (video_dir.join("content/display.mp4"), false),- ];-- for (file_path, is_audio) in files_to_upload {- if file_path.exists() {- let file_name = file_path.file_name().unwrap().to_str().unwrap();- let result = if is_audio {- upload_individual_file(- &app,- file_path.clone(),- uploaded_video.config.clone(),- file_name,- true,- )- .await- } else {- upload_individual_file(- &app,- file_path.clone(),- uploaded_video.config.clone(),- file_name,- false,- )- .await- };+ match upload_video(&app, video_id.clone(), output_path, false, None).await {+ Ok(uploaded_video) => {+ meta.sharing = Some(SharingMeta {+ link: uploaded_video.link.clone(),+ id: uploaded_video.id.clone(),+ });+ meta.save_for_project();+ RecordingMetaChanged { id: video_id }.emit(&app).ok();- match result {- Ok(()) => println!("Successfully uploaded {}", file_name),- Err(e) => println!("Failed to upload {}: {}", file_name, e),- }- }- }+ uploaded_video.link+ }+ Err(e) => {+ notifications::send_notification(+ &app,+ notifications::NotificationType::UploadFailed,+ );+ return Err(e);}- } else {- println!("General settings not found");}-- meta.sharing = Some(SharingMeta {- link: uploaded_video.link.clone(),- id: uploaded_video.id.clone(),- });- meta.save_for_project();- RecordingMetaChanged { id: video_id }.emit(&app).ok();-- uploaded_video.link};- println!("Copying to clipboard: {:?}", share_link);+ // Only send success notification if we actually got here+ notifications::send_notification(&app, notifications::NotificationType::ShareableLinkCopied);#[cfg(target_os = "macos")]{@@ -1760,11 +1786,8 @@ async fn upload_rendered_video(autoreleasepool(|| {let pasteboard: id = NSPasteboard::generalPasteboard(nil);NSPasteboard::clearContents(pasteboard);-let ns_string = NSString::alloc(nil).init_str(&share_link);-let objects: id = NSArray::arrayWithObject(nil, ns_string);-NSPasteboard::writeObjects(pasteboard, objects);});}@@ -1878,6 +1901,9 @@ async fn upload_screenshot(}}+ // Send notification after successful upload and clipboard copy+ notifications::send_notification(&app, notifications::NotificationType::ShareableLinkCopied);+Ok(UploadResult::Success(share_link))}@@ -2062,14 +2088,21 @@ async fn save_file_dialog(});println!("Waiting for user selection");- let result = rx.recv().map_err(|e| {- println!("Error receiving result: {}", e);- e.to_string()- })?;-- println!("Save dialog result: {:?}", result);-- Ok(result)+ match rx.recv() {+ Ok(result) => {+ println!("Save dialog result: {:?}", result);+ // Don't send any notifications here - we'll do it after the file is actually copied+ Ok(result)+ }+ Err(e) => {+ println!("Error receiving result: {}", e);+ notifications::send_notification(+ &app,+ notifications::NotificationType::VideoSaveFailed,+ );+ Err(e.to_string())+ }+ }}#[derive(Serialize, specta::Type, tauri_specta::Event, Debug, Clone)]@@ -2223,7 +2256,7 @@ async fn delete_auth_open_signin(app: AppHandle) -> Result<(), String> {#[tauri::command]#[specta::specta]-async fn reset_camera_permissions(app: AppHandle) -> Result<(), ()> {+async fn reset_camera_permissions(_app: AppHandle) -> Result<(), ()> {#[cfg(debug_assertions)]let bundle_id = "com.apple.Terminal";#[cfg(not(debug_assertions))]@@ -2241,7 +2274,7 @@ async fn reset_camera_permissions(app: AppHandle) -> Result<(), ()> {#[tauri::command]#[specta::specta]-async fn reset_microphone_permissions(app: AppHandle) -> Result<(), ()> {+async fn reset_microphone_permissions(_app: AppHandle) -> Result<(), ()> {#[cfg(debug_assertions)]let bundle_id = "com.apple.Terminal";#[cfg(not(debug_assertions))]diff --git a/apps/desktop/src-tauri/src/notifications.rs b/apps/desktop/src-tauri/src/notifications.rsindex ad116894a..aae036452 100644--- a/apps/desktop/src-tauri/src/notifications.rs+++ b/apps/desktop/src-tauri/src/notifications.rs@@ -1,4 +1,4 @@-use crate::NewNotification;+use crate::{AppSounds, NewNotification};use tauri_specta::Event;pub enum NotificationType {@@ -6,25 +6,60 @@ pub enum NotificationType {VideoCopiedToClipboard,ShareableLinkCopied,UploadFailed,+ VideoSaveFailed,+ VideoCopyFailed,+ ShareableLinkFailed,+ ScreenshotSaved,+ ScreenshotCopiedToClipboard,+ ScreenshotSaveFailed,+ ScreenshotCopyFailed,}impl NotificationType {- fn details(&self) -> (&'static str, &'static str) {+ fn details(&self) -> (&'static str, &'static str, bool) {match self {- NotificationType::VideoSaved => {- ("Video Saved", "Your video has been successfully saved.")+ NotificationType::VideoSaved => ("Video Saved", "Video saved successfully", false),+ NotificationType::VideoCopiedToClipboard => {+ ("Video Copied", "Video copied to clipboard", false)+ }+ NotificationType::ShareableLinkCopied => {+ ("Link Copied", "Link copied to clipboard", false)}- NotificationType::VideoCopiedToClipboard => (- "Video Copied",- "Your video has been copied to the clipboard.",- ),- NotificationType::ShareableLinkCopied => (- "Link Copied",- "Shareable link has been copied to the clipboard.",- ),NotificationType::UploadFailed => ("Upload Failed",- "Failed to upload your video after multiple attempts. Please try again later.",+ "Unable to upload media. Please try again",+ true,+ ),+ NotificationType::VideoSaveFailed => (+ "Save Failed",+ "Unable to save video. Please try again",+ true,+ ),+ NotificationType::VideoCopyFailed => (+ "Copy Failed",+ "Unable to copy video to clipboard. Please try again",+ true,+ ),+ NotificationType::ShareableLinkFailed => (+ "Share Failed",+ "Unable to create shareable link. Please try again",+ true,+ ),+ NotificationType::ScreenshotSaved => {+ ("Screenshot Saved", "Screenshot saved successfully", false)+ }+ NotificationType::ScreenshotCopiedToClipboard => {+ ("Screenshot Copied", "Screenshot copied to clipboard", false)+ }+ NotificationType::ScreenshotSaveFailed => (+ "Save Failed",+ "Unable to save screenshot. Please try again",+ true,+ ),+ NotificationType::ScreenshotCopyFailed => (+ "Copy Failed",+ "Unable to copy screenshot to clipboard. Please try again",+ true,),}}@@ -47,13 +82,19 @@ impl NotificationType {}pub fn send_notification(app: &tauri::AppHandle, notification_type: NotificationType) {- let (title, body) = notification_type.details();+ let (title, body, is_error) = notification_type.details();++ println!(+ "Sending notification: Title: '{}', Body: '{}', Error: {}",+ title, body, is_error+ );- println!("Sending notification: Title: '{}', Body: '{}'", title, body);+ AppSounds::Notification.play();let _ = NewNotification {title: title.to_string(),body: body.to_string(),+ is_error,}.emit(app);}diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rsindex 381740729..1a70b5f68 100644--- a/apps/desktop/src-tauri/src/windows.rs+++ b/apps/desktop/src-tauri/src/windows.rs@@ -217,7 +217,9 @@ impl CapWindow {window}- Self::InProgressRecording { position } => {+ Self::InProgressRecording {+ position: _position,+ } => {let width = 160.0;let height = 40.0;diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsxindex 36840dd1d..ebd18f745 100644--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx@@ -508,7 +508,7 @@ export function ConfigSidebar() {<Slidervalue={[project.cursor.size]}onChange={(v) => setProject("cursor", "size", v[0])}- minValue={100}+ minValue={500}maxValue={300}/></Field>diff --git a/apps/desktop/src/routes/notifications.tsx b/apps/desktop/src/routes/notifications.tsxindex 9264c1508..5028091b8 100644--- a/apps/desktop/src/routes/notifications.tsx+++ b/apps/desktop/src/routes/notifications.tsx@@ -1,9 +1,65 @@import { events } from "~/utils/tauri";import toast, { Toaster } from "solid-toast";+import { onCleanup, onMount } from "solid-js";export default function Page() {- events.newNotification.listen((e) => {- toast.success(e.payload.body);+ let unlisten: (() => void) | undefined;++ const SuccessIcon = () => (+ <svg+ class="w-6 h-6"+ xmlns="http://www.w3.org/2000/svg"+ fill="none"+ viewBox="0 0 142 142"+ >+ <path+ fill="#fff"+ d="M113.6.888H28.4C13.205.888.887 13.205.887 28.4v85.2c0 15.195 12.318 27.513 27.513 27.513h85.2c15.195 0 27.512-12.318 27.512-27.513V28.4c0-15.195-12.317-27.512-27.512-27.512"+ ></path>+ <path+ fill="#4785FF"+ d="M71 127.8c31.37 0 56.8-25.43 56.8-56.8S102.37 14.2 71 14.2 14.2 39.63 14.2 71s25.43 56.8 56.8 56.8"+ ></path>+ <path+ fill="#ADC9FF"+ d="M71 117.15c25.488 0 46.15-20.662 46.15-46.15S96.488 24.85 71 24.85 24.85 45.512 24.85 71 45.512 117.15 71 117.15"+ ></path>+ <path+ fill="#fff"+ d="M71 106.5c19.606 0 35.5-15.894 35.5-35.5S90.606 35.5 71 35.5 35.5 51.394 35.5 71s15.894 35.5 35.5 35.5"+ ></path>+ </svg>+ );++ onMount(async () => {+ unlisten = await events.newNotification.listen((e) => {+ if (e.payload.is_error) {+ toast.error(e.payload.body, {+ style: {+ background: "#FEE2E2",+ color: "#991B1B",+ border: "1px solid #F87171",+ },+ iconTheme: {+ primary: "#991B1B",+ secondary: "#FEE2E2",+ },+ });+ } else {+ toast.success(e.payload.body, {+ icon: <SuccessIcon />,+ style: {+ background: "#FFFFFF",+ color: "#000000",+ border: "1px solid #FFFFFF",+ },+ });+ }+ });+ });++ onCleanup(() => {+ unlisten?.();});return (@@ -15,7 +71,17 @@ export default function Page() {}`}</style>- <Toaster />+ <Toaster+ position="top-right"+ toastOptions={{+ duration: 3500,+ style: {+ padding: "8px 16px",+ "border-radius": "15px",+ "font-size": "1rem",+ },+ }}+ /></>);}diff --git a/apps/desktop/src/routes/prev-recordings.tsx b/apps/desktop/src/routes/prev-recordings.tsxindex 65650ec38..fcf252236 100644--- a/apps/desktop/src/routes/prev-recordings.tsx+++ b/apps/desktop/src/routes/prev-recordings.tsx@@ -136,13 +136,25 @@ export default function () {const saveMedia = createMutation(() => ({mutationFn: async () => {- const newFileName = isRecording+ const meta = recordingMeta.data;+ if (!meta) {+ throw new Error("Recording metadata not available");+ }++ const defaultName = isRecording? "Cap Recording": media.path.split(".cap/")[1];+ const suggestedName = meta.pretty_name || defaultName;+const fileType = isRecording ? "recording" : "screenshot";+ const extension = isRecording ? ".mp4" : ".png";++ const fullFileName = suggestedName.endsWith(extension)+ ? suggestedName+ : `${suggestedName}${extension}`;const savePathResult = await commands.saveFileDialog(- newFileName,+ fullFileName,fileType);@@ -195,7 +207,8 @@ export default function () {if (isRecording) {res = await commands.uploadRenderedVideo(mediaId,- presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG+ presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG,+ null);} else {res = await commands.uploadScreenshot(media.path);diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex aff15b4a3..e43065dc0 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -396,7 +396,7 @@ export type HotkeysConfiguration = { show: boolean }export type HotkeysStore = { hotkeys: { [key in HotkeyAction]: Hotkey } }export type InProgressRecording = { recordingDir: string; displaySource: ScreenCaptureTarget; segments: number[] }export type JsonValue<T> = [T]-export type NewNotification = { title: string; body: string }+export type NewNotification = { title: string; body: string; is_error: boolean }export type NewRecordingAdded = { path: string }export type NewScreenshotAdded = { path: string }export type OSPermission = "screenRecording" | "camera" | "microphone" | "accessibility"diff --git a/crates/flags/src/lib.rs b/crates/flags/src/lib.rsindex 9a1e97e7b..86d40bc16 100644--- a/crates/flags/src/lib.rs+++ b/crates/flags/src/lib.rs@@ -11,5 +11,5 @@ pub const FLAGS: Flags = Flags {record_mouse: cfg!(debug_assertions),split: false,pause_resume: false,- zoom: true,+ zoom: false,};diff --git a/crates/media/Cargo.toml b/crates/media/Cargo.tomlindex 6ad971fb7..09e153913 100644--- a/crates/media/Cargo.toml+++ b/crates/media/Cargo.toml@@ -23,6 +23,7 @@ specta = "=2.0.0-rc.19"tempfile = "3.12.0"thiserror = "1.0"tracing = "0.1"+cap-flags = { path = "../flags" }[target.'cfg(target_os = "macos")'.dependencies]cocoa = "0.26.0"diff --git a/crates/media/src/sources/screen_capture.rs b/crates/media/src/sources/screen_capture.rsindex 17f69b825..f69ebb73d 100644--- a/crates/media/src/sources/screen_capture.rs+++ b/crates/media/src/sources/screen_capture.rs@@ -1,3 +1,4 @@+use cap_flags::FLAGS;use flume::Sender;use scap::{capturer::{get_output_frame_size, Area, Capturer, Options, Point, Resolution, Size},@@ -123,7 +124,7 @@ impl ScreenCaptureSource {let options = Options {fps,- show_cursor: false,+ show_cursor: !FLAGS.zoom,show_highlight: true,excluded_targets: Some(excluded_targets),output_type: FrameType::BGRAFrame,diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex 94c2a6d5b..9544bdf93 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -26,8 +26,8 @@ use image::GenericImageView;pub mod decoder;pub use decoder::DecodedFrame;-// Add this constant at the top of the file-const STANDARD_CURSOR_HEIGHT: f32 = 100.0; // Standard height for all cursors+// Change this constant from 100.0 to 50.0+const STANDARD_CURSOR_HEIGHT: f32 = 50.0; // Standard height for all cursors#[derive(Debug, Clone, Serialize, Deserialize, Type)]pub struct RenderOptions {@@ -860,117 +860,125 @@ pub async fn produce_frame(// Finally, render the cursor directly to the output texture{- if let Some(cursor_position) = interpolate_cursor_position(&constants.cursor, time) {- println!(- "Raw cursor position: ({}, {})",- cursor_position.0, cursor_position.1- );-- let cursor_event = find_cursor_event(&constants.cursor, time);- println!("Found cursor event with ID: {}", cursor_event.cursor_id);+ if FLAGS.zoom {+ if let Some(cursor_position) = interpolate_cursor_position(&constants.cursor, time) {+ println!(+ "Raw cursor position: ({}, {})",+ cursor_position.0, cursor_position.1+ );- if let Some(cursor_texture) = constants.cursor_textures.get(&cursor_event.cursor_id) {- let cursor_size = cursor_texture.size();- let aspect_ratio = cursor_size.width as f32 / cursor_size.height as f32;+ let cursor_event = find_cursor_event(&constants.cursor, time);+ println!("Found cursor event with ID: {}", cursor_event.cursor_id);- // Use a default cursor size if the uniform value is 0- let cursor_size_percentage = if uniforms.cursor_size <= 0.0 {- 100.0- } else {- uniforms.cursor_size- };- let scale_factor = cursor_size_percentage / 100.0;+ if let Some(cursor_texture) = constants.cursor_textures.get(&cursor_event.cursor_id)+ {+ let cursor_size = cursor_texture.size();+ let aspect_ratio = cursor_size.width as f32 / cursor_size.height as f32;- let normalized_size = [- STANDARD_CURSOR_HEIGHT * aspect_ratio * scale_factor,- STANDARD_CURSOR_HEIGHT * scale_factor,- ];+ // Use a default cursor size if the uniform value is 0+ let cursor_size_percentage = if uniforms.cursor_size <= 0.0 {+ 100.0+ } else {+ uniforms.cursor_size+ };+ let scale_factor = cursor_size_percentage / 100.0;- println!(- "Original cursor size: {}x{}, Normalized size: {}x{}",- cursor_size.width, cursor_size.height, normalized_size[0], normalized_size[1]- );+ let normalized_size = [+ STANDARD_CURSOR_HEIGHT * aspect_ratio * scale_factor,+ STANDARD_CURSOR_HEIGHT * scale_factor,+ ];- // Convert normalized cursor position to screen space- let screen_x = cursor_position.0 * uniforms.output_size.0 as f64;- let screen_y = cursor_position.1 * uniforms.output_size.1 as f64;+ println!(+ "Original cursor size: {}x{}, Normalized size: {}x{}",+ cursor_size.width,+ cursor_size.height,+ normalized_size[0],+ normalized_size[1]+ );- println!("Screen position: ({}, {})", screen_x, screen_y);+ // Convert normalized cursor position to screen space+ let screen_x = cursor_position.0 * uniforms.output_size.0 as f64;+ let screen_y = cursor_position.1 * uniforms.output_size.1 as f64;++ println!("Screen position: ({}, {})", screen_x, screen_y);++ let cursor_uniforms = CursorUniforms {+ position: [screen_x as f32, screen_y as f32, 0.0, 0.0],+ size: [normalized_size[0], normalized_size[1], 0.0, 0.0],+ output_size: [+ uniforms.output_size.0 as f32,+ uniforms.output_size.1 as f32,+ 0.0,+ 0.0,+ ],+ screen_bounds: uniforms.display.target_bounds,+ cursor_size: cursor_size_percentage,+ padding: [0.0; 3],+ _alignment: [0.0; 4],+ };- let cursor_uniforms = CursorUniforms {- position: [screen_x as f32, screen_y as f32, 0.0, 0.0],- size: [normalized_size[0], normalized_size[1], 0.0, 0.0],- output_size: [- uniforms.output_size.0 as f32,- uniforms.output_size.1 as f32,- 0.0,- 0.0,- ],- screen_bounds: uniforms.display.target_bounds,- cursor_size: cursor_size_percentage,- padding: [0.0; 3],- _alignment: [0.0; 4],- };+ println!("Cursor uniforms: {:?}", cursor_uniforms);++ // Create the uniform buffer with the correct size+ let cursor_uniform_buffer =+ constants+ .device+ .create_buffer_init(&wgpu::util::BufferInitDescriptor {+ label: Some("Cursor Uniform Buffer"),+ contents: bytemuck::cast_slice(&[cursor_uniforms]), // This ensures proper size+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,+ });++ let cursor_bind_group =+ constants+ .device+ .create_bind_group(&wgpu::BindGroupDescriptor {+ layout: &constants.cursor_pipeline.bind_group_layout,+ entries: &[+ wgpu::BindGroupEntry {+ binding: 0,+ resource: cursor_uniform_buffer.as_entire_binding(),+ },+ wgpu::BindGroupEntry {+ binding: 1,+ resource: wgpu::BindingResource::TextureView(+ &cursor_texture.create_view(+ &wgpu::TextureViewDescriptor::default(),+ ),+ ),+ },+ wgpu::BindGroupEntry {+ binding: 2,+ resource:+ wgpu::BindingResource::Sampler(+ &constants.device.create_sampler(+ &wgpu::SamplerDescriptor::default(),+ ),+ ),+ },+ ],+ label: Some("Cursor Bind Group"),+ });++ let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {+ label: Some("Cursor Render Pass"),+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {+ view: get_either(texture_views, !output_is_left),+ resolve_target: None,+ ops: wgpu::Operations {+ load: wgpu::LoadOp::Load,+ store: wgpu::StoreOp::Store,+ },+ })],+ depth_stencil_attachment: None,+ timestamp_writes: None,+ occlusion_query_set: None,+ });- println!("Cursor uniforms: {:?}", cursor_uniforms);-- // Create the uniform buffer with the correct size- let cursor_uniform_buffer =- constants- .device- .create_buffer_init(&wgpu::util::BufferInitDescriptor {- label: Some("Cursor Uniform Buffer"),- contents: bytemuck::cast_slice(&[cursor_uniforms]), // This ensures proper size- usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,- });-- let cursor_bind_group =- constants- .device- .create_bind_group(&wgpu::BindGroupDescriptor {- layout: &constants.cursor_pipeline.bind_group_layout,- entries: &[- wgpu::BindGroupEntry {- binding: 0,- resource: cursor_uniform_buffer.as_entire_binding(),- },- wgpu::BindGroupEntry {- binding: 1,- resource: wgpu::BindingResource::TextureView(- &cursor_texture- .create_view(&wgpu::TextureViewDescriptor::default()),- ),- },- wgpu::BindGroupEntry {- binding: 2,- resource: wgpu::BindingResource::Sampler(- &constants- .device- .create_sampler(&wgpu::SamplerDescriptor::default()),- ),- },- ],- label: Some("Cursor Bind Group"),- });-- let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {- label: Some("Cursor Render Pass"),- color_attachments: &[Some(wgpu::RenderPassColorAttachment {- view: get_either(texture_views, !output_is_left),- resolve_target: None,- ops: wgpu::Operations {- load: wgpu::LoadOp::Load,- store: wgpu::StoreOp::Store,- },- })],- depth_stencil_attachment: None,- timestamp_writes: None,- occlusion_query_set: None,- });-- render_pass.set_pipeline(&constants.cursor_pipeline.render_pipeline);- render_pass.set_bind_group(0, &cursor_bind_group, &[]);- render_pass.draw(0..4, 0..1);+ render_pass.set_pipeline(&constants.cursor_pipeline.render_pipeline);+ render_pass.set_bind_group(0, &cursor_bind_group, &[]);+ render_pass.draw(0..4, 0..1);+ }}}}