Skip to content

Commit

Permalink
On Windows, fix invalid hmonitor panic
Browse files Browse the repository at this point in the history
Co-authored-by: Kirill Chibisov <[email protected]>
  • Loading branch information
xiaopengli89 and kchibisov committed Oct 21, 2023
1 parent 20384d2 commit f6cc6c1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/platform_impl/windows/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,15 @@ impl MonitorHandle {

#[inline]
pub fn position(&self) -> PhysicalPosition<i32> {
let rc_monitor = get_monitor_info(self.0).unwrap().monitorInfo.rcMonitor;
PhysicalPosition {
x: rc_monitor.left,
y: rc_monitor.top,
}
get_monitor_info(self.0)
.map(|info| {
let rc_monitor = info.monitorInfo.rcMonitor;
PhysicalPosition {
x: rc_monitor.left,
y: rc_monitor.top,
}
})
.unwrap_or(PhysicalPosition { x: 0, y: 0 })
}

#[inline]
Expand Down

0 comments on commit f6cc6c1

Please sign in to comment.