fix session restoration for maximized and fullscreen windows (#9536)

## Description

We currently have a bug with session restoration where maximized windows
won't restore into the maximized state. This is due to the "vertical
adjustment" code which tries to make sure the title bar is on screen (it
moves the window downward if that isn't the case). Without getting too
much into the details, on Windows when windows are maximized, winit
reports the physical size of the window _as if_ it had the native window
decorations, even when it doesn't. It treats the native title bar as
being off the screen and represents that with a negative origin (above
the screen). This triggers `fn maybe_adjust_window_vertically` to return
a value which triggers the caller to try to move the window which makes
Windows un-maximize the window. This simple guard fixes the problem

## Testing

1. Run Warp on Windows
2. Make sure session restoration is enabled
3. Maximize the window
4. quit warp
5. Start warp again
6. The window should be maximized but it isn't

On this branch, that bug no longer occurs.
This commit is contained in:
Andy
2026-04-30 11:08:50 -07:00
committed by GitHub
parent 182c1ac641
commit a7279b36ab

View File

@@ -1433,6 +1433,9 @@ fn create_window(
///
/// Returns the vertical difference of the adjustment, or None.
fn maybe_adjust_window_vertically(window: &winit::window::Window) -> Option<i32> {
if window.is_maximized() || window.fullscreen().is_some() {
return None;
}
let window_position = window.outer_position().ok()?;
let window_size = window.outer_size();
let bottom_of_window = window_position.y + window_size.height as i32;