Open madsmtm opened 3 weeks ago
Responding to https://github.com/rust-windowing/winit/pull/3890#issuecomment-2343623057 here:
It doesn't have to be synced though, you should emit it only when the area changes, resize doesn't mean that it changed, because it may not apply at all.
The issue with exposing size
in the event is that if the user stores that size, and they get a SurfaceResized
event, the size from the previous SafeAreaChanged
that they stored would now be wrong.
So we'd have to emit the SafeAreaChanged
again, or state something like "SurfaceResized
invalidates the safe area rectangle, you should re-query it with Window::safe_area
".
If we expose the insets directly, they would never be wrong, even if the surface itself is resized.
If we expose the insets directly, they would never be wrong, even if the surface itself is resized.
Yeah, that's probably not a bad idea after all, since it's just an extra padding one could say and it'll be much easier actually, since you likely already have a padding handling of some sort in your application just to not make elements render right at the border of the window.
https://github.com/rust-windowing/winit/pull/3890 added an API to query the safe area, but left an API for listening to changes to that value unspecified (only noting that
RedrawRequested
would be called if it changed).The API could look something like this:
But that'd mean we have to emit it whenever the surface resizes too, which isn't so nice.
Perhaps something like the following would be better?
See also discussion starting from https://github.com/rust-windowing/winit/pull/3890#issuecomment-2343351828.