Skip to content

Commit

Permalink
fix: 修复 macos Monitor::from_point 未找到窗口时仍然返回数据问题 (#189)
Browse files Browse the repository at this point in the history
* fix: 修复 macos Monitor::from_point 未找到窗口时仍然返回数据问题

* chore: 修改版本号

---------

Co-authored-by: nashaofu <[email protected]>
  • Loading branch information
nashaofu and nashaofu authored Feb 4, 2025
1 parent a6f508a commit fa60300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xcap"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
description = "XCap is a cross-platform screen capture library written in Rust. It supports Linux (X11, Wayland), MacOS, and Windows. XCap supports screenshot and video recording (WIP)."
license = "Apache-2.0"
Expand Down
5 changes: 5 additions & 0 deletions src/macos/impl_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ impl ImplMonitor {
)));
}

if display_count == 0 {
return Err(XCapError::new("Monitor not found"));
}

if let Some(&display_id) = display_ids.first() {
if unsafe { !CGDisplayIsActive(display_id) } {
return Err(XCapError::new("Monitor is not active"));
}
println!("display_id: {}", display_id);
ImplMonitor::new(display_id)
} else {
Err(XCapError::new("Monitor not found"))
Expand Down

0 comments on commit fa60300

Please sign in to comment.