-
Notifications
You must be signed in to change notification settings - Fork 921
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
Add MonitorHandle::current_video_mode()
#3802
Conversation
The The only information which is not video mode related is basically monitor name/position, etc, depth is not it. |
That's a good point. That would solve the issue for Web as well. |
@kchibisov I started working on it right now and realized that this argument invalidates |
I think it was always like that, which doesn't make much sense. Probably it was like that for convenience or something. Just route everything into |
d34b3dc
to
521e071
Compare
MonitorHandle::bit_depth()
MonitorHandle::current_video_mode()
Done. I also changed |
9b26bdd
to
0f42269
Compare
0f42269
to
949e9d4
Compare
949e9d4
to
ac685d3
Compare
ac685d3
to
49d38ff
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.
Approving the Android side given that all the weirdness in there (due to a lack of API in the NDK - we could call into Java for this though) was already there and is only moving in this patch but not fundamentally changing.
Re-requested reviews because I changed |
6d4bbd2
to
a045f81
Compare
a045f81
to
dd70949
Compare
src/platform_impl/android/mod.rs
Outdated
ffi::context(&mut env) | ||
.display_manager(&mut env) | ||
.display(&mut env, self.id) | ||
.unwrap() |
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 could panic, but is a known issue on all backends.
See #3258.
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.
Well, if you function returns Option
you can easily avoid panic.
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 will make a follow-up PR where I finally tackle #3258.
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.
The thing is that monitor data, such as name, etc, is static more or less. The position could change, indeed, but generally unless we make all of that into events and lifetime I'm not sure we can do much.
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 point.
I'm happy to cache the name, but again, lets discuss it in a follow-up PR.
src/platform_impl/android/ffi.rs
Outdated
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.
@MarijnS95 let me know if you think anything in here might actually panic.
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 probably separate android impl into separate commit and rebase 2 commits in the end, but up to you.
dd70949
to
694fa95
Compare
I did change it up a bit to make it easier to review. |
Without going through the details, it looks like the Android implementation is quite overdone, now with JNI. Even if we discussed this before, I'd like to revise my statement. When I proposed looking at Android functions and eventually calling them through JNI, it was meant as a hint that there appear to be matching APIs, and could eventually be used if there is a pressing need for it. After all, having multiple displays on Android is extremely unlikely, and even for the current display, what is the user going to use this information for? Anything involving dimensions, pixel formats, refresh rate or color spaces will always end up going through the EDIT: The only thing I cannot find available in the NDK is a list of available frame rates to help the user guide if it makes sense to request a switch: Summary: even if we could (as you have already shown): are you sure we want to start having and managing this blob of JNI "noise" in the Android backend? For likely zero actual use-case? |
AFAIC I was only doing this to prevent having an On the other hand I've already implemented it and we will need some JNI sooner or later anyway (I assume?). I don't know if a multi-monitor setup on Android would even work with the current API (not talking about the implementation) or if it actually needs a dedicated platform-specific API (which I would assume). Let me know how you would like to proceed. |
694fa95
to
f938fc5
Compare
Besides the effort you've put in, my preference goes out to not returning this information to the user at all. In case someone requests it we can always aim to re-land your commit from this PR (let's track it somewhere just in case) or keep it around as a reference for users desiring to implement this themselves? I am not thinking of much that needs JNI now, except maybe the PRs that are ramping up towards IME support (whether that belongs in our out Either way, I've always desired to create an " |
I'd note that if |
I'm unsure why we would remove it in the first place if we would be willing to put it back in? EDIT: Considering we may want that as a reference at a future date daxpedda@f938fc5.
Yes, lets discuss it on Matrix further!
I'm gonna do the removal in a couple of hours or so. |
b41ae81
to
c48740a
Compare
@MarijnS95 PR is ready for your approval. |
Yeah, this mostly. I don't want to commit to maintaining JNI inside |
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.
Android looks good!
c48740a
to
ae7550c
Compare
`VideoModeHandle::refresh_rate_millihertz()` and `bit_depth()` now return a `Option<NonZero*>`. `MonitorHandle::position()` now returns an `Option`. On Orbital `MonitorHandle::name()` now returns `None` instead of a dummy name.
Because we don't want to force all methods on `VideoModeHandle` to return `Option`, we decided to remove the already incomplete support in Android for both types.
ae7550c
to
3bab4ef
Compare
After some discussion we decided its more useful to encode current monitor information into
VideoModeHandle
then move more information toMonitorHandle
. To this end this PR implementsMonitorHandle::current_video_mode()
.Additionally
MonitorHandle::size()
andrefresh_rate_millihertz()
were removed, because it logically fits into video modes and not the monitor itself.To improve the output, this PR also changes
VideoModeHandle::refresh_rate_millihertz()
to return aOption<NonZeroU32>
andsize()
andbit_depth()
anOption
.Follow up to #3801.