From aabe42d252f66c6410b2f805a9ea80f12517e16d Mon Sep 17 00:00:00 2001 From: Yanchi Toth Date: Sun, 19 Apr 2020 21:52:48 +0200 Subject: [PATCH] Preserve with_maximized on windows (#1515) --- CHANGELOG.md | 2 ++ src/platform_impl/windows/window.rs | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecb4aa4f..e428fbbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +- On Windows, fix `WindowBuilder::with_maximized` being ignored. + # 0.22.1 (2020-04-16) - On X11, fix `ResumeTimeReached` being fired too early. diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 3c58e1fd..45a3b5de 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -728,8 +728,6 @@ unsafe fn init( } } - window_flags.set(WindowFlags::MAXIMIZED, attributes.maximized); - // If the system theme is dark, we need to set the window theme now // before we update the window flags (and possibly show the // window for the first time). @@ -757,6 +755,11 @@ unsafe fn init( .inner_size .unwrap_or_else(|| PhysicalSize::new(1024, 768).into()); win.set_inner_size(dimensions); + if attributes.maximized { + // Need to set MAXIMIZED after setting `inner_size` as + // `Window::set_inner_size` changes MAXIMIZED to false. + win.set_maximized(true); + } win.set_visible(attributes.visible); if let Some(_) = attributes.fullscreen {