aboutsummaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-20 21:44:34 +0100
committerBert <ber.t@gmx.com>2011-01-20 21:44:34 +0100
commit029e1208b91250f4bd91ecc2015d051294fb9d3f (patch)
treec746d1a81e7babb17283d2326bdd2dea310eb4ed /image.c
parent08018427c61435de9cd8dca1d1cc9bb69ca2fd74 (diff)
downloadnsxiv-029e1208b91250f4bd91ecc2015d051294fb9d3f.tar.zst
No more expose handling
Diffstat (limited to 'image.c')
-rw-r--r--image.c41
1 files changed, 20 insertions, 21 deletions
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);
}