Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions app/src/main/runtime/display/XServerDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7104,7 +7104,19 @@ private boolean handleDrawerAction(int itemId) {
renderDrawerMenu();
break;
case R.id.main_menu_pip_mode:
enterPictureInPictureMode(new android.app.PictureInPictureParams.Builder().build());
// OEM builds can throw when entering PiP; guard so the button never crashes the session.
try {
android.graphics.Point pipSize = new android.graphics.Point();
getWindowManager().getDefaultDisplay().getSize(pipSize);
float pipRatio = Math.max(1.0f / 2.39f, Math.min((float) pipSize.x / pipSize.y, 2.39f));
android.app.PictureInPictureParams pipParams =
new android.app.PictureInPictureParams.Builder()
.setAspectRatio(new android.util.Rational((int) (pipRatio * 1000), 1000))
.build();
enterPictureInPictureMode(pipParams);
} catch (Throwable t) {
Log.w("XServerDisplayActivity", "Failed to enter PiP mode", t);
}
closeDrawerMenu();
break;
case R.id.main_menu_magnifier:
Expand Down Expand Up @@ -11493,7 +11505,7 @@ && new File(storeInstallPath).exists()) {
dir = "F:\\";
}

File nativeDir = com.winlator.cmod.runtime.wine.WineUtils.getNativePath(imageFs, dir);
File nativeDir = com.winlator.cmod.runtime.wine.WineUtils.getNativePath(this.container, imageFs, dir);
if (nativeDir != null && nativeDir.exists()) {
launcherComponent.setWorkingDir(nativeDir);
Log.d("XServerDisplayActivity", "Set native working dir for store process: " + nativeDir.getPath());
Expand All @@ -11515,9 +11527,39 @@ && new File(storeInstallPath).exists()) {
} else if (path != null) {
String nativeDirPath = getActiveGameDirectoryPath();
if (nativeDirPath != null) {
File nativeDir = new File(nativeDirPath);
launcherComponent.setWorkingDir(nativeDir);
Log.d("XServerDisplayActivity", "Set native working dir for Custom process: " + nativeDir.getPath());
File nativeDir = null;
// Round-trip host -> Wine -> host to re-resolve through this container's dosdevices symlinks.
String winDir =
com.winlator.cmod.runtime.wine.WineUtils
.hostPathToRootWinePath(container, nativeDirPath);
if (winDir != null && !winDir.isEmpty()) {
nativeDir =
com.winlator.cmod.runtime.wine.WineUtils
.getNativePath(container, imageFs, winDir);
}
String exeName = null;
int lastSlash = path.lastIndexOf("\\");
if (lastSlash > 0 && lastSlash + 1 < path.length()) exeName = path.substring(lastSlash + 1);
if (nativeDir == null || !nativeDir.isDirectory()
|| (exeName != null && !new File(nativeDir, exeName).isFile())) {
File exeDir = null;
if (lastSlash > 0) {
exeDir =
com.winlator.cmod.runtime.wine.WineUtils
.getNativePath(container, imageFs, path.substring(0, lastSlash));
}
if (exeDir != null && exeDir.isDirectory()) {
nativeDir = exeDir;
} else if (new File(nativeDirPath).isDirectory()) {
nativeDir = new File(nativeDirPath);
} else {
nativeDir = null;
}
}
if (nativeDir != null && nativeDir.isDirectory()) {
launcherComponent.setWorkingDir(nativeDir);
Log.d("XServerDisplayActivity", "Set native working dir for Custom process: " + nativeDir.getPath());
}
} else {
int lastBackslash = path.lastIndexOf("\\");
if (lastBackslash >= 0) {
Expand Down
Loading