rem: max_width = (int)floor((dmax_x - dmin_x + IMG_EXTRA) *
add: max_width = (int)floor((dmax_x - dmin_x) *
context: redraw_pixmap(GtkWidget *widget){    int i;    double dmax_x = LONG_MIN, dmax_y = LONG_MIN;    double dmin_x = LONG_MAX, dmin_y = LONG_MAX;    int max_width = 0, max_height = 0;    GdkGC *gc = gdk_gc_new(widget->window);    GdkRectangle update_rect;    int file_loaded = 0;    GdkWindow *window;    GdkPixmap *curr_pixmap;    GdkPixmap *clipmask;    int retval = TRUE;    window = gtk_widget_get_parent_window(widget);    /* This might be lengthy, show that we're busy by changing the pointer */    if (window) {	GdkCursor *cursor;	cursor = gdk_cursor_new(GDK_WATCH);	gdk_window_set_cursor(window, cursor);	gdk_cursor_destroy(cursor);    }    /* Called first when opening window and then when resizing window */    for(i = 0; i < MAX_FILES; i++) {	if (g_main_pending()) {	    /* Set idle function to ensure we wont miss to redraw */	    start_idle_redraw_pixmap(screen.drawing_area);	    goto redraw_pixmap_end;	}	if (screen.file[i]) {	    file_loaded = 1;	}    }    /*     * Paranoia check; size in width or height is zero     */    if (!file_loaded) {	retval = FALSE;	goto redraw_pixmap_end;    }    /*     * Setup scale etc first time we load a file     */    if (file_loaded && screen.scale == 0) autoscale();    /*     * Find the biggest image and use as a size reference     */    dmax_x = screen.gerber_bbox.x2;    dmax_y = screen.gerber_bbox.y2;    /*     * Also find the smallest coordinates to see if we have negative     * ones that must be compensated for.     */    dmin_x = screen.gerber_bbox.x1;    dmin_y = screen.gerber_bbox.y1;    /*     * Scale width to actual windows size. Make picture a little bit      * bigger so things on the edges comes inside. Actual width is     * abs(max) + abs(min) -> max - min. Same with height.     */    max_width = (int)floor((dmax_x - dmin_x + IMG_EXTRA) * 			   (double)screen.scale);    max_height = (int)floor((dmax_y - dmin_y + IMG_EXTRA) * 			    (double)screen.scale);    /*      * Remove old pixmap, allocate a new one, draw the background and set     * superimposing function.     */    if (screen.pixmap) 	gdk_pixmap_unref(screen.pixmap);    screen.pixmap = gdk_pixmap_new(widget->window, max_width, max_height,  -1);    gdk_gc_set_foreground(gc, screen.background);    gdk_draw_rectangle(screen.pixmap, gc, TRUE, 0, 0, -1, -1);    gdk_gc_set_function(gc, screen.si_func);    /*     * Allocate the pixmap and the clipmask (a one pixel pixmap)     */    curr_pixmap = gdk_pixmap_new(widget->window, max_width, max_height,  -1);    clipmask = gdk_pixmap_new(widget->window, max_width, max_height,  1);    /*      * This now allows drawing several layers on top of each other.     * Higher layer numbers have higher priority in the Z-order.      */    for(i = 0; i < MAX_FILES; i++) {	/* Do some events so we don't lag to much behind */	gtk_main_iteration_do(FALSE);	if (g_main_pending()) {	    /* Set idle function to ensure we wont miss to redraw */	    start_idle_redraw_pixmap(screen.drawing_area);	    goto redraw_pixmap_end;	}	if (GTK_TOGGLE_BUTTON(screen.layer_button[i])->active &&	    screen.file[i]) {	    /*	     * Fill up image with all the foreground color. Excess pixels	     * will be removed by clipmask.	     */	    gdk_gc_set_foreground(gc, screen.file[i]->color);	    gdk_draw_rectangle(curr_pixmap, gc, TRUE, 0, 0, -1, -1);	    /*	     * Translation is to get it inside the allocated pixmap,	     * which is not always centered perfectly for GTK/X.	     */	    image2pixmap(&clipmask, screen.file[i]->image, screen.scale, 			 -dmin_x * screen.scale,dmax_y * screen.scale,			 screen.file[i]->image->info->polarity);	    /* 	     * Set clipmask and draw the clipped out image onto the	     * screen pixmap. Afterwards we remove the clipmask, else	     * it will screw things up when run this loop again.	     */	    gdk_gc_set_clip_mask(gc, clipmask);	    gdk_gc_set_clip_origin(gc, 0, 0);	    gdk_draw_pixmap(screen.pixmap, gc, curr_pixmap, 0, 0, 0, 0, -1, -1);	    gdk_gc_set_clip_mask(gc, NULL);	}    }    gdk_pixmap_unref(curr_pixmap);    gdk_pixmap_unref(clipmask);        update_rect.x = 0, update_rect.y = 0;    update_rect.width =	widget->allocation.width;    update_rect.height = widget->allocation.height;    /*     * Calls expose_event     */    gtk_widget_draw(widget, &update_rect);redraw_pixmap_end:    /* Return default pointer shape */    if (window) {	gdk_window_set_cursor(window, GERBV_DEF_CURSOR);    }    gdk_gc_unref(gc);    return retval;} /* redraw_pixmap */