Skip to content

Commit

Permalink
Return insets in logical pixels (#6225)
Browse files Browse the repository at this point in the history
  • Loading branch information
obigu committed Oct 14, 2020
1 parent ba925c9 commit 939088c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Expand Up @@ -551,18 +551,11 @@ protected void updateSafeInsets() {
safeInsetBottom = 0;

if (Foundation.getMajorSystemVersion() >= 11) {
UIView view = UIApplication.getSharedApplication().getKeyWindow().getRootViewController().getView();
UIEdgeInsets edgeInsets = view.getSafeAreaInsets();

double top = edgeInsets.getTop() * view.getContentScaleFactor();
double bottom = edgeInsets.getBottom() * view.getContentScaleFactor();
double left = edgeInsets.getLeft() * view.getContentScaleFactor();
double right = edgeInsets.getRight() * view.getContentScaleFactor();

safeInsetTop = (int) top;
safeInsetLeft = (int) left;
safeInsetRight = (int) right;
safeInsetBottom = (int) bottom;
UIEdgeInsets edgeInsets = viewController.getView().getSafeAreaInsets();
safeInsetTop = (int) edgeInsets.getTop();
safeInsetLeft = (int) edgeInsets.getLeft();
safeInsetRight = (int) edgeInsets.getRight();
safeInsetBottom = (int) edgeInsets.getBottom();
}
}

Expand Down
8 changes: 4 additions & 4 deletions gdx/src/com/badlogic/gdx/Graphics.java
Expand Up @@ -154,22 +154,22 @@ public String toString () {
public int getBackBufferHeight ();

/**
* @return the inset from the left which avoids display cutouts in pixels
* @return the inset from the left which avoids display cutouts in logical pixels
*/
int getSafeInsetLeft();

/**
* @return the inset from the top which avoids display cutouts in pixels
* @return the inset from the top which avoids display cutouts in logical pixels
*/
int getSafeInsetTop();

/**
* @return the inset from the bottom which avoids display cutouts or floating gesture bars, in pixels
* @return the inset from the bottom which avoids display cutouts or floating gesture bars, in logical pixels
*/
int getSafeInsetBottom();

/**
* @return the inset from the right which avoids display cutouts in pixels
* @return the inset from the right which avoids display cutouts in logical pixels
*/
int getSafeInsetRight();

Expand Down

0 comments on commit 939088c

Please sign in to comment.