summaryrefslogtreecommitdiff
path: root/src/ui/root.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/root.c')
-rw-r--r--src/ui/root.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/ui/root.c b/src/ui/root.c
index 114ab040..4849d0c7 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -1532,6 +1532,35 @@ iRect safeRect_Root(const iRoot *d) {
1532 return rect; 1532 return rect;
1533} 1533}
1534 1534
1535iInt2 visibleSize_Root(const iRoot *d) { 1535iRect visibleRect_Root(const iRoot *d) {
1536 return addY_I2(size_Root(d), -get_MainWindow()->keyboardHeight); 1536 iRect visRect = rect_Root(d);
1537#if defined (iPlatformAppleMobile)
1538 /* TODO: Check this on device... Maybe DisplayUsableBounds would be good here, too? */
1539 float left, top, right, bottom;
1540 safeAreaInsets_iOS(&left, &top, &right, &bottom);
1541 visRect.pos.x = (int) left;
1542 visRect.size.x -= (int) (left + right);
1543 visRect.pos.y = (int) top;
1544 visRect.size.y -= (int) (top + bottom);
1545#endif
1546#if defined (iPlatformDesktop)
1547 /* Apply the usable bounds of the display. */
1548 SDL_Rect usable; {
1549 const float ratio = d->window->pixelRatio;
1550 SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(d->window->win), &usable);
1551 iInt2 winPos;
1552 SDL_GetWindowPosition(d->window->win, &winPos.x, &winPos.y);
1553 mulfv_I2(&winPos, ratio);
1554 usable.x *= ratio;
1555 usable.y *= ratio;
1556 usable.w *= ratio;
1557 usable.h *= ratio;
1558 /* Make it relative to the window. */
1559 usable.x -= winPos.x;
1560 usable.y -= winPos.y;
1561 visRect = intersect_Rect(visRect, init_Rect(usable.x, usable.y, usable.w, usable.h));
1562 }
1563#endif
1564 adjustEdges_Rect(&visRect, 0, 0, -get_MainWindow()->keyboardHeight, 0);
1565 return visRect;
1537} 1566}