Merge branch 'master' into imlib2
[monky] / src / conky.c
index 1ff323f..edbe90b 100644 (file)
@@ -49,7 +49,7 @@
 #include <X11/extensions/Xdamage.h>
 #endif
 #ifdef IMLIB2
-#include <Imlib2.h>
+#include "imlib2.h"
 #endif /* IMLIB2 */
 #endif /* X11 */
 #include <sys/types.h>
@@ -204,13 +204,16 @@ static void print_version(void)
 #endif /* IBM */
 #ifdef NVIDIA
                   "  * nvidia\n"
-#endif
+#endif /* NVIDIA */
 #ifdef EVE
                   "  * eve-online\n"
 #endif /* EVE */
 #ifdef CONFIG_OUTPUT
                   "  * config-output\n"
 #endif /* CONFIG_OUTPUT */
+#ifdef IMLIB2
+                  "  * IMLIB2\n"
+#endif /* IMLIB2 */
 #ifdef MIXER_IS_ALSA
                   "  * ALSA mixer support\n"
 #endif /* MIXER_IS_ALSA */
@@ -3677,41 +3680,13 @@ static void generate_text_internal(char *p, int p_max_size,
                                         strcpy(p, "0.0.0.0");
            }
 #endif /* __linux__ */
-
 #if defined(IMLIB2) && defined(X11)
                        OBJ(image) {
-                               if (obj->a < 1) {
-                                       obj->a++;
-                               } else {
-                                       Imlib_Image image, buffer;
-
-                                       image = imlib_load_image(obj->data.s);
-                                       imlib_context_set_image(image);
-                                       if (image) {
-                                               int w, h;
-
-                                               w = imlib_image_get_width();
-                                               h = imlib_image_get_height();
-                                               buffer = imlib_create_image(w, h);
-                                               imlib_context_set_display(display);
-                                               imlib_context_set_drawable(window.drawable);
-                                               imlib_context_set_colormap(DefaultColormap(display,
-                                                       screen));
-                                               imlib_context_set_visual(DefaultVisual(display,
-                                                       screen));
-                                               imlib_context_set_image(buffer);
-                                               imlib_blend_image_onto_image(image, 0, 0, 0, w, h,
-                                                       text_start_x, text_start_y, w, h);
-                                               imlib_render_image_on_drawable(text_start_x,
-                                                       text_start_y);
-                                               imlib_free_image();
-                                               imlib_context_set_image(image);
-                                               imlib_free_image();
-                                       }
-                               }
+                               /* doesn't actually draw anything, just queues it omp.  the
+                                * image will get drawn after the X event loop */
+                               cimlib_add_image(obj->data.s); 
                        }
 #endif /* IMLIB2 */
-
                        OBJ(eval) {
                                struct information *tmp_info;
                                struct text_object subroot, subroot2;
@@ -6170,6 +6145,9 @@ static int need_to_update;
 /* update_text() generates new text and clears old text area */
 static void update_text(void)
 {
+#ifdef IMLIB2
+       cimlib_cleanup();
+#endif /* IMLIB2 */
        generate_text();
 #ifdef X11
        if (output_methods & TO_X)
@@ -6227,6 +6205,10 @@ static void main_loop(void)
                if (output_methods & TO_X) {
                        XFlush(display);
 
+#ifdef IMLIB2
+                       cimlib_event_start();
+#endif /* IMLIB2 */
+
                        /* wait for X event or timeout */
 
                        if (!XPending(display)) {
@@ -6319,6 +6301,9 @@ static void main_loop(void)
                                                r.width = ev.xexpose.width;
                                                r.height = ev.xexpose.height;
                                                XUnionRectWithRegion(&r, region, region);
+#ifdef IMLIB2
+                                               cimlib_event_expose(&ev);
+#endif /* IMLIB2 */
                                                break;
                                        }
 
@@ -6459,6 +6444,9 @@ static void main_loop(void)
                                }
 #endif
                                draw_stuff();
+#ifdef IMLIB2
+                               cimlib_event_end(/*window.x, window.y, */0, 0, window.width, window.height);
+#endif /* IMLIB2 */
                                XDestroyRegion(region);
                                region = XCreateRegion();
                        }
@@ -6632,6 +6620,7 @@ static void clean_up(void)
                XFreeGC(display, window.gc);
                free_fonts();
        }
+
 #endif /* X11 */
 
        free_text_objects(&global_root_object);
@@ -7488,6 +7477,11 @@ static void load_config_file(const char *f)
                                stippled_borders = 4;
                        }
                }
+               CONF("imlib_cache_size") {
+                       if (value) {
+                               cimlib_set_cache_size(atoi(value));
+                       }
+               }
 #endif /* X11 */
                CONF("update_interval") {
                        if (value) {