SNI: Gracefully handle empty IconPixmap

An empty pixmap caused extreme flickering.
https://github.com/scorpion-26/gBar/issues/38
This commit is contained in:
scorpion-26 2023-08-22 22:30:38 +02:00
parent b246e9fad4
commit a15bb1e17e

View file

@ -78,6 +78,8 @@ namespace SNI
// g_variant_unref(param);
return res;
};
bool hasPixmap = false;
GVariant* iconPixmap = getProperty("IconPixmap");
if (iconPixmap)
{
@ -88,6 +90,8 @@ namespace SNI
GVariantIter* arrIter = nullptr;
g_variant_get(arr, "a(iiay)", &arrIter);
if (g_variant_iter_n_children(arrIter) == 3)
{
int width;
int height;
GVariantIter* data = nullptr;
@ -122,10 +126,15 @@ namespace SNI
g_variant_iter_free(data);
g_variant_iter_free(arrIter);
hasPixmap = true;
}
g_variant_unref(arr);
g_variant_unref(iconPixmap);
}
else
// Pixmap querying has failed, try IconName
if (!hasPixmap)
{
auto findIconWithoutPath = [](const char* iconName) -> std::string
{