if (clipshift) { tx1 -= coff_x; ty1 -= coff_y; tx2 -= coff_x; ty2 -= coff_y; } if (subwin) { tx1 -= off_x; ty1 -= off_y; tx2 -= off_x; ty2 -= off_y; }
int do_bdpush(Window wm_win, int x0, int y0, int w0, int h0, int bdx,    int bdy, int bdskinny) {	XWindowAttributes attr;	sraRectangleIterator *iter;	sraRect rect;	sraRegionPtr frame, whole, tmpregion;	int tx1, ty1, tx2, ty2;	static Window last_wm_win = None;	static int last_x, last_y, last_w, last_h;	int do_fb_push = 0;	int db = debug_scroll;	if (wm_win == last_wm_win) {		attr.x = last_x;		attr.y = last_y;		attr.width = last_w;		attr.height = last_h;	} else {		if (!valid_window(wm_win, &attr, 1)) {			return do_fb_push;		}		last_wm_win = wm_win;		last_x = attr.x;		last_y = attr.y;		last_w = attr.width;		last_h = attr.height;	}if (db > 1) fprintf(stderr, "BDP  %d %d %d %d  %d %d %d  %d %d %d %d\n",	x0, y0, w0, h0, bdx, bdy, bdskinny, last_x, last_y, last_w, last_h);	/* wm frame: */	tx1 = attr.x;	ty1 = attr.y;	tx2 = attr.x + attr.width;	ty2 = attr.y + attr.height;	whole = sraRgnCreateRect(0, 0, dpy_x, dpy_y);	frame = sraRgnCreateRect(tx1, ty1, tx2, ty2);	sraRgnAnd(frame, whole);	/* scrolling window: */	tmpregion = sraRgnCreateRect(x0, y0, x0 + w0, y0 + h0);	sraRgnAnd(tmpregion, whole);	sraRgnSubtract(frame, tmpregion);	sraRgnDestroy(tmpregion);	if (!sraRgnEmpty(frame)) {		double dt = 0.0, dm;		dtime0(&dm);		iter = sraRgnGetIterator(frame);		while (sraRgnIteratorNext(iter, &rect)) {			tx1 = rect.x1;			ty1 = rect.y1;			tx2 = rect.x2;			ty2 = rect.y2;			if (bdskinny > 0) {				int ok = 0;				if (nabs(ty2-ty1) <= bdskinny) {					ok = 1;				}				if (nabs(tx2-tx1) <= bdskinny) {					ok = 1;				}				if (! ok) {					continue;				}			}			if (bdx >= 0) {				if (bdx < tx1 || tx2 <= bdx) {					continue;				}			}			if (bdy >= 0) {				if (bdy < ty1 || ty2 <= bdy) {					continue;				}			}			direct_fb_copy(tx1, ty1, tx2, ty2, 1);			do_fb_push++;			dt += dtime(&dm);if (db > 1) fprintf(stderr, "  BDP(%d,%d-%d,%d)  dt: %.4f\n", tx1, ty1, tx2, ty2, dt);		}		sraRgnReleaseIterator(iter);	}	sraRgnDestroy(whole);	sraRgnDestroy(frame);	return do_fb_push;}