Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fmt

Richie McIlroy36ee402cc196
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index ea8f81e9f..a964cf3e4 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -31,6 +31,7 @@ use regex::Regex;
use serde::{Deserialize, Serialize};
use specta::Type;
use std::borrow::Cow;
+use std::error::Error as StdError;
use std::{
any::Any,
collections::{HashMap, VecDeque},
@@ -54,7 +55,9 @@ use crate::{
audio::AppSounds,
auth::AuthStore,
create_screenshot,
- general_settings::{GeneralSettingsStore, PostDeletionBehaviour, PostStudioRecordingBehaviour},
+ general_settings::{
+ self, GeneralSettingsStore, PostDeletionBehaviour, PostStudioRecordingBehaviour,
+ },
open_external_link,
presets::PresetsStore,
thumbnails::*,
diff --git a/apps/desktop/src-tauri/src/target_select_overlay.rs b/apps/desktop/src-tauri/src/target_select_overlay.rs
index 6374e4340..f72949c09 100644
--- a/apps/desktop/src-tauri/src/target_select_overlay.rs
+++ b/apps/desktop/src-tauri/src/target_select_overlay.rs
@@ -142,7 +142,7 @@ fn should_skip_window(window: &Window, exclusions: &[WindowExclusion]) -> bool {
exclusions.iter().any(|entry| {
entry.matches(
- bundle_identifier,
+ bundle_identifier.as_deref(),
owner_name.as_deref(),
window_title.as_deref(),
)
diff --git a/apps/desktop/src-tauri/src/window_exclusion.rs b/apps/desktop/src-tauri/src/window_exclusion.rs
index 70f473041..67fc1c1e1 100644
--- a/apps/desktop/src-tauri/src/window_exclusion.rs
+++ b/apps/desktop/src-tauri/src/window_exclusion.rs
@@ -1,5 +1,4 @@
-use scap_targets::Window;
-use scap_targets::WindowId;
+use scap_targets::{Window, WindowId};
use serde::{Deserialize, Serialize};
use specta::Type;
@@ -61,3 +60,34 @@ impl WindowExclusion {
false
}
}
+
+pub fn resolve_window_ids(exclusions: &[WindowExclusion]) -> Vec<WindowId> {
+ if exclusions.is_empty() {
+ return Vec::new();
+ }
+
+ Window::list()
+ .into_iter()
+ .filter_map(|window| {
+ let owner_name = window.owner_name();
+ let window_title = window.name();
+
+ #[cfg(target_os = "macos")]
+ let bundle_identifier = window.raw_handle().bundle_identifier();
+
+ #[cfg(not(target_os = "macos"))]
+ let bundle_identifier = None::<&str>;
+
+ exclusions
+ .iter()
+ .find(|entry| {
+ entry.matches(
+ bundle_identifier.as_deref(),
+ owner_name.as_deref(),
+ window_title.as_deref(),
+ )
+ })
+ .map(|_| window.id())
+ })
+ .collect()
+}
diff --git a/crates/recording/src/cursor.rs b/crates/recording/src/cursor.rs
index 0f303730d..a3701dfea 100644
--- a/crates/recording/src/cursor.rs
+++ b/crates/recording/src/cursor.rs
@@ -48,14 +48,14 @@ fn flush_cursor_data(output_path: &Path, moves: &[CursorMoveEvent], clicks: &[Cu
clicks: clicks.to_vec(),
moves: moves.to_vec(),
};
- if let Ok(json) = serde_json::to_string_pretty(&events) {
- if let Err(e) = std::fs::write(output_path, json) {
- tracing::error!(
- "Failed to write cursor data to {}: {}",
- output_path.display(),
- e
- );
- }
+ if let Ok(json) = serde_json::to_string_pretty(&events)
+ && let Err(e) = std::fs::write(output_path, json)
+ {
+ tracing::error!(
+ "Failed to write cursor data to {}: {}",
+ output_path.display(),
+ e
+ );
}
}
diff --git a/crates/recording/src/sources/screen_capture/mod.rs b/crates/recording/src/sources/screen_capture/mod.rs
index c55224f7c..536507b7e 100644
--- a/crates/recording/src/sources/screen_capture/mod.rs
+++ b/crates/recording/src/sources/screen_capture/mod.rs
@@ -305,8 +305,8 @@ impl<TCaptureFormat: ScreenCaptureFormat> ScreenCaptureConfig<TCaptureFormat> {
let target_refresh = validated_refresh_rate(display.refresh_rate());
let fps = std::cmp::max(1, std::cmp::min(max_fps, target_refresh));
- let output_size = crop_bounds
- .and_then(|b| {
+ let output_size: PhysicalSize = crop_bounds
+ .and_then(|b| -> Option<PhysicalSize> {
#[cfg(target_os = "macos")]
{
let logical_size = b.size();