Winit: Minimise behaviour

Created on 27 Jan 2019  路  4Comments  路  Source: rust-windowing/winit

I noticed recently that minimising in Windows causes a WindowEvent::Resized(size=0) event, this doesn't seem to happen in X11.

On windows this becomes a way to tell that the window has been minimised. Is there a way I can tell this on X11, or in general?

Most helpful comment

I'm not comfortable with this being a documented feature, seeing as it's a hacky way to get the data and we don't know if it even works on non-Windows platforms. Honestly, I'd prefer to suppress the resize event on Windows to prevent people from relying on it, then see about introducing minimized events once the platform support story becomes more clear. The behavior on X11 and MacOS needs to be investigated before any action on this would get taken, though.

All 4 comments

I can't speak for other platforms, but on wayland it is not possible for a window to know whether is it currently displayed or not.

Depending on the compositor it might be inferred if it appears that the set of current ouputs of the window is empty (so the window is not displayed on any output), but I expect this to be unreliable at best.

Good to know about wayland.

As the windows behaviour surprised me, maybe we should note in the WindowEvent::Resized docs that some, but not all, platforms will generate zero resized events when the window is minimised.

I couldn't find any info on minimising behaviour in the docs, hence this issue.

I'm not comfortable with this being a documented feature, seeing as it's a hacky way to get the data and we don't know if it even works on non-Windows platforms. Honestly, I'd prefer to suppress the resize event on Windows to prevent people from relying on it, then see about introducing minimized events once the platform support story becomes more clear. The behavior on X11 and MacOS needs to be investigated before any action on this would get taken, though.

This is actually something Alacritty has run into (see https://github.com/jwilm/alacritty/pull/3081) and I can confirm that this is only the case on Windows.

Was this page helpful?
0 / 5 - 0 ratings