1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-06-02 07:20:47 +00:00

Add config option to disable blending (#682)

* Add config option to disable blending

This is intended to work around issues with some images blending incorrectly with ARGB visuals.

* Fix order of config documentation.

* Update configuration variable name to simply "draw_blended".

* Fix for SonarCloud malloc warning.

* Update free to delete as part of malloc change.
This commit is contained in:
Dan McCombs 2018-12-02 11:29:33 -05:00 committed by Brenden Matthews
parent 8d149471b5
commit c1ef8c5cd4
2 changed files with 26 additions and 4 deletions

View File

@ -254,6 +254,18 @@
double buffer won't be so big.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>draw_blended</option>
</command>
</term>
<listitem>Boolean, blend when rendering drawn image?
Some images blend incorrectly breaking alpha with ARBG visuals. This
provides a possible work around by disabling blending. Defaults to
true.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>

View File

@ -61,6 +61,9 @@ conky::range_config_setting<unsigned int> imlib_cache_flush_interval(
0, true);
unsigned int cimlib_cache_flush_last = 0;
conky::simple_config_setting<bool> draw_blended(
"draw_blended", true, true);
} // namespace
void imlib_cache_size_setting::lua_setter(lua::state &l, bool init) {
@ -112,7 +115,7 @@ void cimlib_add_image(const char *args) {
struct image_list_s *cur = nullptr;
const char *tmp;
cur = static_cast<struct image_list_s *>(malloc(sizeof(struct image_list_s)));
cur = new struct image_list_s[sizeof(struct image_list_s)];
memset(cur, 0, sizeof(struct image_list_s));
if (sscanf(args, "%1023s", cur->name) == 0) {
@ -120,7 +123,7 @@ void cimlib_add_image(const char *args) {
"Invalid args for $image. Format is: '<path to image> (-p"
"x,y) (-s WxH) (-n) (-f interval)' (got '%s')",
args);
free(cur);
delete [] cur;
return;
}
strncpy(cur->name, to_real_path(cur->name).c_str(), 1024);
@ -259,8 +262,15 @@ void cimlib_render(int x, int y, int width, int height) {
/* clear our buffer */
imlib_context_set_image(buffer);
imlib_image_clear();
/* we can blend stuff now */
imlib_context_set_blend(1);
/* check if we should blend when rendering */
if (draw_blended.get(*state)) {
/* we can blend stuff now */
imlib_context_set_blend(1);
} else {
imlib_context_set_blend(0);
}
/* turn alpha channel on */
imlib_image_set_has_alpha(1);