From 5aaeb70722f8b4eae568d1a1d55a3c494b045690 Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Thu, 23 Jan 2025 01:51:17 +0800 Subject: [PATCH] Add option to enable/disable client commands per-app --- src/nvhttp.cpp | 10 ++++++++++ src/process.cpp | 9 ++++++--- src/process.h | 3 ++- src_assets/common/assets/web/apps.html | 11 ++++++++++- .../common/assets/web/public/assets/locale/en.json | 2 ++ .../common/assets/web/public/assets/locale/zh.json | 6 ++++++ 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index 2bd19ffe..394dfa5c 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -1148,6 +1148,11 @@ namespace nvhttp { return; } + if (!app_iter->allow_client_commands) { + launch_session->client_do_cmds.clear(); + launch_session->client_undo_cmds.clear(); + } + auto err = proc::proc.execute(appid, *app_iter, launch_session); if (err) { tree.put("root..status_code", err); @@ -1224,6 +1229,11 @@ namespace nvhttp { } auto launch_session = make_launch_session(host_audio, 0, args, named_cert_p); + if (!proc::proc.allow_client_commands) { + launch_session->client_do_cmds.clear(); + launch_session->client_undo_cmds.clear(); + } + if (no_active_sessions && !proc::proc.virtual_display) { // We want to prepare display only if there are no active sessions // and the current session isn't virtual display at the moment. diff --git a/src/process.cpp b/src/process.cpp index 125e6d79..8ffa7935 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -166,6 +166,7 @@ namespace proc { _app = app; _app_id = app_id; _launch_session = launch_session; + allow_client_commands = app.allow_client_commands; uint32_t client_width = launch_session->width ? launch_session->width : 1920; uint32_t client_height = launch_session->height ? launch_session->height : 1080; @@ -409,7 +410,7 @@ namespace proc { } else { auto currentDisplayW = platf::from_utf8(currentDisplay).c_str(); - this->initial_hdr = VDISPLAY::getDisplayHDRByName(currentDisplayW); + bool initial_hdr = VDISPLAY::getDisplayHDRByName(currentDisplayW); if (config::video.dd.hdr_option == config::video_t::dd_t::hdr_option_e::automatic) { if (!VDISPLAY::setDisplayHDRByName(currentDisplayW, false)) { @@ -423,7 +424,7 @@ namespace proc { BOOST_LOG(info) << "HDR enable failed for display " << currentDisplay; } } - } else if (this->initial_hdr) { + } else if (initial_hdr) { if (VDISPLAY::setDisplayHDRByName(currentDisplayW, false) && VDISPLAY::setDisplayHDRByName(currentDisplayW, true)) { BOOST_LOG(info) << "HDR toggled successfully for display " << currentDisplay; } else { @@ -566,10 +567,10 @@ namespace proc { _app_id = -1; display_name.clear(); - initial_hdr = false; initial_display.clear(); _launch_session.reset(); virtual_display = false; + allow_client_commands = false; } const std::vector & @@ -912,6 +913,7 @@ namespace proc { auto virtual_display = app_node.get_optional("virtual-display"s); auto resolution_scale_factor = app_node.get_optional("scale-factor"s); auto use_app_identity = app_node.get_optional("use-app-identity"s); + auto allow_client_commands = app_node.get_optional("allow-client-commands"); ctx.uuid = app_uuid.value(); @@ -986,6 +988,7 @@ namespace proc { ctx.virtual_display = virtual_display.value_or(false); ctx.scale_factor = resolution_scale_factor.value_or(100); ctx.use_app_identity = use_app_identity.value_or(false); + ctx.allow_client_commands = allow_client_commands.value_or(true); auto possible_ids = calculate_app_id(name, ctx.image_path, i++); if (ids.count(std::get<0>(possible_ids)) == 0) { diff --git a/src/process.h b/src/process.h index 633ed1a1..1c3543b4 100644 --- a/src/process.h +++ b/src/process.h @@ -73,6 +73,7 @@ namespace proc { bool virtual_display; bool virtual_display_primary; bool use_app_identity; + bool allow_client_commands; int scale_factor; std::chrono::seconds exit_timeout; }; @@ -84,7 +85,7 @@ namespace proc { std::string display_name; std::string initial_display; bool virtual_display; - bool initial_hdr; + bool allow_client_commands; proc_t( diff --git a/src_assets/common/assets/web/apps.html b/src_assets/common/assets/web/apps.html index 476f4a3d..4ecfffe8 100644 --- a/src_assets/common/assets/web/apps.html +++ b/src_assets/common/assets/web/apps.html @@ -150,6 +150,14 @@ v-model="editForm['image-path']" />
{{ $t('apps.image_desc') }}
+ +