Skip to content

Commit

Permalink
fix: 修复 macos Monitor::from_point 未找到窗口时仍然返回数据问题
Browse files Browse the repository at this point in the history
  • Loading branch information
nashaofu committed Feb 4, 2025
1 parent a6f508a commit 5494a8a
Showing 1 changed file with 5 additions and 0 deletions.
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 5494a8a

Please sign in to comment.