Updated vncHooksComposite, to fix additional RENDER problems. It's not
enough to check that xDst/yDst is greater than zero: we must take
greater care not to add change regions that are fully or partially
outside the framebuffer.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@305 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/xc/programs/Xserver/vnc/vncHooks.cc b/xc/programs/Xserver/vnc/vncHooks.cc
index d040e4f..34c7aca 100644
--- a/xc/programs/Xserver/vnc/vncHooks.cc
+++ b/xc/programs/Xserver/vnc/vncHooks.cc
@@ -504,21 +504,22 @@
vncHooksScreenPtr vncHooksScreen = ((vncHooksScreenPtr)pScreen->devPrivates[vncHooksScreenIndex].ptr);
BoxRec box;
PictureScreenPtr ps = GetPictureScreen(pScreen);
+ rfb::Rect rect1, rect2;
- // For some reason, this hook is sometimes called with a negative
- // xDst. This causes graphics errors, as well as error messages of
- // the type:
- // ComparingUpdateTracker: rect outside fb (-47,76-171,89)
- // I've never observed a negative yDst, but let's check it anyway.
- if ((xDst >= 0) && (yDst >= 0)) {
- box.x1 = pDst->pDrawable->x + xDst;
- box.y1 = pDst->pDrawable->y + yDst;
- box.x2 = box.x1 + width;
- box.y2 = box.y1 + height;
-
- RegionHelper changed(pScreen, &box, 0);
- vncHooksScreen->desktop->add_changed(changed.reg);
- }
+ rect1.setXYWH(pDst->pDrawable->x + xDst,
+ pDst->pDrawable->y + yDst,
+ width,
+ height);
+
+ rect2 = rect1.intersect(vncHooksScreen->desktop->getRect());
+ if (!rect2.is_empty()) {
+ box.x1 = rect2.tl.x;
+ box.y1 = rect2.tl.y;
+ box.x2 = rect2.br.x;
+ box.y2 = rect2.br.y;
+ RegionHelper changed(pScreen, &box, 0);
+ vncHooksScreen->desktop->add_changed(changed.reg);
+ }
ps->Composite = vncHooksScreen->Composite;
(*ps->Composite)(op, pSrc, pMask, pDst, xSrc, ySrc,