From b99ba046d12e8bfff5f6083f80fe4e6f40fe0c2b Mon Sep 17 00:00:00 2001 From: Lance Colton Date: Sat, 14 Jan 2012 01:12:44 -0700 Subject: [PATCH] imlib2 fixed, i forgot when the window size changes we totally destroy the pixmap back buffer, so we need to init imlib2 again so it gets a fresh pointer to it --- src/conky.c | 13 ++++++++++++- src/imlib2.c | 50 +------------------------------------------------- src/imlib2.h | 3 +-- src/x11.c | 2 +- 4 files changed, 15 insertions(+), 53 deletions(-) diff --git a/src/conky.c b/src/conky.c index 7f5ec00..53fd918 100644 --- a/src/conky.c +++ b/src/conky.c @@ -3656,7 +3656,12 @@ static void main_loop(void) else { window.drawable = window.window; use_xdbe = 0; - } + } +#ifdef IMLIB2 + { + cimlib_init(display, window.drawable, window.visual, window.colourmap); + } +#endif /* IMLIB2 */ } #endif set_transparent_background(window.window, own_window_argb_value); @@ -3797,6 +3802,12 @@ static void main_loop(void) window.drawable = window.window; use_xdbe = 0; } +#ifdef IMLIB2 + { + cimlib_init(display, window.drawable, window.visual, window.colourmap); + } +#endif /* IMLIB2 */ + } #endif } diff --git a/src/imlib2.c b/src/imlib2.c index 6af0c71..0ffce8c 100644 --- a/src/imlib2.c +++ b/src/imlib2.c @@ -61,14 +61,12 @@ static int cimlib_cache_flush_last = 0; void cimlib_set_cache_size(long size) { - fprintf(stderr, PACKAGE_NAME": cimlib_set_cache_size start\n"); imlib_set_cache_size(size); cache_size_set = 1; } void cimlib_set_cache_flush_interval(long interval) { - fprintf(stderr, PACKAGE_NAME": cimlib_set_cache_flush_interval start\n"); if (interval >= 0) { cimlib_cache_flush_interval = interval; } else { @@ -78,7 +76,6 @@ void cimlib_set_cache_flush_interval(long interval) void cimlib_cleanup(void) { - fprintf(stderr, PACKAGE_NAME": cimlib_cleanup start\n"); struct image_list_s *cur = image_list_start, *last = NULL; while (cur) { last = cur; @@ -90,30 +87,10 @@ void cimlib_cleanup(void) Imlib_Context context; -void cimlib_init(Display *disp, Window drawable, Visual *visual, Colormap - colourmap) -{ - fprintf(stderr, PACKAGE_NAME": cimlib_init start\n"); - 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); - /* dither for depths < 24bpp */ - imlib_context_set_dither(1); - /* set the display , visual, colormap and drawable we are using */ - imlib_context_set_display(disp); - imlib_context_set_visual(visual); - imlib_context_set_colormap(colourmap); - imlib_context_set_drawable(drawable); - fprintf(stderr, PACKAGE_NAME": cimlib_init okay\n"); -} -void cimlib_initp(Display *disp, Pixmap drawable, Visual *visual, Colormap +void cimlib_init(Display *disp, Drawable drawable, Visual *visual, Colormap colourmap) { - fprintf(stderr, PACKAGE_NAME": cimlib_initp start\n"); image_list_start = image_list_end = NULL; context = imlib_context_new(); imlib_context_push(context); @@ -127,23 +104,19 @@ void cimlib_initp(Display *disp, Pixmap drawable, Visual *visual, Colormap imlib_context_set_visual(visual); imlib_context_set_colormap(colourmap); imlib_context_set_drawable(drawable); - fprintf(stderr, PACKAGE_NAME": cimlib_initp okay\n"); } void cimlib_deinit(void) { - fprintf(stderr, PACKAGE_NAME": cimlib_deinit start\n"); cimlib_cleanup(); cache_size_set = 0; // imlib_context_disconnect_display(); imlib_context_pop(); imlib_context_free(context); - fprintf(stderr, PACKAGE_NAME": cimlib_deinit okay\n"); } void cimlib_add_image(const char *args) { - fprintf(stderr, PACKAGE_NAME": cimlib_add_image start\n"); struct image_list_s *cur = NULL; char *tmp; @@ -194,13 +167,11 @@ void cimlib_add_image(const char *args) } else { image_list_start = image_list_end = cur; } - fprintf(stderr, PACKAGE_NAME": cimlib_add_image okay\n"); } static void cimlib_draw_image(struct image_list_s *cur, int *clip_x, int *clip_y, int *clip_x2, int *clip_y2) { - fprintf(stderr, PACKAGE_NAME": cimlib_draw_image start\n"); int w, h; time_t now = time(NULL); static int rep = 0; @@ -242,23 +213,19 @@ static void cimlib_draw_image(struct image_list_s *cur, int *clip_x, int if (cur->y < *clip_y) *clip_y = cur->y; if (cur->x + cur->w > *clip_x2) *clip_x2 = cur->x + cur->w; if (cur->y + cur->h > *clip_y2) *clip_y2 = cur->y + cur->h; - fprintf(stderr, PACKAGE_NAME": cimlib_draw_image okay\n"); } static void cimlib_draw_all(int *clip_x, int *clip_y, int *clip_x2, int *clip_y2) { - fprintf(stderr, PACKAGE_NAME": cimlib_draw_all start\n"); struct image_list_s *cur = image_list_start; while (cur) { cimlib_draw_image(cur, clip_x, clip_y, clip_x2, clip_y2); cur = cur->next; } - fprintf(stderr, PACKAGE_NAME": cimlib_draw_all okay\n"); } void cimlib_render(int x, int y, int width, int height) { - int clip_x = INT_MAX, clip_y = INT_MAX; int clip_x2 = 0, clip_y2 = 0; time_t now; @@ -274,42 +241,27 @@ void cimlib_render(int x, int y, int width, int height) cimlib_cache_flush_last = now; DBGP("Flushing Imlib2 cache (%li)\n", now); } - fprintf(stderr, PACKAGE_NAME": render1\n"); /* take all the little rectangles to redraw and merge them into * something sane for rendering */ buffer = imlib_create_image(width, height); - fprintf(stderr, PACKAGE_NAME": render2\n"); /* clear our buffer */ imlib_context_set_image(buffer); - fprintf(stderr, PACKAGE_NAME": render3\n"); imlib_image_clear(); - fprintf(stderr, PACKAGE_NAME": render4\n"); /* we can blend stuff now */ imlib_context_set_blend(1); - fprintf(stderr, PACKAGE_NAME": render5\n"); /* turn alpha channel on */ imlib_image_set_has_alpha(1); - fprintf(stderr, PACKAGE_NAME": rende6\n"); - cimlib_draw_all(&clip_x, &clip_y, &clip_x2, &clip_y2); - fprintf(stderr, PACKAGE_NAME": render7\n"); - /* set the buffer image as our current image */ imlib_context_set_image(buffer); - fprintf(stderr, PACKAGE_NAME": render8\n"); - /* setup our clip rect */ if (clip_x == INT_MAX) clip_x = 0; if (clip_y == INT_MAX) clip_y = 0; - fprintf(stderr, PACKAGE_NAME": render9\n"); - /* render the image at 0, 0 */ imlib_render_image_part_on_drawable_at_size(clip_x, clip_y, clip_x2 - clip_x, clip_y2 - clip_y, x + clip_x, y + clip_y, clip_x2 - clip_x, clip_y2 - clip_y); - fprintf(stderr, PACKAGE_NAME": render10\n"); /* don't need that temporary buffer image anymore */ imlib_free_image(); - fprintf(stderr, PACKAGE_NAME": cimlib_render okay\n"); } diff --git a/src/imlib2.h b/src/imlib2.h index 3bb17cb..7eceeee 100644 --- a/src/imlib2.h +++ b/src/imlib2.h @@ -29,8 +29,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_initp(Display *display, Pixmap drawable, Visual *visual, Colormap colourmap); +void cimlib_init(Display *display, Drawable drawable, Visual *visual, Colormap colourmap); void cimlib_deinit(void); void cimlib_render(int x, int y, int width, int height); void cimlib_cleanup(void); diff --git a/src/x11.c b/src/x11.c index cb3bda9..024fd20 100644 --- a/src/x11.c +++ b/src/x11.c @@ -578,7 +578,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, #endif #ifdef IMLIB2 { - cimlib_init(display, window.drawable, window.visual, window.colourmap); + cimlib_init(display, window.drawable, window.visual, window.colourmap); } #endif /* IMLIB2 */ XFlush(display); -- 1.7.9.5