From: Brenden Matthews Date: Mon, 3 Aug 2009 18:39:44 +0000 (-0600) Subject: Fix imlib2 context. X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=51ddee12ddad1cb3b00d8a29516c10869a8ac9e4;p=monky Fix imlib2 context. --- diff --git a/src/conky.c b/src/conky.c index 86bdbb9..da73332 100644 --- a/src/conky.c +++ b/src/conky.c @@ -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++) { diff --git a/src/imlib2.c b/src/imlib2.c index 394da1f..fd72790 100644 --- a/src/imlib2.c +++ b/src/imlib2.c @@ -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: ' (-p x,y) (-s WxH) (-n) (-f interval)' (got '%s')", args); + NORM_ERR("Invalid args for $image. Format is: ' (-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); diff --git a/src/imlib2.h b/src/imlib2.h index f36aac8..747571c 100644 --- a/src/imlib2.h +++ b/src/imlib2.h @@ -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);