MCPcopy Create free account
hub / github.com/defold/defold / GetSafeAreaAndroid

Function GetSafeAreaAndroid

engine/platform/src/platform_window_glfw_android.cpp:79–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 }
78
79 bool GetSafeAreaAndroid(HWindow window, WindowSafeArea* out)
80 {
81 const int32_t window_width = (int32_t) GetWindowWidth(window);
82 const int32_t window_height = (int32_t) GetWindowHeight(window);
83 if (window_width <= 0 || window_height <= 0)
84 {
85 return false;
86 }
87
88 int32_t inset_left = 0;
89 int32_t inset_top = 0;
90 int32_t inset_right = 0;
91 int32_t inset_bottom = 0;
92
93 if (_glfwAndroidGetSafeAreaInsets(&inset_left, &inset_top, &inset_right, &inset_bottom))
94 {
95 out->m_X = inset_left;
96 out->m_Y = inset_bottom;
97 out->m_Width = (uint32_t) dmMath::Max(0, window_width - inset_left - inset_right);
98 out->m_Height = (uint32_t) dmMath::Max(0, window_height - inset_top - inset_bottom);
99 out->m_InsetLeft = inset_left;
100 out->m_InsetTop = inset_top;
101 out->m_InsetRight = inset_right;
102 out->m_InsetBottom = inset_bottom;
103 return true;
104 }
105
106 android_app* app = dmAndroid::GetAndroidApp();
107 // ARect content depends on window settings we swt in DefoldActivity.java
108 const ARect rect = app->contentRect;
109 const int32_t rect_width = rect.right - rect.left;
110 const int32_t rect_height = rect.bottom - rect.top;
111 if (rect_width <= 0 || rect_height <= 0)
112 {
113 return false;
114 }
115
116 inset_left = rect.left;
117 inset_right = window_width - rect.right;
118 inset_top = rect.top;
119 inset_bottom = window_height - rect.bottom;
120
121 out->m_X = rect.left;
122 out->m_Y = window_height - rect.bottom;
123 out->m_Width = (uint32_t) rect_width;
124 out->m_Height = (uint32_t) rect_height;
125 out->m_InsetLeft = inset_left;
126 out->m_InsetTop = inset_top;
127 out->m_InsetRight = inset_right;
128 out->m_InsetBottom = inset_bottom;
129
130 return true;
131 }
132}

Callers

nothing calls this directly

Calls 5

GetWindowWidthFunction · 0.70
GetWindowHeightFunction · 0.70
GetAndroidAppFunction · 0.70
MaxFunction · 0.50

Tested by

no test coverage detected