diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.toml index 92792dd1c..c9f2b8f7a 100644 --- a/screenpipe-vision/Cargo.toml +++ b/screenpipe-vision/Cargo.toml @@ -43,6 +43,9 @@ tracing = { workspace = true } which = "6.0" serde = "1.0.200" +# TO-DO: use a released version. Done for now to avoid waiting xcap release. +xcap = { package = "xcap", git = "https://github.com/nashaofu/xcap", rev = "214cb44" } + once_cell = { workspace = true } base64 = "0.22.1" @@ -96,13 +99,10 @@ windows = { version = "0.58", features = [ "Storage", "Storage_Streams", ] } -xcap = "0.0.12" [target.'cfg(target_os = "macos")'.dependencies] libc = "=0.2.164" -xcap-macos = { package = "xcap", git = "https://github.com/mediar-ai/xcap", rev = "965bc99" } cidre = { git = "https://github.com/yury/cidre.git", version = "0.5.0" } [target.'cfg(target_os = "linux")'.dependencies] libc = "=0.2.164" -xcap = "0.0.14" diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs index a87248219..4524ce7b3 100644 --- a/screenpipe-vision/src/capture_screenshot_by_window.rs +++ b/screenpipe-vision/src/capture_screenshot_by_window.rs @@ -7,10 +7,6 @@ use std::fmt; use std::time::Duration; use tokio::time; -#[cfg(target_os = "macos")] -use xcap_macos::{Monitor, Window, XCapError}; - -#[cfg(not(target_os = "macos"))] use xcap::{Monitor, Window, XCapError}; #[derive(Debug)] @@ -238,7 +234,7 @@ pub async fn capture_all_visible_windows( image, app_name: app_name.to_string(), window_name: window_name.to_string(), - is_focused: is_valid, + is_focused: window.is_focused(), }); } Err(e) => error!( @@ -260,13 +256,8 @@ pub fn is_valid_window( capture_unfocused_windows: bool, ) -> bool { if !capture_unfocused_windows { - // Early returns for simple checks - #[cfg(target_os = "macos")] let is_focused = window.current_monitor().id() == monitor.id() && window.is_focused(); - #[cfg(not(target_os = "macos"))] - let is_focused = window.current_monitor().id() == monitor.id() && !window.is_minimized(); - if !is_focused { return false; } diff --git a/screenpipe-vision/src/core.rs b/screenpipe-vision/src/core.rs index b45b70b15..bb992143d 100644 --- a/screenpipe-vision/src/core.rs +++ b/screenpipe-vision/src/core.rs @@ -33,10 +33,6 @@ use tokio::sync::watch; use tracing::info; use tracing::warn; -#[cfg(target_os = "macos")] -use xcap_macos::Monitor; - -#[cfg(not(target_os = "macos"))] use xcap::Monitor; fn serialize_image(image: &Option, serializer: S) -> Result diff --git a/screenpipe-vision/src/monitor.rs b/screenpipe-vision/src/monitor.rs index f96196751..133a0889a 100644 --- a/screenpipe-vision/src/monitor.rs +++ b/screenpipe-vision/src/monitor.rs @@ -1,10 +1,5 @@ -#[cfg(target_os = "macos")] -use xcap_macos::Monitor; - -#[cfg(not(target_os = "macos"))] use xcap::Monitor; - pub async fn list_monitors() -> Vec { Monitor::all().unwrap().to_vec() } diff --git a/screenpipe-vision/src/utils.rs b/screenpipe-vision/src/utils.rs index 28a8f2349..9a21585a7 100644 --- a/screenpipe-vision/src/utils.rs +++ b/screenpipe-vision/src/utils.rs @@ -9,10 +9,6 @@ use log::{debug, error, warn}; use std::hash::{DefaultHasher, Hash, Hasher}; use std::time::{Duration, Instant}; -#[cfg(target_os = "macos")] -use xcap_macos::Monitor; - -#[cfg(not(target_os = "macos"))] use xcap::Monitor; #[derive(Clone, Debug, Default)]