Don't trust the file extension when loading icons

Fixes #439
This commit is contained in:
Guillaume Meunier
2025-08-18 21:16:08 +02:00
parent 94aceb3f0f
commit c2f23223a2
3 changed files with 337 additions and 346 deletions
+13 -2
View File
@@ -759,11 +759,22 @@ void wivrn_session::operator()(from_headset::get_application_list && request)
{
try
{
auto icon = load_icon(*app.icon_path, 256);
const auto & icons = load_icon(*app.icon_path);
if (icons.empty())
continue;
const auto & largest_icon = std::ranges::max(icons, [](const wivrn::icon & a, const wivrn::icon & b) {
if (a.bpp < b.bpp)
return true;
if (a.bpp > b.bpp)
return false;
return a.width * a.height < b.width * b.height;
});
send_control(to_headset::application_icon{
.id = id,
.image = std::move(icon),
.image = largest_icon.png_data,
});
}
catch (std::exception & e)