mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 11:12:49 +00:00
SNI: Gracefully handle empty IconPixmap
An empty pixmap caused extreme flickering. https://github.com/scorpion-26/gBar/issues/38
This commit is contained in:
parent
b246e9fad4
commit
a15bb1e17e
1 changed files with 41 additions and 32 deletions
11
src/SNI.cpp
11
src/SNI.cpp
|
@ -78,6 +78,8 @@ namespace SNI
|
||||||
// g_variant_unref(param);
|
// g_variant_unref(param);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool hasPixmap = false;
|
||||||
GVariant* iconPixmap = getProperty("IconPixmap");
|
GVariant* iconPixmap = getProperty("IconPixmap");
|
||||||
if (iconPixmap)
|
if (iconPixmap)
|
||||||
{
|
{
|
||||||
|
@ -88,6 +90,8 @@ namespace SNI
|
||||||
GVariantIter* arrIter = nullptr;
|
GVariantIter* arrIter = nullptr;
|
||||||
g_variant_get(arr, "a(iiay)", &arrIter);
|
g_variant_get(arr, "a(iiay)", &arrIter);
|
||||||
|
|
||||||
|
if (g_variant_iter_n_children(arrIter) == 3)
|
||||||
|
{
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
GVariantIter* data = nullptr;
|
GVariantIter* data = nullptr;
|
||||||
|
@ -122,10 +126,15 @@ namespace SNI
|
||||||
|
|
||||||
g_variant_iter_free(data);
|
g_variant_iter_free(data);
|
||||||
g_variant_iter_free(arrIter);
|
g_variant_iter_free(arrIter);
|
||||||
|
|
||||||
|
hasPixmap = true;
|
||||||
|
}
|
||||||
g_variant_unref(arr);
|
g_variant_unref(arr);
|
||||||
g_variant_unref(iconPixmap);
|
g_variant_unref(iconPixmap);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Pixmap querying has failed, try IconName
|
||||||
|
if (!hasPixmap)
|
||||||
{
|
{
|
||||||
auto findIconWithoutPath = [](const char* iconName) -> std::string
|
auto findIconWithoutPath = [](const char* iconName) -> std::string
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue