Windows: inner_size() reports 0x0 size when window is minimized
Noticed this weird behavior.
If you minimize the window on Windows and then request window size using inner_size(), the returned value is 0x0. I think the window size should not be zero since you can hover over minimized window taskbar icon and still see the preview of the window (it can continue to render).
Basically if you now want to always render (even when minimized) you have to track and maintain your own window size metrics and not rely on inner_size(). Seems like a bug maybe, but not sure how other platforms behave when minimized?
The behaviour you're expecting seems to match what I'd expect myself. The only (desktop) platform I'd expect to be different in some way is Wayland.
I checked and it looks like the problem comes from the Windows API call itself. It's not mentioned in the documentation but GetClientRect reports a 0x0 rectangle when called on a minimized window. This is passed straight through the winapi crate and then into inner_size().
If we want to implement the expected behavior it would require storing the window size somewhere. I'm not sure what the best way to handle that would be.
Since this was tagged with "platform parity": at least on the systems I tested my code on, in MacOS and Wayland, there is no WindowEvent::Resized triggered on minimizing windows. So, whatever inner_size() returns on these platforms has no consequence for windows minimization.
On the other hand, Windows triggers WM_SIZE when the window is minimized or maximized (https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-size#parameters).
So from a platform parity perspective, I wonder if it would make sense to issue WindowEvent::Resized only if wParam == SIZE_RESTORED and issue separate minimized/maximized events (https://github.com/rust-windowing/winit/issues/1578) in the respective other cases.
On Wayland window doesn't even know that it got minimized iirc or it's minimized, so that's kind of expected that the size doesn't change. It's a pure compositor thing and nothing can be done to know that. But returning the 0x0 size doesn't make any sense, if anything it should be the size before minimization or something?
We can't issue minimized event on Wayland, since there's no information about that, like at all.
For more take a look at https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_minimized
I understand and agree. My question is whether minimizing and maximizing events on windows should at all be handled via WindowEvent::Resized because it doesn't happen on any other platform.
Maximized on Wayland should resize the window, and Maximized should issue Resized, however minimize should likely not.
Related to https://github.com/rust-windowing/winit/issues/783.
@kchibisov this was fixed in #4394 too.