diff --git a/.changes/windows-set-fullscreen-early-return.md b/.changes/windows-set-fullscreen-early-return.md new file mode 100644 index 000000000..49f6c0956 --- /dev/null +++ b/.changes/windows-set-fullscreen-early-return.md @@ -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)`. diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 92a92ed06..cad629d0b 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -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);