From b03e589987d7c95b526ad5d85ae8f1f3d0f5d050 Mon Sep 17 00:00:00 2001 From: Osspial Date: Mon, 26 Aug 2019 22:07:15 -0400 Subject: [PATCH] On Windows, Unset maximized when transforming window (#1014) * Unset maximized when functionally transforming window * Add docs * Fix compile issues --- CHANGELOG.md | 1 + src/platform_impl/windows/window.rs | 18 ++++++++++++++++++ src/window.rs | 6 ++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a37fe9aa..3cfd9f5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ and `WindowEvent::HoveredFile`. - On Windows, fix the trail effect happening on transparent decorated windows. Borderless (or un-decorated) windows were not affected. - On Windows, fix `with_maximized` not properly setting window size to entire window. - On macOS, change `WindowExtMacOS::request_user_attention()` to take an `enum` instead of a `bool`. +- On Windows, unset `maximized` when manually changing the window's position or size. # 0.20.0 Alpha 1 (2019-06-21) diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 8704ccfb..5b55c7c8 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -212,6 +212,15 @@ impl Window { pub fn set_outer_position(&self, logical_position: LogicalPosition) { let dpi_factor = self.hidpi_factor(); let (x, y) = logical_position.to_physical(dpi_factor).into(); + + let window_state = Arc::clone(&self.window_state); + let window = self.window.clone(); + self.thread_executor.execute_in_thread(move || { + WindowState::set_window_flags(window_state.lock(), window.0, |f| { + f.set(WindowFlags::MAXIMIZED, false) + }); + }); + self.set_position_physical(x, y); } @@ -287,6 +296,15 @@ impl Window { pub fn set_inner_size(&self, logical_size: LogicalSize) { let dpi_factor = self.hidpi_factor(); let (width, height) = logical_size.to_physical(dpi_factor).into(); + + let window_state = Arc::clone(&self.window_state); + let window = self.window.clone(); + self.thread_executor.execute_in_thread(move || { + WindowState::set_window_flags(window_state.lock(), window.0, |f| { + f.set(WindowFlags::MAXIMIZED, false) + }); + }); + self.set_inner_size_physical(width, height); } diff --git a/src/window.rs b/src/window.rs index 7866b70d..db86773d 100644 --- a/src/window.rs +++ b/src/window.rs @@ -413,7 +413,8 @@ impl Window { /// Modifies the position of the window. /// - /// See `outer_position` for more information about the coordinates. + /// See `outer_position` for more information about the coordinates. This automatically un-maximizes the + /// window if it's maximized. /// /// ## Platform-specific /// @@ -443,7 +444,8 @@ impl Window { /// Modifies the inner size of the window. /// - /// See `inner_size` for more information about the values. + /// See `inner_size` for more information about the values. This automatically un-maximizes the + /// window if it's maximized. /// /// ## Platform-specific ///