some imlib2 work
authorBrenden Matthews <brenden@rty.ca>
Thu, 19 Mar 2009 04:02:25 +0000 (22:02 -0600)
committerBrenden Matthews <brenden@rty.ca>
Thu, 19 Mar 2009 04:02:25 +0000 (22:02 -0600)
configure.ac.in
src/conky.c
src/x11.c

index 9ec2fe5..b6002cb 100644 (file)
@@ -321,18 +321,17 @@ dnl
 dnl IMLIB2
 dnl
 
-dnl --commented out until brenden finishes it --
-dnl AC_ARG_ENABLE([imlib2],
-dnl    AC_HELP_STRING([--enable-imlib2], [enable if you want Imlib2 support [[default=no]]]),
-dnl    [want_imlib2="$enableval"], [want_imlib2=no])
-dnl
-dnl AM_CONDITIONAL(BUILD_IMLIB2, test x$want_imlib2 = xyes)
-dnl if test x$want_imlib2 = xyes; then
-dnl PKG_CHECK_MODULES([Imlib2], [imlib2])
-dnl CFLAGS="$CFLAGS $Imlib2_CFLAGS"
-dnl LIBS="$LIBS $Imlib2_LIBS"
-dnl AC_DEFINE(IMLIB2, 1, [Define if you want Imlib2 support])
-dnl fi
+AC_ARG_ENABLE([imlib2],
+                         AC_HELP_STRING([--enable-imlib2], [enable if you want Imlib2 support [[default=no]]]),
+                         [want_imlib2="$enableval"], [want_imlib2=no])
+
+AM_CONDITIONAL(BUILD_IMLIB2, test x$want_imlib2 = xyes)
+if test x$want_imlib2 = xyes; then
+       PKG_CHECK_MODULES([Imlib2], [imlib2])
+       CFLAGS="$CFLAGS $Imlib2_CFLAGS"
+       LIBS="$LIBS $Imlib2_LIBS"
+       AC_DEFINE(IMLIB2, 1, [Define if you want Imlib2 support])
+fi
 
 
 dnl
@@ -732,4 +731,5 @@ $PACKAGE $VERSION configured successfully:
   nvidia:           $want_nvidia
   eve-online:       $want_eve
   config-output:    $want_config_output
+  IMLIB2:           $want_imlib2
 EOF
index 924c21a..b4efb63 100644 (file)
@@ -203,13 +203,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 */
        );
 
        exit(0);
@@ -3490,27 +3493,19 @@ static void generate_text_internal(char *p, int p_max_size,
                                        Imlib_Image image, buffer;
 
                                        image = imlib_load_image(obj->data.s);
-                                       imlib_context_set_image(image);
                                        if (image) {
                                                int w, h;
+                                               imlib_context_set_image(image);
 
                                                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();
                                        }
                                }
                        }
index ee59e68..9ed7d6d 100644 (file)
--- a/src/x11.c
+++ b/src/x11.c
@@ -35,6 +35,9 @@
 #include <X11/Xatom.h>
 #include <X11/Xmd.h>
 #include <X11/Xutil.h>
+#ifdef IMLIB2
+#include <Imlib2.h>
+#endif /* IMLIB2 */
 
 #ifdef XFT
 #include <X11/Xft/Xft.h>
@@ -47,6 +50,11 @@ int use_xdbe;
 
 /* some basic X11 stuff */
 Display *display;
+#ifdef IMLIB2
+Visual  *visual;
+Colormap colourmap;
+int depth;
+#endif /* IMLIB2 */
 int display_width;
 int display_height;
 int screen;
@@ -418,9 +426,10 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
                fflush(stderr);
 
                XMapWindow(display, window.window);
+
        } else /* if (own_window) { */
 #endif
-       /* root / desktop window */
+               /* root / desktop window */
        {
                XWindowAttributes attrs;
 
@@ -463,7 +472,25 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour,
                fprintf(stderr, PACKAGE_NAME": drawing to single buffer\n");
        }
 #endif
-
+#ifdef IMLIB2
+       visual = DefaultVisual(display, DefaultScreen(display));
+       depth = DefaultDepth(display, DefaultScreen(display));
+       colourmap = DefaultColormap(display, DefaultScreen(display));
+       /* set our cache to 4MiB so it doesn't have to go hit the disk as long as */
+       /* the images we use use less than 4MiB of RAM (that is uncompressed) */
+       imlib_set_cache_size(4092 * 1024);
+       /* set the font cache to 512KiB - again to avoid re-loading */
+       imlib_set_font_cache_size(512 * 1024);
+       /* set the maximum number of colors to allocate for 8bpp and less to 128 */
+       imlib_set_color_usage(128);
+       /* dither for depths < 24bpp */
+       imlib_context_set_dither(1);
+       /* set the display , visual, colormap and drawable we are using */
+       imlib_context_set_display(display);
+       imlib_context_set_visual(visual);
+       imlib_context_set_colormap(colourmap);
+       imlib_context_set_drawable(window.drawable);
+#endif /* IMLIB2 */
        XFlush(display);
 
        /* set_transparent_background(window.window);