diff --git a/Cargo.lock b/Cargo.lock index a124216..6ea3aa8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1551,10 +1551,10 @@ dependencies = [ [[package]] name = "mouse_position" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffd272ac3ad817af3d158eecd4d4ba6f92a1fa5f7255e3c0d63b72d4dac12edd" +source = "git+https://github.com/SergioRibera/mouse_position?branch=compositors_protocols#d17b901b0d39885708b4b6b42c4caed8f799e914" dependencies = [ - "core-graphics 0.22.3", + "core-graphics 0.23.1", + "thiserror", "winapi", "x11-dl", ] diff --git a/Cargo.toml b/Cargo.toml index b8d5d6a..5a18aab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,13 +36,16 @@ merge2 = "0.3.0" env_logger = "0.10.0" directories = "5.0.1" clap = { version = "4.4.8", features = [ - "derive", - "color", - "env", - "suggestions", - "wrap_help", + "derive", + "color", + "env", + "suggestions", + "wrap_help", ] } +[patch.crates-io] +mouse_position = { git = "https://github.com/SergioRibera/mouse_position", branch = "compositors_protocols" } + # Config for 'cargo dist' [workspace.metadata.dist] # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) @@ -55,10 +58,10 @@ installers = ["shell", "powershell", "homebrew", "msi"] tap = "SergioRibera/homebrew-tap" # Target platforms to build apps for (Rust target-triple syntax) targets = [ - "x86_64-unknown-linux-gnu", - "aarch64-apple-darwin", - "x86_64-apple-darwin", - "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "aarch64-apple-darwin", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", ] # Publish jobs to run in CI publish-jobs = ["homebrew"] diff --git a/crates/sss_cli/src/img.rs b/crates/sss_cli/src/img.rs index d017ebd..7bd31aa 100644 --- a/crates/sss_cli/src/img.rs +++ b/crates/sss_cli/src/img.rs @@ -1,4 +1,5 @@ -use mouse_position::mouse_position::Mouse; +use mouse_position::{Mouse, MouseExt}; +use screenshots::display_info::DisplayInfo; use sss_lib::DynImageContent; use crate::config::CliConfig; @@ -15,12 +16,10 @@ impl DynImageContent for Screenshot { let shot = ShotImpl::default(); if self.config.screen && self.config.current { - let Mouse::Position { x, y } = Mouse::get_mouse_position() else { + let Ok((x, y)) = Mouse::default().get_pos() else { panic!("Cannot get mouse position"); }; - screenshots::Screen::from_point(x, y) // replace by mouse - .unwrap() - .capture() + shot.screen(Some((x, y)), None, None, self.config.show_cursor) .unwrap() } else if let Some(area) = self.config.area { shot.capture_area(area, self.config.show_cursor).unwrap() diff --git a/crates/sss_cli/src/shot.rs b/crates/sss_cli/src/shot.rs index 3e63896..95e243e 100644 --- a/crates/sss_cli/src/shot.rs +++ b/crates/sss_cli/src/shot.rs @@ -261,9 +261,7 @@ impl ShotImpl { #[cfg(not(target_os = "linux"))] return Err("No Context loaded".to_string()); - let Some(screen_name) = name else { - return Err("No name set".to_string()); - }; + let screen_name = name.unwrap_or_default(); #[cfg(target_os = "linux")] self.wayland