Skip to content

Commit

Permalink
fix: don't panic if primary monitor not discoverable. (#705)
Browse files Browse the repository at this point in the history
* fix(linux): don't panic if primary monitor not discoverable. (#704)

* chore: add change file.
  • Loading branch information
2e0byo committed Feb 22, 2023
1 parent e9eba85 commit 28b53f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/linux-primary-monitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Attempt to get primary monitor on linux will now return None rather than panicking if monitor not found.
8 changes: 5 additions & 3 deletions src/platform_impl/linux/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ impl<T> EventLoopWindowTarget<T> {

#[inline]
pub fn primary_monitor(&self) -> Option<RootMonitorHandle> {
let monitor = self.display.primary_monitor().unwrap();
let handle = MonitorHandle { monitor };
Some(RootMonitorHandle { inner: handle })
let monitor = self.display.primary_monitor();
monitor.and_then(|monitor| {
let handle = MonitorHandle { monitor };
Some(RootMonitorHandle { inner: handle })
})
}

pub fn raw_display_handle(&self) -> RawDisplayHandle {
Expand Down

0 comments on commit 28b53f8

Please sign in to comment.