Skip to content

Commit

Permalink
fix(linux): avoid unwrapping in Window::current_monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 16, 2023
1 parent 081ba16 commit eecd1c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/linux-current-monitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Fix `Window::current_monitor` sometimes panicking on Linux when the window is invisible.
11 changes: 6 additions & 5 deletions src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,12 @@ impl Window {
let monitor = self
.window
.window()
.map(|window| display.monitor_at_window(&window))
.unwrap_or_else(|| display.primary_monitor())
.unwrap();
let handle = MonitorHandle { monitor };
Some(RootMonitorHandle { inner: handle })
.and_then(|window| display.monitor_at_window(&window))
.or_else(|| display.primary_monitor());

monitor.map(|monitor| RootMonitorHandle {
inner: MonitorHandle { monitor },
})
}

#[inline]
Expand Down

0 comments on commit eecd1c7

Please sign in to comment.