Skip to content

Commit

Permalink
fix(linux): fullscreen on current monitor (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Feb 13, 2022
1 parent 5ed41e5 commit 456147d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-fullscreen-linux.md
@@ -0,0 +1,5 @@
---
"tao": patch
---

Fixes the `set_fullscreen` implementation on Linux when the `Fullscreen::Borderless` value is set to `None`.
3 changes: 2 additions & 1 deletion examples/fullscreen.rs
Expand Up @@ -16,7 +16,7 @@ fn main() {
env_logger::init();
let event_loop = EventLoop::new();

print!("Please choose the fullscreen mode: (1) exclusive, (2) borderless: ");
print!("Please choose the fullscreen mode: (1) exclusive, (2) borderless, (3) borderless on current monitor: ");
stdout().flush().unwrap();

let mut num = String::new();
Expand All @@ -26,6 +26,7 @@ fn main() {
let fullscreen = Some(match num {
1 => Fullscreen::Exclusive(prompt_for_video_mode(&prompt_for_monitor(&event_loop))),
2 => Fullscreen::Borderless(Some(prompt_for_monitor(&event_loop))),
3 => Fullscreen::Borderless(None),
_ => panic!("Please enter a valid number"),
});

Expand Down
12 changes: 8 additions & 4 deletions src/platform_impl/linux/event_loop.rs
Expand Up @@ -259,10 +259,14 @@ impl<T: 'static> EventLoop<T> {
}
WindowRequest::Fullscreen(fullscreen) => match fullscreen {
Some(f) => {
if let Fullscreen::Borderless(Some(monitor)) = f {
let number = monitor.inner.number;
let screen = window.display().default_screen();
window.fullscreen_on_monitor(&screen, number);
if let Fullscreen::Borderless(m) = f {
if let Some(monitor) = m {
let number = monitor.inner.number;
let screen = window.display().default_screen();
window.fullscreen_on_monitor(&screen, number);
} else {
window.fullscreen();
}
}
}
None => window.unfullscreen(),
Expand Down

0 comments on commit 456147d

Please sign in to comment.