Skip to content
Permalink
Browse files

Android: Display measurement fixes

No longer set display parameters on surface create - surface is resized
after create to match screen dimensions. Fixes offset issue when started
in immersive mode.

Also update measurements on multi-window change, and use getMetrics when
in multi-window mode as getRealMetrics returns full screen size, not
window size.
  • Loading branch information...
rlac committed May 12, 2019
1 parent 624e240 commit c01186d35c70fd0bb42931757872b8bdcb03d27e
Showing with 14 additions and 2 deletions.
  1. +14 −2 android/src/org/ppsspp/ppsspp/NativeActivity.java
@@ -457,7 +457,12 @@ public void updateDisplayMeasurements() {

DisplayMetrics metrics = new DisplayMetrics();
if (useImmersive() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealMetrics(metrics);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N || !isInMultiWindowMode()) {
display.getRealMetrics(metrics);
} else {
// multi-window mode
display.getMetrics(metrics);
}
} else {
display.getMetrics(metrics);
}
@@ -568,7 +573,6 @@ public void surfaceCreated(SurfaceHolder holder) {
}

Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight + " holder: " + holder.toString() + " or: " + requestedOr);
NativeApp.setDisplayParameters(pixelWidth, pixelHeight, (int) densityDpi, refreshRate);
getDesiredBackbufferSize(desiredSize);

// Note that desiredSize might be 0,0 here - but that's fine when calling setFixedSize! It means auto.
@@ -788,6 +792,14 @@ public void onConfigurationChanged(Configuration newConfig) {
}
}

@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) {
// onConfigurationChanged not called on multi-window change
Log.i(TAG, "onMultiWindowModeChanged: isInMultiWindowMode = " + isInMultiWindowMode);
super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig);
updateDisplayMeasurements();
}

// keep this static so we can call this even if we don't
// instantiate NativeAudioPlayer
public static void gainAudioFocus(AudioManager audioManager, AudioFocusChangeListener focusChangeListener) {

0 comments on commit c01186d

Please sign in to comment.
You can’t perform that action at this time.