List running applications
This commit is contained in:
@@ -730,6 +730,7 @@ bool scenes::stream::is_gui_interactable() const
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::applications:
|
||||
return true;
|
||||
|
||||
case gui_status::hidden:
|
||||
@@ -1000,6 +1001,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
break;
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||
break;
|
||||
}
|
||||
@@ -1091,6 +1093,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::applications:
|
||||
gui_status = gui_status::hidden;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,8 @@ private:
|
||||
compact,
|
||||
stats,
|
||||
settings,
|
||||
foveation_settings
|
||||
foveation_settings,
|
||||
applications,
|
||||
};
|
||||
|
||||
bool is_gui_interactable() const;
|
||||
@@ -173,6 +174,8 @@ private:
|
||||
// Last application list received from server
|
||||
thread_safe<std::vector<app>> applications;
|
||||
|
||||
thread_safe<to_headset::running_applications> running_applications;
|
||||
|
||||
stream();
|
||||
|
||||
public:
|
||||
@@ -198,6 +201,7 @@ public:
|
||||
void operator()(to_headset::refresh_rate_change &&);
|
||||
void operator()(to_headset::application_list &&);
|
||||
void operator()(to_headset::application_icon &&);
|
||||
void operator()(to_headset::running_applications &&);
|
||||
void operator()(audio_data &&);
|
||||
|
||||
void push_blit_handle(wivrn::shard_accumulator * decoder, std::shared_ptr<wivrn::shard_accumulator::blit_handle> handle);
|
||||
@@ -305,6 +309,7 @@ private:
|
||||
void gui_compact_view();
|
||||
void gui_settings();
|
||||
void gui_foveation_settings(float predicted_display_period);
|
||||
void gui_applications();
|
||||
void draw_gui(XrTime predicted_display_time, XrDuration predicted_display_period);
|
||||
};
|
||||
} // namespace scenes
|
||||
|
||||
@@ -603,6 +603,21 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
|
||||
});
|
||||
}
|
||||
|
||||
void scenes::stream::gui_applications()
|
||||
{
|
||||
ImGui::Text("%s", _S("Running XR applications:"));
|
||||
auto apps = running_applications.lock();
|
||||
for (const auto & app: apps->applications)
|
||||
{
|
||||
ImGui::Text("%s", app.name.c_str());
|
||||
if (app.id == apps->active_id)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", _S("(focused)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the vector v such that dot(v, x) > 0 iff x is on the side where the composition layer is visible
|
||||
static glm::vec4 compute_ray_limits(const XrPosef & pose, float margin = 0)
|
||||
{
|
||||
@@ -642,6 +657,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
break;
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
break;
|
||||
}
|
||||
imgui_ctx->set_controllers_enabled(interactable);
|
||||
@@ -708,6 +724,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
case gui_status::compact:
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
imgui_ctx->layers()[0].orientation = head_position->second * head_gui_orientation;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * head_gui_position;
|
||||
break;
|
||||
@@ -748,6 +765,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
ImGui::SetNextWindowPos(margin_around_window);
|
||||
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size - margin_around_window * 2);
|
||||
always_auto_resize = false;
|
||||
@@ -804,6 +822,13 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
case gui_status::foveation_settings:
|
||||
gui_foveation_settings(predicted_display_period * 1.e-9f);
|
||||
break;
|
||||
|
||||
case gui_status::applications:
|
||||
ImGui::SetCursorPos({tab_width + 20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_applications();
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2); // ImGuiStyleVar_WindowPadding, ImGuiStyleVar_FrameRounding
|
||||
@@ -822,6 +847,10 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), gui_status, gui_status::settings, {tab_width, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
if (RadioButtonWithoutCheckBox(ICON_FA_LIST " " + _("Applications"), gui_status, gui_status::applications, {tab_width, 0}))
|
||||
network_session->send_control(from_headset::get_running_applications{});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
int n_items_at_end = 4;
|
||||
ImGui::SetCursorPosY(ImGui::GetContentRegionMax().y - n_items_at_end * ImGui::GetCurrentContext()->FontSize - (n_items_at_end * 2) * style.FramePadding.y - (n_items_at_end - 1) * style.ItemSpacing.y - style.WindowPadding.y);
|
||||
|
||||
|
||||
@@ -133,6 +133,11 @@ void scenes::stream::operator()(to_headset::application_icon && icon)
|
||||
it->image = std::move(icon.image);
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::running_applications && apps)
|
||||
{
|
||||
*running_applications.lock() = std::move(apps);
|
||||
}
|
||||
|
||||
void scenes::stream::start_application(std::string appid)
|
||||
{
|
||||
network_session->send_control(wivrn::from_headset::start_app{
|
||||
|
||||
+19
-2
@@ -462,6 +462,9 @@ struct start_app
|
||||
std::string app_id;
|
||||
};
|
||||
|
||||
struct get_running_applications
|
||||
{};
|
||||
|
||||
using packets = std::variant<
|
||||
crypto_handshake,
|
||||
pin_check_1,
|
||||
@@ -484,7 +487,8 @@ using packets = std::variant<
|
||||
user_presence_changed,
|
||||
override_foveation_center,
|
||||
get_application_list,
|
||||
start_app>;
|
||||
start_app,
|
||||
get_running_applications>;
|
||||
} // namespace from_headset
|
||||
|
||||
namespace to_headset
|
||||
@@ -692,6 +696,18 @@ struct application_icon
|
||||
std::vector<std::byte> image; // In PNG
|
||||
};
|
||||
|
||||
struct running_applications
|
||||
{
|
||||
struct application
|
||||
{
|
||||
std::string name;
|
||||
uint32_t id;
|
||||
bool overlay;
|
||||
bool active;
|
||||
};
|
||||
std::vector<application> applications;
|
||||
};
|
||||
|
||||
using packets = std::variant<
|
||||
crypto_handshake,
|
||||
pin_check_2,
|
||||
@@ -706,6 +722,7 @@ using packets = std::variant<
|
||||
tracking_control,
|
||||
refresh_rate_change,
|
||||
application_list,
|
||||
application_icon>;
|
||||
application_icon,
|
||||
running_applications>;
|
||||
} // namespace to_headset
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -783,6 +783,30 @@ void wivrn_session::operator()(const from_headset::start_app & request)
|
||||
send_to_main(request);
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(const from_headset::get_running_applications &)
|
||||
{
|
||||
scoped_lock lock(inst.server->global_state.lock);
|
||||
to_headset::running_applications msg{};
|
||||
for (auto & t: inst.server->threads)
|
||||
{
|
||||
if (t.ics.server_thread_index < 0)
|
||||
continue;
|
||||
// nasty volatile
|
||||
std::array<char, sizeof(t.ics.client_state.info.application_name)> tmp;
|
||||
for (size_t i = 0; i + 1 < tmp.size(); ++i)
|
||||
tmp[i] = t.ics.client_state.info.application_name[i];
|
||||
tmp.back() = 0;
|
||||
msg.applications.push_back(
|
||||
{
|
||||
.name = std::string(tmp.data()),
|
||||
.id = t.ics.client_state.id,
|
||||
.overlay = t.ics.client_state.session_overlay,
|
||||
.active = t.ics.server_thread_index == inst.server->global_state.active_client_index,
|
||||
});
|
||||
}
|
||||
connection->send_control(std::move(msg));
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(audio_data && data)
|
||||
{
|
||||
if (audio_handle)
|
||||
|
||||
@@ -192,6 +192,7 @@ public:
|
||||
void operator()(from_headset::override_foveation_center &&);
|
||||
void operator()(from_headset::get_application_list &&);
|
||||
void operator()(const from_headset::start_app &);
|
||||
void operator()(const from_headset::get_running_applications &);
|
||||
void operator()(audio_data &&);
|
||||
|
||||
void operator()(to_monado::disconnect &&);
|
||||
|
||||
Reference in New Issue
Block a user