Skip to content

Commit

Permalink
On Windows, fix set_fullscreen early return for `Fullscreen::Border…
Browse files Browse the repository at this point in the history
…less(None)`
  • Loading branch information
amrbashir authored and kchibisov committed Dec 21, 2023
1 parent 40cee23 commit 44052a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Unreleased` header.
- On macOS, fix `refresh_rate_millihertz`.
- On Wayland, disable Client Side Decorations when `wl_subcompositor` is not supported.
- On X11, fix `Xft.dpi` detection from Xresources.
- 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)`.

# 0.29.4

Expand Down
14 changes: 12 additions & 2 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,19 @@ impl Window {

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

match (&old_fullscreen, &fullscreen) {
// Return if we already are 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 == monitor::current_monitor(window.0) =>
{
return
}
_ => {}
}

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

Expand Down

0 comments on commit 44052a0

Please sign in to comment.