Open AdriaandeJongh opened 2 months ago
(get_display_cutouts
) This is an Android specific thing. Does Android support multiple screens for this?
It is not an Android specific thing. All recent Apple devices (iPhones, MacBooks, Apple TVs, etc) return safe areas other than their full screen size. Calling get_display_safe_area()
on a MacBook rightfully returns the safe area – but like I said, it is ambiguous as to what screen that rect applies to if there are additional monitors connected.
Aside from that, I do believe Android can theoretically have external monitors, in which case this applies on Android as well.
Yes but Godot doesn't support cutouts on any other device, so that would first have to be implemented on macOS
~The get_display_safe_area
works by "default", as it just removes all the zero cutouts from get_display_cutouts
, as per the documentation:~
And get_display_cutouts
is Android specific:
Currently only implemented on Android. Other platforms will return an empty array even if they do have display cutouts or notches.
So what you are really asking for is support for this feature on other platforms
The android code assumes a single display, unsure if this code can be adjusted:
public int[] getDisplayCutouts() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
return new int[0];
DisplayCutout cutout = activity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
if (cutout == null)
return new int[0];
List<Rect> rects = cutout.getBoundingRects();
int cutouts = rects.size();
int[] result = new int[cutouts * 4];
int index = 0;
for (Rect rect : rects) {
result[index++] = rect.left;
result[index++] = rect.top;
result[index++] = rect.width();
result[index++] = rect.height();
}
return result;
}
Hmm. get_display_safe_area()
works on iOS as well, so it seems it is already implemented on multiple platforms.
Yes, it is, but it just gets the area and removes the cutouts, aka none, or it works but get_display_cutouts
is not
Indeed the safe area is implemented specifically, my bad, but only it
You're right. I guess the point I'm trying to make here is: it makes sense for both of these functions to have screen_id parameters, because both cutouts and safe areas are dependent on that.
Would be good to get some information on what platforms would support such an argument, if the various APIs support that and how
I've opened a more generic proposal for it to be added to Window, possibly with a new built-in node to go with it, so you don't have to worry about screen id or window positioning, and it should also push away from rounded corners: #11106
Describe the project you are working on
Rift Riff and soon a sequel to Hidden Folks.
Describe the problem or limitation you are having in your project
As of the last few years, MacBook screens (and maybe other laptops?) have cutouts at the top of the screen.
get_display_cutouts()
andget_display_safe_area()
works as expected if the user only has one screen connected, but it's ambiguous when the user has an external screen connected.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add an optional
screen_id
param toget_display_cutouts()
andget_display_safe_area()
so that you can get the display cutouts and safe area of a specific screen as supposed to the (?) screen.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I don't know anything about the inner workings of the engine so I am of no help here. I am not aware of any external screens with safe areas or cutouts, so perhaps the implementation is simple: only return the safe area and cutouts for screens that are not external – whatever that means...?
If this enhancement will not be used often, can it be worked around with a few lines of script?
n/a
Is there a reason why this should be core and not an add-on in the asset library?
n/a