Fix imlib2 context.
authorBrenden Matthews <brenden@rty.ca>
Mon, 3 Aug 2009 18:39:44 +0000 (12:39 -0600)
committerBrenden Matthews <brenden@rty.ca>
Mon, 3 Aug 2009 18:39:44 +0000 (12:39 -0600)
src/conky.c
src/imlib2.c
src/imlib2.h

index 86bdbb9..da73332 100644 (file)
@@ -7787,6 +7787,9 @@ void clean_up(void *memtofree1, void* memtofree2)
        llua_shutdown_hook();
        llua_close();
 #endif /* HAVE_LUA */
+#ifdef IMLIB2
+       cimlib_deinit();
+#endif /* IMLIB2 */
 
        if (specials) {
                for (i = 0; i < special_count; i++) {
index 394da1f..fd72790 100644 (file)
@@ -86,9 +86,14 @@ void cimlib_cleanup(void)
        image_list_start = image_list_end = NULL;
 }
 
-void cimlib_init(Display *disp, Window drawable, Visual *visual, Colormap colourmap)
+Imlib_Context context;
+
+void cimlib_init(Display *disp, Window drawable, Visual *visual, Colormap
+               colourmap)
 {
        image_list_start = image_list_end = NULL;
+       context = imlib_context_new();
+       imlib_context_push(context);
        if (!cache_size_set) cimlib_set_cache_size(DEFAULT_IMLIB2_CACHE_SIZE);
        /* set the maximum number of colors to allocate for 8bpp and less to 256 */
        imlib_set_color_usage(256);
@@ -101,6 +106,15 @@ void cimlib_init(Display *disp, Window drawable, Visual *visual, Colormap colour
        imlib_context_set_drawable(drawable);
 }
 
+void cimlib_deinit(void)
+{
+       cimlib_cleanup();
+       cache_size_set = 0;
+       imlib_context_disconnect_display();
+       imlib_context_pop();
+       imlib_context_free(context);
+}
+
 void cimlib_add_image(const char *args)
 {
        struct image_list_s *cur = NULL;
@@ -110,7 +124,8 @@ void cimlib_add_image(const char *args)
        memset(cur, 0, sizeof(struct image_list_s));
 
        if (!sscanf(args, "%1023s", cur->name)) {
-               NORM_ERR("Invalid args for $image.  Format is: '<path to image> (-p x,y) (-s WxH) (-n) (-f interval)' (got '%s')", args);
+               NORM_ERR("Invalid args for $image.  Format is: '<path to image> (-p"
+                               "x,y) (-s WxH) (-n) (-f interval)' (got '%s')", args);
                free(cur);
                return;
        }
@@ -154,9 +169,8 @@ void cimlib_add_image(const char *args)
        }
 }
 
-static void
-cimlib_draw_image(struct image_list_s *cur, int *clip_x,
-                       int *clip_y, int *clip_x2, int *clip_y2)
+static void cimlib_draw_image(struct image_list_s *cur, int *clip_x, int
+               *clip_y, int *clip_x2, int *clip_y2)
 {
        int w, h;
        time_t now = time(NULL);
index f36aac8..747571c 100644 (file)
@@ -30,6 +30,7 @@ void cimlib_add_image(const char *name);
 void cimlib_set_cache_size(long size);
 void cimlib_set_cache_flush_interval(long interval);
 void cimlib_init(Display *display, Window drawable, Visual *visual, Colormap colourmap);
+void cimlib_deinit(void);
 void cimlib_render(int x, int y, int width, int height);
 void cimlib_cleanup(void);