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

OS.get_window_safe_area() returns incorrect size on Android when not in fullscreen #61467

Closed
madmiraal opened this issue May 27, 2022 · 10 comments · Fixed by #86761
Closed

OS.get_window_safe_area() returns incorrect size on Android when not in fullscreen #61467

madmiraal opened this issue May 27, 2022 · 10 comments · Fixed by #86761

Comments

@madmiraal
Copy link
Contributor

madmiraal commented May 27, 2022

Godot version

3.4.4, 3.5 RC2 and master

System information

Android 8

Issue description

OS.get_window_safe_area() uses the display size not the window size; so when Godot is not in full-screen mode e.g. when immersive mode is disabled, and the window size is not the display size, the calculations for get_window_safe_area() are wrong.

Steps to reproduce

Disable immersive mode. Call OS.get_window_safe_area().

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented May 27, 2022

In case anyone is wondering, Android API level < 28 refers to Android 8 and below.

@Calinou Calinou added this to the 4.0 milestone May 27, 2022
@madmiraal
Copy link
Contributor Author

Actually the problem applies to all versions of Android not just to earlier versions of Android. OS.get_windows_safe_area() is using the display size not the window size to calculate the safe area; so when immersive mode is disabled, and the window size is smaller than the display size, the OS.get_windows_safe_area() calculations are wrong.

@madmiraal
Copy link
Contributor Author

It's worth pointing out that, on master, we've renamed OS.get_windows_safe_area() to DisplayServer.get_display_safe_area(). So, it's technically returning the correct Rect2 i.e. it's the display safe area not the window safe area. The question is: how useful is this? As already identified in #49887 and #55463, even in full-screen mode, the Rect2 returned by OS.get_windows_safe_area() is in the display coordinates not Viewport coordinates, which is typically what is required. That been said, it appears that when not in full-screen mode, OS.get_windows_safe_area() is the window area.

@sosasees
Copy link

sosasees commented Jan 1, 2024

¿are there any updates?.
this issue seems to be completely forgotten for 11 months,
and i can still reproduce it in Godot 4.2.1

@Alex2782
Copy link
Contributor

Alex2782 commented Jan 2, 2024

get_display_safe_area ( ) const
Returns the unobscured area of the display where interactive controls should be rendered.

Does this description mean that the virtual keyboard should also be taken into account?

Bildschirmfoto 2024-01-02 um 02 57 23

@sosasees
Copy link

sosasees commented Jan 2, 2024

get_display_safe_area ( ) const
Returns the unobscured area of the display where interactive controls should be rendered.

Does this description mean that the virtual keyboard should also be taken into account?

yes, this means the safe area is smaller when the keyboard blocks part of the screen.

@Alex2782

This comment was marked as outdated.

@Alex2782

This comment was marked as outdated.

@Alex2782
Copy link
Contributor

Alex2782 commented Jan 2, 2024

uses the display size not the window size

I am trying to find solutions for this, with no guarantee of success 😃

@Alex2782
Copy link
Contributor

Alex2782 commented Jan 3, 2024

What else should be tested?

Screen_recording_20240103_205441.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants