-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 winit's MonitorHandle
#13669
Expose winit's MonitorHandle
#13669
Conversation
ffad6f7
to
29458b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! Left some comments with suggestions, but no big things.
I haven't tested this, and I'm not sure how to easily do that. Would it make sense to add an example that prints metadata about connected monitors to show how to use this?
I like this feature, and I'm on board with the general design. |
Made a small example, feel free to pull in this commit if you think it's useful: killercup@62baba9 |
Mostly we just need to check that things compile and run on most platforms, but I'm also going to do some experiments with un/replugging monitors just to make sure that we correctly spawn and despawn these as that happens.
Thanks! Will absolutely take this. |
33759f8
to
fa93d46
Compare
would it be possible in the example to open a window in each monitor detected, displaying that monitor information? |
That's a great idea, I noticed we don't have any examples of that anywhere. Will add. |
The text updates when displays are connected/disconnected.
fa93d46
to
cc65cb3
Compare
Okay, so in working through this new example, I realized that we really needed to also make the window's mode configurable by a monitor selection, as this is actually the correct way to open a window on a particular monitor in winit. Setting the window's position worked sometimes in my experiments, but depended a lot on whether the app was starting on the primary or secondary monitor. I did confirm that plugging and unplugging monitors works. |
For the record, I think we should document the limitations and merge this. It's immature, but fully opt-in, and virtually nothing more can be done on our end to improve this. These bugs need to be fixed in winit, and sending users / contributors their way is IMO the best way to actually improve things. |
Unfortuantely had to revert the changes to use
Tried doing this, but the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Let's merge this while noting the limitations and get fixes from winit over time as well as have people test this in main :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a suggestion to add a note on the issues found here as docs to WinitMonitors
. We might not want to to link to this PR but a tracking issue.
use bevy_ecs::system::Resource; | ||
|
||
/// Stores [`winit`] monitors and their corresponding entities | ||
#[derive(Resource, Debug, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any value in this being Reflect
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resources being reflect is mildly useful, but IME not nearly as important as for things that want to be inspected or serialized.
Co-authored-by: Pascal Hertleif <[email protected]>
@tychedelia build failure on Android looks related; check the CI logs and ping me when it's fixed up? |
@alice-i-cecile should be fixed now? |
b7da07c
to
063be9a
Compare
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1668 if you'd like to help out. |
Objective
Adds a new
Monitor
component representing a winitMonitorHandle
that can be used to spawn new windows and check for system monitor information.Closes #12955.
Solution
For every winit event, check available monitors and spawn them into the world as components.
Testing
TODO:
Changelog
Monitor
component that can be queried for information about available system monitors.Migration Guide
WindowMode
variants now take aMonitorSelection
, which can be set toMonitorSelection::Primary
to mirror the old behavior.