diff --git a/CHANGELOG.md b/CHANGELOG.md index ee66a3a..f0c8806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Breaking Changes + +- `Window::set_inner_size` has been replaced with `Window::request_inner_size`, + and it matches the semantics of winit's underlying `request_inner_size`. The + function returns an option containing the new size if the size was able to be + applied before the function returns. + + This new function properly updates the `inner_size` and `outer_size` when the + underlying window is resized immediately. Notably, this happens on Wayland but + may happen on some other platforms as well. + ## v0.4.0 (2024-09-14) ### Breaking Changes diff --git a/src/window.rs b/src/window.rs index c5976ac..9cf8a93 100644 --- a/src/window.rs +++ b/src/window.rs @@ -397,10 +397,14 @@ where } /// Sets the inner size of the window, in pixels. - pub fn set_inner_size(&self, new_size: PhysicalSize) { - // TODO not sure if this is reasonable - self.window.set_min_inner_size(Some(new_size)); - self.window.set_max_inner_size(Some(new_size)); + #[must_use] + pub fn request_inner_size(&mut self, new_size: PhysicalSize) -> Option> { + let result = self.window.request_inner_size(new_size); + if let Some(applied_size) = result { + self.inner_size = applied_size; + self.outer_size = self.window.outer_size(); + } + result } /// Returns the current outer size of the window, in pixels.