Skip to content

Commit

Permalink
fix: support capture current on wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed Feb 17, 2024
1 parent 877de2e commit cef39b0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"]
Expand Down
9 changes: 4 additions & 5 deletions crates/sss_cli/src/img.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions crates/sss_cli/src/shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cef39b0

Please sign in to comment.