From 6477962dc9c21d86ec00542dfc6abcc562d66fa0 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Sun, 17 May 2009 23:11:22 -0600 Subject: [PATCH] Added support for rending images by way of IMLIB2. --- ChangeLog | 1 + doc/variables.xml | 2 +- src/conky.c | 6 +++--- src/imlib2.c | 7 +++++-- src/imlib2.h | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a08ebbfa..2fba8bf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2009-05-17 * Added support for the Lua programming language + * Added support for rending images by way of IMLIB2 2009-05-11 * Added arguments to hwmon for value precalculation diff --git a/doc/variables.xml b/doc/variables.xml index dfabd8d4..48df5bfa 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -1048,7 +1048,7 @@ - Renders an image from the path specified using IMLIB2. Takes 2 optional arguments, one being a position, the other an size. Changing the x,y position will move the position of the image, and changing the WxH will scale the image. Example: ${image /home/brenden/cheeseburger.jpg -p 20,20 -s 200x200} will render 'cheeseburger.jpg' at (20,20) scaled to 200x200 pixels. + Renders an image from the path specified using IMLIB2. Takes 2 optional arguments, one being a position, the other an size. Changing the x,y position will move the position of the image, and changing the WxH will scale the image. Example: ${image /home/brenden/cheeseburger.jpg -p 20,20 -s 200x200} will render 'cheeseburger.jpg' at (20,20) scaled to 200x200 pixels. Conky does not make any attempt to adjust the position (or any other formatting) of images, they are just rendered as per the arguments passed. The only reason $image is part of the TEXT section, is to allow for runtime modifications, through $execp $lua_parse, $lua_read_parse, or some other method. diff --git a/src/conky.c b/src/conky.c index 81cbfe36..4a2fc9da 100644 --- a/src/conky.c +++ b/src/conky.c @@ -6660,12 +6660,12 @@ static void main_loop(void) XftDrawSetClip(window.xftdraw, region); } #endif +#ifdef IMLIB2 + cimlib_render(text_start_x + border_margin, text_start_y + border_margin, window.width, window.height); +#endif /* IMLIB2 */ draw_stuff(); XDestroyRegion(region); region = XCreateRegion(); -#ifdef IMLIB2 - cimlib_event_end(text_start_x + border_margin, text_start_y + border_margin, window.width, window.height); -#endif /* IMLIB2 */ } } else { #endif /* X11 */ diff --git a/src/imlib2.c b/src/imlib2.c index 4387b6d3..ff564fdc 100644 --- a/src/imlib2.c +++ b/src/imlib2.c @@ -118,7 +118,7 @@ static void cimlib_draw_image(struct image_list_s *cur) image = imlib_load_image(cur->name); if (image) { int w, h; - DBGP("Drawing image '%s'", cur->name); + DBGP("Drawing image '%s' at (%i,%i) scaled to %ix%i", cur->name, cur->x, cur->y, cur->w, cur->h); imlib_context_set_image(image); w = imlib_image_get_width(); h = imlib_image_get_height(); @@ -141,12 +141,15 @@ static void cimlib_draw_all(void) } } -void cimlib_event_end(int x, int y, int width, int height) +void cimlib_render(int x, int y, int width, int height) { if (!image_list_start) return; /* are we actually drawing anything? */ /* take all the little rectangles to redraw and merge them into * something sane for rendering */ buffer = imlib_create_image(width, height); + /* clear our buffer */ + imlib_context_set_image(buffer); + imlib_image_clear(); /* we can blend stuff now */ imlib_context_set_blend(1); diff --git a/src/imlib2.h b/src/imlib2.h index a276dd82..69b9d1cc 100644 --- a/src/imlib2.h +++ b/src/imlib2.h @@ -27,7 +27,7 @@ void cimlib_add_image(const char *name); void cimlib_set_cache_size(long size); void cimlib_init(Display *display, Window drawable, Visual *visual, Colormap colourmap); -void cimlib_event_end(int x, int y, int width, int height); +void cimlib_render(int x, int y, int width, int height); void cimlib_cleanup(void); #endif /* _CONKY_IMBLI2_H_ */