Add app index
This commit is contained in:
@@ -1089,6 +1089,7 @@ namespace nvhttp {
|
||||
app_node.put("IsHdrSupported"s, video::active_hevc_mode == 3 ? 1 : 0);
|
||||
app_node.put("AppTitle"s, app.name);
|
||||
app_node.put("UUID", app.uuid);
|
||||
app_node.put("IDX", app.idx);
|
||||
app_node.put("ID", app.id);
|
||||
|
||||
apps.push_back(std::make_pair("App", std::move(app_node)));
|
||||
@@ -1101,6 +1102,7 @@ namespace nvhttp {
|
||||
app_node.put("IsHdrSupported"s, 0);
|
||||
app_node.put("AppTitle"s, "Permission Denied");
|
||||
app_node.put("UUID", "");
|
||||
app_node.put("IDX", "0");
|
||||
app_node.put("ID", "114514");
|
||||
|
||||
apps.push_back(std::make_pair("App", std::move(app_node)));
|
||||
|
||||
@@ -1100,39 +1100,6 @@ namespace proc {
|
||||
|
||||
size_t fail_count = 0;
|
||||
do {
|
||||
// Virtual Display entry
|
||||
#ifdef _WIN32
|
||||
if (vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
|
||||
proc::ctx_t ctx;
|
||||
ctx.uuid = VIRTUAL_DISPLAY_UUID;
|
||||
ctx.name = "Virtual Display";
|
||||
ctx.image_path = parse_env_val(this_env, "virtual_desktop.png");
|
||||
ctx.virtual_display = true;
|
||||
ctx.scale_factor = 100;
|
||||
ctx.use_app_identity = false;
|
||||
ctx.per_client_app_identity = false;
|
||||
ctx.allow_client_commands = false;
|
||||
|
||||
ctx.elevated = false;
|
||||
ctx.auto_detach = true;
|
||||
ctx.wait_all = false;
|
||||
ctx.exit_timeout = 5s;
|
||||
|
||||
auto possible_ids = calculate_app_id(ctx.name, ctx.image_path, i++);
|
||||
if (ids.count(std::get<0>(possible_ids)) == 0) {
|
||||
// Avoid using index to generate id if possible
|
||||
ctx.id = std::get<0>(possible_ids);
|
||||
}
|
||||
else {
|
||||
// Fallback to include index on collision
|
||||
ctx.id = std::get<1>(possible_ids);
|
||||
}
|
||||
ids.insert(ctx.id);
|
||||
|
||||
apps.emplace_back(std::move(ctx));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Read the JSON file into a tree.
|
||||
nlohmann::json tree;
|
||||
try {
|
||||
@@ -1161,6 +1128,7 @@ namespace proc {
|
||||
// Iterate over each application in the "apps" array.
|
||||
for (auto &app_node : tree["apps"]) {
|
||||
proc::ctx_t ctx;
|
||||
ctx.idx = std::to_string(i);
|
||||
ctx.uuid = app_node.at("uuid");
|
||||
|
||||
// Build the list of preparation commands.
|
||||
@@ -1266,6 +1234,11 @@ namespace proc {
|
||||
break;
|
||||
}
|
||||
|
||||
this_env = boost::this_process::environment();
|
||||
ids.clear();
|
||||
apps.clear();
|
||||
i = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1275,6 +1248,7 @@ namespace proc {
|
||||
if (fail_count > 0) {
|
||||
BOOST_LOG(warning) << "No applications configured, adding fallback Desktop entry.";
|
||||
proc::ctx_t ctx;
|
||||
ctx.idx = std::to_string(i);
|
||||
ctx.uuid = FALLBACK_DESKTOP_UUID; // Placeholder UUID
|
||||
ctx.name = "Desktop (fallback)";
|
||||
ctx.image_path = parse_env_val(this_env, "desktop-alt.png");
|
||||
@@ -1303,10 +1277,47 @@ namespace proc {
|
||||
apps.emplace_back(std::move(ctx));
|
||||
}
|
||||
|
||||
// Virtual Display entry
|
||||
#ifdef _WIN32
|
||||
if (vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
|
||||
proc::ctx_t ctx;
|
||||
ctx.idx = std::to_string(i);
|
||||
ctx.uuid = VIRTUAL_DISPLAY_UUID;
|
||||
ctx.name = "Virtual Display";
|
||||
ctx.image_path = parse_env_val(this_env, "virtual_desktop.png");
|
||||
ctx.virtual_display = true;
|
||||
ctx.scale_factor = 100;
|
||||
ctx.use_app_identity = false;
|
||||
ctx.per_client_app_identity = false;
|
||||
ctx.allow_client_commands = false;
|
||||
|
||||
ctx.elevated = false;
|
||||
ctx.auto_detach = true;
|
||||
ctx.wait_all = false;
|
||||
ctx.exit_timeout = 5s;
|
||||
|
||||
auto possible_ids = calculate_app_id(ctx.name, ctx.image_path, i++);
|
||||
if (ids.count(std::get<0>(possible_ids)) == 0) {
|
||||
// Avoid using index to generate id if possible
|
||||
ctx.id = std::get<0>(possible_ids);
|
||||
}
|
||||
else {
|
||||
// Fallback to include index on collision
|
||||
ctx.id = std::get<1>(possible_ids);
|
||||
}
|
||||
ids.insert(ctx.id);
|
||||
|
||||
BOOST_LOG(info) << "VIRTUAL DISPLAY APP ID::: " << ctx.id;
|
||||
|
||||
apps.emplace_back(std::move(ctx));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (config::input.enable_input_only_mode) {
|
||||
// Input Only entry
|
||||
{
|
||||
proc::ctx_t ctx;
|
||||
ctx.idx = std::to_string(i);
|
||||
ctx.uuid = REMOTE_INPUT_UUID;
|
||||
ctx.name = "Remote Input";
|
||||
ctx.image_path = parse_env_val(this_env, "input_only.png");
|
||||
@@ -1341,6 +1352,7 @@ namespace proc {
|
||||
// Terminate entry
|
||||
{
|
||||
proc::ctx_t ctx;
|
||||
ctx.idx = std::to_string(i);
|
||||
ctx.uuid = TERMINATE_APP_UUID;
|
||||
ctx.name = "Terminate";
|
||||
ctx.image_path = parse_env_val(this_env, "terminate.png");
|
||||
@@ -1364,7 +1376,7 @@ namespace proc {
|
||||
// Fallback to include index on collision
|
||||
ctx.id = std::get<1>(possible_ids);
|
||||
}
|
||||
ids.insert(ctx.id);
|
||||
// ids.insert(ctx.id);
|
||||
|
||||
terminate_app_id_str = ctx.id;
|
||||
terminate_app_id = util::from_view(ctx.id);
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace proc {
|
||||
*/
|
||||
std::vector<std::string> detached;
|
||||
|
||||
std::string idx;
|
||||
std::string uuid;
|
||||
std::string name;
|
||||
std::string cmd;
|
||||
|
||||
Reference in New Issue
Block a user