Add AVNC screen scale feature

This commit is contained in:
Caten
2025-09-10 17:32:08 +08:00
parent 0793f589f2
commit db4431d4c7
6 changed files with 80 additions and 31 deletions

View File

@@ -92,6 +92,8 @@ class Util {
//bool isHidpiEnabled = false 是否开启高分辨率
//bool isJpEnabled = false 是否切换系统到日语
//bool useAvnc = false 是否默认使用AVNC
//bool avncResizeDesktop = true 是否默认AVNC按当前屏幕大小调整分辨率
//double avncScaleFactor = -0.5 AVNC在当前屏幕大小的基础上调整缩放的比例。范围-1~1对应比例4^-1~4^1
//String defaultHidpiOpt 默认HiDPI环境变量
//? int bootstrapVersion: 启动包版本
//String[] containersInfo: 所有容器信息(json)
@@ -120,6 +122,8 @@ class Util {
case "isHidpiEnabled" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
case "isJpEnabled" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
case "useAvnc" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(true);
case "avncResizeDesktop" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(true);
case "avncScaleFactor" : return b ? G.prefs.getDouble(key)!.clamp(-1.0, 1.0) : (value){G.prefs.setDouble(key, value); return value;}(-0.5);
case "useX11" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
case "defaultFFmpegCommand" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("-hide_banner -an -max_delay 1000000 -r 30 -f android_camera -camera_index 0 -i 0:0 -vf scale=iw/2:-1 -rtsp_transport udp -f rtsp rtsp://127.0.0.1:8554/stream");
case "defaultVirglCommand" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("--use-egl-surfaceless --use-gles --socket-path=\$CONTAINER_DIR/tmp/.virgl_test");
@@ -771,7 +775,7 @@ clear""");
}
static Future<void> launchAvnc() async {
await AvncFlutter.launchUsingUri(Util.getCurrentProp("vncUri") as String);
await AvncFlutter.launchUsingUri(Util.getCurrentProp("vncUri") as String, resizeRemoteDesktop: Util.getGlobal("avncResizeDesktop") as bool, resizeRemoteDesktopScaleFactor: pow(4, Util.getGlobal("avncScaleFactor") as double).toDouble());
}
static Future<void> launchXServer() async {