Added support for rending images by way of IMLIB2.
authorBrenden Matthews <brenden@rty.ca>
Mon, 18 May 2009 05:11:22 +0000 (23:11 -0600)
committerBrenden Matthews <brenden@rty.ca>
Mon, 18 May 2009 05:11:22 +0000 (23:11 -0600)
ChangeLog
doc/variables.xml
src/conky.c
src/imlib2.c
src/imlib2.h

index a08ebbf..2fba8bf 100644 (file)
--- 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
index dfabd8d..48df5bf 100644 (file)
                        <option>&lt;path to image&gt; (-p x,y) (-s WxH)</option>
                </term>
                <listitem>
-                       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.
                        <para></para></listitem>
        </varlistentry>
 
index 81cbfe3..4a2fc9d 100644 (file)
@@ -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 */
index 4387b6d..ff564fd 100644 (file)
@@ -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);
 
index a276dd8..69b9d1c 100644 (file)
@@ -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_ */