Currently, we just skipped the notification comparison, if the
notification had a raw icon attached. This is a bit counterintuitive.
Calculating a checksum of the raw icon's data is the solution.
For that we cache the pixel buffer and introduce a field, which saves
the current icon's id. The icon_id may be a path or a hash.
So you can compare two notifications by their icon_id field regardless
of their icon type by their icon_id field.
Just recently, I started using g_return_val_if_fail as a brief assertion
checker. It'll also exit the function with a specified return value.
But actually this introduces some weird behavior. It's configurable by
environment variables and it'll print out a log message, if the
expression didn't validate properly. But some of these assertions are
actually ment to be silent.
Using a simple macro makes it simple to structure the assertions and its
return values in a block at the start of a function or anywhere else.
As already noted in the code comment, we all knew that the in memory
conversion to a PNG stream is a cumbersome technique. But it was worth
to remove the GTK dependency.
After finding out, that gdk_pixbuf_new_from_data can actually use a
GVariant and share its memory without allocating new memory, I poked
the cairo docs for a similar technique.
There is cairo_image_surface_create_for_data, which would achieve the
same, but cairo uses another color byte order. So we have to manually
copy and reassemble the bytes.
It may look like a big rise in complexity, but actually, it's straight
forward copying pixel by pixel and changing the byte's order.
And the gdk_pixbuf_to_cairo_surface is 33x faster.
As the get_pixbuf_from_file should retrieve a file's content, it
shouldn't fail silently, if the file isn't there.
For codepaths, which don't use the `icon_path` to search for a given
icon, it gives a clearer error message.
The icon_path has no point for searching an absolute filename. It was
actually meant to avoid the complex lookup algorithm of the icon theme
spec. And the iconname in this case should be actually just the icon's
basename when searching the path.
Concatenating icons like `~/testimg.png` with all icon paths has no
point and also an additional suffix has no point.
Cleans up the clutter in draw and since only a single icon function is
called externally from icon.c it'll make things easier if we ever decide
to switch icon libraries.
Rename both functions to make clear, what the difference between the
previous functions _from_file and _from_path is. Also remove the
superfluous `== NULL` checks as these don't match dunst's current style.