From 029e1208b91250f4bd91ecc2015d051294fb9d3f Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 20 Jan 2011 21:44:34 +0100 Subject: No more expose handling --- image.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'image.c') diff --git a/image.c b/image.c index 7b0df5d..c98c310 100644 --- a/image.c +++ b/image.c @@ -31,7 +31,6 @@ void imlib_init(win_t *win) { imlib_context_set_display(win->env.dpy); imlib_context_set_visual(win->env.vis); imlib_context_set_colormap(win->env.cmap); - imlib_context_set_drawable(win->xwin); } void imlib_destroy() { @@ -86,43 +85,43 @@ void img_display(img_t *img, win_t *win) { img->x = (win->w - img->w * img->zoom) / 2; img->y = (win->h - img->h * img->zoom) / 2; - win_clear(win); - - img_render(img, win, 0, 0, win->w, win->h); + img_render(img, win); } -void img_render(img_t *img, win_t *win, int x, int y, int w, int h) { +void img_render(img_t *img, win_t *win) { int sx, sy, sw, sh; int dx, dy, dw, dh; if (!img || !win || !imlib_context_get_image()) return; - if (img->x < x) { - sx = (x - img->x) / img->zoom; - sw = MIN(w / img->zoom, img->w - sx); - dx = x; - dw = sw * img->zoom; + if (img->x < 0) { + sx = -img->x / img->zoom; + sw = win->w / img->zoom; + dx = 0; + dw = win->w; } else { sx = 0; - sw = MIN((w - img->x + x) / img->zoom, img->w); + sw = img->w; dx = img->x; - dw = sw * img->zoom; + dw = img->w * img->zoom; } - if (img->y < y) { - sy = (y - img->y) / img->zoom; - sh = MIN(h / img->zoom, img->h - sy); - dy = y; - dh = sh * img->zoom; + if (img->y < 0) { + sy = -img->y / img->zoom; + sh = win->h / img->zoom; + dy = 0; + dh = win->h; } else { sy = 0; - sh = MIN((h - img->y + y) / img->zoom, img->h); + sh = img->h; dy = img->y; - dh = sh * img->zoom; + dh = img->h * img->zoom; } - if (sw < 0 || sh < 0) - return; + win_clear(win); + imlib_context_set_drawable(win->pm); imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh); + + win_draw(win); } -- cgit v1.2.3-54-g00ecf