Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
clippy
Richie McIlroyc2898f2fb8db
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex 6d39fbf48..ecdab8f75 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -416,7 +416,10 @@ pub fn format_project_name<'a>(};let result = AC- .try_replace_all(haystack, &[recording_mode, mode, target_kind, &truncated_target_name])+ .try_replace_all(+ haystack,+ &[recording_mode, mode, target_kind, &truncated_target_name],+ ).expect("AhoCorasick replace should never fail with default configuration");let result = DATE_REGEX.replace_all(&result, |caps: ®ex::Captures| {@@ -2180,125 +2183,6 @@ pub fn remux_fragmented_recording(recording_dir: &Path) -> Result<(), String> {}}-fn analyze_recording_for_remux(- project_path: &Path,- meta: &RecordingMeta,-) -> Option<cap_recording::recovery::IncompleteRecording> {- use cap_recording::recovery::{IncompleteRecording, RecoverableSegment};-- let StudioRecordingMeta::MultipleSegments { inner, .. } = meta.studio_meta()? else {- return None;- };-- let mut recoverable_segments = Vec::new();-- for (index, segment) in inner.segments.iter().enumerate() {- let display_path = segment.display.path.to_path(project_path);- let (display_fragments, display_init_segment) = if display_path.is_dir() {- let frags = find_fragments_in_dir(&display_path);- let init = display_path.join("init.mp4");- (frags, if init.exists() { Some(init) } else { None })- } else if display_path.exists() {- (vec![display_path], None)- } else {- continue;- };-- if display_fragments.is_empty() {- continue;- }-- let (camera_fragments, camera_init_segment) = segment- .camera- .as_ref()- .map(|cam| {- let cam_path = cam.path.to_path(project_path);- if cam_path.is_dir() {- let frags = find_fragments_in_dir(&cam_path);- let init = cam_path.join("init.mp4");- let init_seg = if init.exists() { Some(init) } else { None };- if frags.is_empty() {- (None, None)- } else {- (Some(frags), init_seg)- }- } else if cam_path.exists() {- (Some(vec![cam_path]), None)- } else {- (None, None)- }- })- .unwrap_or((None, None));-- let cursor_path = segment- .cursor- .as_ref()- .map(|c| c.to_path(project_path))- .filter(|p| p.exists());-- let mic_fragments = segment.mic.as_ref().and_then(|mic| {- let mic_path = mic.path.to_path(project_path);- if mic_path.is_dir() {- let frags = find_fragments_in_dir(&mic_path);- if frags.is_empty() { None } else { Some(frags) }- } else if mic_path.exists() {- Some(vec![mic_path])- } else {- None- }- });-- let system_audio_fragments = segment.system_audio.as_ref().and_then(|sys| {- let sys_path = sys.path.to_path(project_path);- if sys_path.is_dir() {- let frags = find_fragments_in_dir(&sys_path);- if frags.is_empty() { None } else { Some(frags) }- } else if sys_path.exists() {- Some(vec![sys_path])- } else {- None- }- });-- recoverable_segments.push(RecoverableSegment {- index: index as u32,- display_fragments,- display_init_segment,- camera_fragments,- camera_init_segment,- mic_fragments,- system_audio_fragments,- cursor_path,- });- }-- if recoverable_segments.is_empty() {- return None;- }-- Some(IncompleteRecording {- project_path: project_path.to_path_buf(),- meta: meta.clone(),- recoverable_segments,- estimated_duration: Duration::ZERO,- })-}--fn find_fragments_in_dir(dir: &Path) -> Vec<PathBuf> {- let Ok(entries) = std::fs::read_dir(dir) else {- return Vec::new();- };-- let mut fragments: Vec<_> = entries- .filter_map(|e| e.ok())- .map(|e| e.path())- .filter(|p| p.extension().is_some_and(|e| e == "mp4" || e == "m4a"))- .collect();-- fragments.sort();- fragments-}-#[cfg(test)]mod tests {use super::*;diff --git a/crates/scap-targets/src/platform/win.rs b/crates/scap-targets/src/platform/win.rsindex c3573e54e..9c304b5cb 100644--- a/crates/scap-targets/src/platform/win.rs+++ b/crates/scap-targets/src/platform/win.rs@@ -1,28 +1,29 @@use std::{ffi::OsString, mem, os::windows::ffi::OsStringExt, path::PathBuf, str::FromStr};use tracing::error;use windows::{+ core::{BOOL, PCWSTR, PWSTR},Graphics::Capture::GraphicsCaptureItem,Win32::{Foundation::{CloseHandle, HWND, LPARAM, POINT, RECT, TRUE, WPARAM},Graphics::{- Dwm::{DWMWA_CLOAKED, DWMWA_EXTENDED_FRAME_BOUNDS, DwmGetWindowAttribute},+ Dwm::{DwmGetWindowAttribute, DWMWA_CLOAKED, DWMWA_EXTENDED_FRAME_BOUNDS},Gdi::{- BI_RGB, BITMAP, BITMAPINFO, BITMAPINFOHEADER, CreateCompatibleBitmap,- CreateCompatibleDC, CreateSolidBrush, DEVMODEW, DIB_RGB_COLORS,- DISPLAY_DEVICE_STATE_FLAGS, DISPLAY_DEVICEW, DeleteDC, DeleteObject,- ENUM_CURRENT_SETTINGS, EnumDisplayDevicesW, EnumDisplayMonitors,- EnumDisplaySettingsW, FillRect, GetDC, GetDIBits, GetMonitorInfoW, GetObjectA,- HBRUSH, HDC, HGDIOBJ, HMONITOR, MONITOR_DEFAULTTONEAREST, MONITOR_DEFAULTTONULL,- MONITORINFOEXW, MonitorFromPoint, MonitorFromWindow, ReleaseDC, SelectObject,+ CreateCompatibleBitmap, CreateCompatibleDC, CreateSolidBrush, DeleteDC,+ DeleteObject, EnumDisplayDevicesW, EnumDisplayMonitors, EnumDisplaySettingsW,+ FillRect, GetDC, GetDIBits, GetMonitorInfoW, GetObjectA, MonitorFromPoint,+ MonitorFromWindow, ReleaseDC, SelectObject, BITMAP, BITMAPINFO, BITMAPINFOHEADER,+ BI_RGB, DEVMODEW, DIB_RGB_COLORS, DISPLAY_DEVICEW, DISPLAY_DEVICE_STATE_FLAGS,+ ENUM_CURRENT_SETTINGS, HBRUSH, HDC, HGDIOBJ, HMONITOR, MONITORINFOEXW,+ MONITOR_DEFAULTTONEAREST, MONITOR_DEFAULTTONULL,},},Storage::FileSystem::{- FILE_FLAGS_AND_ATTRIBUTES, GetFileVersionInfoSizeW, GetFileVersionInfoW, VerQueryValueW,+ GetFileVersionInfoSizeW, GetFileVersionInfoW, VerQueryValueW, FILE_FLAGS_AND_ATTRIBUTES,},System::{Threading::{- GetCurrentProcessId, OpenProcess, PROCESS_NAME_FORMAT,- PROCESS_QUERY_LIMITED_INFORMATION, QueryFullProcessImageNameW,+ GetCurrentProcessId, OpenProcess, QueryFullProcessImageNameW, PROCESS_NAME_FORMAT,+ PROCESS_QUERY_LIMITED_INFORMATION,},WinRT::Graphics::Capture::IGraphicsCaptureItemInterop,},@@ -32,25 +33,26 @@ use windows::{PROCESS_PER_MONITOR_DPI_AWARE,},Shell::{- ExtractIconExW, SHFILEINFOW, SHGFI_ICON, SHGFI_LARGEICON, SHGFI_SMALLICON,- SHGetFileInfoW,+ ExtractIconExW, SHGetFileInfoW, SHFILEINFOW, SHGFI_ICON, SHGFI_LARGEICON,+ SHGFI_SMALLICON,},WindowsAndMessaging::{- DI_FLAGS, DestroyIcon, DrawIconEx, EnumChildWindows, EnumWindows, GCLP_HICON,- GW_HWNDNEXT, GWL_EXSTYLE, GWL_STYLE, GetClassLongPtrW, GetClassNameW,- GetClientRect, GetCursorPos, GetDesktopWindow, GetIconInfo,+ DestroyIcon, DrawIconEx, EnumChildWindows, EnumWindows, GetClassLongPtrW,+ GetClassNameW, GetClientRect, GetCursorPos, GetDesktopWindow, GetIconInfo,GetLayeredWindowAttributes, GetWindow, GetWindowLongPtrW, GetWindowLongW,GetWindowRect, GetWindowTextLengthW, GetWindowTextW, GetWindowThreadProcessId,- HICON, ICONINFO, IsIconic, IsWindowVisible, PrivateExtractIconsW, SendMessageW,+ IsIconic, IsWindowVisible, PrivateExtractIconsW, SendMessageW, WindowFromPoint,+ DI_FLAGS, GCLP_HICON, GWL_EXSTYLE, GWL_STYLE, GW_HWNDNEXT, HICON, ICONINFO,WM_GETICON, WS_CHILD, WS_EX_LAYERED, WS_EX_TOOLWINDOW, WS_EX_TOPMOST,- WS_EX_TRANSPARENT, WindowFromPoint,+ WS_EX_TRANSPARENT,},},},- core::{BOOL, PCWSTR, PWSTR},};-use crate::bounds::{LogicalSize, PhysicalBounds, PhysicalPosition, PhysicalSize};+use crate::bounds::{+ LogicalBounds, LogicalPosition, LogicalSize, PhysicalBounds, PhysicalPosition, PhysicalSize,+};// All of this assumes PROCESS_PER_MONITOR_DPI_AWARE//@@ -124,7 +126,7 @@ impl DisplayImpl {}pub fn raw_id(&self) -> DisplayIdImpl {- DisplayIdImpl(self.0.0 as u64)+ DisplayIdImpl(self.0 .0 as u64)}pub fn from_id(id: String) -> Option<Self> {@@ -149,6 +151,29 @@ impl DisplayImpl {))}+ pub fn logical_bounds(&self) -> Option<LogicalBounds> {+ let physical_bounds = self.physical_bounds()?;++ let dpi = unsafe {+ let mut dpi_x = 0;+ GetDpiForMonitor(self.0, MDT_EFFECTIVE_DPI, &mut dpi_x, &mut 0).ok()?;+ dpi_x+ };++ let scale = dpi as f64 / 96.0;++ Some(LogicalBounds::new(+ LogicalPosition::new(+ physical_bounds.position().x() / scale,+ physical_bounds.position().y() / scale,+ ),+ LogicalSize::new(+ physical_bounds.size().width() / scale,+ physical_bounds.size().height() / scale,+ ),+ ))+ }+pub fn get_containing_cursor() -> Option<Self> {let cursor = get_cursor_position()?;let point = POINT {@@ -424,7 +449,7 @@ impl WindowImpl {}pub fn id(&self) -> WindowIdImpl {- WindowIdImpl(self.0.0 as u64)+ WindowIdImpl(self.0 .0 as u64)}pub fn level(&self) -> Option<i32> {