-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Return the applied size for synchronious set_inner_size #2868
Description
The Window::set_inner_size(Size) is an async request with the semantic of asking the OS to resize, such request results in a response with the Resized event from the OS, however it's not the case on at least Wayland, because the buffer is managed by the client, and the intent of doing set_inner_size could mean that you want to draw the window with the sizes you want. However on async platforms you can't really do that, because you have to wait for OS to reply back.
What we could do is the following:
#[must_use]
fn set_inner_size(Size) -> Option<PhysicalSize>Where Some will be returned when the value was applied immediately so the users can use it and None when the request went to OS for waiting.
The key point here, is that some clients might want to draw with the sizes they want to set on the current frame, so what they could do with such API is the following
let new_size = window.set_inner_size(PhysicalSize(200, 200)).unwrap_or_else(|| window.inner_size());So when they want to draw with the sizes they set, they'll not unconditionally assume that what they've used was applied right away.
In addition, the set_inner_size should state explicitly that semantic of Size under the hood is not being taken into the account and the value which fits better for the backend is used.