Send app icons one by one
This commit is contained in:
@@ -400,7 +400,7 @@ void scenes::lobby::gui_connected()
|
||||
|
||||
auto apps = next_scene->get_applications();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {20, 20});
|
||||
if (apps->applications.empty())
|
||||
if (apps->empty())
|
||||
{
|
||||
CenterTextHV(_("Start an application on the server to start streaming."));
|
||||
}
|
||||
@@ -426,7 +426,7 @@ void scenes::lobby::gui_connected()
|
||||
ImGui::Indent((usable_window_width - icon_line_width) / 2);
|
||||
|
||||
auto t0 = std::chrono::steady_clock::now();
|
||||
for (const auto [index, app]: utils::enumerate(apps->applications))
|
||||
for (const auto [index, app]: utils::enumerate(*apps))
|
||||
{
|
||||
ImTextureID texture = [&]() -> ImTextureID {
|
||||
if (app.image.empty())
|
||||
@@ -470,7 +470,7 @@ void scenes::lobby::gui_connected()
|
||||
std::vector<std::pair<std::string, ImTextureID>> to_be_removed;
|
||||
for (const auto & [app_id, app_icon]: app_icons)
|
||||
{
|
||||
if (not std::ranges::contains(apps->applications, app_id, &to_headset::application_list::application::id))
|
||||
if (not std::ranges::contains(*apps, app_id, &scenes::stream::app::id))
|
||||
to_be_removed.emplace_back(app_id, app_icon);
|
||||
}
|
||||
for (const auto & [app_id, app_icon]: to_be_removed)
|
||||
|
||||
+10
-1
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "audio/audio.h"
|
||||
#include "decoder/shard_accumulator.h"
|
||||
#include "imgui.h"
|
||||
#include "render/imgui_impl.h"
|
||||
#include "scene.h"
|
||||
#include "scenes/input_profile.h"
|
||||
@@ -48,6 +49,13 @@ public:
|
||||
};
|
||||
static const size_t image_buffer_size = 3;
|
||||
|
||||
struct app
|
||||
{
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::vector<std::byte> image;
|
||||
};
|
||||
|
||||
private:
|
||||
static const size_t view_count = 2;
|
||||
|
||||
@@ -176,7 +184,7 @@ private:
|
||||
std::vector<std::shared_ptr<wivrn::shard_accumulator::blit_handle>> current_blit_handles;
|
||||
|
||||
// Last application list received from server
|
||||
thread_safe<to_headset::application_list> applications;
|
||||
thread_safe<std::vector<app>> applications;
|
||||
|
||||
stream();
|
||||
|
||||
@@ -202,6 +210,7 @@ public:
|
||||
void operator()(to_headset::video_stream_description &&);
|
||||
void operator()(to_headset::refresh_rate_change &&);
|
||||
void operator()(to_headset::application_list &&);
|
||||
void operator()(to_headset::application_icon &&);
|
||||
void operator()(audio_data &&);
|
||||
|
||||
void push_blit_handle(wivrn::shard_accumulator * decoder, std::shared_ptr<wivrn::shard_accumulator::blit_handle> handle);
|
||||
|
||||
@@ -111,8 +111,26 @@ void scenes::stream::operator()(to_headset::application_list && apps)
|
||||
std::ranges::sort(apps.applications, [](auto & l, auto & r) {
|
||||
return una::casesens::collate_utf8(l.name, r.name) < 0;
|
||||
});
|
||||
|
||||
auto locked = applications.lock();
|
||||
*locked = std::move(apps);
|
||||
|
||||
locked->clear();
|
||||
locked->reserve(apps.applications.size());
|
||||
for (const auto & i: apps.applications)
|
||||
{
|
||||
locked->push_back(app{
|
||||
.id = std::move(i.id),
|
||||
.name = std::move(i.name),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::application_icon && icon)
|
||||
{
|
||||
auto locked = applications.lock();
|
||||
|
||||
if (auto it = std::ranges::find(*locked, icon.id, &app::id); it != locked->end())
|
||||
it->image = std::move(icon.image);
|
||||
}
|
||||
|
||||
void scenes::stream::start_application(std::string appid)
|
||||
|
||||
Reference in New Issue
Block a user