rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.88k stars 913 forks source link

AppKit/UIKit: Do not emit default state events upon window creation #3912

Open madsmtm opened 2 months ago

madsmtm commented 2 months ago

In Winit, we generally do not emit events for the initial value of things on the window. Existing examples include ThemeChanged, ModifiersChanged, Moved, CursorMoved and so on. So let's not do that for ScaleFactorChanged, SurfaceResized and Focused either!

See also https://github.com/rust-windowing/winit/pull/2696 and https://github.com/rust-windowing/winit/pull/2585 for some of the history on Focused. I don't know what I was thinking in https://github.com/rust-windowing/winit/pull/2585#issuecomment-1396208659, but it's clearly wrong, we don't need to emit Focused(false) since it's the default for all platforms.

Part of https://github.com/rust-windowing/winit/issues/2640.

kchibisov commented 2 months ago

As long as the values are the same as the user queried them at the point of create_window it should be fine to not emit those, since the events imply that something default got changed, when it clearly not changed.

madsmtm commented 2 months ago

I have updated since you looked to also remove the redundant Focused(false) event on macOS that I added myself in https://github.com/rust-windowing/winit/pull/2585#issuecomment-1396208659.

kchibisov commented 2 months ago

The focus stuff was required before since it wasn't stated whether the window is focused by default or not, so some assumed yeS, others not, so it was a bit messy.

I know that right now we explicitly declare that the window is not focused by default.

madsmtm commented 2 months ago

Ah, nice, thanks!