mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-04 15:06:08 +00:00
Add additional native resolution options on Android 10+ with display insets included
Fixes #956 Fixes #986
This commit is contained in:
@@ -214,9 +214,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
prefConfig = PreferenceConfiguration.readPreferences(this);
|
||||
tombstonePrefs = Game.this.getSharedPreferences("DecoderTombstone", 0);
|
||||
|
||||
if (prefConfig.stretchVideo) {
|
||||
if (prefConfig.stretchVideo || shouldIgnoreInsetsForResolution(prefConfig.width, prefConfig.height)) {
|
||||
// Allow the activity to layout under notches if the fill-screen option
|
||||
// was turned on by the user
|
||||
// was turned on by the user or it's a full-screen native resolution
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
getWindow().getAttributes().layoutInDisplayCutoutMode =
|
||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
@@ -627,6 +627,26 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
Math.round(refreshRate) % prefConfig.fps <= 3;
|
||||
}
|
||||
|
||||
private boolean shouldIgnoreInsetsForResolution(int width, int height) {
|
||||
// Never ignore insets for non-native resolutions
|
||||
if (!PreferenceConfiguration.isNativeResolution(width, height)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
for (Display.Mode candidate : display.getSupportedModes()) {
|
||||
// Ignore insets if this is an exact match for the display resolution
|
||||
if ((width == candidate.getPhysicalWidth() && height == candidate.getPhysicalHeight()) ||
|
||||
(height == candidate.getPhysicalWidth() && width == candidate.getPhysicalHeight())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private float prepareDisplayForRendering() {
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
WindowManager.LayoutParams windowLayoutParams = getWindow().getAttributes();
|
||||
|
||||
Reference in New Issue
Block a user