Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: inner_size() reports 0x0 size when window is minimized #2015

Open
simast opened this issue Aug 29, 2021 · 6 comments · May be fixed by #2176
Open

Windows: inner_size() reports 0x0 size when window is minimized #2015

simast opened this issue Aug 29, 2021 · 6 comments · May be fixed by #2176
Labels
D - easy Likely easier than most tasks here DS - windows H - good first issue Ideal for new contributors H - help wanted Someone please save us S - platform parity Unintended platform differences

Comments

@simast
Copy link
Contributor

simast commented Aug 29, 2021

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?

@maroider maroider added D - easy Likely easier than most tasks here H - good first issue Ideal for new contributors DS - windows H - help wanted Someone please save us C - needs discussion Direction must be ironed out S - platform parity Unintended platform differences and removed C - needs discussion Direction must be ironed out labels Aug 29, 2021
@maroider
Copy link
Member

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.

@chelmich
Copy link
Contributor

chelmich commented Oct 7, 2021

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.

@supervacuus
Copy link

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 (#1578) in the respective other cases.

@kchibisov
Copy link
Member

kchibisov commented Apr 22, 2022

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

@supervacuus
Copy link

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.

@kchibisov
Copy link
Member

Maximized on Wayland should resize the window, and Maximized should issue Resized, however minimize should likely not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D - easy Likely easier than most tasks here DS - windows H - good first issue Ideal for new contributors H - help wanted Someone please save us S - platform parity Unintended platform differences
Development

Successfully merging a pull request may close this issue.

5 participants