mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Implement love.window.getSafeArea for Android
--HG-- branch : android-safearea
This commit is contained in:
@@ -845,9 +845,24 @@ void Window::getPosition(int &x, int &y, int &displayindex)
|
||||
|
||||
Rect Window::getSafeArea() const
|
||||
{
|
||||
#ifdef LOVE_IOS
|
||||
#if defined(LOVE_IOS)
|
||||
if (window != nullptr)
|
||||
return love::ios::getSafeArea(window);
|
||||
#elif defined(LOVE_ANDROID)
|
||||
if (window != nullptr)
|
||||
{
|
||||
int top, left, bottom, right;
|
||||
|
||||
if (love::android::getSafeArea(top, left, bottom, right))
|
||||
{
|
||||
// DisplayCutout API returns safe area in pixels
|
||||
// and is affected by display orientation.
|
||||
double safeLeft, safeTop, safeWidth, safeHeight;
|
||||
fromPixels(left, top, safeLeft, safeTop);
|
||||
fromPixels(pixelWidth - left - right, pixelHeight - top - bottom, safeWidth, safeHeight);
|
||||
return {(int) safeLeft, (int) safeTop, (int) safeWidth, (int) safeHeight};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
double dw, dh;
|
||||
|
||||
Reference in New Issue
Block a user