Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use human friendly monitor names #1272

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions screenpipe-vision/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
11 changes: 1 addition & 10 deletions screenpipe-vision/src/capture_screenshot_by_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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!(
Expand All @@ -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;
}
Expand Down
4 changes: 0 additions & 4 deletions screenpipe-vision/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S>(image: &Option<DynamicImage>, serializer: S) -> Result<S::Ok, S::Error>
Expand Down
5 changes: 0 additions & 5 deletions screenpipe-vision/src/monitor.rs
Original file line number Diff line number Diff line change
@@ -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> {
Monitor::all().unwrap().to_vec()
}
Expand Down
4 changes: 0 additions & 4 deletions screenpipe-vision/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Loading