]> source.dussan.org Git - tigervnc.git/commitdiff
Sometimes we get copy requests that are partially or fully outside the
authorPierre Ossman <ossman@cendio.se>
Tue, 21 Dec 2010 16:06:36 +0000 (16:06 +0000)
committerPierre Ossman <ossman@cendio.se>
Tue, 21 Dec 2010 16:06:36 +0000 (16:06 +0000)
framebuffer. Not sure if this is a bug or not, but for now add some handling
to deal with these gracefully.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4230 3789f03b-4d11-0410-bbf8-ca57d06f2519

unix/xserver/hw/vnc/vncHooks.cc

index 52ef42aecffbdab0df44341a7bc157e74298d479..1bf61a383893b749960ee32a7bd31795548e63a3 100644 (file)
@@ -400,12 +400,19 @@ static void vncHooksCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
   int dx, dy;
   RegionHelper copied(pScreen, pOldRegion);
 
+  BoxRec screen_box = {0, 0, pScreen->width, pScreen->height};
+  RegionHelper screen_rgn(pScreen, &screen_box, 1);
+
   dx = pWin->drawable.x - ptOldOrg.x;
   dy = pWin->drawable.y - ptOldOrg.y;
 
   // RFB tracks copies in terms of destination rectangle, not source.
   // We also need to copy with changes to the Window's clipping region.
+  // Finally, make sure we don't get copies to or from regions outside
+  // the framebuffer.
+  REGION_INTERSECT(pScreen, copied.reg, copied.reg, screen_rgn.reg);
   REGION_TRANSLATE(pScreen, copied.reg, dx, dy);
+  REGION_INTERSECT(pScreen, copied.reg, copied.reg, screen_rgn.reg);
   REGION_INTERSECT(pScreen, copied.reg, copied.reg, &pWin->borderClip);
 
   (*pScreen->CopyWindow) (pWin, ptOldOrg, pOldRegion);