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

api: make VideoModeHandle into VideoMode #4060

Merged
merged 5 commits into from
Jan 2, 2025
Merged

Conversation

kchibisov
Copy link
Member

@kchibisov kchibisov commented Dec 25, 2024

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

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.
@kchibisov kchibisov force-pushed the kchibisov/video-mode branch from b2c9c0b to 6c0c47d Compare December 25, 2024 05:06
src/changelog/unreleased.md Outdated Show resolved Hide resolved
src/monitor.rs Outdated Show resolved Hide resolved
src/monitor.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/x11/monitor.rs Outdated Show resolved Hide resolved
src/monitor.rs Outdated Show resolved Hide resolved
@kchibisov kchibisov requested a review from MarijnS95 December 28, 2024 08:36
Copy link
Member

@MarijnS95 MarijnS95 left a 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 👍

src/monitor.rs Outdated Show resolved Hide resolved
Comment on lines +1027 to 1028
pub fn video_modes(&self) -> std::iter::Empty<VideoMode> {
unreachable!()
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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,
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

src/platform_impl/orbital/mod.rs Show resolved Hide resolved
src/platform_impl/linux/wayland/output.rs Outdated Show resolved Hide resolved
Copy link
Member

@madsmtm madsmtm left a 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.

src/changelog/unreleased.md Outdated Show resolved Hide resolved
@kchibisov
Copy link
Member Author

You can still encounter error if you pass a video mode from a different monitor.

@kchibisov kchibisov merged commit ee245c5 into master Jan 2, 2025
58 checks passed
@kchibisov kchibisov deleted the kchibisov/video-mode branch January 2, 2025 00:29
@madsmtm madsmtm added the S - api Design and usability label Jan 2, 2025
@madsmtm madsmtm added this to the Version 0.31.0 milestone Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - api Design and usability
Development

Successfully merging this pull request may close these issues.

3 participants