wdvi

network DVI viewer
Log | Files | Refs

commit bf2784da4a1cf916804f96f561d08e7ac563d445
parent 4480e73bfd3d9fc2428dcf37161d805698f71322
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Thu,  9 Mar 2023 01:16:47 +0000

clean up put_image()

- ansi function prototype
- early return

Diffstat:
Mdvi-draw.c | 30++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/dvi-draw.c b/dvi-draw.c @@ -146,31 +146,29 @@ put_bitmap(struct bitmap *bitmap, int x, int y) static void shrink_glyph_grey(struct glyph *); static void -put_image(g, x, y) - struct glyph *g; - int x, y; +put_image(struct glyph *g, int x, int y) { XImage *img = g->image2; - if (x < max_x && x + img->width >= min_x && - y < max_y && y + img->height >= min_y) { + if (x >= max_x || x + img->width < min_x || + y >= max_y || y + img->height < min_y) + return; - if (g->fg != fg_current) /* if color change since last use */ + if (g->fg != fg_current) /* if color change since last use */ shrink_glyph_grey(g); - else if (fg_active != fg_current) /* if GCs need updating */ + else if (fg_active != fg_current) /* if GCs need updating */ do_color_change(); - XPutImage(DISP, currwin.win, foreGC, img, - 0, 0, - x - currwin.base_x, y - currwin.base_y, - (unsigned int) img->width, (unsigned int) img->height); - if (foreGC2 != NULL) { + XPutImage(DISP, currwin.win, foreGC, img, + 0, 0, + x - currwin.base_x, y - currwin.base_y, + (unsigned int) img->width, (unsigned int) img->height); + if (foreGC2 != NULL) { img->data = g->pixmap2_t; XPutImage(DISP, currwin.win, foreGC2, img, - 0, 0, - x - currwin.base_x, y - currwin.base_y, - (unsigned int) img->width, (unsigned int) img->height); + 0, 0, + x - currwin.base_x, y - currwin.base_y, + (unsigned int) img->width, (unsigned int) img->height); img->data = g->pixmap2; - } } }