From 4effb62e99925e19f2b4b14041d57574f3763f23 Mon Sep 17 00:00:00 2001 From: runge Date: Tue, 31 May 2005 03:26:04 +0000 Subject: main.c: fix copyRect for non-cursor-shape-aware clients. --- libvncserver/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'libvncserver') diff --git a/libvncserver/main.c b/libvncserver/main.c index bf1f211..e4d1ea7 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -130,6 +130,49 @@ void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,in sraRgnAnd(modifiedRegionBackup,cl->copyRegion); sraRgnOr(cl->modifiedRegion,modifiedRegionBackup); sraRgnDestroy(modifiedRegionBackup); + + if(!cl->enableCursorShapeUpdates) { + /* + * n.b. (dx, dy) is the vector pointing in the direction the + * copyrect displacement will take place. copyRegion is the + * destination rectangle (say), not the source rectangle. + */ + sraRegionPtr cursorRegion; + int x = cl->cursorX - cl->screen->cursor->xhot; + int y = cl->cursorY - cl->screen->cursor->yhot; + int w = cl->screen->cursor->width; + int h = cl->screen->cursor->height; + + cursorRegion = sraRgnCreateRect(x, y, x + w, y + h); + sraRgnAnd(cursorRegion, cl->copyRegion); + if(!sraRgnEmpty(cursorRegion)) { + /* + * current cursor rect overlaps with the copy region *dest*, + * so remove it from the copy-rect treatment, and mark it as + * modified since we won't copy-rect stuff to it. + */ + sraRgnSubtract(cl->copyRegion, cursorRegion); + sraRgnOr(cl->modifiedRegion, cursorRegion); + } + sraRgnDestroy(cursorRegion); + + cursorRegion = sraRgnCreateRect(x, y, x + w, y + h); + /* displace it to check for overlap with copy region source: */ + sraRgnOffset(cursorRegion, dx, dy); + sraRgnAnd(cursorRegion, cl->copyRegion); + if(!sraRgnEmpty(cursorRegion)) { + /* + * current cursor rect overlaps with the copy region *source*, + * so remove it from the copy-rect treatment, and mark the + * *displaced* cursorRegion as modified since we won't copyrect + * stuff to it. + */ + sraRgnSubtract(cl->copyRegion, cursorRegion); + sraRgnOr(cl->modifiedRegion, cursorRegion); + } + sraRgnDestroy(cursorRegion); + } + } else { sraRgnOr(cl->modifiedRegion,copyRegion); } -- cgit v1.2.1