Fix termux:x11 start & scale

This commit is contained in:
Caten
2025-09-14 13:36:20 +08:00
parent bd546e7da7
commit e523a044bb
7 changed files with 16 additions and 17 deletions

View File

@@ -110,6 +110,5 @@
"updateRequest": "Please try to use the latest version. Visit the project address to check for the latest version.",
"avncScreenResize": "Adaptive Screen Size",
"avncResizeFactor": "Screen Scaling Ratio",
"avncResizeFactorValue": "Current scaling is",
"recommendHidpi": "Recommended to enable HiDPI Support simultaneously"
"avncResizeFactorValue": "Current scaling is"
}

View File

@@ -110,6 +110,5 @@
"updateRequest": "请尽量使用最新版本。前往项目地址可查看最新版本。",
"avncScreenResize": "自适应屏幕尺寸",
"avncResizeFactor": "屏幕缩放比",
"avncResizeFactorValue": "当前缩放为",
"recommendHidpi": "推荐同步开启高分辨率支持"
"avncResizeFactorValue": "当前缩放为"
}

View File

@@ -110,6 +110,5 @@
"updateRequest": "請盡量使用最新版本。前往專案網址查看最新版本。",
"avncScreenResize": "自適應螢幕尺寸",
"avncResizeFactor": "螢幕縮放比",
"avncResizeFactorValue": "目前縮放為",
"recommendHidpi": "推薦同步開啟高解析度支援"
"avncResizeFactorValue": "目前縮放為"
}

View File

@@ -354,6 +354,8 @@ class _SettingPageState extends State<SettingPage> {
_avncScaleFactor += value ? 0.5 : -0.5;
_avncScaleFactor = _avncScaleFactor.clamp(-1, 1);
G.prefs.setDouble("avncScaleFactor", _avncScaleFactor);
// Termux:X11 并不是设置缩放比例本身,而是倍率
X11Flutter.setX11ScaleFactor(value ? 0.5 : 2.0);
setState(() {});
},),
const SizedBox.square(dimension: 16),
@@ -463,12 +465,6 @@ sed -i -E "s@^(VNC_RESOLUTION)=.*@\\1=${w}x${h}@" \$(command -v startvnc)""");
if (!value && Util.getGlobal("dri3")) {
G.prefs.setBool("dri3", false);
}
if (value) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(AppLocalizations.of(context)!.recommendHidpi))
);
}
setState(() {});
},),
const SizedBox.square(dimension: 16),

View File

@@ -212,10 +212,10 @@ class Util {
while (true) {
bool isReady = await isXServerReady(host, port);
await Future.delayed(Duration(seconds: 1));
if (isReady) {
return;
}
await Future.delayed(Duration(seconds: 1));
}
}
@@ -785,10 +785,14 @@ export PROOT_LOADER=\$DATA_DIR/applib/libproot-loader.so
export PROOT_LOADER_32=\$DATA_DIR/applib/libproot-loader32.so
${Util.getCurrentProp("boot")}
${G.postCommand}
${(Util.getGlobal("autoLaunchVnc") as bool)?((Util.getGlobal("useX11") as bool)?"""mkdir -p "\$HOME/.vnc" && bash /etc/X11/xinit/Xsession &> "\$HOME/.vnc/x.log" &""":Util.getCurrentProp("vnc")):""}
clear""");
}
static Future<void> launchGUIBackend() async {
Util.termWrite((Util.getGlobal("autoLaunchVnc") as bool)?((Util.getGlobal("useX11") as bool)?"""mkdir -p "\$HOME/.vnc" && bash /etc/X11/xinit/Xsession &> "\$HOME/.vnc/x.log" &""":Util.getCurrentProp("vnc")):"");
Util.termWrite("clear");
}
static Future<void> waitForConnection() async {
await retry(
// Make a GET request
@@ -847,9 +851,11 @@ clear""");
if (Util.getGlobal("autoLaunchVnc") as bool) {
if (G.wasX11Enabled) {
await Util.waitForXServer();
launchGUIBackend();
launchX11();
return;
}
launchGUIBackend();
waitForConnection().then((value) => G.wasAvncEnabled?launchAvnc():launchBrowser());
}
}