Skip to content

Commit

Permalink
fix(windows): fix set_fullscreen early return for `Fullscreen::Bord…
Browse files Browse the repository at this point in the history
…erless(None)` (#854)
  • Loading branch information
amrbashir committed Dec 14, 2023
1 parent 5eb2124 commit 68803e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/windows-set-fullscreen-early-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On Windows, fix consecutive calls to `window.set_fullscreen(Some(Fullscreen::Borderless(None)))` resulting in losing previous window state when eventually exiting fullscreen using `window.set_fullscreen(None)`.
14 changes: 12 additions & 2 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,19 @@ impl Window {

let mut window_state_lock = window_state.lock();
let old_fullscreen = window_state_lock.fullscreen.clone();
if window_state_lock.fullscreen == fullscreen {
return;

match (&old_fullscreen, &fullscreen) {
// Return if we already in the same fullscreen mode
_ if old_fullscreen == fullscreen => return,
// Return if saved Borderless(monitor) is the same as current monitor when requested fullscreen is Borderless(None)
(Some(Fullscreen::Borderless(Some(monitor))), Some(Fullscreen::Borderless(None)))
if monitor.inner == monitor::current_monitor(window.0) =>
{
return
}
_ => {}
}

window_state_lock.fullscreen = fullscreen.clone();
drop(window_state_lock);

Expand Down

0 comments on commit 68803e6

Please sign in to comment.