From 0ce131f40bb15746ee4692a47abe32560f71d061 Mon Sep 17 00:00:00 2001 From: Wesley Matos Date: Tue, 4 Feb 2025 18:13:00 -0300 Subject: [PATCH 1/6] feat: use human friendly monitor names --- screenpipe-vision/Cargo.toml | 5 +++-- screenpipe-vision/src/capture_screenshot_by_window.rs | 4 ---- screenpipe-vision/src/core.rs | 4 ---- screenpipe-vision/src/monitor.rs | 5 ----- screenpipe-vision/src/utils.rs | 4 ---- 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.toml index 92792dd1c..592c68e4f 100644 --- a/screenpipe-vision/Cargo.toml +++ b/screenpipe-vision/Cargo.toml @@ -96,13 +96,14 @@ windows = { version = "0.58", features = [ "Storage", "Storage_Streams", ] } -xcap = "0.0.12" +xcap = "0.3.1" [target.'cfg(target_os = "macos")'.dependencies] libc = "=0.2.164" xcap-macos = { package = "xcap", git = "https://github.com/mediar-ai/xcap", rev = "965bc99" } +xcap = "0.3.1" 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" +xcap = "0.3.1" diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs index a87248219..6c29d3fe6 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)] 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)] From dbe9f8be75219cb43c0abeeeebe226a5928a7afc Mon Sep 17 00:00:00 2001 From: Wesley Matos Date: Thu, 6 Feb 2025 23:24:10 -0300 Subject: [PATCH 2/6] refactor: capture anything that is not minimized on all platforms --- screenpipe-vision/src/capture_screenshot_by_window.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs index 6c29d3fe6..c63fcfc3c 100644 --- a/screenpipe-vision/src/capture_screenshot_by_window.rs +++ b/screenpipe-vision/src/capture_screenshot_by_window.rs @@ -256,11 +256,6 @@ 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 { From 2e8e89585eb94e7f9ecd8bf06422deebbb3a6d0e Mon Sep 17 00:00:00 2001 From: Wesley Matos Date: Thu, 6 Feb 2025 23:24:28 -0300 Subject: [PATCH 3/6] chore: delete unnecessary dependency --- screenpipe-vision/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.toml index 592c68e4f..57311810b 100644 --- a/screenpipe-vision/Cargo.toml +++ b/screenpipe-vision/Cargo.toml @@ -100,7 +100,6 @@ xcap = "0.3.1" [target.'cfg(target_os = "macos")'.dependencies] libc = "=0.2.164" -xcap-macos = { package = "xcap", git = "https://github.com/mediar-ai/xcap", rev = "965bc99" } xcap = "0.3.1" cidre = { git = "https://github.com/yury/cidre.git", version = "0.5.0" } From 6e3431b952aa3d5242ba234cfa4df7a5ea5880a4 Mon Sep 17 00:00:00 2001 From: Wesley Matos Date: Fri, 7 Feb 2025 16:38:45 -0300 Subject: [PATCH 4/6] fix: save _actual_ `is_focused` value instead of if window is valid --- screenpipe-vision/src/capture_screenshot_by_window.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs index c63fcfc3c..f55641a11 100644 --- a/screenpipe-vision/src/capture_screenshot_by_window.rs +++ b/screenpipe-vision/src/capture_screenshot_by_window.rs @@ -234,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!( From 18b571c2cdc101289dade901ad07909e02f571c3 Mon Sep 17 00:00:00 2001 From: Wesley Matos Date: Fri, 14 Feb 2025 10:21:14 -0300 Subject: [PATCH 5/6] chore: use same xcap version for all OSes --- screenpipe-vision/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.toml index 57311810b..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.3.1" [target.'cfg(target_os = "macos")'.dependencies] libc = "=0.2.164" -xcap = "0.3.1" cidre = { git = "https://github.com/yury/cidre.git", version = "0.5.0" } [target.'cfg(target_os = "linux")'.dependencies] libc = "=0.2.164" -xcap = "0.3.1" From 6203f2837e7d4c5f154f2b8273e9c4fdcd3c3845 Mon Sep 17 00:00:00 2001 From: Wesley Matos Date: Fri, 14 Feb 2025 10:24:23 -0300 Subject: [PATCH 6/6] fix: consider old macos as default behavior --- screenpipe-vision/src/capture_screenshot_by_window.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs index f55641a11..4524ce7b3 100644 --- a/screenpipe-vision/src/capture_screenshot_by_window.rs +++ b/screenpipe-vision/src/capture_screenshot_by_window.rs @@ -256,7 +256,7 @@ pub fn is_valid_window( capture_unfocused_windows: bool, ) -> bool { if !capture_unfocused_windows { - let is_focused = window.current_monitor().id() == monitor.id() && !window.is_minimized(); + let is_focused = window.current_monitor().id() == monitor.id() && window.is_focused(); if !is_focused { return false;