-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Expose is_minimized
and is_visible
from Winit
#9433
Comments
I exposed the |
Window State & VisiblityNew to Bevy so I am not sure if these struct/enums already exist but I would imagine the window state and visibility status could be represented with something like: enum WindowState {
Normal,
Maximized,
Minimized,
Fullscreen, // macOS
}
enum WindowVisibility {
Visible,
Hidden,
} I am a fan of using enums over booleans, even in the case of For the case of Or would the "fullscreen" behavior be more a separate enum for the traditional video game behavior like so: enum RenderMode {
Windowed,
BorderlessFullscreen,
Fullscreen,
} Which in this case would just assume "fullscreen" button on macOS windows to be "maximized" in the above Window EventsI second the idea of exposing various window events for when these things change. Assuming the above, something like You could have convenience events which are also emitted for Request User AttentionWould also be good to expose the In Windows this flashes the icon in the taskbar, in macOS the dock icon bounces until the user clicks it. I assume Linux desktop environments have a similar flash or attention getting mechanism. This could be done with an event writer perhaps |
I'll try to open a PR that exposes the minimized and maximized statuses of the windows as boolean (just to mimic what the winit API returns). I'll keep it simple and just forward the values exposed by winit. I'll take a look at the events and the user attention feature later. |
You can take a look at #9815. I made it as concise as possible. I still have to test it properly, but I'd like some early feedback on the code as I'm not very convinced on the implementation. |
I'm considering blocking or closing my PR until A potential solution that I can think of would be to have an independent system check the winit status periodically and update fields in the I've also checked the Any input on this will be welcome, but I think the implementation will be incomplete under these circumstances. |
What problem does this solve or what need does it fill?
I think right now the only way to access those Winit APIs from Bevy is to get
NonSendMut<WinitWindows>
.This is the only way to know if a window is minimized/maximized, since there is not even an event for them so it's not possible to just keep track of that, as far as I know.
What solution would you like?
One or several of those:
is_minimized
,is_maximized
, andis_visible
methods onWindow
, to reflect Winit's method. (note: those are not available for all platforms)minimized
andvisible
field onWindow
, similar tofocused
, for minimized it could also be mutated to request minimizing/maximizing, replacing theset_maximized
/set_minimized
methods. (note on this: mutating this field if the request fails might lead to confusing behavior, same for visible that is not supposed to be mutated at all, right now we have similar problems withfocused
actually since aWindow
can't be put out of focus, but the field can be set to true with no consequence)Window
is maximized/minimized/visible, if Winit have those (not sure), similar toWindowFocused
What alternative(s) have you considered?
Use
NonSendMut<WinitWindows>
, and potentially document it forset_maximized
/set_minimized
methods.The text was updated successfully, but these errors were encountered: