systray: search for the best available resolution of a icon

For example in telegram the first icon which was transmitted was in a
pretty bad resolution, the new code searches the best res.
This commit is contained in:
Marcel Hollerbach 2015-10-14 12:18:41 +02:00
parent 432d1e3776
commit adbb5719f0
1 changed files with 13 additions and 7 deletions

View File

@ -60,6 +60,7 @@ static void
icon_pixmap_deserialize(Eldbus_Message_Iter *variant, uint32_t **data, int *w, int *h)
{
Eldbus_Message_Iter *iter, *struc;
int tmpw, tmph;
*data = NULL;
*w = *h = 0;
@ -68,19 +69,24 @@ icon_pixmap_deserialize(Eldbus_Message_Iter *variant, uint32_t **data, int *w, i
{
Eldbus_Message_Iter *imgdata;
if (eldbus_message_iter_arguments_get(struc, "iiay", w, h, &imgdata))
if (eldbus_message_iter_arguments_get(struc, "iiay", &tmpw, &tmph, &imgdata))
{
uint32_t *img;
int len;
if (eldbus_message_iter_fixed_array_get(imgdata, 'y', &img, &len))
//only take this img if it has a higher resolution
if (tmpw > *w || tmph > *h)
{
unsigned int pos;
*w = tmpw;
*h = tmph;
if (eldbus_message_iter_fixed_array_get(imgdata, 'y', &img, &len))
{
unsigned int pos;
*data = malloc(len * sizeof(int));
for (pos = 0; pos < (unsigned int)len; pos++)
(*data)[pos] = eina_swap32(img[pos]);
return;
*data = malloc(len * sizeof(int));
for (pos = 0; pos < (unsigned int)len; pos++)
(*data)[pos] = eina_swap32(img[pos]);
}
}
}
}