Skip to content

Commit

Permalink
Add global option for set virtual display as primary display
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Sep 19, 2024
1 parent 4982074 commit 9f01263
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ namespace config {
video_t video {
false, // headless_mode
false, // follow_client_hdr
true, // set_vdisplay_primary
28, // qp

0, // hevc_mode
Expand Down Expand Up @@ -983,6 +984,7 @@ namespace config {

bool_f(vars, "headless_mode", video.headless_mode);
bool_f(vars, "follow_client_hdr", video.follow_client_hdr);
bool_f(vars, "set_vdisplay_primary", video.set_vdisplay_primary);
int_f(vars, "qp", video.qp);
int_f(vars, "min_threads", video.min_threads);
int_between_f(vars, "hevc_mode", video.hevc_mode, { 0, 3 });
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace config {
struct video_t {
bool headless_mode;
bool follow_client_hdr;
bool set_vdisplay_primary;
// ffmpeg params
int qp; // higher == more compression and less quality

Expand Down
25 changes: 17 additions & 8 deletions src/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,29 @@ namespace proc {
VDISPLAY::changeDisplaySettings(vdisplayName.c_str(), render_width, render_height, launch_session->fps);
}

bool shouldActuallySetPrimary = false;

// Determine if we need to set the virtual display as primary
bool shouldSetPrimary = false;
// Client request overrides local config
bool shouldSetVDisplayPrimary = launch_session->virtual_display;
if (!shouldSetVDisplayPrimary) {
// App config overrides global config
if (_app.virtual_display) {
shouldSetVDisplayPrimary = _app.virtual_display_primary;
} else {
shouldSetVDisplayPrimary = config::video.set_vdisplay_primary;
}
}

if (launch_session->virtual_display || _app.virtual_display_primary) {
shouldSetPrimary = (currentPrimaryDisplayName != vdisplayName);
if (shouldSetVDisplayPrimary) {
shouldActuallySetPrimary = (currentPrimaryDisplayName != vdisplayName);
} else {
shouldSetPrimary = (currentPrimaryDisplayName != prevPrimaryDisplayName);
shouldActuallySetPrimary = (currentPrimaryDisplayName != prevPrimaryDisplayName);
}

// Set primary display if needed
if (shouldSetPrimary) {
auto disp = (launch_session->virtual_display || _app.virtual_display_primary)
? vdisplayName
: prevPrimaryDisplayName;
if (shouldActuallySetPrimary) {
auto disp = shouldSetVDisplayPrimary ? vdisplayName : prevPrimaryDisplayName;
BOOST_LOG(info) << "Setting display " << disp << " primary!!!";

VDISPLAY::setPrimaryDisplay(disp.c_str());
Expand Down
3 changes: 3 additions & 0 deletions src_assets/common/assets/web/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ <h1 class="my-4">{{ $t('config.configuration') }}</h1>
"auto_capture_sink": "enabled",
"adapter_name": "",
"output_name": "",
"headless_mode": "disabled",
"fallback_mode": "",
"set_vdisplay_primary": "enabled",
"min_fps_factor": 1,
},
},
Expand Down
12 changes: 10 additions & 2 deletions src_assets/common/assets/web/configs/tabs/AudioVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,21 @@ const validateFallbackMode = (event) => {
<div class="form-text pre-wrap">{{ $t('config.follow_client_hdr_desc') }}</div>
</div>

<!--headless_mode-->
<!-- Headless Mode -->
<div class="mb-3 form-check" v-if="platform === 'windows'">
<input type="checkbox" class="form-check-input" id="headless_mode" v-model="config.headless_mode" true-value="enabled" false-value="disabled"/>
<label for="qp" class="form-check-label">{{ $t('config.headless_mode') }}</label>
<label for="headless_mode" class="form-check-label">{{ $t('config.headless_mode') }}</label>
<div class="form-text">{{ $t('config.headless_mode_desc') }}</div>
</div>

<!-- Set VDisplay Primary -->
<div class="mb-3 form-check" v-if="platform === 'windows'">
<input type="checkbox" class="form-check-input" id="set_vdisplay_primary" v-model="config.set_vdisplay_primary" true-value="enabled" false-value="disabled"/>
<label for="set_vdisplay_primary" class="form-check-label">{{ $t('config.set_vdisplay_primary') }}</label>
<div class="form-text">{{ $t('config.set_vdisplay_primary_desc') }}</div>
</div>

<!-- SudoVDA Driver Status -->
<div class="alert" :class="[vdisplay === '0' ? 'alert-success' : 'alert-warning']" v-if="platform === 'windows'">
<i class="fa-solid fa-xl fa-circle-info"></i> SudoVDA Driver status: {{currentDriverStatus}}
</div>
Expand Down
6 changes: 4 additions & 2 deletions src_assets/common/assets/web/public/assets/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@
"name": "Name",
"output_desc": "The file where the output of the command is stored, if it is not specified, the output is ignored",
"output_name": "Output",
"run_as_desc": "This can be necessary for some applications that require administrator permissions to run properly.",
"run_as_desc": "This can be necessary for some applications that require administrator permissions to run properly. Might cause URL schemes to fail.",
"wait_all": "Continue streaming until all app processes exit",
"wait_all_desc": "This will continue streaming until all processes started by the app have terminated. When unchecked, streaming will stop when the initial app process exits, even if other app processes are still running.",
"working_dir": "Working Directory",
"working_dir_desc": "The working directory that should be passed to the process. For example, some applications use the working directory to search for configuration files. If not set, Apollo will default to the parent directory of the command",
"virtual_display": "Always use Virtual Display",
"virtual_display_desc": "Always use virtual display on this app, overriding client request. Please make sure the SudoVDA driver is installed and enabled.",
"virtual_display_primary": "Set virtual display as primary display",
"virtual_display_primary": "Enforce Virtual Display Primary",
"virtual_display_primary_desc": "Automatically set the virtual display as primary display when the app starts. Virtual display will always be set to primary when client requests to use virtual display. (Recommended to keep on)",
"resolution_scale_factor": "Resolution Scale Factor",
"resolution_scale_factor_desc": "Scale the client requested resolution based on this factor. e.g. 2000x1000 with a factor of 120% will become 2400x1200. Overrides client requested factor when the number isn't 100%. This option won't affect client requested streaming resolution."
Expand Down Expand Up @@ -322,6 +322,8 @@
"restart_note": "Apollo is restarting to apply changes.",
"server_cmd": "Server Commands",
"server_cmd_desc": "Configure a list of commands to be executed when called from client during streaming.",
"set_vdisplay_primary": "Enforce Virtual Display Primary",
"set_vdisplay_primary_desc": "Automatically set the virtual display as primary display when the app starts. Virtual display will always be set to primary when client requests to use virtual display. (Recommended to keep on)",
"sunshine_name": "Apollo Name",
"sunshine_name_desc": "The name displayed by Moonlight. If not specified, the PC's hostname is used",
"sw_preset": "SW Presets",
Expand Down
10 changes: 6 additions & 4 deletions src_assets/common/assets/web/public/assets/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@
"name": "名称",
"output_desc": "存储命令输出的文件,如果未指定,输出将被忽略",
"output_name": "输出",
"run_as_desc": "这可能是某些需要管理员权限才能正常运行的应用程序所必需的。",
"run_as_desc": "这可能是某些需要管理员权限才能正常运行的应用程序所必需的。可能会导致 URL schemes 无法正常启动。",
"wait_all": "继续串流直到所有应用进程退出",
"wait_all_desc": "这将继续串流直到应用程序启动的所有进程终止。 当未选中时,串流将在初始应用进程终止时停止,即使其他应用进程仍在运行。",
"working_dir": "工作目录",
"working_dir_desc": "应传递给进程的工作目录。例如,某些应用程序使用工作目录搜索配置文件。如果不设置,Apollo 将默认使用命令的父目录",
"virtual_display": "总是使用虚拟显示器",
"virtual_display_desc": "在使用这个App的时候总是使用虚拟显示器,覆盖客户端请求。请确保 SudoVDA 虚拟显示器驱动已安装并启用。",
"virtual_display_primary": "设置虚拟显示器为主显示器",
"virtual_display_primary_desc": "在App启动时自动将虚拟显示器设为主显示器。当客户端请求使用虚拟显示器时将无条件设为主显示器。(推荐保持开启)",
"virtual_display_primary": "强制设置虚拟显示器为主显示器",
"virtual_display_primary_desc": "在App启动时强制将虚拟显示器设为主显示器。当客户端请求使用虚拟显示器时将无条件设为主显示器。(覆盖全局设置,推荐保持开启)",
"resolution_scale_factor": "分辨率缩放比例",
"resolution_scale_factor_desc": "基于此比例缩放客户端请求的分辨率。例如 2000x1000 缩放 120% 将变成 2400x1200。当此项为非 100% 时覆盖客户端请求的缩放比例。此选项不会影响客户端请求的串流分辨率。"
},
Expand Down Expand Up @@ -322,11 +322,13 @@
"restart_note": "正在重启 Apollo 以应用更改。",
"server_cmd": "服务端命令",
"server_cmd_desc": "配置一个命令列表,当串流时从客户端调用。",
"set_vdisplay_primary": "强制虚拟显示为主显示",
"set_vdisplay_primary_desc": "当应用程序启动时,自动将虚拟显示设置为主显示。当客户端请求使用虚拟显示时,虚拟显示将始终设置为主显示。(建议保持开启)",
"sunshine_name": "Apollo 主机名称",
"sunshine_name_desc": "在 Moonlight 中显示的名称。如果未指定,则使用 PC 的主机名",
"sw_preset": "软件编码预设",
"sw_preset_desc": "在编码速度和压缩效率之间权衡。默认为 superfast - 超快。",
"sw_preset_fast": "快速的",
"sw_preset_fast": "fast - 快速",
"sw_preset_faster": "faster - 更快",
"sw_preset_medium": "medium - 中等",
"sw_preset_slow": "slow - 慢",
Expand Down

0 comments on commit 9f01263

Please sign in to comment.