-
Notifications
You must be signed in to change notification settings - Fork 932
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
api: make VideoModeHandle into VideoMode #4060
Conversation
The video mode is generally a static data and not a reference to some video mode. This changes the exclusive fullscreen API to match that an accept a monitor now.
b2c9c0b
to
6c0c47d
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.
This looks great, I'm happy to see that you managed to remove this amount of duplicate code/wrappers from the backends 👍
pub fn video_modes(&self) -> std::iter::Empty<VideoMode> { | ||
unreachable!() |
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.
On orbital
you implemented this to return std::iter::empty()
, I'm not sure what to do here. There, the type is impl Iterator
and not std::iter::Empty
too.
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.
You can not have unreachable!()
with impl Iterator
.
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.
Hence the question is: should Android return std::iter::empty()
with std::iter::Empty<>
type?
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.
it doesn't really matter, the function can not be reached anyway. If you feel like something else should be returned send a separate patch, since I just did it the same as other functions were.
let video_mode = | ||
match monitor.video_mode_handles().find(|mode| &mode.mode == video_mode) { | ||
Some(monitor) => monitor, | ||
None => return, |
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.
Perhaps this is planned for a future change, but are we missing any feedback to the user here that the passed VideoMode
isn't valid and wasn't applied?
I expect that video_mode_handles()
might change during app runtime.
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.
Video modes usually don't change, unless monitor is reconfigured. In general though, there's no guarantee that the API will work, though, on windows it likely should generally work.
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.
I'd add an error for that, but once we have monitor handle changed.
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.
Thanks, this is much easier to review!
Just for completeness, I'll note that the approach here forces us to do the fallible operation monitor.video_modes_handles().find(|mode| &mode.mode == video_mode)
when requesting exclusive fullscreen, but I think that's fine.
We might want to consider making the size
, bit_depth
and refresh_rate_millihertz
fields public in the future, but such a decision should consider the increased probability that users will encounter an error here, so let's defer that.
You can still encounter error if you pass a video mode from a different monitor. |
Co-authored-by: Mads Marquart <[email protected]>
The video mode is generally a static data and not a reference to some video mode. This changes the exclusive fullscreen API to match that and accept a monitor now.
Extracted from #3927