Merge branch 'fix_desc_ptr' of https://github.com/uglym8/tigervnc
diff --git a/common/Xregion/Region.c b/common/Xregion/Region.c
index 604ecde..5209443 100644
--- a/common/Xregion/Region.c
+++ b/common/Xregion/Region.c
@@ -1,4 +1,3 @@
-/* $Xorg: Region.c,v 1.6 2001/02/09 02:03:35 xorgcvs Exp $ */
/************************************************************************
Copyright 1987, 1988, 1998 The Open Group
@@ -28,13 +27,13 @@
All Rights Reserved
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
+both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
+software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -45,7 +44,6 @@
SOFTWARE.
************************************************************************/
-/* $XFree86: xc/lib/X11/Region.c,v 1.8 2001/12/14 19:54:05 dawes Exp $ */
/*
* The functions in this file implement the Region abstraction, similar to one
* used in the X11 sample server. A Region is simply an area, as the name
@@ -72,8 +70,11 @@
* the y-x-banding that's so nice to have...
*/
+#include <string.h>
+
+#include "Xlibint.h"
+#include "Xutil.h"
#include "Xregion.h"
-#include "region.h"
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
@@ -90,19 +91,63 @@
#define assert(expr)
#endif
-typedef void (*voidProcp)();
+typedef int (*overlapProcp)(
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2);
-static void miRegionOp();
+typedef int (*nonOverlapProcp)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2);
+
+static void miRegionOp(
+ register Region newReg, /* Place to store result */
+ Region reg1, /* First region in operation */
+ Region reg2, /* 2d region in operation */
+ int (*overlapFunc)(
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2), /* Function to call for over-
+ * lapping bands */
+ int (*nonOverlap1Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2), /* Function to call for non-
+ * overlapping bands in region
+ * 1 */
+ int (*nonOverlap2Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)); /* Function to call for non-
+ * overlapping bands in region
+ * 2 */
+
+
/* Create a new empty region */
Region
-XCreateRegion()
+XCreateRegion(void)
{
Region temp;
- if (! (temp = ( Region )Xmalloc( (unsigned) sizeof( REGION ))))
+ if (! (temp = Xmalloc(sizeof( REGION ))))
return (Region) NULL;
- if (! (temp->rects = ( BOX * )Xmalloc( (unsigned) sizeof( BOX )))) {
- Xfree((char *) temp);
+ if (! (temp->rects = Xmalloc(sizeof( BOX )))) {
+ Xfree(temp);
return (Region) NULL;
}
temp->numRects = 0;
@@ -115,9 +160,9 @@
}
int
-XClipBox( r, rect )
- Region r;
- XRectangle *rect;
+XClipBox(
+ Region r,
+ XRectangle *rect)
{
rect->x = r->extents.x1;
rect->y = r->extents.y1;
@@ -127,9 +172,9 @@
}
int
-XUnionRectWithRegion(rect, source, dest)
- register XRectangle *rect;
- Region source, dest;
+XUnionRectWithRegion(
+ register XRectangle *rect,
+ Region source, Region dest)
{
REGION region;
@@ -162,8 +207,8 @@
*-----------------------------------------------------------------------
*/
static void
-miSetExtents (pReg)
- Region pReg;
+miSetExtents (
+ Region pReg)
{
register BoxPtr pBox,
pBoxEnd,
@@ -210,14 +255,12 @@
assert(pExtents->x1 < pExtents->x2);
}
-extern void _XSetClipRectangles();
-
#if 0
int
-XSetRegion( dpy, gc, r )
- Display *dpy;
- GC gc;
- register Region r;
+XSetRegion(
+ Display *dpy,
+ GC gc,
+ register Region r)
{
register int i;
register XRectangle *xr, *pr;
@@ -245,8 +288,8 @@
#endif
int
-XDestroyRegion( r )
- Region r;
+XDestroyRegion(
+ Region r)
{
Xfree( (char *) r->rects );
Xfree( (char *) r );
@@ -260,10 +303,10 @@
*/
int
-XOffsetRegion(pRegion, x, y)
- register Region pRegion;
- register int x;
- register int y;
+XOffsetRegion(
+ register Region pRegion,
+ register int x,
+ register int y)
{
register int nbox;
register BOX *pbox;
@@ -286,9 +329,9 @@
return 1;
}
-/*
+/*
Utility procedure Compress:
- Replace r by the region r', where
+ Replace r by the region r', where
p in r' iff (Quantifer m <= dx) (p + m in r), and
Quantifier is Exists if grow is TRUE, For all if grow is FALSE, and
(x,y) + m = (x+m,y) if xdir is TRUE; (x,y+m) if xdir is FALSE.
@@ -313,10 +356,10 @@
#define ZCopyRegion(a,b) XUnionRegion(a,a,b)
static void
-Compress(r, s, t, dx, xdir, grow)
- Region r, s, t;
- register unsigned dx;
- register int xdir, grow;
+Compress(
+ Region r, Region s, Region t,
+ register unsigned dx,
+ register int xdir, register int grow)
{
register unsigned shift = 1;
@@ -340,15 +383,20 @@
#undef ZCopyRegion
int
-XShrinkRegion(r, dx, dy)
- Region r;
- int dx, dy;
+XShrinkRegion(
+ Region r,
+ int dx, int dy)
{
Region s, t;
int grow;
if (!dx && !dy) return 0;
- if ((! (s = XCreateRegion())) || (! (t = XCreateRegion()))) return 0;
+ if (! (s = XCreateRegion()) )
+ return 0;
+ if (! (t = XCreateRegion()) ) {
+ XDestroyRegion(s);
+ return 0;
+ }
if ((grow = (dx < 0))) dx = -dx;
if (dx) Compress(r, s, t, (unsigned) 2*dx, TRUE, grow);
if ((grow = (dy < 0))) dy = -dy;
@@ -359,23 +407,6 @@
return 0;
}
-#ifdef notdef
-/***********************************************************
- * Bop down the array of rects until we have passed
- * scanline y. numRects is the size of the array.
- ***********************************************************/
-
-static BOX
-*IndexRects(rects, numRects, y)
- register BOX *rects;
- register int numRects;
- register int y;
-{
- while ((numRects--) && (rects->y2 <= y))
- rects++;
- return(rects);
-}
-#endif
/*======================================================================
* Region Intersection
@@ -395,14 +426,14 @@
*/
/* static void*/
static int
-miIntersectO (pReg, r1, r1End, r2, r2End, y1, y2)
- register Region pReg;
- register BoxPtr r1;
- BoxPtr r1End;
- register BoxPtr r2;
- BoxPtr r2End;
- short y1;
- short y2;
+miIntersectO (
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2)
{
register short x1;
register short x2;
@@ -459,19 +490,19 @@
}
int
-XIntersectRegion(reg1, reg2, newReg)
- Region reg1;
- Region reg2; /* source regions */
- register Region newReg; /* destination Region */
+XIntersectRegion(
+ Region reg1,
+ Region reg2, /* source regions */
+ register Region newReg) /* destination Region */
{
/* check for trivial reject */
if ( (!(reg1->numRects)) || (!(reg2->numRects)) ||
(!EXTENTCHECK(®1->extents, ®2->extents)))
newReg->numRects = 0;
else
- miRegionOp (newReg, reg1, reg2,
- (voidProcp) miIntersectO, (voidProcp) NULL, (voidProcp) NULL);
-
+ miRegionOp (newReg, reg1, reg2,
+ miIntersectO, NULL, NULL);
+
/*
* Can't alter newReg's extents before we call miRegionOp because
* it might be one of the source regions and miRegionOp depends
@@ -483,25 +514,26 @@
return 1;
}
-static void
-miRegionCopy(dstrgn, rgn)
- register Region dstrgn;
- register Region rgn;
+static int
+miRegionCopy(
+ register Region dstrgn,
+ register Region rgn)
{
if (dstrgn != rgn) /* don't want to copy to itself */
- {
+ {
if (dstrgn->size < rgn->numRects)
{
if (dstrgn->rects)
{
BOX *prevRects = dstrgn->rects;
-
- if (! (dstrgn->rects = (BOX *)
- Xrealloc((char *) dstrgn->rects,
- (unsigned) rgn->numRects * (sizeof(BOX))))) {
+
+ dstrgn->rects = Xrealloc(dstrgn->rects,
+ rgn->numRects * (sizeof(BOX)));
+ if (! dstrgn->rects) {
Xfree(prevRects);
- return;
+ dstrgn->size = 0;
+ return 0;
}
}
dstrgn->size = rgn->numRects;
@@ -515,137 +547,8 @@
memcpy((char *) dstrgn->rects, (char *) rgn->rects,
(int) (rgn->numRects * sizeof(BOX)));
}
-}
-
-#ifdef notdef
-
-/*
- * combinRegs(newReg, reg1, reg2)
- * if one region is above or below the other.
-*/
-
-static void
-combineRegs(newReg, reg1, reg2)
- register Region newReg;
- Region reg1;
- Region reg2;
-{
- register Region tempReg;
- register BOX *rects;
- register BOX *rects1;
- register BOX *rects2;
- register int total;
-
- rects1 = reg1->rects;
- rects2 = reg2->rects;
-
- total = reg1->numRects + reg2->numRects;
- if (! (tempReg = XCreateRegion()))
- return;
- tempReg->size = total;
- /* region 1 is below region 2 */
- if (reg1->extents.y1 > reg2->extents.y1)
- {
- miRegionCopy(tempReg, reg2);
- rects = &tempReg->rects[tempReg->numRects];
- total -= tempReg->numRects;
- while (total--)
- *rects++ = *rects1++;
- }
- else
- {
- miRegionCopy(tempReg, reg1);
- rects = &tempReg->rects[tempReg->numRects];
- total -= tempReg->numRects;
- while (total--)
- *rects++ = *rects2++;
- }
- tempReg->extents = reg1->extents;
- tempReg->numRects = reg1->numRects + reg2->numRects;
- EXTENTS(®2->extents, tempReg);
- miRegionCopy(newReg, tempReg);
- Xfree((char *)tempReg);
-}
-
-/*
- * QuickCheck checks to see if it does not have to go through all the
- * the ugly code for the region call. It returns 1 if it did all
- * the work for Union, otherwise 0 - still work to be done.
-*/
-
-static int
-QuickCheck(newReg, reg1, reg2)
- Region newReg, reg1, reg2;
-{
-
- /* if unioning with itself or no rects to union with */
- if ( (reg1 == reg2) || (!(reg1->numRects)) )
- {
- miRegionCopy(newReg, reg2);
- return TRUE;
- }
-
- /* if nothing to union */
- if (!(reg2->numRects))
- {
- miRegionCopy(newReg, reg1);
- return TRUE;
- }
-
- /* could put an extent check to see if add above or below */
-
- if ((reg1->extents.y1 >= reg2->extents.y2) ||
- (reg2->extents.y1 >= reg1->extents.y2) )
- {
- combineRegs(newReg, reg1, reg2);
- return TRUE;
- }
- return FALSE;
-}
-
-/* TopRects(rects, reg1, reg2)
- * N.B. We now assume that reg1 and reg2 intersect. Therefore we are
- * NOT checking in the two while loops for stepping off the end of the
- * region.
- */
-
-static int
-TopRects(newReg, rects, reg1, reg2, FirstRect)
- register Region newReg;
- register BOX *rects;
- register Region reg1;
- register Region reg2;
- BOX *FirstRect;
-{
- register BOX *tempRects;
-
- /* need to add some rects from region 1 */
- if (reg1->extents.y1 < reg2->extents.y1)
- {
- tempRects = reg1->rects;
- while(tempRects->y1 < reg2->extents.y1)
- {
- MEMCHECK(newReg, rects, FirstRect);
- ADDRECTNOX(newReg,rects, tempRects->x1, tempRects->y1,
- tempRects->x2, MIN(tempRects->y2, reg2->extents.y1));
- tempRects++;
- }
- }
- /* need to add some rects from region 2 */
- if (reg2->extents.y1 < reg1->extents.y1)
- {
- tempRects = reg2->rects;
- while (tempRects->y1 < reg1->extents.y1)
- {
- MEMCHECK(newReg, rects, FirstRect);
- ADDRECTNOX(newReg, rects, tempRects->x1,tempRects->y1,
- tempRects->x2, MIN(tempRects->y2, reg1->extents.y1));
- tempRects++;
- }
- }
return 1;
}
-#endif
/*======================================================================
* Generic Region Operator
@@ -670,10 +573,10 @@
*/
/* static int*/
static int
-miCoalesce (pReg, prevStart, curStart)
- register Region pReg; /* Region to coalesce */
- int prevStart; /* Index of start of previous band */
- int curStart; /* Index of start of current band */
+miCoalesce(
+ register Region pReg, /* Region to coalesce */
+ int prevStart, /* Index of start of previous band */
+ int curStart) /* Index of start of current band */
{
register BoxPtr pPrevBox; /* Current box in previous band */
register BoxPtr pCurBox; /* Current box in current band */
@@ -702,7 +605,7 @@
{
pCurBox++;
}
-
+
if (pCurBox != pRegEnd)
{
/*
@@ -719,7 +622,7 @@
curStart = pRegEnd - pReg->rects;
pRegEnd = pReg->rects + pReg->numRects;
}
-
+
if ((curNumRects == prevNumRects) && (curNumRects != 0)) {
pCurBox -= curNumRects;
/*
@@ -787,7 +690,7 @@
*pPrevBox++ = *pCurBox++;
} while (pCurBox != pRegEnd);
}
-
+
}
}
return (curStart);
@@ -821,16 +724,33 @@
*/
/* static void*/
static void
-miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func)
- register Region newReg; /* Place to store result */
- Region reg1; /* First region in operation */
- Region reg2; /* 2d region in operation */
- void (*overlapFunc)(); /* Function to call for over-
+miRegionOp(
+ register Region newReg, /* Place to store result */
+ Region reg1, /* First region in operation */
+ Region reg2, /* 2d region in operation */
+ int (*overlapFunc)(
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ short y1,
+ short y2), /* Function to call for over-
* lapping bands */
- void (*nonOverlap1Func)(); /* Function to call for non-
+ int (*nonOverlap1Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2), /* Function to call for non-
* overlapping bands in region
* 1 */
- void (*nonOverlap2Func)(); /* Function to call for non-
+ int (*nonOverlap2Func)(
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)) /* Function to call for non-
* overlapping bands in region
* 2 */
{
@@ -851,7 +771,7 @@
* band */
short bot; /* Bottom of non-overlapping
* band */
-
+
/*
* Initialization:
* set r1, r2, r1End and r2End appropriately, preserve the important
@@ -863,9 +783,9 @@
r2 = reg2->rects;
r1End = r1 + reg1->numRects;
r2End = r2 + reg2->numRects;
-
+
oldRects = newReg->rects;
-
+
EMPTY_REGION(newReg);
/*
@@ -877,12 +797,11 @@
*/
newReg->size = max(reg1->numRects,reg2->numRects) * 2;
- if (! (newReg->rects = (BoxPtr)
- Xmalloc ((unsigned) (sizeof(BoxRec) * newReg->size)))) {
+ if (! (newReg->rects = Xmalloc (sizeof(BoxRec) * newReg->size))) {
newReg->size = 0;
return;
}
-
+
/*
* Initialize ybot and ytop.
* In the upcoming loop, ybot and ytop serve different functions depending
@@ -900,7 +819,7 @@
ybot = reg1->extents.y1;
else
ybot = reg2->extents.y1;
-
+
/*
* prevBand serves to mark the start of the previous band so rectangles
* can be coalesced into larger rectangles. qv. miCoalesce, above.
@@ -911,7 +830,7 @@
* array of rectangles.
*/
prevBand = 0;
-
+
do
{
curBand = newReg->numRects;
@@ -928,13 +847,13 @@
{
r1BandEnd++;
}
-
+
r2BandEnd = r2;
while ((r2BandEnd != r2End) && (r2BandEnd->y1 == r2->y1))
{
r2BandEnd++;
}
-
+
/*
* First handle the band that doesn't intersect, if any.
*
@@ -948,7 +867,7 @@
top = max(r1->y1,ybot);
bot = min(r1->y2,r2->y1);
- if ((top != bot) && (nonOverlap1Func != (void (*)())NULL))
+ if ((top != bot) && (nonOverlap1Func != NULL))
{
(* nonOverlap1Func) (newReg, r1, r1BandEnd, top, bot);
}
@@ -960,7 +879,7 @@
top = max(r2->y1,ybot);
bot = min(r2->y2,r1->y1);
- if ((top != bot) && (nonOverlap2Func != (void (*)())NULL))
+ if ((top != bot) && (nonOverlap2Func != NULL))
{
(* nonOverlap2Func) (newReg, r2, r2BandEnd, top, bot);
}
@@ -994,7 +913,7 @@
(* overlapFunc) (newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot);
}
-
+
if (newReg->numRects != curBand)
{
prevBand = miCoalesce (newReg, prevBand, curBand);
@@ -1020,7 +939,7 @@
curBand = newReg->numRects;
if (r1 != r1End)
{
- if (nonOverlap1Func != (void (*)())NULL)
+ if (nonOverlap1Func != NULL)
{
do
{
@@ -1035,7 +954,7 @@
} while (r1 != r1End);
}
}
- else if ((r2 != r2End) && (nonOverlap2Func != (void (*)())NULL))
+ else if ((r2 != r2End) && (nonOverlap2Func != NULL))
{
do
{
@@ -1068,11 +987,12 @@
if (REGION_NOT_EMPTY(newReg))
{
BoxPtr prev_rects = newReg->rects;
- newReg->size = newReg->numRects;
- newReg->rects = (BoxPtr) Xrealloc ((char *) newReg->rects,
- (unsigned) (sizeof(BoxRec) * newReg->size));
+ newReg->rects = Xrealloc (newReg->rects,
+ sizeof(BoxRec) * newReg->numRects);
if (! newReg->rects)
newReg->rects = prev_rects;
+ else
+ newReg->size = newReg->numRects;
}
else
{
@@ -1081,11 +1001,11 @@
* the region is empty
*/
newReg->size = 1;
- Xfree((char *) newReg->rects);
- newReg->rects = (BoxPtr) Xmalloc(sizeof(BoxRec));
+ Xfree(newReg->rects);
+ newReg->rects = Xmalloc(sizeof(BoxRec));
}
}
- Xfree ((char *) oldRects);
+ Xfree (oldRects);
return;
}
@@ -1112,12 +1032,12 @@
*/
/* static void*/
static int
-miUnionNonO (pReg, r, rEnd, y1, y2)
- register Region pReg;
- register BoxPtr r;
- BoxPtr rEnd;
- register short y1;
- register short y2;
+miUnionNonO (
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)
{
register BoxPtr pNextRect;
@@ -1161,17 +1081,17 @@
/* static void*/
static int
-miUnionO (pReg, r1, r1End, r2, r2End, y1, y2)
- register Region pReg;
- register BoxPtr r1;
- BoxPtr r1End;
- register BoxPtr r2;
- BoxPtr r2End;
- register short y1;
- register short y2;
+miUnionO (
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ register short y1,
+ register short y2)
{
register BoxPtr pNextRect;
-
+
pNextRect = &pReg->rects[pReg->numRects];
#define MERGERECT(r) \
@@ -1198,7 +1118,7 @@
} \
assert(pReg->numRects<=pReg->size);\
r++;
-
+
assert (y1<y2);
while ((r1 != r1End) && (r2 != r2End))
{
@@ -1211,7 +1131,7 @@
MERGERECT(r2);
}
}
-
+
if (r1 != r1End)
{
do
@@ -1227,10 +1147,10 @@
}
int
-XUnionRegion(reg1, reg2, newReg)
- Region reg1;
- Region reg2; /* source regions */
- Region newReg; /* destination Region */
+XUnionRegion(
+ Region reg1,
+ Region reg2, /* source regions */
+ Region newReg) /* destination Region */
{
/* checks all the simple cases */
@@ -1240,7 +1160,7 @@
if ( (reg1 == reg2) || (!(reg1->numRects)) )
{
if (newReg != reg2)
- miRegionCopy(newReg, reg2);
+ return miRegionCopy(newReg, reg2);
return 1;
}
@@ -1250,40 +1170,40 @@
if (!(reg2->numRects))
{
if (newReg != reg1)
- miRegionCopy(newReg, reg1);
+ return miRegionCopy(newReg, reg1);
return 1;
}
/*
* Region 1 completely subsumes region 2
*/
- if ((reg1->numRects == 1) &&
+ if ((reg1->numRects == 1) &&
(reg1->extents.x1 <= reg2->extents.x1) &&
(reg1->extents.y1 <= reg2->extents.y1) &&
(reg1->extents.x2 >= reg2->extents.x2) &&
(reg1->extents.y2 >= reg2->extents.y2))
{
if (newReg != reg1)
- miRegionCopy(newReg, reg1);
+ return miRegionCopy(newReg, reg1);
return 1;
}
/*
* Region 2 completely subsumes region 1
*/
- if ((reg2->numRects == 1) &&
+ if ((reg2->numRects == 1) &&
(reg2->extents.x1 <= reg1->extents.x1) &&
(reg2->extents.y1 <= reg1->extents.y1) &&
(reg2->extents.x2 >= reg1->extents.x2) &&
(reg2->extents.y2 >= reg1->extents.y2))
{
if (newReg != reg2)
- miRegionCopy(newReg, reg2);
+ return miRegionCopy(newReg, reg2);
return 1;
}
- miRegionOp (newReg, reg1, reg2, (voidProcp) miUnionO,
- (voidProcp) miUnionNonO, (voidProcp) miUnionNonO);
+ miRegionOp (newReg, reg1, reg2, miUnionO,
+ miUnionNonO, miUnionNonO);
newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1);
newReg->extents.y1 = min(reg1->extents.y1, reg2->extents.y1);
@@ -1314,17 +1234,17 @@
*/
/* static void*/
static int
-miSubtractNonO1 (pReg, r, rEnd, y1, y2)
- register Region pReg;
- register BoxPtr r;
- BoxPtr rEnd;
- register short y1;
- register short y2;
+miSubtractNonO1 (
+ register Region pReg,
+ register BoxPtr r,
+ BoxPtr rEnd,
+ register short y1,
+ register short y2)
{
register BoxPtr pNextRect;
-
+
pNextRect = &pReg->rects[pReg->numRects];
-
+
assert(y1<y2);
while (r != rEnd)
@@ -1361,20 +1281,20 @@
*/
/* static void*/
static int
-miSubtractO (pReg, r1, r1End, r2, r2End, y1, y2)
- register Region pReg;
- register BoxPtr r1;
- BoxPtr r1End;
- register BoxPtr r2;
- BoxPtr r2End;
- register short y1;
- register short y2;
+miSubtractO (
+ register Region pReg,
+ register BoxPtr r1,
+ BoxPtr r1End,
+ register BoxPtr r2,
+ BoxPtr r2End,
+ register short y1,
+ register short y2)
{
register BoxPtr pNextRect;
register int x1;
-
+
x1 = r1->x1;
-
+
assert(y1<y2);
pNextRect = &pReg->rects[pReg->numRects];
@@ -1464,8 +1384,8 @@
assert(pReg->numRects<=pReg->size);
}
r1++;
- if (r1 != r1End)
- x1 = r1->x1;
+ if (r1 != r1End)
+ x1 = r1->x1;
}
}
@@ -1493,7 +1413,7 @@
}
return 0; /* lint */
}
-
+
/*-
*-----------------------------------------------------------------------
* miSubtract --
@@ -1510,21 +1430,20 @@
*/
int
-XSubtractRegion(regM, regS, regD)
- Region regM;
- Region regS;
- register Region regD;
+XSubtractRegion(
+ Region regM,
+ Region regS,
+ register Region regD)
{
/* check for trivial reject */
if ( (!(regM->numRects)) || (!(regS->numRects)) ||
(!EXTENTCHECK(®M->extents, ®S->extents)) )
{
- miRegionCopy(regD, regM);
- return 1;
+ return miRegionCopy(regD, regM);
}
-
- miRegionOp (regD, regM, regS, (voidProcp) miSubtractO,
- (voidProcp) miSubtractNonO1, (voidProcp) NULL);
+
+ miRegionOp (regD, regM, regS, miSubtractO,
+ miSubtractNonO1, NULL);
/*
* Can't alter newReg's extents before we call miRegionOp because
@@ -1538,13 +1457,16 @@
}
int
-XXorRegion( sra, srb, dr )
- Region sra, srb, dr;
+XXorRegion(Region sra, Region srb, Region dr)
{
Region tra, trb;
- if ((! (tra = XCreateRegion())) || (! (trb = XCreateRegion())))
+ if (! (tra = XCreateRegion()) )
return 0;
+ if (! (trb = XCreateRegion()) ) {
+ XDestroyRegion(tra);
+ return 0;
+ }
(void) XSubtractRegion(sra,srb,tra);
(void) XSubtractRegion(srb,sra,trb);
(void) XUnionRegion(tra,trb,dr);
@@ -1554,23 +1476,22 @@
}
/*
- * Check to see if the region is empty. Assumes a region is passed
+ * Check to see if the region is empty. Assumes a region is passed
* as a parameter
*/
-int
-XEmptyRegion( r )
- Region r;
+int
+XEmptyRegion(
+ Region r)
{
if( r->numRects == 0 ) return TRUE;
else return FALSE;
}
/*
- * Check to see if two regions are equal
+ * Check to see if two regions are equal
*/
-int
-XEqualRegion( r1, r2 )
- Region r1, r2;
+int
+XEqualRegion(Region r1, Region r2)
{
int i;
@@ -1589,10 +1510,10 @@
return TRUE;
}
-int
-XPointInRegion( pRegion, x, y )
- Region pRegion;
- int x, y;
+int
+XPointInRegion(
+ Region pRegion,
+ int x, int y)
{
int i;
@@ -1608,11 +1529,11 @@
return FALSE;
}
-int
-XRectInRegion(region, rx, ry, rwidth, rheight)
- register Region region;
- int rx, ry;
- unsigned int rwidth, rheight;
+int
+XRectInRegion(
+ register Region region,
+ int rx, int ry,
+ unsigned int rwidth, unsigned int rheight)
{
register BoxPtr pbox;
register BoxPtr pboxEnd;
@@ -1624,7 +1545,7 @@
prect->y1 = ry;
prect->x2 = rwidth + rx;
prect->y2 = rheight + ry;
-
+
/* this is (just) a useful optimization */
if ((region->numRects == 0) || !EXTENTCHECK(®ion->extents, prect))
return(RectangleOut);
@@ -1686,6 +1607,6 @@
}
- return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
+ return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
RectangleOut);
}
diff --git a/common/Xregion/Xlib.h b/common/Xregion/Xlib.h
new file mode 100644
index 0000000..ba6f281
--- /dev/null
+++ b/common/Xregion/Xlib.h
@@ -0,0 +1,50 @@
+/*
+
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+
+/*
+ * Xlib.h - Header definition and support file for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol (V11).
+ * Structures and symbols starting with "_" are private to the library.
+ */
+#ifndef _X11_XLIB_H_
+#define _X11_XLIB_H_
+
+#define NeedFunctionPrototypes 1
+
+#define Bool int
+
+typedef struct {
+ short x, y;
+} XPoint;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+} XRectangle;
+
+
+#endif /* _X11_XLIB_H_ */
diff --git a/common/Xregion/Xlibint.h b/common/Xregion/Xlibint.h
new file mode 100644
index 0000000..9b9ae28
--- /dev/null
+++ b/common/Xregion/Xlibint.h
@@ -0,0 +1,48 @@
+
+/*
+
+Copyright 1984, 1985, 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifndef _X11_XLIBINT_H_
+#define _X11_XLIBINT_H_ 1
+
+/*
+ * Xlibint.h - Header definition and support file for the internal
+ * support routines used by the C subroutine interface
+ * library (Xlib) to the X Window System.
+ *
+ * Warning, there be dragons here....
+ */
+
+#include <stdlib.h>
+
+#define Xfree(ptr) free((ptr))
+#define Xmalloc(size) malloc((size))
+#define Xrealloc(ptr, size) realloc((ptr), (size))
+#define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
+
+#endif /* _X11_XLIBINT_H_ */
diff --git a/common/Xregion/Xregion.h b/common/Xregion/Xregion.h
index 28cfa0a..cf10f86 100644
--- a/common/Xregion/Xregion.h
+++ b/common/Xregion/Xregion.h
@@ -1,6 +1,4 @@
-/* $Xorg: Xutil.h,v 1.8 2001/02/09 02:03:39 xorgcvs Exp $ */
-
-/***********************************************************
+/************************************************************************
Copyright 1987, 1998 The Open Group
@@ -29,13 +27,13 @@
All Rights Reserved
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
+both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
+software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -45,168 +43,148 @@
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
-******************************************************************/
-/* $XFree86: xc/lib/X11/Xutil.h,v 3.4 2001/12/14 19:54:10 dawes Exp $ */
+************************************************************************/
-#ifndef _XREGION_H_
-#define _XREGION_H_
-
-/* - Faked defines to fool the X11 region code */
-
-#include <stdlib.h>
-#include <string.h>
-
-#define Bool int
-#define Xmalloc malloc
-#define Xfree free
-#define Xrealloc realloc
-
-#define NeedFunctionPrototypes 1
-
-/* - Cribbed from Xlib.h */
+#ifndef _X11_XREGION_H_
+#define _X11_XREGION_H_
typedef struct {
- short x, y;
-} XPoint;
+ short x1, x2, y1, y2;
+} Box, BOX, BoxRec, *BoxPtr;
typedef struct {
- short x, y;
- unsigned short width, height;
-} XRectangle;
+ short x, y, width, height;
+}RECTANGLE, RectangleRec, *RectanglePtr;
+
+#define TRUE 1
+#define FALSE 0
+#define MAXSHORT 32767
+#define MINSHORT -MAXSHORT
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
/*
- * opaque reference to Region data type
+ * clip region
*/
-typedef struct _XRegion *Region;
-/* Return values from XRectInRegion() */
-
-#define RectangleOut 0
-#define RectangleIn 1
-#define RectanglePart 2
+typedef struct _XRegion {
+ long size;
+ long numRects;
+ BOX *rects;
+ BOX extents;
+} REGION;
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* Xutil.h contains the declaration:
+ * typedef struct _XRegion *Region;
+ */
-extern int XClipBox(
-#if NeedFunctionPrototypes
- Region /* r */,
- XRectangle* /* rect_return */
-#endif
-);
+/* 1 if two BOXs overlap.
+ * 0 if two BOXs do not overlap.
+ * Remember, x2 and y2 are not in the region
+ */
+#define EXTENTCHECK(r1, r2) \
+ ((r1)->x2 > (r2)->x1 && \
+ (r1)->x1 < (r2)->x2 && \
+ (r1)->y2 > (r2)->y1 && \
+ (r1)->y1 < (r2)->y2)
-extern Region XCreateRegion(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+/*
+ * update region extents
+ */
+#define EXTENTS(r,idRect){\
+ if((r)->x1 < (idRect)->extents.x1)\
+ (idRect)->extents.x1 = (r)->x1;\
+ if((r)->y1 < (idRect)->extents.y1)\
+ (idRect)->extents.y1 = (r)->y1;\
+ if((r)->x2 > (idRect)->extents.x2)\
+ (idRect)->extents.x2 = (r)->x2;\
+ if((r)->y2 > (idRect)->extents.y2)\
+ (idRect)->extents.y2 = (r)->y2;\
+ }
-extern const char *XDefaultString (void);
+/*
+ * Check to see if there is enough memory in the present region.
+ */
+#define MEMCHECK(reg, rect, firstrect){\
+ if ((reg)->numRects >= ((reg)->size - 1)){\
+ BoxPtr tmpRect = Xrealloc ((firstrect), \
+ (2 * (sizeof(BOX)) * ((reg)->size))); \
+ if (tmpRect == NULL) \
+ return(0);\
+ (firstrect) = tmpRect; \
+ (reg)->size *= 2;\
+ (rect) = &(firstrect)[(reg)->numRects];\
+ }\
+ }
-extern int XDestroyRegion(
-#if NeedFunctionPrototypes
- Region /* r */
-#endif
-);
+/* this routine checks to see if the previous rectangle is the same
+ * or subsumes the new rectangle to add.
+ */
-extern int XEmptyRegion(
-#if NeedFunctionPrototypes
- Region /* r */
-#endif
-);
+#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
+ (!(((Reg)->numRects > 0)&&\
+ ((R-1)->y1 == (Ry1)) &&\
+ ((R-1)->y2 == (Ry2)) &&\
+ ((R-1)->x1 <= (Rx1)) &&\
+ ((R-1)->x2 >= (Rx2))))
-extern int XEqualRegion(
-#if NeedFunctionPrototypes
- Region /* r1 */,
- Region /* r2 */
-#endif
-);
+/* add a rectangle to the given Region */
+#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
+ if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
+ CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
+ (r)->x1 = (rx1);\
+ (r)->y1 = (ry1);\
+ (r)->x2 = (rx2);\
+ (r)->y2 = (ry2);\
+ EXTENTS((r), (reg));\
+ (reg)->numRects++;\
+ (r)++;\
+ }\
+ }
-extern int XIntersectRegion(
-#if NeedFunctionPrototypes
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-#endif
-);
-extern int XOffsetRegion(
-#if NeedFunctionPrototypes
- Region /* r */,
- int /* dx */,
- int /* dy */
-#endif
-);
-extern Bool XPointInRegion(
-#if NeedFunctionPrototypes
- Region /* r */,
- int /* x */,
- int /* y */
-#endif
-);
+/* add a rectangle to the given Region */
+#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
+ if ((rx1 < rx2) && (ry1 < ry2) &&\
+ CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
+ (r)->x1 = (rx1);\
+ (r)->y1 = (ry1);\
+ (r)->x2 = (rx2);\
+ (r)->y2 = (ry2);\
+ (reg)->numRects++;\
+ (r)++;\
+ }\
+ }
-extern Region XPolygonRegion(
-#if NeedFunctionPrototypes
- XPoint* /* points */,
- int /* n */,
- int /* fill_rule */
-#endif
-);
+#define EMPTY_REGION(pReg) pReg->numRects = 0
-extern int XRectInRegion(
-#if NeedFunctionPrototypes
- Region /* r */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-#endif
-);
+#define REGION_NOT_EMPTY(pReg) pReg->numRects
-extern int XShrinkRegion(
-#if NeedFunctionPrototypes
- Region /* r */,
- int /* dx */,
- int /* dy */
-#endif
-);
+#define INBOX(r, x, y) \
+ ( ( ((r).x2 > x)) && \
+ ( ((r).x1 <= x)) && \
+ ( ((r).y2 > y)) && \
+ ( ((r).y1 <= y)) )
-extern int XSubtractRegion(
-#if NeedFunctionPrototypes
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-#endif
-);
+/*
+ * number of points to buffer before sending them off
+ * to scanlines() : Must be an even number
+ */
+#define NUMPTSTOBUFFER 200
-extern int XUnionRectWithRegion(
-#if NeedFunctionPrototypes
- XRectangle* /* rectangle */,
- Region /* src_region */,
- Region /* dest_region_return */
-#endif
-);
+/*
+ * used to allocate buffers for points and link
+ * the buffers together
+ */
+typedef struct _POINTBLOCK {
+ XPoint pts[NUMPTSTOBUFFER];
+ struct _POINTBLOCK *next;
+} POINTBLOCK;
-extern int XUnionRegion(
-#if NeedFunctionPrototypes
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-#endif
-);
-
-extern int XXorRegion(
-#if NeedFunctionPrototypes
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-#endif
-);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* _XUTIL_H_ */
+#endif /* _X11_XREGION_H_ */
diff --git a/common/Xregion/Xutil.h b/common/Xregion/Xutil.h
new file mode 100644
index 0000000..4da56a5
--- /dev/null
+++ b/common/Xregion/Xutil.h
@@ -0,0 +1,167 @@
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifndef _X11_XUTIL_H_
+#define _X11_XUTIL_H_
+
+/* You must include <X11/Xlib.h> before including this file */
+#include "Xlib.h"
+
+/****** Avoid symbol clash with "real" libX11 ******/
+#define XClipBox vncXClipBox
+#define XCreateRegion vncXCreateRegion
+#define XDestroyRegion vncXDestroyRegion
+#define XEmptyRegion vncXEmptyRegion
+#define XEqualRegion vncXEqualRegion
+#define XIntersectRegion vncXIntersectRegion
+#define XOffsetRegion vncXOffsetRegion
+#define XPointInRegion vncXPointInRegion
+#define XPolygonRegion vncXPolygonRegion
+#define XRectInRegion vncXRectInRegion
+#define XShrinkRegion vncXShrinkRegion
+#define XSubtractRegion vncXSubtractRegion
+#define XUnionRectWithRegion vncXUnionRectWithRegion
+#define XUnionRegion vncXUnionRegion
+#define XXorRegion vncXXorRegion
+
+/*
+ * opaque reference to Region data type
+ */
+typedef struct _XRegion *Region;
+
+/* Return values from XRectInRegion() */
+
+#define RectangleOut 0
+#define RectangleIn 1
+#define RectanglePart 2
+
+extern int XClipBox(
+ Region /* r */,
+ XRectangle* /* rect_return */
+);
+
+extern Region XCreateRegion(
+ void
+);
+
+extern int XDestroyRegion(
+ Region /* r */
+);
+
+extern int XEmptyRegion(
+ Region /* r */
+);
+
+extern int XEqualRegion(
+ Region /* r1 */,
+ Region /* r2 */
+);
+
+extern int XIntersectRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+extern int XOffsetRegion(
+ Region /* r */,
+ int /* dx */,
+ int /* dy */
+);
+
+extern Bool XPointInRegion(
+ Region /* r */,
+ int /* x */,
+ int /* y */
+);
+
+extern Region XPolygonRegion(
+ XPoint* /* points */,
+ int /* n */,
+ int /* fill_rule */
+);
+
+extern int XRectInRegion(
+ Region /* r */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XShrinkRegion(
+ Region /* r */,
+ int /* dx */,
+ int /* dy */
+);
+
+extern int XSubtractRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+extern int XUnionRectWithRegion(
+ XRectangle* /* rectangle */,
+ Region /* src_region */,
+ Region /* dest_region_return */
+);
+
+extern int XUnionRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+extern int XXorRegion(
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+);
+
+#endif /* _X11_XUTIL_H_ */
diff --git a/common/Xregion/region.h b/common/Xregion/region.h
deleted file mode 100644
index 2ddf12c..0000000
--- a/common/Xregion/region.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* $Xorg: region.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
-/************************************************************************
-
-Copyright 1987, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-************************************************************************/
-
-#ifndef _XREGION_H
-#define _XREGION_H
-
-typedef struct {
- short x1, x2, y1, y2;
-} Box, BOX, BoxRec, *BoxPtr;
-
-typedef struct {
- short x, y, width, height;
-}RECTANGLE, RectangleRec, *RectanglePtr;
-
-#define TRUE 1
-#define FALSE 0
-#define MAXSHORT 32767
-#define MINSHORT -MAXSHORT
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-
-/*
- * clip region
- */
-
-typedef struct _XRegion {
- long size;
- long numRects;
- BOX *rects;
- BOX extents;
-} REGION;
-
-/* Xutil.h contains the declaration:
- * typedef struct _XRegion *Region;
- */
-
-/* 1 if two BOXs overlap.
- * 0 if two BOXs do not overlap.
- * Remember, x2 and y2 are not in the region
- */
-#define EXTENTCHECK(r1, r2) \
- ((r1)->x2 > (r2)->x1 && \
- (r1)->x1 < (r2)->x2 && \
- (r1)->y2 > (r2)->y1 && \
- (r1)->y1 < (r2)->y2)
-
-/*
- * update region extents
- */
-#define EXTENTS(r,idRect){\
- if((r)->x1 < (idRect)->extents.x1)\
- (idRect)->extents.x1 = (r)->x1;\
- if((r)->y1 < (idRect)->extents.y1)\
- (idRect)->extents.y1 = (r)->y1;\
- if((r)->x2 > (idRect)->extents.x2)\
- (idRect)->extents.x2 = (r)->x2;\
- if((r)->y2 > (idRect)->extents.y2)\
- (idRect)->extents.y2 = (r)->y2;\
- }
-
-/*
- * Check to see if there is enough memory in the present region.
- */
-#define MEMCHECK(reg, rect, firstrect){\
- if ((reg)->numRects >= ((reg)->size - 1)){\
- (firstrect) = (BOX *) Xrealloc \
- ((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
- if ((firstrect) == 0)\
- return(0);\
- (reg)->size *= 2;\
- (rect) = &(firstrect)[(reg)->numRects];\
- }\
- }
-
-/* this routine checks to see if the previous rectangle is the same
- * or subsumes the new rectangle to add.
- */
-
-#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
- (!(((Reg)->numRects > 0)&&\
- ((R-1)->y1 == (Ry1)) &&\
- ((R-1)->y2 == (Ry2)) &&\
- ((R-1)->x1 <= (Rx1)) &&\
- ((R-1)->x2 >= (Rx2))))
-
-/* add a rectangle to the given Region */
-#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
- if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
- CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
- (r)->x1 = (rx1);\
- (r)->y1 = (ry1);\
- (r)->x2 = (rx2);\
- (r)->y2 = (ry2);\
- EXTENTS((r), (reg));\
- (reg)->numRects++;\
- (r)++;\
- }\
- }
-
-
-
-/* add a rectangle to the given Region */
-#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
- if ((rx1 < rx2) && (ry1 < ry2) &&\
- CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
- (r)->x1 = (rx1);\
- (r)->y1 = (ry1);\
- (r)->x2 = (rx2);\
- (r)->y2 = (ry2);\
- (reg)->numRects++;\
- (r)++;\
- }\
- }
-
-#define EMPTY_REGION(pReg) pReg->numRects = 0
-
-#define REGION_NOT_EMPTY(pReg) pReg->numRects
-
-#define INBOX(r, x, y) \
- ( ( ((r).x2 > x)) && \
- ( ((r).x1 <= x)) && \
- ( ((r).y2 > y)) && \
- ( ((r).y1 <= y)) )
-
-/*
- * number of points to buffer before sending them off
- * to scanlines() : Must be an even number
- */
-#define NUMPTSTOBUFFER 200
-
-/*
- * used to allocate buffers for points and link
- * the buffers together
- */
-typedef struct _POINTBLOCK {
- XPoint pts[NUMPTSTOBUFFER];
- struct _POINTBLOCK *next;
-} POINTBLOCK;
-
-#endif
diff --git a/common/rfb/Region.cxx b/common/rfb/Region.cxx
index 7965a6c..995f8c5 100644
--- a/common/rfb/Region.cxx
+++ b/common/rfb/Region.cxx
@@ -24,11 +24,15 @@
//
#include <rfb/Region.h>
-#include <Xregion/Xregion.h>
-#include <Xregion/region.h>
#include <assert.h>
#include <stdio.h>
+extern "C" {
+#include <Xregion/Xlibint.h>
+#include <Xregion/Xutil.h>
+#include <Xregion/Xregion.h>
+}
+
// A _RectRegion must never be passed as a return parameter to the Xlib region
// operations. This is because for efficiency its "rects" member has not been
// allocated with Xmalloc. It is however safe to pass it as an input
diff --git a/contrib/packages/deb/ubuntu-precise/debian/patches/debian_libtool.patch b/contrib/packages/deb/ubuntu-precise/debian/patches/debian_libtool.patch
new file mode 100644
index 0000000..7be0ba2
--- /dev/null
+++ b/contrib/packages/deb/ubuntu-precise/debian/patches/debian_libtool.patch
@@ -0,0 +1,52 @@
+--- a/ltmain.sh 2016-05-11 23:23:25.796742323 -0400
++++ b/ltmain.sh 2016-05-11 23:24:47.173010324 -0400
+@@ -6447,6 +6447,9 @@
+ # It is a libtool convenience library, so add in its objects.
+ func_append convenience " $ladir/$objdir/$old_library"
+ func_append old_convenience " $ladir/$objdir/$old_library"
++ elif test "$linkmode" != prog && test "$linkmode" != lib; then
++ func_fatal_error "\`$lib' is not a convenience library"
++ fi
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+@@ -6457,9 +6460,6 @@
+ fi
+ func_append tmp_libs " $deplib"
+ done
+- elif test "$linkmode" != prog && test "$linkmode" != lib; then
+- func_fatal_error "\`$lib' is not a convenience library"
+- fi
+ continue
+ fi # $pass = conv
+
+--- a/m4/libtool.m4 2016-05-11 23:26:23.801328557 -0400
++++ b/m4/libtool.m4 2016-05-11 23:27:12.701489603 -0400
+@@ -4589,9 +4589,6 @@
+ ;;
+ esac
+ ;;
+- linux* | k*bsd*-gnu | gnu*)
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+- ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+@@ -4654,9 +4651,6 @@
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+- linux* | k*bsd*-gnu | gnu*)
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+- ;;
+ esac
+
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+@@ -5055,7 +5049,6 @@
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
diff --git a/contrib/packages/deb/ubuntu-precise/debian/rules b/contrib/packages/deb/ubuntu-precise/debian/rules
index 1a759a5..f803861 100755
--- a/contrib/packages/deb/ubuntu-precise/debian/rules
+++ b/contrib/packages/deb/ubuntu-precise/debian/rules
@@ -58,6 +58,7 @@
(cd unix/xserver; \
export PIXMANINCDIR=/usr/include/pixman-1; \
autoreconf -fiv; \
+ patch -p1 -i ../../debian/patches/debian_libtool.patch; \
./configure --prefix=/usr \
--disable-silent-rules \
--disable-static \
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/patches/debian_libtool.patch b/contrib/packages/deb/ubuntu-trusty/debian/patches/debian_libtool.patch
new file mode 100644
index 0000000..7be0ba2
--- /dev/null
+++ b/contrib/packages/deb/ubuntu-trusty/debian/patches/debian_libtool.patch
@@ -0,0 +1,52 @@
+--- a/ltmain.sh 2016-05-11 23:23:25.796742323 -0400
++++ b/ltmain.sh 2016-05-11 23:24:47.173010324 -0400
+@@ -6447,6 +6447,9 @@
+ # It is a libtool convenience library, so add in its objects.
+ func_append convenience " $ladir/$objdir/$old_library"
+ func_append old_convenience " $ladir/$objdir/$old_library"
++ elif test "$linkmode" != prog && test "$linkmode" != lib; then
++ func_fatal_error "\`$lib' is not a convenience library"
++ fi
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+@@ -6457,9 +6460,6 @@
+ fi
+ func_append tmp_libs " $deplib"
+ done
+- elif test "$linkmode" != prog && test "$linkmode" != lib; then
+- func_fatal_error "\`$lib' is not a convenience library"
+- fi
+ continue
+ fi # $pass = conv
+
+--- a/m4/libtool.m4 2016-05-11 23:26:23.801328557 -0400
++++ b/m4/libtool.m4 2016-05-11 23:27:12.701489603 -0400
+@@ -4589,9 +4589,6 @@
+ ;;
+ esac
+ ;;
+- linux* | k*bsd*-gnu | gnu*)
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+- ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+@@ -4654,9 +4651,6 @@
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+- linux* | k*bsd*-gnu | gnu*)
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+- ;;
+ esac
+
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+@@ -5055,7 +5049,6 @@
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
diff --git a/contrib/packages/deb/ubuntu-trusty/debian/rules b/contrib/packages/deb/ubuntu-trusty/debian/rules
index 97aebb3..3811477 100755
--- a/contrib/packages/deb/ubuntu-trusty/debian/rules
+++ b/contrib/packages/deb/ubuntu-trusty/debian/rules
@@ -65,6 +65,7 @@
(cd unix/xserver; \
export PIXMANINCDIR=/usr/include/pixman-1; \
autoreconf -fiv; \
+ patch -p1 -i ../../debian/patches/debian_libtool.patch; \
./configure --prefix=/usr \
--disable-silent-rules \
--disable-static \
diff --git a/contrib/packages/deb/ubuntu-xenial/debian/rules b/contrib/packages/deb/ubuntu-xenial/debian/rules
index 9770083..1a7a20b 100644
--- a/contrib/packages/deb/ubuntu-xenial/debian/rules
+++ b/contrib/packages/deb/ubuntu-xenial/debian/rules
@@ -59,6 +59,7 @@
(cd unix/xserver; \
export PIXMANINCDIR=/usr/include/pixman-1; \
autoreconf -fiv; \
+ patch -p1 -i ../../debian/xorg-source-patches/debian_libtool.patch; \
./configure --prefix=/usr \
--disable-silent-rules \
--disable-static \
diff --git a/contrib/packages/deb/ubuntu-xenial/debian/xorg-source-patches/debian_libtool.patch b/contrib/packages/deb/ubuntu-xenial/debian/xorg-source-patches/debian_libtool.patch
new file mode 100644
index 0000000..d24877d
--- /dev/null
+++ b/contrib/packages/deb/ubuntu-xenial/debian/xorg-source-patches/debian_libtool.patch
@@ -0,0 +1,87 @@
+Index: a/ltmain.sh
+===================================================================
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -7890,19 +7890,19 @@
+ # It is a libtool convenience library, so add in its objects.
+ func_append convenience " $ladir/$objdir/$old_library"
+ func_append old_convenience " $ladir/$objdir/$old_library"
+- tmp_libs=
+- for deplib in $dependency_libs; do
+- deplibs="$deplib $deplibs"
+- if $opt_preserve_dup_deps; then
+- case "$tmp_libs " in
+- *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+- esac
+- fi
+- func_append tmp_libs " $deplib"
+- done
+ elif test prog != "$linkmode" && test lib != "$linkmode"; then
+ func_fatal_error "'$lib' is not a convenience library"
+ fi
++ tmp_libs=
++ for deplib in $dependency_libs; do
++ deplibs="$deplib $deplibs"
++ if $opt_preserve_dup_deps; then
++ case "$tmp_libs " in
++ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
++ esac
++ fi
++ func_append tmp_libs " $deplib"
++ done
+ continue
+ fi # $pass = conv
+
+## Do not link against deplibs. This is not needed for shared libs
+## on atleast ELF systems since those already know which libs they
+## need themself. This seems to break a few things and will be fixed
+## in a better way in a future upstream version.
+
+Index: a/ltmain.sh
+===================================================================
+--- a/ltmain.sh
++++ b/ltmain.sh
+@@ -7568,10 +7568,7 @@
+ case $pass in
+ dlopen) libs=$dlfiles ;;
+ dlpreopen) libs=$dlprefiles ;;
+- link)
+- libs="$deplibs %DEPLIBS%"
+- test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+- ;;
++ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+ esac
+ fi
+ if test lib,dlpreopen = "$linkmode,$pass"; then
+Index: a/m4/libtool.m4
+===================================================================
+--- a/m4/libtool.m4
++++ b/m4/libtool.m4
+@@ -4936,9 +4936,6 @@
+ ;;
+ esac
+ ;;
+- linux* | k*bsd*-gnu | gnu*)
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+- ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+@@ -4998,9 +5001,6 @@
+ openbsd* | bitrig*)
+ with_gnu_ld=no
+ ;;
+- linux* | k*bsd*-gnu | gnu*)
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+- ;;
+ esac
+
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+@@ -5773,7 +5779,6 @@
+ if test yes = "$lt_cv_irix_exported_symbol"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
+ fi
+- _LT_TAGVAR(link_all_deplibs, $1)=no
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
diff --git a/unix/xserver/hw/vnc/vncModule.c b/unix/xserver/hw/vnc/vncModule.c
index 21f87ce..5b4db96 100644
--- a/unix/xserver/hw/vnc/vncModule.c
+++ b/unix/xserver/hw/vnc/vncModule.c
@@ -58,7 +58,7 @@
static XF86ModuleVersionInfo vncVersRec =
{
"vnc",
- "Constantin Kaplinsky",
+ "TigerVNC Project",
MODINFOSTRING1,
MODINFOSTRING2,
XORG_VERSION_CURRENT,
diff --git a/vncviewer/CMakeLists.txt b/vncviewer/CMakeLists.txt
index f2a0aca..f11bae3 100644
--- a/vncviewer/CMakeLists.txt
+++ b/vncviewer/CMakeLists.txt
@@ -46,7 +46,7 @@
add_executable(vncviewer ${VNCVIEWER_SOURCES})
endif()
-target_link_libraries(vncviewer rfb network rdr os Xregion ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES})
+target_link_libraries(vncviewer rfb network rdr os ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES})
if(APPLE)
target_link_libraries(vncviewer "-framework Cocoa" "-framework Carbon")
diff --git a/win/vncconfig/CMakeLists.txt b/win/vncconfig/CMakeLists.txt
index 54e6643..6ed22c7 100644
--- a/win/vncconfig/CMakeLists.txt
+++ b/win/vncconfig/CMakeLists.txt
@@ -6,7 +6,7 @@
vncconfig.cxx
vncconfig.rc)
-target_link_libraries(vncconfig rfb_win32 rfb Xregion network rdr ws2_32.lib)
+target_link_libraries(vncconfig rfb_win32 rfb network rdr ws2_32.lib)
install(TARGETS vncconfig
RUNTIME DESTINATION ${BIN_DIR}
diff --git a/win/winvnc/CMakeLists.txt b/win/winvnc/CMakeLists.txt
index 16f30b7..ac9ae29 100644
--- a/win/winvnc/CMakeLists.txt
+++ b/win/winvnc/CMakeLists.txt
@@ -17,7 +17,7 @@
winvnc.cxx
${CMAKE_CURRENT_BINARY_DIR}/winvnc.rc)
-target_link_libraries(winvnc4 rfb rfb_win32 Xregion network rdr ws2_32.lib)
+target_link_libraries(winvnc4 rfb rfb_win32 network rdr ws2_32.lib)
if(BUILD_JAVA)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/winvnc.rc
diff --git a/win/wm_hooks/wm_hooks.rc b/win/wm_hooks/wm_hooks.rc
index 4ea519a..aabe732 100644
--- a/win/wm_hooks/wm_hooks.rc
+++ b/win/wm_hooks/wm_hooks.rc
@@ -72,7 +72,7 @@
BLOCK "080904b0"
BEGIN
VALUE "Comments", "\0"
- VALUE "CompanyName", "Constantin Kaplinsky\0"
+ VALUE "CompanyName", "TigerVNC Project\0"
#ifdef WIN64
VALUE "FileDescription", "TigerVNC Server Hooking DLL for Win64\0"
VALUE "ProductName", "TigerVNC Server Hooking DLL for Win64\0"