Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.801 diff -u -2 -0 -r1.801 ChangeLog --- xc/ChangeLog 7 Mar 2005 19:39:57 -0000 1.801 +++ xc/ChangeLog 7 Mar 2005 22:54:51 -0000 @@ -1,24 +1,53 @@ 2005-03-07 Roland Mainz + * xc/programs/Xserver/dix/atom.c + * xc/programs/Xserver/dix/colormap.c + * xc/programs/Xserver/dix/cursor.c + * xc/programs/Xserver/dix/devices.c + * xc/programs/Xserver/dix/dispatch.c + * xc/programs/Xserver/dix/dixfonts.c + * xc/programs/Xserver/dix/dixutils.c + * xc/programs/Xserver/dix/events.c + * xc/programs/Xserver/dix/extension.c + * xc/programs/Xserver/dix/gc.c + * xc/programs/Xserver/dix/glyphcurs.c + * xc/programs/Xserver/dix/grabs.c + * xc/programs/Xserver/dix/main.c + * xc/programs/Xserver/dix/pixmap.c + * xc/programs/Xserver/dix/privates.c + * xc/programs/Xserver/dix/property.c + * xc/programs/Xserver/dix/resource.c + * xc/programs/Xserver/dix/swaprep.c + * xc/programs/Xserver/dix/swapreq.c + * xc/programs/Xserver/dix/window.c + bugzilla #2560 (https://bugs.freedesktop.org/show_bug.cgi?id=2560) + attachment #xxx (https://bugs.freedesktop.org/attachment.cgi?id=xxx) + ANSI-fy Xserver/dix code. + The conversion preserves the comments which annotate variables. + These have been moved into doxygen(esque?) "stubs" above each + function. + Patch by Mike Owens + +2005-03-07 Roland Mainz * xc/programs/glxgears/glxgears.c bugzilla #2220 (https://bugs.freedesktop.org/show_bug.cgi?id=2220) - attachment #xxx (https://bugs.freedesktop.org/attachment.cgi?id=xxx) + attachment #2035 (https://bugs.freedesktop.org/attachment.cgi?id=2035) Backout of attachment #1630 (https://bugs.freedesktop.org/attachment.cgi?id=1630) as the described issue should be fixed in the GLX implementation of the server side (per discussion in xorg@freedesktop.org). 2005-03-07 Roland Mainz * xc/config/cf/Imake.rules * xc/programs/Xserver/hw/xfree86/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/ark/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/dummy/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/i2c/Imakefile * xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile Index: xc/programs/Xserver/dix/atom.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/atom.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 atom.c --- xc/programs/Xserver/dix/atom.c 23 Apr 2004 19:04:43 -0000 1.2 +++ xc/programs/Xserver/dix/atom.c 7 Mar 2005 22:55:07 -0000 @@ -54,44 +54,41 @@ #include "resource.h" #include "dix.h" #define InitialTableSize 100 typedef struct _Node { struct _Node *left, *right; Atom a; unsigned int fingerPrint; char *string; } NodeRec, *NodePtr; static Atom lastAtom = None; static NodePtr atomRoot = (NodePtr)NULL; static unsigned long tableLength; static NodePtr *nodeTable; void FreeAtom(NodePtr patom); Atom -MakeAtom(string, len, makeit) - char *string; - unsigned len; - Bool makeit; +MakeAtom(char *string, unsigned len, Bool makeit) { register NodePtr * np; unsigned i; int comp; register unsigned int fp = 0; np = &atomRoot; for (i = 0; i < (len+1)/2; i++) { fp = fp * 27 + string[i]; fp = fp * 27 + string[len - 1 - i]; } while (*np != (NodePtr) NULL) { if (fp < (*np)->fingerPrint) np = &((*np)->left); else if (fp > (*np)->fingerPrint) np = &((*np)->right); else { /* now start testing the strings */ @@ -134,49 +131,47 @@ if (nd->string != string) xfree(nd->string); xfree(nd); return BAD_RESOURCE; } tableLength <<= 1; nodeTable = table; } *np = nd; nd->left = nd->right = (NodePtr) NULL; nd->fingerPrint = fp; nd->a = (++lastAtom); *(nodeTable+lastAtom) = nd; return nd->a; } else return None; } Bool -ValidAtom(atom) - Atom atom; +ValidAtom(Atom atom) { return (atom != None) && (atom <= lastAtom); } char * -NameForAtom(atom) - Atom atom; +NameForAtom(Atom atom) { NodePtr node; if (atom > lastAtom) return 0; if ((node = nodeTable[atom]) == (NodePtr)NULL) return 0; return node->string; } void AtomError() { FatalError("initializing atoms"); } void FreeAtom(NodePtr patom) { if(patom->left) FreeAtom(patom->left); if(patom->right) FreeAtom(patom->right); Index: xc/programs/Xserver/dix/colormap.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/colormap.c,v retrieving revision 1.5 diff -u -2 -0 -r1.5 colormap.c --- xc/programs/Xserver/dix/colormap.c 13 Aug 2004 08:16:14 -0000 1.5 +++ xc/programs/Xserver/dix/colormap.c 7 Mar 2005 22:55:08 -0000 @@ -228,49 +228,49 @@ (bits) += (base); \ while((bits) & ~(mask)) \ (bits) += ((bits) & ~(mask)); /* ID of server as client */ #define SERVER_ID 0 typedef struct _colorResource { Colormap mid; int client; } colorResource; /* Invariants: * refcnt == 0 means entry is empty * refcnt > 0 means entry is useable by many clients, so it can't be changed * refcnt == AllocPrivate means entry owned by one client only * fShared should only be set if refcnt == AllocPrivate, and only in red map */ -/* Create and initialize the color map */ +/** + * Create and initialize the color map + * + * \param mid resource to use for this colormap + * \param alloc 1 iff all entries are allocated writable + */ int -CreateColormap (mid, pScreen, pVisual, ppcmap, alloc, client) - Colormap mid; /* resource to use for this colormap */ - ScreenPtr pScreen; - VisualPtr pVisual; - ColormapPtr *ppcmap; - int alloc; /* 1 iff all entries are allocated writeable */ - int client; +CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, + ColormapPtr *ppcmap, int alloc, int client) { int class, size; unsigned long sizebytes; ColormapPtr pmap; register EntryPtr pent; int i; register Pixel *ppix, **pptr; class = pVisual->class; if(!(class & DynamicClass) && (alloc != AllocNone) && (client != SERVER_ID)) return (BadMatch); size = pVisual->ColormapEntries; sizebytes = (size * sizeof(Entry)) + (MAXCLIENTS * sizeof(Pixel *)) + (MAXCLIENTS * sizeof(int)); if ((class | DynamicClass) == DirectColor) sizebytes *= 3; sizebytes += sizeof(ColormapRec); pmap = (ColormapPtr) xalloc(sizebytes); @@ -397,44 +397,46 @@ pmap->devPrivates = (DevUnion *) xalloc ( colormapPrivateCount * sizeof(DevUnion)); if (!pmap->devPrivates) { FreeResource (mid, RT_NONE); return BadAlloc; } } if (!(*pScreen->CreateColormap)(pmap)) { FreeResource (mid, RT_NONE); return BadAlloc; } pmap->flags &= ~BeingCreated; *ppcmap = pmap; return (Success); } +/** + * + * \param value must conform to DeleteType + */ int -FreeColormap (value, mid) - pointer value; /* must conform to DeleteType */ - XID mid; +FreeColormap (pointer value, XID mid) { int i; register EntryPtr pent; ColormapPtr pmap = (ColormapPtr)value; if(CLIENT_ID(mid) != SERVER_ID) { (*pmap->pScreen->UninstallColormap) (pmap); WalkTree(pmap->pScreen, (VisitWindowProcPtr)TellNoMap, (pointer) &mid); } /* This is the device's chance to undo anything it needs to, especially * to free any storage it allocated */ (*pmap->pScreen->DestroyColormap)(pmap); if(pmap->clientPixelsRed) { for(i = 0; i < MAXCLIENTS; i++) xfree(pmap->clientPixelsRed[i]); } @@ -457,127 +459,118 @@ } } if((pmap->class | DynamicClass) == DirectColor) { for(i = 0; i < MAXCLIENTS; i++) { xfree(pmap->clientPixelsGreen[i]); xfree(pmap->clientPixelsBlue[i]); } } if (pmap->devPrivates) xfree(pmap->devPrivates); xfree(pmap); return(Success); } /* Tell window that pmid has disappeared */ static int -TellNoMap (pwin, pmid) - WindowPtr pwin; - Colormap *pmid; +TellNoMap (WindowPtr pwin, Colormap *pmid) { xEvent xE; if (wColormap(pwin) == *pmid) { /* This should be call to DeliverEvent */ xE.u.u.type = ColormapNotify; xE.u.colormap.window = pwin->drawable.id; xE.u.colormap.colormap = None; xE.u.colormap.new = TRUE; xE.u.colormap.state = ColormapUninstalled; #ifdef PANORAMIX if(noPanoramiXExtension || !pwin->drawable.pScreen->myNum) #endif DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL); if (pwin->optional) { pwin->optional->colormap = None; CheckWindowOptionalNeed (pwin); } } return (WT_WALKCHILDREN); } /* Tell window that pmid got uninstalled */ int -TellLostMap (pwin, value) - WindowPtr pwin; - pointer value; +TellLostMap (WindowPtr pwin, pointer value) { Colormap *pmid = (Colormap *)value; xEvent xE; #ifdef PANORAMIX if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum) return WT_STOPWALKING; #endif if (wColormap(pwin) == *pmid) { /* This should be call to DeliverEvent */ xE.u.u.type = ColormapNotify; xE.u.colormap.window = pwin->drawable.id; xE.u.colormap.colormap = *pmid; xE.u.colormap.new = FALSE; xE.u.colormap.state = ColormapUninstalled; DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL); } return (WT_WALKCHILDREN); } /* Tell window that pmid got installed */ int -TellGainedMap (pwin, value) - WindowPtr pwin; - pointer value; +TellGainedMap (WindowPtr pwin, pointer value) { Colormap *pmid = (Colormap *)value; xEvent xE; #ifdef PANORAMIX if(!noPanoramiXExtension && pwin->drawable.pScreen->myNum) return WT_STOPWALKING; #endif if (wColormap (pwin) == *pmid) { /* This should be call to DeliverEvent */ xE.u.u.type = ColormapNotify; xE.u.colormap.window = pwin->drawable.id; xE.u.colormap.colormap = *pmid; xE.u.colormap.new = FALSE; xE.u.colormap.state = ColormapInstalled; DeliverEvents(pwin, &xE, 1, (WindowPtr)NULL); } return (WT_WALKCHILDREN); } int -CopyColormapAndFree (mid, pSrc, client) - Colormap mid; - ColormapPtr pSrc; - int client; +CopyColormapAndFree (Colormap mid, ColormapPtr pSrc, int client) { ColormapPtr pmap = (ColormapPtr) NULL; int result, alloc, size; Colormap midSrc; ScreenPtr pScreen; VisualPtr pVisual; pScreen = pSrc->pScreen; pVisual = pSrc->pVisual; midSrc = pSrc->mid; alloc = ((pSrc->flags & AllAllocated) && CLIENT_ID(midSrc) == client) ? AllocAll : AllocNone; size = pVisual->ColormapEntries; /* If the create returns non-0, it failed */ result = CreateColormap (mid, pScreen, pVisual, &pmap, alloc, client); if(result != Success) return(result); if(alloc == AllocAll) { @@ -590,43 +583,41 @@ pSrc->flags &= ~AllAllocated; FreePixels(pSrc, client); UpdateColors(pmap); return(Success); } CopyFree(REDMAP, client, pSrc, pmap); if ((pmap->class | DynamicClass) == DirectColor) { CopyFree(GREENMAP, client, pSrc, pmap); CopyFree(BLUEMAP, client, pSrc, pmap); } if (pmap->class & DynamicClass) UpdateColors(pmap); /* XXX should worry about removing any RT_CMAPENTRY resource */ return(Success); } /* Helper routine for freeing large numbers of cells from a map */ static void -CopyFree (channel, client, pmapSrc, pmapDst) - int channel, client; - ColormapPtr pmapSrc, pmapDst; +CopyFree (int channel, int client, ColormapPtr pmapSrc, ColormapPtr pmapDst) { int z, npix; EntryPtr pentSrcFirst, pentDstFirst; EntryPtr pentSrc, pentDst; Pixel *ppix; int nalloc; switch(channel) { default: /* so compiler can see that everything gets initialized */ case REDMAP: ppix = (pmapSrc->clientPixelsRed)[client]; npix = (pmapSrc->numPixelsRed)[client]; pentSrcFirst = pmapSrc->red; pentDstFirst = pmapDst->red; break; case GREENMAP: ppix = (pmapSrc->clientPixelsGreen)[client]; npix = (pmapSrc->numPixelsGreen)[client]; pentSrcFirst = pmapSrc->green; @@ -679,44 +670,41 @@ pmapDst->freeGreen -= nalloc; (pmapDst->clientPixelsGreen)[client] = (pmapSrc->clientPixelsGreen)[client]; (pmapSrc->clientPixelsGreen)[client] = (Pixel *) NULL; (pmapDst->numPixelsGreen)[client] = (pmapSrc->numPixelsGreen)[client]; (pmapSrc->numPixelsGreen)[client] = 0; break; case BLUEMAP: pmapDst->freeBlue -= nalloc; pmapDst->clientPixelsBlue[client] = pmapSrc->clientPixelsBlue[client]; pmapSrc->clientPixelsBlue[client] = (Pixel *) NULL; pmapDst->numPixelsBlue[client] = pmapSrc->numPixelsBlue[client]; pmapSrc->numPixelsBlue[client] = 0; break; } } /* Free the ith entry in a color map. Must handle freeing of * colors allocated through AllocColorPlanes */ static void -FreeCell (pmap, i, channel) - ColormapPtr pmap; - Pixel i; - int channel; +FreeCell (ColormapPtr pmap, Pixel i, int channel) { EntryPtr pent; int *pCount; switch (channel) { default: /* so compiler can see that everything gets initialized */ case PSEUDOMAP: case REDMAP: pent = (EntryPtr) &pmap->red[i]; pCount = &pmap->freeRed; break; case GREENMAP: pent = (EntryPtr) &pmap->green[i]; pCount = &pmap->freeGreen; break; case BLUEMAP: pent = (EntryPtr) &pmap->blue[i]; pCount = &pmap->freeBlue; @@ -729,42 +717,41 @@ else { /* If the color type is shared, find the sharedcolor. If decremented * refcnt is 0, free the shared cell. */ if (pent->fShared) { if(--pent->co.shco.red->refcnt == 0) xfree(pent->co.shco.red); if(--pent->co.shco.green->refcnt == 0) xfree(pent->co.shco.green); if(--pent->co.shco.blue->refcnt == 0) xfree(pent->co.shco.blue); pent->fShared = FALSE; } pent->refcnt = 0; *pCount += 1; } } static void -UpdateColors (pmap) - ColormapPtr pmap; +UpdateColors (ColormapPtr pmap) { xColorItem *defs; register xColorItem *pdef; register EntryPtr pent; register VisualPtr pVisual; int i, n, size; pVisual = pmap->pVisual; size = pVisual->ColormapEntries; defs = (xColorItem *)ALLOCATE_LOCAL(size * sizeof(xColorItem)); if (!defs) return; n = 0; pdef = defs; if (pmap->class == DirectColor) { for (i = 0; i < size; i++) { if (!pmap->red[i].refcnt && !pmap->green[i].refcnt && @@ -797,45 +784,43 @@ else { pdef->red = pent->co.local.red; pdef->green = pent->co.local.green; pdef->blue = pent->co.local.blue; } pdef->flags = DoRed|DoGreen|DoBlue; pdef++; n++; } } if (n) (*pmap->pScreen->StoreColors)(pmap, n, defs); DEALLOCATE_LOCAL(defs); } /* Get a read-only color from a ColorMap (probably slow for large maps) * Returns by changing the value in pred, pgreen, pblue and pPix */ int -AllocColor (pmap, pred, pgreen, pblue, pPix, client) - ColormapPtr pmap; - unsigned short *pred, *pgreen, *pblue; - Pixel *pPix; - int client; +AllocColor (ColormapPtr pmap, + unsigned short *pred, unsigned short *pgreen, unsigned short *pblue, + Pixel *pPix, int client) { Pixel pixR, pixG, pixB; int entries; xrgb rgb; int class; VisualPtr pVisual; int npix; Pixel *ppix; pVisual = pmap->pVisual; (*pmap->pScreen->ResolveColor) (pred, pgreen, pblue, pVisual); rgb.red = *pred; rgb.green = *pgreen; rgb.blue = *pblue; class = pmap->class; entries = pVisual->ColormapEntries; /* If the colormap is being created, then we want to be able to change * the colormap, even if it's a static type. Otherwise, we'd never be * able to initialize static colormaps @@ -984,43 +969,41 @@ (void)FreeColors(pmap, client, 1, pPix, (Pixel)0); return (BadAlloc); } pcr->mid = pmap->mid; pcr->client = client; if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) return (BadAlloc); } return (Success); } /* * FakeAllocColor -- fake an AllocColor request by * returning a free pixel if availible, otherwise returning * the closest matching pixel. This is used by the mi * software sprite code to recolor cursors. A nice side-effect * is that this routine will never return failure. */ void -FakeAllocColor (pmap, item) - register ColormapPtr pmap; - register xColorItem *item; +FakeAllocColor (register ColormapPtr pmap, register xColorItem *item) { Pixel pixR, pixG, pixB; Pixel temp; int entries; xrgb rgb; int class; register VisualPtr pVisual; pVisual = pmap->pVisual; rgb.red = item->red; rgb.green = item->green; rgb.blue = item->blue; (*pmap->pScreen->ResolveColor) (&rgb.red, &rgb.green, &rgb.blue, pVisual); class = pmap->class; entries = pVisual->ColormapEntries; switch (class) { case GrayScale: case PseudoColor: item->pixel = 0; @@ -1052,43 +1035,41 @@ -1, BlueComp) != Success) pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP) << pVisual->offsetBlue; item->pixel = pixR | pixG | pixB; break; case TrueColor: /* Look up each component in its own map, then OR them together */ pixR = FindBestPixel(pmap->red, NUMRED(pVisual), &rgb, REDMAP); pixG = FindBestPixel(pmap->green, NUMGREEN(pVisual), &rgb, GREENMAP); pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP); item->pixel = (pixR << pVisual->offsetRed) | (pixG << pVisual->offsetGreen) | (pixB << pVisual->offsetBlue); break; } } /* free a pixel value obtained from FakeAllocColor */ void -FakeFreeColor(pmap, pixel) - register ColormapPtr pmap; - Pixel pixel; +FakeFreeColor(register ColormapPtr pmap, Pixel pixel) { register VisualPtr pVisual; Pixel pixR, pixG, pixB; switch (pmap->class) { case GrayScale: case PseudoColor: if (pmap->red[pixel].refcnt == AllocTemporary) pmap->red[pixel].refcnt = 0; break; case DirectColor: pVisual = pmap->pVisual; pixR = (pixel & pVisual->redMask) >> pVisual->offsetRed; pixG = (pixel & pVisual->greenMask) >> pVisual->offsetGreen; pixB = (pixel & pVisual->blueMask) >> pVisual->offsetBlue; if (pmap->red[pixR].refcnt == AllocTemporary) pmap->red[pixR].refcnt = 0; if (pmap->green[pixG].refcnt == AllocTemporary) pmap->green[pixG].refcnt = 0; if (pmap->blue[pixB].refcnt == AllocTemporary) @@ -1119,45 +1100,41 @@ ((r)->lower = LOWERPART(u))) #define MaxBigNum(r) (((r)->upper = BIGNUMUPPER-1), \ ((r)->lower = BIGNUMLOWER-1)) static void BigNumAdd (BigNumPtr x, BigNumPtr y, BigNumPtr r) { BigNumLower lower, carry = 0; lower = x->lower + y->lower; if (lower >= BIGNUMLOWER) { lower -= BIGNUMLOWER; carry = 1; } r->lower = lower; r->upper = x->upper + y->upper + carry; } static Pixel -FindBestPixel(pentFirst, size, prgb, channel) - EntryPtr pentFirst; - int size; - xrgb *prgb; - int channel; +FindBestPixel(EntryPtr pentFirst, int size, xrgb *prgb, int channel) { EntryPtr pent; Pixel pixel, final; long dr, dg, db; unsigned long sq; BigNumRec minval, sum, temp; final = 0; MaxBigNum(&minval); /* look for the minimal difference */ for (pent = pentFirst, pixel = 0; pixel < size; pent++, pixel++) { dr = dg = db = 0; switch(channel) { case PSEUDOMAP: dg = (long) pent->co.local.green - prgb->green; db = (long) pent->co.local.blue - prgb->blue; case REDMAP: dr = (long) pent->co.local.red - prgb->red; @@ -1170,93 +1147,82 @@ break; } sq = dr * dr; UnsignedToBigNum (sq, &sum); sq = dg * dg; UnsignedToBigNum (sq, &temp); BigNumAdd (&sum, &temp, &sum); sq = db * db; UnsignedToBigNum (sq, &temp); BigNumAdd (&sum, &temp, &sum); if (BigNumGreater (&minval, &sum)) { final = pixel; minval = sum; } } return(final); } static void -FindColorInRootCmap (pmap, pentFirst, size, prgb, pPixel, channel, comp) - ColormapPtr pmap; - EntryPtr pentFirst; - int size; - xrgb* prgb; - Pixel* pPixel; - int channel; - ColorCompareProcPtr comp; +FindColorInRootCmap (ColormapPtr pmap, EntryPtr pentFirst, int size, + xrgb *prgb, Pixel *pPixel, int channel, + ColorCompareProcPtr comp) { EntryPtr pent; Pixel pixel; int count; if ((pixel = *pPixel) >= size) pixel = 0; for (pent = pentFirst + pixel, count = size; --count >= 0; pent++, pixel++) { if (pent->refcnt > 0 && (*comp) (pent, prgb)) { switch (channel) { case REDMAP: pixel <<= pmap->pVisual->offsetRed; break; case GREENMAP: pixel <<= pmap->pVisual->offsetGreen; break; case BLUEMAP: pixel <<= pmap->pVisual->offsetBlue; break; default: /* PSEUDOMAP */ break; } *pPixel = pixel; } } } /* Tries to find a color in pmap that exactly matches the one requested in prgb * if it can't it allocates one. * Starts looking at pentFirst + *pPixel, so if you want a specific pixel, * load *pPixel with that value, otherwise set it to 0 */ int -FindColor (pmap, pentFirst, size, prgb, pPixel, channel, client, comp) - ColormapPtr pmap; - EntryPtr pentFirst; - int size; - xrgb *prgb; - Pixel *pPixel; - int channel; - int client; - ColorCompareProcPtr comp; +FindColor (ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb *prgb, + Pixel *pPixel, int channel, int client, + ColorCompareProcPtr comp) { EntryPtr pent; Bool foundFree; Pixel pixel, Free = 0; int npix, count, *nump = NULL; Pixel **pixp = NULL, *ppix; xColorItem def; foundFree = FALSE; if((pixel = *pPixel) >= size) pixel = 0; /* see if there is a match, and also look for a free entry */ for (pent = pentFirst + pixel, count = size; --count >= 0; ) { if (pent->refcnt > 0) { if ((*comp) (pent, prgb)) { if (client >= 0) @@ -1395,90 +1361,78 @@ break; case GREENMAP: pmap->freeGreen++; break; case BLUEMAP: pmap->freeBlue++; break; } return(BadAlloc); } ppix[npix] = pixel; pixp[client] = ppix; nump[client]++; return(Success); } /* Comparison functions -- passed to FindColor to determine if an * entry is already the color we're looking for or not */ static int -AllComp (pent, prgb) - EntryPtr pent; - xrgb *prgb; +AllComp (EntryPtr pent, xrgb *prgb) { if((pent->co.local.red == prgb->red) && (pent->co.local.green == prgb->green) && (pent->co.local.blue == prgb->blue) ) return (1); return (0); } static int -RedComp (pent, prgb) - EntryPtr pent; - xrgb *prgb; +RedComp (EntryPtr pent, xrgb *prgb) { if (pent->co.local.red == prgb->red) return (1); return (0); } static int -GreenComp (pent, prgb) - EntryPtr pent; - xrgb *prgb; +GreenComp (EntryPtr pent, xrgb *prgb) { if (pent->co.local.green == prgb->green) return (1); return (0); } static int -BlueComp (pent, prgb) - EntryPtr pent; - xrgb *prgb; +BlueComp (EntryPtr pent, xrgb *prgb) { if (pent->co.local.blue == prgb->blue) return (1); return (0); } /* Read the color value of a cell */ int -QueryColors (pmap, count, ppixIn, prgbList) - ColormapPtr pmap; - int count; - Pixel *ppixIn; - xrgb *prgbList; +QueryColors (ColormapPtr pmap, int count, Pixel *ppixIn, xrgb *prgbList) { Pixel *ppix, pixel; xrgb *prgb; VisualPtr pVisual; EntryPtr pent; Pixel i; int errVal = Success; pVisual = pmap->pVisual; if ((pmap->class | DynamicClass) == DirectColor) { int numred, numgreen, numblue; Pixel rgbbad; numred = NUMRED(pVisual); numgreen = NUMGREEN(pVisual); numblue = NUMBLUE(pVisual); rgbbad = ~RGBMASK(pVisual); for( ppix = ppixIn, prgb = prgbList; --count >= 0; ppix++, prgb++) { @@ -1529,43 +1483,41 @@ pent = (EntryPtr)&pmap->red[pixel]; if (pent->fShared) { prgb->red = pent->co.shco.red->color; prgb->green = pent->co.shco.green->color; prgb->blue = pent->co.shco.blue->color; } else { prgb->red = pent->co.local.red; prgb->green = pent->co.local.green; prgb->blue = pent->co.local.blue; } } } } return (errVal); } static void -FreePixels(pmap, client) - register ColormapPtr pmap; - register int client; +FreePixels(register ColormapPtr pmap, register int client) { register Pixel *ppix, *ppixStart; register int n; int class; #ifdef LBX Bool grabbed; Bool zeroRefCount; Bool anyRefCountReachedZero = 0; #endif class = pmap->class; ppixStart = pmap->clientPixelsRed[client]; if (class & DynamicClass) { n = pmap->numPixelsRed[client]; #ifdef LBX grabbed = LbxCheckCmapGrabbed (pmap); if (grabbed) { /* @@ -1620,65 +1572,62 @@ if ((class | DynamicClass) == DirectColor) { ppixStart = pmap->clientPixelsGreen[client]; if (class & DynamicClass) for (ppix = ppixStart, n = pmap->numPixelsGreen[client]; --n >= 0;) FreeCell(pmap, *ppix++, GREENMAP); xfree(ppixStart); pmap->clientPixelsGreen[client] = (Pixel *) NULL; pmap->numPixelsGreen[client] = 0; ppixStart = pmap->clientPixelsBlue[client]; if (class & DynamicClass) for (ppix = ppixStart, n = pmap->numPixelsBlue[client]; --n >= 0; ) FreeCell(pmap, *ppix++, BLUEMAP); xfree(ppixStart); pmap->clientPixelsBlue[client] = (Pixel *) NULL; pmap->numPixelsBlue[client] = 0; } } -/* Free all of a client's colors and cells */ -/*ARGSUSED*/ +/** + * Frees all of a client's colors and cells. + * + * \param value must conform to DeleteType + * \unused fakeid + */ int -FreeClientPixels (value, fakeid) - pointer value; /* must conform to DeleteType */ - XID fakeid; +FreeClientPixels (pointer value, XID fakeid) { ColormapPtr pmap; colorResource *pcr = (colorResource *)value; pmap = (ColormapPtr) LookupIDByType(pcr->mid, RT_COLORMAP); if (pmap) FreePixels(pmap, pcr->client); xfree(pcr); return Success; } int -AllocColorCells (client, pmap, colors, planes, contig, ppix, masks) - int client; - ColormapPtr pmap; - int colors, planes; - Bool contig; - Pixel *ppix; - Pixel *masks; +AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, + Bool contig, Pixel *ppix, Pixel *masks) { Pixel rmask, gmask, bmask, *ppixFirst, r, g, b; int n, class; int ok; int oldcount; colorResource *pcr = (colorResource *)NULL; class = pmap->class; if (!(class & DynamicClass)) return (BadAlloc); /* Shouldn't try on this type */ oldcount = pmap->numPixelsRed[client]; if (pmap->class == DirectColor) oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client]; if (!oldcount && (CLIENT_ID(pmap->mid) != client)) { pcr = (colorResource *) xalloc(sizeof(colorResource)); if (!pcr) return (BadAlloc); } @@ -1715,48 +1664,43 @@ } } /* if this is the client's first pixels in this colormap, tell the * resource manager that the client has pixels in this colormap which * should be freed when the client dies */ if ((ok == Success) && pcr) { pcr->mid = pmap->mid; pcr->client = client; if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) ok = BadAlloc; } else if (pcr) xfree(pcr); return (ok); } int -AllocColorPlanes (client, pmap, colors, r, g, b, contig, pixels, - prmask, pgmask, pbmask) - int client; - ColormapPtr pmap; - int colors, r, g, b; - Bool contig; - Pixel *pixels; - Pixel *prmask, *pgmask, *pbmask; +AllocColorPlanes (int client, ColormapPtr pmap, int colors, + int r, int g, int b, Bool contig, Pixel *pixels, + Pixel *prmask, Pixel *pgmask, Pixel *pbmask) { int ok; Pixel mask, *ppixFirst; register Pixel shift; register int i; int class; int oldcount; colorResource *pcr = (colorResource *)NULL; class = pmap->class; if (!(class & DynamicClass)) return (BadAlloc); /* Shouldn't try on this type */ oldcount = pmap->numPixelsRed[client]; if (class == DirectColor) oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client]; if (!oldcount && (CLIENT_ID(pmap->mid) != client)) { pcr = (colorResource *) xalloc(sizeof(colorResource)); if (!pcr) return (BadAlloc); @@ -1810,47 +1754,42 @@ } } } /* if this is the client's first pixels in this colormap, tell the * resource manager that the client has pixels in this colormap which * should be freed when the client dies */ if ((ok == Success) && pcr) { pcr->mid = pmap->mid; pcr->client = client; if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) ok = BadAlloc; } else if (pcr) xfree(pcr); return (ok); } static int -AllocDirect (client, pmap, c, r, g, b, contig, pixels, prmask, pgmask, pbmask) - int client; - ColormapPtr pmap; - int c, r, g, b; - Bool contig; - Pixel *pixels; - Pixel *prmask, *pgmask, *pbmask; +AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool contig, + Pixel *pixels, Pixel *prmask, Pixel *pgmask, Pixel *pbmask) { Pixel *ppixRed, *ppixGreen, *ppixBlue; Pixel *ppix, *pDst, *p; int npix, npixR, npixG, npixB; Bool okR, okG, okB; Pixel *rpix = 0, *gpix = 0, *bpix = 0; npixR = c << r; npixG = c << g; npixB = c << b; if ((r >= 32) || (g >= 32) || (b >= 32) || (npixR > pmap->freeRed) || (npixR < c) || (npixG > pmap->freeGreen) || (npixG < c) || (npixB > pmap->freeBlue) || (npixB < c)) return BadAlloc; /* start out with empty pixels */ for(p = pixels; p < pixels + c; p++) *p = 0; @@ -1934,48 +1873,42 @@ { *ppix++ = *p; if(p < ppixBlue + c) *pDst++ |= *p << pmap->pVisual->offsetBlue; } pmap->numPixelsBlue[client] += npixB; pmap->freeBlue -= npixB; for (pDst = pixels; pDst < pixels + c; pDst++) *pDst |= ALPHAMASK(pmap->pVisual); DEALLOCATE_LOCAL(ppixBlue); DEALLOCATE_LOCAL(ppixGreen); DEALLOCATE_LOCAL(ppixRed); return (Success); } static int -AllocPseudo (client, pmap, c, r, contig, pixels, pmask, pppixFirst) - int client; - ColormapPtr pmap; - int c, r; - Bool contig; - Pixel *pixels; - Pixel *pmask; - Pixel **pppixFirst; +AllocPseudo (int client, ColormapPtr pmap, int c, int r, Bool contig, + Pixel *pixels, Pixel *pmask, Pixel **pppixFirst) { Pixel *ppix, *p, *pDst, *ppixTemp; int npix; Bool ok; npix = c << r; if ((r >= 32) || (npix > pmap->freeRed) || (npix < c)) return(BadAlloc); if(!(ppixTemp = (Pixel *)ALLOCATE_LOCAL(npix * sizeof(Pixel)))) return(BadAlloc); ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask); if (ok) { /* all the allocated pixels are added to the client pixel list, * but only the unique ones are returned to the client */ ppix = (Pixel *)xrealloc(pmap->clientPixelsRed[client], (pmap->numPixelsRed[client] + npix) * sizeof(Pixel)); if (!ppix) @@ -1995,47 +1928,42 @@ *pDst++ = *p; } pmap->numPixelsRed[client] += npix; pmap->freeRed -= npix; } DEALLOCATE_LOCAL(ppixTemp); return (ok ? Success : BadAlloc); } /* Allocates count << planes pixels from colormap pmap for client. If * contig, then the plane mask is made of consecutive bits. Returns * all count << pixels in the array pixels. The first count of those * pixels are the unique pixels. *pMask has the mask to Or with the * unique pixels to get the rest of them. * * Returns True iff all pixels could be allocated * All cells allocated will have refcnt set to AllocPrivate and shared to FALSE * (see AllocShared for why we care) */ static Bool -AllocCP (pmap, pentFirst, count, planes, contig, pixels, pMask) - ColormapPtr pmap; - EntryPtr pentFirst; - int count, planes; - Bool contig; - Pixel *pixels, *pMask; - +AllocCP (ColormapPtr pmap, EntryPtr pentFirst, int count, int planes, + Bool contig, Pixel *pixels, Pixel *pMask) { EntryPtr ent; Pixel pixel, base, entries, maxp, save; int dplanes, found; Pixel *ppix; Pixel mask; Pixel finalmask; dplanes = pmap->pVisual->nplanes; /* Easy case. Allocate pixels only */ if (planes == 0) { /* allocate writable entries */ ppix = pixels; ent = pentFirst; pixel = 0; while (--count >= 0) { /* Just find count unallocated cells */ @@ -2170,47 +2098,47 @@ while (--count >= 0) { pixel = (pixels)[count]; maxp = 0; while (1) { ent[pixel + maxp].refcnt = AllocPrivate; ent[pixel + maxp].fShared = FALSE; GetNextBitsOrBreak(maxp, mask, base); *ppix++ = pixel + maxp; } } *pMask = mask; return (TRUE); } } return (FALSE); } +/** + * + * \param ppixFirst First of the client's new pixels + */ static Bool -AllocShared (pmap, ppix, c, r, g, b, rmask, gmask, bmask, ppixFirst) - ColormapPtr pmap; - Pixel *ppix; - int c, r, g, b; - Pixel rmask, gmask, bmask; - Pixel *ppixFirst; /* First of the client's new pixels */ +AllocShared (ColormapPtr pmap, Pixel *ppix, int c, int r, int g, int b, + Pixel rmask, Pixel gmask, Pixel bmask, Pixel *ppixFirst) { Pixel *pptr, *cptr; int npix, z, npixClientNew, npixShared; Pixel basemask, base, bits, common; SHAREDCOLOR *pshared, **ppshared, **psharedList; npixClientNew = c << (r + g + b); npixShared = (c << r) + (c << g) + (c << b); psharedList = (SHAREDCOLOR **)ALLOCATE_LOCAL(npixShared * sizeof(SHAREDCOLOR *)); if (!psharedList) return FALSE; ppshared = psharedList; for (z = npixShared; --z >= 0; ) { if (!(ppshared[z] = (SHAREDCOLOR *)xalloc(sizeof(SHAREDCOLOR)))) { for (z++ ; z < npixShared; z++) xfree(ppshared[z]); return FALSE; @@ -2305,98 +2233,96 @@ } } else { pshared = *ppshared++; pshared->refcnt = 1 << (g + b); for (cptr = ppixFirst, z = npixClientNew; --z >= 0; cptr++) { if ((*cptr & basemask) == common) { pmap->red[*cptr].co.shco.blue = pshared; } } } } DEALLOCATE_LOCAL(psharedList); return TRUE; } -/* Free colors and/or cells (probably slow for large numbers) */ - +/** FreeColors + * Free colors and/or cells (probably slow for large numbers) + */ int -FreeColors (pmap, client, count, pixels, mask) - ColormapPtr pmap; - int client, count; - Pixel *pixels; - Pixel mask; +FreeColors (ColormapPtr pmap, int client, int count, Pixel *pixels, Pixel mask) { int rval, result, class; Pixel rmask; class = pmap->class; if (pmap->flags & AllAllocated) return(BadAccess); if ((class | DynamicClass) == DirectColor) { rmask = mask & RGBMASK(pmap->pVisual); result = FreeCo(pmap, client, REDMAP, count, pixels, mask & pmap->pVisual->redMask); /* If any of the three calls fails, we must report that, if more * than one fails, it's ok that we report the last one */ rval = FreeCo(pmap, client, GREENMAP, count, pixels, mask & pmap->pVisual->greenMask); if(rval != Success) result = rval; rval = FreeCo(pmap, client, BLUEMAP, count, pixels, mask & pmap->pVisual->blueMask); if(rval != Success) result = rval; } else { rmask = mask & ((((Pixel)1) << pmap->pVisual->nplanes) - 1); result = FreeCo(pmap, client, PSEUDOMAP, count, pixels, rmask); } if ((mask != rmask) && count) { clientErrorValue = *pixels | mask; result = BadValue; } /* XXX should worry about removing any RT_CMAPENTRY resource */ return (result); } -/* Helper for FreeColors -- frees all combinations of *newpixels and mask bits +/** + * Helper for FreeColors -- frees all combinations of *newpixels and mask bits * which the client has allocated in channel colormap cells of pmap. - * doesn't change newpixels if it doesn't need to */ + * doesn't change newpixels if it doesn't need to + * + * \param pmap which colormap head + * \param color which sub-map, eg, RED, BLUE, PSEUDO + * \param npixIn number of pixels passed in + * \param ppixIn number of base pixels + * \param mask mask client gave us + */ static int -FreeCo (pmap, client, color, npixIn, ppixIn, mask) - ColormapPtr pmap; /* which colormap head */ - int client; - int color; /* which sub-map, eg RED, BLUE, PSEUDO */ - int npixIn; /* number of pixels passed in */ - Pixel *ppixIn; /* list of base pixels */ - Pixel mask; /* mask client gave us */ +FreeCo (ColormapPtr pmap, int client, int color, int npixIn, Pixel *ppixIn, Pixel mask) { - Pixel *ppixClient, pixTest; int npixClient, npixNew, npix; Pixel bits, base, cmask, rgbbad; Pixel *pptr, *cptr; int n, zapped; int errVal = Success; int offset, numents; #ifdef LBX Bool grabbed; Bool zeroRefCount; Bool anyRefCountReachedZero = 0; #endif if (npixIn == 0) return (errVal); bits = 0; zapped = 0; base = lowbit (mask); switch(color) @@ -2555,44 +2481,41 @@ pmap->clientPixelsRed[client] = ppixClient; pmap->numPixelsRed[client] = npixClient; break; case GREENMAP: pmap->clientPixelsGreen[client] = ppixClient; pmap->numPixelsGreen[client] = npixClient; break; case BLUEMAP: pmap->clientPixelsBlue[client] = ppixClient; pmap->numPixelsBlue[client] = npixClient; break; } } return (errVal); } /* Redefine color values */ int -StoreColors (pmap, count, defs) - ColormapPtr pmap; - int count; - xColorItem *defs; +StoreColors (ColormapPtr pmap, int count, xColorItem *defs) { register Pixel pix; register xColorItem *pdef; register EntryPtr pent, pentT, pentLast; register VisualPtr pVisual; SHAREDCOLOR *pred, *pgreen, *pblue; int n, ChgRed, ChgGreen, ChgBlue, idef; int class, errVal = Success; int ok; class = pmap->class; if(!(class & DynamicClass) && !(pmap->flags & BeingCreated)) { return(BadAccess); } pVisual = pmap->pVisual; idef = 0; if((class | DynamicClass) == DirectColor) @@ -2825,43 +2748,41 @@ defChg.pixel = pentT - pmap->red; defChg.red = pentT->co.shco.red->color; defChg.green = pentT->co.shco.green->color; defChg.blue = pentT->co.shco.blue->color; (*pmap->pScreen->StoreColors) (pmap, 1, &defChg); } } } } } } /* Note that we use idef, the count of acceptable entries, and not * count, the count of proposed entries */ if (idef != 0) ( *pmap->pScreen->StoreColors) (pmap, idef, defs); return (errVal); } int -IsMapInstalled(map, pWin) - Colormap map; - WindowPtr pWin; +IsMapInstalled(Colormap map, WindowPtr pWin) { Colormap *pmaps; int imap, nummaps, found; pmaps = (Colormap *) ALLOCATE_LOCAL( pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap)); if(!pmaps) return(FALSE); nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps) (pWin->drawable.pScreen, pmaps); found = FALSE; for(imap = 0; imap < nummaps; imap++) { if(pmaps[imap] == map) { found = TRUE; break; } } DEALLOCATE_LOCAL(pmaps); Index: xc/programs/Xserver/dix/cursor.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/cursor.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 cursor.c --- xc/programs/Xserver/dix/cursor.c 31 Jul 2004 01:48:27 -0000 1.3 +++ xc/programs/Xserver/dix/cursor.c 7 Mar 2005 22:55:08 -0000 @@ -83,48 +83,47 @@ xfree(bits->argb); #endif if (bits->refcnt == 0) { register GlyphSharePtr *prev, this; for (prev = &sharedGlyphs; (this = *prev) && (this->bits != bits); prev = &this->next) ; if (this) { *prev = this->next; CloseFont(this->font, (Font)0); xfree(this); } xfree(bits); } } -/* - * To be called indirectly by DeleteResource; must use exactly two args +/** + * To be called indirectly by DeleteResource; must use exactly two args. + * + * \param value must conform to DeleteType */ -/*ARGSUSED*/ int -FreeCursor(value, cid) - pointer value; /* must conform to DeleteType */ - XID cid; +FreeCursor(pointer value, XID cid) { int nscr; CursorPtr pCurs = (CursorPtr)value; ScreenPtr pscr; if ( --pCurs->refcnt > 0) return(Success); for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; (void)( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(pCurs->bits); xfree( pCurs); return(Success); } @@ -135,53 +134,53 @@ CheckForEmptyMask(CursorBitsPtr bits) { register unsigned char *msk = bits->mask; int n = BitmapBytePad(bits->width) * bits->height; bits->emptyMask = FALSE; while(n--) if(*(msk++) != 0) return; #ifdef ARGB_CURSOR if (bits->argb) { CARD32 *argb = bits->argb; int n = bits->width * bits->height; while (n--) if (*argb++ & 0xff000000) return; } #endif bits->emptyMask = TRUE; } -/* +/** * does nothing about the resource table, just creates the data structure. * does not copy the src and mask bits + * + * \param psrcbits server-defined padding + * \param pmaskbits server-defined padding + * \param argb no padding */ CursorPtr -AllocCursorARGB(psrcbits, pmaskbits, argb, cm, - foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue) - unsigned char * psrcbits; /* server-defined padding */ - unsigned char * pmaskbits; /* server-defined padding */ - CARD32 * argb; /* no padding */ - CursorMetricPtr cm; - unsigned foreRed, foreGreen, foreBlue; - unsigned backRed, backGreen, backBlue; +AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, + CursorMetricPtr cm, + unsigned foreRed, unsigned foreGreen, unsigned foreBlue, + unsigned backRed, unsigned backGreen, unsigned backBlue) { CursorBitsPtr bits; CursorPtr pCurs; int nscr; ScreenPtr pscr; pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits)); if (!pCurs) { xfree(psrcbits); xfree(pmaskbits); return (CursorPtr)NULL; } bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec)); bits->source = psrcbits; bits->mask = pmaskbits; #ifdef ARGB_CURSOR bits->argb = argb; #endif bits->width = cm->width; @@ -210,64 +209,61 @@ * realize the cursor for every screen */ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; if (!( *pscr->RealizeCursor)( pscr, pCurs)) { while (--nscr >= 0) { pscr = screenInfo.screens[nscr]; ( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(bits); xfree(pCurs); return (CursorPtr)NULL; } } return pCurs; } +/** + * + * \param psrcbits server-defined padding + * \param pmaskbits server-defined padding + */ CursorPtr -AllocCursor(psrcbits, pmaskbits, cm, - foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue) - unsigned char * psrcbits; /* server-defined padding */ - unsigned char * pmaskbits; /* server-defined padding */ - CursorMetricPtr cm; - unsigned foreRed, foreGreen, foreBlue; - unsigned backRed, backGreen, backBlue; +AllocCursor(unsigned char *psrcbits, unsigned char *pmaskbits, + CursorMetricPtr cm, + unsigned foreRed, unsigned foreGreen, unsigned foreBlue, + unsigned backRed, unsigned backGreen, unsigned backBlue) { return AllocCursorARGB (psrcbits, pmaskbits, (CARD32 *) 0, cm, foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue); } int -AllocGlyphCursor(source, sourceChar, mask, maskChar, - foreRed, foreGreen, foreBlue, backRed, backGreen, backBlue, - ppCurs, client) - Font source, mask; - unsigned int sourceChar, maskChar; - unsigned foreRed, foreGreen, foreBlue; - unsigned backRed, backGreen, backBlue; - CursorPtr *ppCurs; - ClientPtr client; +AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, + unsigned foreRed, unsigned foreGreen, unsigned foreBlue, + unsigned backRed, unsigned backGreen, unsigned backBlue, + CursorPtr *ppCurs, ClientPtr client) { FontPtr sourcefont, maskfont; unsigned char *srcbits; unsigned char *mskbits; CursorMetricRec cm; int res; CursorBitsPtr bits; CursorPtr pCurs; int nscr; ScreenPtr pscr; GlyphSharePtr pShare; sourcefont = (FontPtr) SecurityLookupIDByType(client, source, RT_FONT, SecurityReadAccess); maskfont = (FontPtr) SecurityLookupIDByType(client, mask, RT_FONT, SecurityReadAccess); if (!sourcefont) { client->errorValue = source; @@ -405,54 +401,51 @@ */ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; if (!( *pscr->RealizeCursor)( pscr, pCurs)) { while (--nscr >= 0) { pscr = screenInfo.screens[nscr]; ( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(pCurs->bits); xfree(pCurs); return BadAlloc; } } *ppCurs = pCurs; return Success; } -/*********************************************************** - * CreateRootCursor +/** CreateRootCursor * * look up the name of a font * open the font * add the font to the resource table * make a cursor from the glyphs * add the cursor to the resource table *************************************************************/ CursorPtr -CreateRootCursor(pfilename, glyph) - char * pfilename; - unsigned int glyph; +CreateRootCursor(char *pfilename, unsigned glyph) { CursorPtr curs; FontPtr cursorfont; int err; XID fontID; fontID = FakeClientID(0); err = OpenFont(serverClient, fontID, FontLoadAll | FontOpenSync, (unsigned)strlen( pfilename), pfilename); if (err != Success) return NullCursor; cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT); if (!cursorfont) return NullCursor; if (AllocGlyphCursor(fontID, glyph, fontID, glyph + 1, 0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success) return NullCursor; if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer)curs)) Index: xc/programs/Xserver/dix/devices.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/devices.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 devices.c --- xc/programs/Xserver/dix/devices.c 23 Apr 2004 19:04:43 -0000 1.2 +++ xc/programs/Xserver/dix/devices.c 7 Mar 2005 22:55:09 -0000 @@ -61,43 +61,41 @@ #include "cursorstr.h" #include "dixstruct.h" #include "site.h" #define XKB_IN_SERVER #ifdef XKB #include "XKBsrv.h" #endif #ifdef XCSECURITY #define _SECURITY_SERVER #include "security.h" #endif #ifdef LBX #include "lbxserve.h" #endif #include "dispatch.h" #include "swaprep.h" #include "dixevents.h" DeviceIntPtr -_AddInputDevice(deviceProc, autoStart) - DeviceProc deviceProc; - Bool autoStart; +_AddInputDevice(DeviceProc deviceProc, Bool autoStart) { register DeviceIntPtr dev; if (inputInfo.numDevices >= MAX_DEVICES) return (DeviceIntPtr)NULL; dev = (DeviceIntPtr) xalloc(sizeof(DeviceIntRec)); if (!dev) return (DeviceIntPtr)NULL; dev->name = (char *)NULL; dev->type = 0; dev->id = inputInfo.numDevices; inputInfo.numDevices++; dev->public.on = FALSE; dev->public.processInputProc = (ProcessInputProc)NoopDDA; dev->public.realInputProc = (ProcessInputProc)NoopDDA; dev->public.enqueueInputProc = EnqueueEvent; dev->deviceProc = deviceProc; dev->startup = autoStart; dev->sync.frozen = FALSE; dev->sync.other = NullGrab; @@ -110,61 +108,59 @@ dev->key = (KeyClassPtr)NULL; dev->valuator = (ValuatorClassPtr)NULL; dev->button = (ButtonClassPtr)NULL; dev->focus = (FocusClassPtr)NULL; dev->proximity = (ProximityClassPtr)NULL; dev->kbdfeed = (KbdFeedbackPtr)NULL; dev->ptrfeed = (PtrFeedbackPtr)NULL; dev->intfeed = (IntegerFeedbackPtr)NULL; dev->stringfeed = (StringFeedbackPtr)NULL; dev->bell = (BellFeedbackPtr)NULL; dev->leds = (LedFeedbackPtr)NULL; dev->next = inputInfo.off_devices; #ifdef XKB dev->xkb_interest= NULL; #endif inputInfo.off_devices = dev; return dev; } Bool -EnableDevice(dev) - register DeviceIntPtr dev; +EnableDevice(register DeviceIntPtr dev) { register DeviceIntPtr *prev; for (prev = &inputInfo.off_devices; *prev && (*prev != dev); prev = &(*prev)->next) ; if ((*prev != dev) || !dev->inited || ((*dev->deviceProc)(dev, DEVICE_ON) != Success)) return FALSE; *prev = dev->next; dev->next = inputInfo.devices; inputInfo.devices = dev; return TRUE; } Bool -DisableDevice(dev) - register DeviceIntPtr dev; +DisableDevice(register DeviceIntPtr dev) { register DeviceIntPtr *prev; for (prev = &inputInfo.devices; *prev && (*prev != dev); prev = &(*prev)->next) ; if (*prev != dev) return FALSE; (void)(*dev->deviceProc)(dev, DEVICE_OFF); *prev = dev->next; dev->next = inputInfo.off_devices; inputInfo.off_devices = dev; return TRUE; } int InitAndStartDevices() { register DeviceIntPtr dev, next; @@ -285,42 +281,41 @@ { register DeviceIntPtr dev, next; for (dev = inputInfo.devices; dev; dev = next) { next = dev->next; CloseDevice(dev); } for (dev = inputInfo.off_devices; dev; dev = next) { next = dev->next; CloseDevice(dev); } inputInfo.devices = NULL; inputInfo.off_devices = NULL; inputInfo.keyboard = NULL; inputInfo.pointer = NULL; } void -RemoveDevice(dev) - register DeviceIntPtr dev; +RemoveDevice(register DeviceIntPtr dev) { register DeviceIntPtr prev,tmp,next; prev= NULL; for (tmp= inputInfo.devices; tmp; (prev = tmp), (tmp = next)) { next = tmp->next; if (tmp==dev) { CloseDevice(tmp); if (prev==NULL) inputInfo.devices = next; else prev->next = next; inputInfo.numDevices--; if (inputInfo.keyboard == tmp) inputInfo.keyboard = NULL; else if (inputInfo.pointer == tmp) inputInfo.pointer = NULL; return; } } @@ -336,135 +331,130 @@ prev->next = next; inputInfo.numDevices--; if (inputInfo.keyboard == tmp) inputInfo.keyboard = NULL; else if (inputInfo.pointer == tmp) inputInfo.pointer = NULL; return; } } ErrorF("Internal Error! Attempt to remove a non-existent device\n"); return; } int NumMotionEvents() { return inputInfo.pointer->valuator->numMotionEvents; } void -_RegisterPointerDevice(device) - DeviceIntPtr device; +_RegisterPointerDevice(DeviceIntPtr device) { inputInfo.pointer = device; #ifdef XKB if (noXkbExtension) { device->public.processInputProc = CoreProcessPointerEvent; device->public.realInputProc = CoreProcessPointerEvent; } else { device->public.processInputProc = ProcessPointerEvent; device->public.realInputProc = ProcessPointerEvent; } #else device->public.processInputProc = ProcessPointerEvent; device->public.realInputProc = ProcessPointerEvent; #endif device->ActivateGrab = ActivatePointerGrab; device->DeactivateGrab = DeactivatePointerGrab; if (!device->name) { char *p = "pointer"; device->name = (char *)xalloc(strlen(p) + 1); strcpy(device->name, p); } } void -_RegisterKeyboardDevice(device) - DeviceIntPtr device; +_RegisterKeyboardDevice(DeviceIntPtr device) { inputInfo.keyboard = device; #ifdef XKB if (noXkbExtension) { device->public.processInputProc = CoreProcessKeyboardEvent; device->public.realInputProc = CoreProcessKeyboardEvent; } else { device->public.processInputProc = ProcessKeyboardEvent; device->public.realInputProc = ProcessKeyboardEvent; } #else device->public.processInputProc = ProcessKeyboardEvent; device->public.realInputProc = ProcessKeyboardEvent; #endif device->ActivateGrab = ActivateKeyboardGrab; device->DeactivateGrab = DeactivateKeyboardGrab; if (!device->name) { char *k = "keyboard"; device->name = (char *)xalloc(strlen(k) + 1); strcpy(device->name, k); } } DevicePtr LookupKeyboardDevice() { return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL; } DevicePtr LookupPointerDevice() { return inputInfo.pointer ? &inputInfo.pointer->public : NULL; } DevicePtr -LookupDevice(id) - int id; +LookupDevice(int id) { DeviceIntPtr dev; for (dev=inputInfo.devices; dev; dev=dev->next) { if (dev->id == (CARD8)id) return (DevicePtr)dev; } for (dev=inputInfo.off_devices; dev; dev=dev->next) { if (dev->id == (CARD8)id) return (DevicePtr)dev; } return NULL; } void -QueryMinMaxKeyCodes(minCode, maxCode) - KeyCode *minCode, *maxCode; +QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode) { if (inputInfo.keyboard) { *minCode = inputInfo.keyboard->key->curKeySyms.minKeyCode; *maxCode = inputInfo.keyboard->key->curKeySyms.maxKeyCode; } } Bool -SetKeySymsMap(dst, src) - register KeySymsPtr dst, src; +SetKeySymsMap(register KeySymsPtr dst, register KeySymsPtr src) { int i, j; int rowDif = src->minKeyCode - dst->minKeyCode; /* if keysym map size changes, grow map first */ if (src->mapWidth < dst->mapWidth) { for (i = src->minKeyCode; i <= src->maxKeyCode; i++) { #define SI(r, c) (((r-src->minKeyCode)*src->mapWidth) + (c)) #define DI(r, c) (((r - dst->minKeyCode)*dst->mapWidth) + (c)) for (j = 0; j < src->mapWidth; j++) dst->map[DI(i, j)] = src->map[SI(i, j)]; for (j = src->mapWidth; j < dst->mapWidth; j++) dst->map[DI(i, j)] = NoSymbol; #undef SI #undef DI } return TRUE; } @@ -521,374 +511,341 @@ return (FALSE); bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier); for (i = 0; i < 8; i++) keysPerModifier[i] = 0; for (i = 8; i < MAP_LENGTH; i++) { for (j = 0, mask = 1; j < 8; j++, mask <<= 1) { if (mask & keyc->modifierMap[i]) { keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) + keysPerModifier[j]] = i; keysPerModifier[j]++; } } } return TRUE; } Bool -InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers) - DeviceIntPtr dev; - KeySymsPtr pKeySyms; - CARD8 pModifiers[]; +InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers[]) { int i; register KeyClassPtr keyc; keyc = (KeyClassPtr)xalloc(sizeof(KeyClassRec)); if (!keyc) return FALSE; keyc->curKeySyms.map = (KeySym *)NULL; keyc->curKeySyms.mapWidth = 0; keyc->curKeySyms.minKeyCode = pKeySyms->minKeyCode; keyc->curKeySyms.maxKeyCode = pKeySyms->maxKeyCode; keyc->modifierKeyMap = (KeyCode *)NULL; keyc->state = 0; keyc->prev_state = 0; if (pModifiers) memmove((char *)keyc->modifierMap, (char *)pModifiers, MAP_LENGTH); else bzero((char *)keyc->modifierMap, MAP_LENGTH); bzero((char *)keyc->down, DOWN_LENGTH); for (i = 0; i < 8; i++) keyc->modifierKeyCount[i] = 0; if (!SetKeySymsMap(&keyc->curKeySyms, pKeySyms) || !InitModMap(keyc)) { xfree(keyc->curKeySyms.map); xfree(keyc->modifierKeyMap); xfree(keyc); return FALSE; } dev->key = keyc; #ifdef XKB dev->key->xkbInfo= NULL; if (!noXkbExtension) XkbInitDevice(dev); #endif return TRUE; } Bool -InitButtonClassDeviceStruct(dev, numButtons, map) - register DeviceIntPtr dev; - int numButtons; - CARD8 *map; +InitButtonClassDeviceStruct(register DeviceIntPtr dev, int numButtons, + CARD8 *map) { register ButtonClassPtr butc; int i; butc = (ButtonClassPtr)xalloc(sizeof(ButtonClassRec)); if (!butc) return FALSE; butc->numButtons = numButtons; for (i = 1; i <= numButtons; i++) butc->map[i] = map[i]; butc->buttonsDown = 0; butc->state = 0; butc->motionMask = 0; bzero((char *)butc->down, DOWN_LENGTH); #ifdef XKB butc->xkb_acts= NULL; #endif dev->button = butc; return TRUE; } Bool -InitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode) - DeviceIntPtr dev; - ValuatorMotionProcPtr motionProc; - int numAxes; - int numMotionEvents; - int mode; +InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, + ValuatorMotionProcPtr motionProc, + int numMotionEvents, int mode) { int i; register ValuatorClassPtr valc; valc = (ValuatorClassPtr)xalloc(sizeof(ValuatorClassRec) + numAxes * sizeof(AxisInfo) + numAxes * sizeof(unsigned int)); if (!valc) return FALSE; valc->GetMotionProc = motionProc; valc->numMotionEvents = numMotionEvents; valc->motionHintWindow = NullWindow; valc->numAxes = numAxes; valc->mode = mode; valc->axes = (AxisInfoPtr)(valc + 1); valc->axisVal = (int *)(valc->axes + numAxes); for (i=0; iaxisVal[i]=0; dev->valuator = valc; return TRUE; } Bool -InitFocusClassDeviceStruct(dev) - DeviceIntPtr dev; +InitFocusClassDeviceStruct(DeviceIntPtr dev) { register FocusClassPtr focc; focc = (FocusClassPtr)xalloc(sizeof(FocusClassRec)); if (!focc) return FALSE; focc->win = PointerRootWin; focc->revert = None; focc->time = currentTime; focc->trace = (WindowPtr *)NULL; focc->traceSize = 0; focc->traceGood = 0; dev->focus = focc; return TRUE; } Bool -InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc) - DeviceIntPtr dev; - BellProcPtr bellProc; - KbdCtrlProcPtr controlProc; +InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc, + KbdCtrlProcPtr controlProc) { register KbdFeedbackPtr feedc; feedc = (KbdFeedbackPtr)xalloc(sizeof(KbdFeedbackClassRec)); if (!feedc) return FALSE; feedc->BellProc = bellProc; feedc->CtrlProc = controlProc; #ifdef XKB defaultKeyboardControl.autoRepeat = TRUE; #endif feedc->ctrl = defaultKeyboardControl; feedc->ctrl.id = 0; if ((feedc->next = dev->kbdfeed) != 0) feedc->ctrl.id = dev->kbdfeed->ctrl.id + 1; dev->kbdfeed = feedc; #ifdef XKB feedc->xkb_sli= NULL; if (!noXkbExtension) XkbFinishDeviceInit(dev); #endif (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl); return TRUE; } Bool -InitPtrFeedbackClassDeviceStruct(dev, controlProc) - DeviceIntPtr dev; - PtrCtrlProcPtr controlProc; +InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc) { register PtrFeedbackPtr feedc; feedc = (PtrFeedbackPtr)xalloc(sizeof(PtrFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; #ifdef sgi feedc->ctrl.num = 1; feedc->ctrl.den = 1; feedc->ctrl.threshold = 1; #else feedc->ctrl = defaultPointerControl; #endif feedc->ctrl.id = 0; if ( (feedc->next = dev->ptrfeed) ) feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1; dev->ptrfeed = feedc; (*controlProc)(dev, &feedc->ctrl); return TRUE; } LedCtrl defaultLedControl = { DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0}; BellCtrl defaultBellControl = { DEFAULT_BELL, DEFAULT_BELL_PITCH, DEFAULT_BELL_DURATION, 0}; IntegerCtrl defaultIntegerControl = { DEFAULT_INT_RESOLUTION, DEFAULT_INT_MIN_VALUE, DEFAULT_INT_MAX_VALUE, DEFAULT_INT_DISPLAYED, 0}; Bool -InitStringFeedbackClassDeviceStruct (dev, controlProc, max_symbols, - num_symbols_supported, symbols) - DeviceIntPtr dev; - StringCtrlProcPtr controlProc; - int max_symbols; - int num_symbols_supported; - KeySym *symbols; +InitStringFeedbackClassDeviceStruct ( + DeviceIntPtr dev, StringCtrlProcPtr controlProc, + int max_symbols, int num_symbols_supported, KeySym *symbols) { int i; register StringFeedbackPtr feedc; feedc = (StringFeedbackPtr)xalloc(sizeof(StringFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; feedc->ctrl.num_symbols_supported = num_symbols_supported; feedc->ctrl.num_symbols_displayed = 0; feedc->ctrl.max_symbols = max_symbols; feedc->ctrl.symbols_supported = (KeySym *) xalloc (sizeof (KeySym) * num_symbols_supported); feedc->ctrl.symbols_displayed = (KeySym *) xalloc (sizeof (KeySym) * max_symbols); if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) { if (feedc->ctrl.symbols_supported) xfree(feedc->ctrl.symbols_supported); if (feedc->ctrl.symbols_displayed) xfree(feedc->ctrl.symbols_displayed); xfree(feedc); return FALSE; } for (i=0; ictrl.symbols_supported+i) = *symbols++; for (i=0; ictrl.symbols_displayed+i) = (KeySym) NULL; feedc->ctrl.id = 0; if ( (feedc->next = dev->stringfeed) ) feedc->ctrl.id = dev->stringfeed->ctrl.id + 1; dev->stringfeed = feedc; (*controlProc)(dev, &feedc->ctrl); return TRUE; } Bool -InitBellFeedbackClassDeviceStruct (dev, bellProc, controlProc) - DeviceIntPtr dev; - BellProcPtr bellProc; - BellCtrlProcPtr controlProc; +InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, + BellCtrlProcPtr controlProc) { register BellFeedbackPtr feedc; feedc = (BellFeedbackPtr)xalloc(sizeof(BellFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; feedc->BellProc = bellProc; feedc->ctrl = defaultBellControl; feedc->ctrl.id = 0; if ( (feedc->next = dev->bell) ) feedc->ctrl.id = dev->bell->ctrl.id + 1; dev->bell = feedc; (*controlProc)(dev, &feedc->ctrl); return TRUE; } Bool -InitLedFeedbackClassDeviceStruct (dev, controlProc) - DeviceIntPtr dev; - LedCtrlProcPtr controlProc; +InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc) { register LedFeedbackPtr feedc; feedc = (LedFeedbackPtr)xalloc(sizeof(LedFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; feedc->ctrl = defaultLedControl; feedc->ctrl.id = 0; if ( (feedc->next = dev->leds) ) feedc->ctrl.id = dev->leds->ctrl.id + 1; #ifdef XKB feedc->xkb_sli= NULL; #endif dev->leds = feedc; (*controlProc)(dev, &feedc->ctrl); return TRUE; } Bool -InitIntegerFeedbackClassDeviceStruct (dev, controlProc) - DeviceIntPtr dev; - IntegerCtrlProcPtr controlProc; +InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc) { register IntegerFeedbackPtr feedc; feedc = (IntegerFeedbackPtr)xalloc(sizeof(IntegerFeedbackClassRec)); if (!feedc) return FALSE; feedc->CtrlProc = controlProc; feedc->ctrl = defaultIntegerControl; feedc->ctrl.id = 0; if ( (feedc->next = dev->intfeed) ) feedc->ctrl.id = dev->intfeed->ctrl.id + 1; dev->intfeed = feedc; (*controlProc)(dev, &feedc->ctrl); return TRUE; } Bool -InitPointerDeviceStruct(device, map, numButtons, motionProc, controlProc, - numMotionEvents) - DevicePtr device; - CARD8 *map; - int numButtons; - PtrCtrlProcPtr controlProc; - ValuatorMotionProcPtr motionProc; - int numMotionEvents; +InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, + ValuatorMotionProcPtr motionProc, + PtrCtrlProcPtr controlProc, int numMotionEvents) { DeviceIntPtr dev = (DeviceIntPtr)device; return(InitButtonClassDeviceStruct(dev, numButtons, map) && InitValuatorClassDeviceStruct(dev, 2, motionProc, numMotionEvents, 0) && InitPtrFeedbackClassDeviceStruct(dev, controlProc)); } Bool -InitKeyboardDeviceStruct(device, pKeySyms, pModifiers, bellProc, controlProc) - DevicePtr device; - KeySymsPtr pKeySyms; - CARD8 pModifiers[]; - BellProcPtr bellProc; - KbdCtrlProcPtr controlProc; +InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms, + CARD8 pModifiers[], BellProcPtr bellProc, + KbdCtrlProcPtr controlProc) { DeviceIntPtr dev = (DeviceIntPtr)device; return(InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers) && InitFocusClassDeviceStruct(dev) && InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc)); } void -SendMappingNotify(request, firstKeyCode, count, client) - unsigned int request, count; - unsigned int firstKeyCode; - ClientPtr client; +SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count, + ClientPtr client) { int i; xEvent event; event.u.u.type = MappingNotify; event.u.mappingNotify.request = request; if (request == MappingKeyboard) { event.u.mappingNotify.firstKeyCode = firstKeyCode; event.u.mappingNotify.count = count; } #ifdef XKB if (!noXkbExtension && ((request == MappingKeyboard) || (request == MappingModifier))) { XkbApplyMappingChange(inputInfo.keyboard,request,firstKeyCode,count, client); } #endif /* 0 is the server client */ @@ -897,45 +854,41 @@ if (clients[i] && clients[i]->clientState == ClientStateRunning) { #ifdef XKB if (!noXkbExtension && (request == MappingKeyboard) && (clients[i]->xkbClientFlags != 0) && (clients[i]->mapNotifyMask&XkbKeySymsMask)) continue; #endif event.u.u.sequenceNumber = clients[i]->sequence; WriteEventsToClient(clients[i], 1, &event); } } } /* * n-squared algorithm. n < 255 and don't want to copy the whole thing and * sort it to do the checking. How often is it called? Just being lazy? */ Bool -BadDeviceMap(buff, length, low, high, errval) - register BYTE *buff; - int length; - unsigned low, high; - XID *errval; +BadDeviceMap(register BYTE *buff, int length, unsigned low, unsigned high, XID *errval) { register int i, j; for (i = 0; i < length; i++) if (buff[i]) /* only check non-zero elements */ { if ((low > buff[i]) || (high < buff[i])) { *errval = buff[i]; return TRUE; } for (j = i + 1; j < length; j++) if (buff[i] == buff[j]) { *errval = buff[i]; return TRUE; } } return FALSE; } @@ -949,42 +902,41 @@ register int i, j, k; register CARD8 *down = dev->key->down; for (i = 8; --i >= 0; map2 += per2) { for (j = per1; --j >= 0; map1++) { if (*map1 && BitIsOn(down, *map1)) { for (k = per2; (--k >= 0) && (*map1 != map2[k]);) ; if (k < 0) return FALSE; } } } return TRUE; } int -ProcSetModifierMapping(client) - ClientPtr client; +ProcSetModifierMapping(ClientPtr client) { xSetModifierMappingReply rep; REQUEST(xSetModifierMappingReq); KeyCode *inputMap; int inputMapLen; register int i; DeviceIntPtr keybd = inputInfo.keyboard; register KeyClassPtr keyc = keybd->key; REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); if (client->req_len != ((stuff->numKeyPerModifier<<1) + (sizeof (xSetModifierMappingReq)>>2))) return BadLength; inputMapLen = 8*stuff->numKeyPerModifier; inputMap = (KeyCode *)&stuff[1]; /* * Now enforce the restriction that "all of the non-zero keycodes must be @@ -1061,64 +1013,62 @@ keyc->maxKeysPerModifier = stuff->numKeyPerModifier; for (i = 0; i < MAP_LENGTH; i++) keyc->modifierMap[i] = 0; for (i = 0; i < inputMapLen; i++) { if (inputMap[i]) keyc->modifierMap[inputMap[i]] |= (1<<(((unsigned int)i)/keyc->maxKeysPerModifier)); } } if (rep.success == MappingSuccess) SendMappingNotify(MappingModifier, 0, 0, client); WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); return(client->noClientException); } int -ProcGetModifierMapping(client) - ClientPtr client; +ProcGetModifierMapping(ClientPtr client) { xGetModifierMappingReply rep; register KeyClassPtr keyc = inputInfo.keyboard->key; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; rep.numKeyPerModifier = keyc->maxKeysPerModifier; rep.sequenceNumber = client->sequence; /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ rep.length = keyc->maxKeysPerModifier << 1; WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep); /* Use the (modified by DDX) map that SetModifierMapping passed in */ (void)WriteToClient(client, (int)(keyc->maxKeysPerModifier << 3), (char *)keyc->modifierKeyMap); return client->noClientException; } int -ProcChangeKeyboardMapping(client) - ClientPtr client; +ProcChangeKeyboardMapping(ClientPtr client) { REQUEST(xChangeKeyboardMappingReq); unsigned len; KeySymsRec keysyms; register KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms; REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2); if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) return BadLength; if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || (stuff->firstKeyCode > curKeySyms->maxKeyCode)) { client->errorValue = stuff->firstKeyCode; return BadValue; } if ( ((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > curKeySyms->maxKeyCode) || (stuff->keySymsPerKeyCode == 0)) { @@ -1129,162 +1079,154 @@ if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE)) return BadAccess; #endif keysyms.minKeyCode = stuff->firstKeyCode; keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1; keysyms.mapWidth = stuff->keySymsPerKeyCode; keysyms.map = (KeySym *)&stuff[1]; if (!SetKeySymsMap(curKeySyms, &keysyms)) return BadAlloc; #ifdef LBX LbxFlushKeyboardMapTag(); #endif SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes, client); return client->noClientException; } int -ProcSetPointerMapping(client) - ClientPtr client; +ProcSetPointerMapping(ClientPtr client) { REQUEST(xSetPointerMappingReq); BYTE *map; xSetPointerMappingReply rep; register unsigned int i; DeviceIntPtr mouse = inputInfo.pointer; REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2) return BadLength; rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.success = MappingSuccess; map = (BYTE *)&stuff[1]; if (stuff->nElts != mouse->button->numButtons) { client->errorValue = stuff->nElts; return BadValue; } if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue)) return BadValue; for (i=0; i < stuff->nElts; i++) if ((mouse->button->map[i + 1] != map[i]) && BitIsOn(mouse->button->down, i + 1)) { rep.success = MappingBusy; WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); return Success; } for (i = 0; i < stuff->nElts; i++) mouse->button->map[i + 1] = map[i]; SendMappingNotify(MappingPointer, 0, 0, client); WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); return Success; } int -ProcGetKeyboardMapping(client) - ClientPtr client; +ProcGetKeyboardMapping(ClientPtr client) { xGetKeyboardMappingReply rep; REQUEST(xGetKeyboardMappingReq); KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms; REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || (stuff->firstKeyCode > curKeySyms->maxKeyCode)) { client->errorValue = stuff->firstKeyCode; return BadValue; } if (stuff->firstKeyCode + stuff->count > (unsigned)(curKeySyms->maxKeyCode + 1)) { client->errorValue = stuff->count; return BadValue; } rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.keySymsPerKeyCode = curKeySyms->mapWidth; /* length is a count of 4 byte quantities and KeySyms are 4 bytes */ rep.length = (curKeySyms->mapWidth * stuff->count); WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep); client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; WriteSwappedDataToClient( client, curKeySyms->mapWidth * stuff->count * sizeof(KeySym), &curKeySyms->map[(stuff->firstKeyCode - curKeySyms->minKeyCode) * curKeySyms->mapWidth]); return client->noClientException; } int -ProcGetPointerMapping(client) - ClientPtr client; +ProcGetPointerMapping(ClientPtr client) { xGetPointerMappingReply rep; ButtonClassPtr butc = inputInfo.pointer->button; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.nElts = butc->numButtons; rep.length = ((unsigned)rep.nElts + (4-1))/4; WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); (void)WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]); return Success; } void -NoteLedState(keybd, led, on) - DeviceIntPtr keybd; - int led; - Bool on; +NoteLedState(DeviceIntPtr keybd, int led, Bool on) { KeybdCtrl *ctrl = &keybd->kbdfeed->ctrl; if (on) ctrl->leds |= ((Leds)1 << (led - 1)); else ctrl->leds &= ~((Leds)1 << (led - 1)); } int -Ones(mask) /* HACKMEM 169 */ - unsigned long mask; +Ones(unsigned long mask) /* HACKMEM 169 */ { register unsigned long y; y = (mask >> 1) &033333333333; y = mask - y - ((y >>1) & 033333333333); return (((y + (y >> 3)) & 030707070707) % 077); } int -ProcChangeKeyboardControl (client) - ClientPtr client; +ProcChangeKeyboardControl (ClientPtr client) { #define DO_ALL (-1) KeybdCtrl ctrl; DeviceIntPtr keybd = inputInfo.keyboard; XID *vlist; int t; int led = DO_ALL; int key = DO_ALL; BITS32 vmask, index2; int mask, i; REQUEST(xChangeKeyboardControlReq); REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); vmask = stuff->mask; if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask)) return BadLength; #ifdef XCSECURITY if (!SecurityCheckDeviceAccess(client, keybd, TRUE)) return BadAccess; #endif @@ -1440,96 +1382,93 @@ default: client->errorValue = stuff->mask; return BadValue; } } keybd->kbdfeed->ctrl = ctrl; #ifdef XKB /* The XKB RepeatKeys control and core protocol global autorepeat */ /* value are linked */ if (!noXkbExtension) { XkbSetRepeatKeys(keybd,key,keybd->kbdfeed->ctrl.autoRepeat); } else #endif (*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl); return Success; #undef DO_ALL } int -ProcGetKeyboardControl (client) - ClientPtr client; +ProcGetKeyboardControl (ClientPtr client) { int i; register KeybdCtrl *ctrl = &inputInfo.keyboard->kbdfeed->ctrl; xGetKeyboardControlReply rep; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; rep.length = 5; rep.sequenceNumber = client->sequence; rep.globalAutoRepeat = ctrl->autoRepeat; rep.keyClickPercent = ctrl->click; rep.bellPercent = ctrl->bell; rep.bellPitch = ctrl->bell_pitch; rep.bellDuration = ctrl->bell_duration; rep.ledMask = ctrl->leds; for (i = 0; i < 32; i++) rep.map[i] = ctrl->autoRepeats[i]; WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep); return Success; } int -ProcBell(client) - ClientPtr client; +ProcBell(ClientPtr client) { register DeviceIntPtr keybd = inputInfo.keyboard; int base = keybd->kbdfeed->ctrl.bell; int newpercent; REQUEST(xBellReq); REQUEST_SIZE_MATCH(xBellReq); if (stuff->percent < -100 || stuff->percent > 100) { client->errorValue = stuff->percent; return BadValue; } newpercent = (base * stuff->percent) / 100; if (stuff->percent < 0) newpercent = base + newpercent; else newpercent = base - newpercent + stuff->percent; #ifdef XKB if (!noXkbExtension) XkbHandleBell(FALSE,FALSE, keybd, newpercent, &keybd->kbdfeed->ctrl, 0, None, NULL, client); else #endif (*keybd->kbdfeed->BellProc)(newpercent, keybd, (pointer) &keybd->kbdfeed->ctrl, 0); return Success; } int -ProcChangePointerControl(client) - ClientPtr client; +ProcChangePointerControl(ClientPtr client) { DeviceIntPtr mouse = inputInfo.pointer; PtrCtrl ctrl; /* might get BadValue part way through */ REQUEST(xChangePointerControlReq); REQUEST_SIZE_MATCH(xChangePointerControlReq); ctrl = mouse->ptrfeed->ctrl; if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) { client->errorValue = stuff->doAccel; return(BadValue); } if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) { client->errorValue = stuff->doThresh; return(BadValue); } if (stuff->doAccel) { if (stuff->accelNum == -1) @@ -1549,78 +1488,74 @@ } else ctrl.den = stuff->accelDenum; } if (stuff->doThresh) { if (stuff->threshold == -1) ctrl.threshold = defaultPointerControl.threshold; else if (stuff->threshold < 0) { client->errorValue = stuff->threshold; return BadValue; } else ctrl.threshold = stuff->threshold; } mouse->ptrfeed->ctrl = ctrl; (*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl); return Success; } int -ProcGetPointerControl(client) - ClientPtr client; +ProcGetPointerControl(ClientPtr client) { register PtrCtrl *ctrl = &inputInfo.pointer->ptrfeed->ctrl; xGetPointerControlReply rep; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.threshold = ctrl->threshold; rep.accelNumerator = ctrl->num; rep.accelDenominator = ctrl->den; WriteReplyToClient(client, sizeof(xGenericReply), &rep); return Success; } void -MaybeStopHint(dev, client) - register DeviceIntPtr dev; - ClientPtr client; +MaybeStopHint(register DeviceIntPtr dev, ClientPtr client) { GrabPtr grab = dev->grab; if ((grab && SameClient(grab, client) && ((grab->eventMask & PointerMotionHintMask) || (grab->ownerEvents && (EventMaskForClient(dev->valuator->motionHintWindow, client) & PointerMotionHintMask)))) || (!grab && (EventMaskForClient(dev->valuator->motionHintWindow, client) & PointerMotionHintMask))) dev->valuator->motionHintWindow = NullWindow; } int -ProcGetMotionEvents(client) - ClientPtr client; +ProcGetMotionEvents(ClientPtr client) { WindowPtr pWin; xTimecoord * coords = (xTimecoord *) NULL; xGetMotionEventsReply rep; int i, count, xmin, xmax, ymin, ymax; unsigned long nEvents; DeviceIntPtr mouse = inputInfo.pointer; TimeStamp start, stop; REQUEST(xGetMotionEventsReq); REQUEST_SIZE_MATCH(xGetMotionEventsReq); pWin = SecurityLookupWindow(stuff->window, client, TRUE); if (!pWin) return BadWindow; if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); rep.type = X_Reply; rep.sequenceNumber = client->sequence; nEvents = 0; start = ClientTimeToServerTime(stuff->start); @@ -1653,76 +1588,73 @@ coords[nEvents].x = coords[i].x - pWin->drawable.x; coords[nEvents].y = coords[i].y - pWin->drawable.y; nEvents++; } } rep.length = nEvents * (sizeof(xTimecoord) >> 2); rep.nEvents = nEvents; WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep); if (nEvents) { client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite; WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord), (char *)coords); } if (coords) DEALLOCATE_LOCAL(coords); return Success; } int -ProcQueryKeymap(client) - ClientPtr client; +ProcQueryKeymap(ClientPtr client) { xQueryKeymapReply rep; int i; CARD8 *down = inputInfo.keyboard->key->down; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 2; #ifdef XCSECURITY if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE)) { bzero((char *)&rep.map[0], 32); } else #endif for (i = 0; i<32; i++) rep.map[i] = down[i]; WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); return Success; } /****************************************************************************** * The following entrypoints are provided for binary compatibility with * previous versions (they make casts, where the current version changes types * for more stringent prototype checking). ******************************************************************************/ #ifdef AddInputDevice #undef AddInputDevice DevicePtr -AddInputDevice( - DeviceProc deviceProc, - Bool autoStart) +AddInputDevice(DeviceProc deviceProc, Bool autoStart) { return (DevicePtr)_AddInputDevice(deviceProc, autoStart); } #endif /* AddInputDevice */ #ifdef RegisterPointerDevice #undef RegisterPointerDevice void RegisterPointerDevice(DevicePtr device) { _RegisterPointerDevice((DeviceIntPtr)device); } #endif /* RegisterPointerDevice */ #ifdef RegisterKeyboardDevice #undef RegisterKeyboardDevice void RegisterKeyboardDevice(DevicePtr device) Index: xc/programs/Xserver/dix/dispatch.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/dispatch.c,v retrieving revision 1.6 diff -u -2 -0 -r1.6 dispatch.c --- xc/programs/Xserver/dix/dispatch.c 15 Sep 2004 09:05:22 -0000 1.6 +++ xc/programs/Xserver/dix/dispatch.c 7 Mar 2005 22:55:11 -0000 @@ -127,69 +127,64 @@ #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i) #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i)) extern xConnSetupPrefix connSetupPrefix; extern char *ConnectionInfo; Selection *CurrentSelections; int NumCurrentSelections; CallbackListPtr SelectionCallback = NULL; static ClientPtr grabClient; #define GrabNone 0 #define GrabActive 1 #define GrabKickout 2 static int grabState = GrabNone; static long grabWaiters[mskcnt]; CallbackListPtr ServerGrabCallback = NULL; HWEventQueuePtr checkForInput[2]; extern int connBlockScreenStart; -static void KillAllClients( - void -); - -static void DeleteClientFromAnySelections( - ClientPtr /*client*/ -); +static void KillAllClients(void); + +static void DeleteClientFromAnySelections(ClientPtr client); static int nextFreeClientID; /* always MIN free client ID */ static int nClients; /* number of authorized clients */ CallbackListPtr ClientStateCallback; char dispatchException = 0; char isItTimeToYield; /* Various of the DIX function interfaces were not designed to allow * the client->errorValue to be set on BadValue and other errors. * Rather than changing interfaces and breaking untold code we introduce * a new global that dispatch can use. */ XID clientErrorValue; /* XXX this is a kludge */ #define SAME_SCREENS(a, b) (\ (a.pScreen == b.pScreen)) void -SetInputCheck(c0, c1) - HWEventQueuePtr c0, c1; +SetInputCheck(HWEventQueuePtr c0, HWEventQueuePtr c1) { checkForInput[0] = c0; checkForInput[1] = c1; } void UpdateCurrentTime() { TimeStamp systime; /* To avoid time running backwards, we must call GetTimeInMillis before * calling ProcessInputEvents. */ systime.months = currentTime.months; systime.milliseconds = GetTimeInMillis(); if (systime.milliseconds < currentTime.milliseconds) systime.months++; if (*checkForInput[0] != *checkForInput[1]) ProcessInputEvents(); if (CompareTimeStamps(systime, currentTime) == LATER) @@ -203,42 +198,41 @@ TimeStamp systime; systime.months = currentTime.months; systime.milliseconds = GetTimeInMillis(); if (systime.milliseconds < currentTime.milliseconds) systime.months++; if (*checkForInput[0] == *checkForInput[1]) currentTime = systime; } void InitSelections() { if (CurrentSelections) xfree(CurrentSelections); CurrentSelections = (Selection *)NULL; NumCurrentSelections = 0; } void -FlushClientCaches(id) - XID id; +FlushClientCaches(XID id) { int i; register ClientPtr client; client = clients[CLIENT_ID(id)]; if (client == NullClient) return ; for (i=0; ilastDrawableID == id) { client->lastDrawableID = WindowTable[0]->drawable.id; client->lastDrawable = (DrawablePtr)WindowTable[0]; } else if (client->lastGCID == id) { client->lastGCID = INVALID; @@ -471,51 +465,48 @@ FlushAllOutput(); #ifdef SMART_SCHEDULE client = clients[clientReady[nready]]; if (client) client->smart_stop_tick = SmartScheduleTime; #endif requestingClient = NULL; } dispatchException &= ~DE_PRIORITYCHANGE; } #if defined(DDXBEFORERESET) ddxBeforeReset (); #endif KillAllClients(); DEALLOCATE_LOCAL(clientReady); dispatchException &= ~DE_RESET; } #undef MAJOROP -/*ARGSUSED*/ int -ProcBadRequest(client) - ClientPtr client; +ProcBadRequest(ClientPtr client) { return (BadRequest); } int -ProcCreateWindow(client) - register ClientPtr client; +ProcCreateWindow(ClientPtr client) { register WindowPtr pParent, pWin; REQUEST(xCreateWindowReq); int result; int len; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); LEGAL_NEW_RESOURCE(stuff->wid, client); if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, SecurityWriteAccess))) return BadWindow; len = client->req_len - (sizeof(xCreateWindowReq) >> 2); if (Ones(stuff->mask) != len) return BadLength; if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; } @@ -524,358 +515,342 @@ stuff->borderWidth, stuff->class, stuff->mask, (XID *) &stuff[1], (int)stuff->depth, client, stuff->visual, &result); if (pWin) { Mask mask = pWin->eventMask; pWin->eventMask = 0; /* subterfuge in case AddResource fails */ if (!AddResource(stuff->wid, RT_WINDOW, (pointer)pWin)) return BadAlloc; pWin->eventMask = mask; } if (client->noClientException != Success) return(client->noClientException); else return(result); } int -ProcChangeWindowAttributes(client) - register ClientPtr client; +ProcChangeWindowAttributes(register ClientPtr client) { register WindowPtr pWin; REQUEST(xChangeWindowAttributesReq); register int result; int len; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityWriteAccess); if (!pWin) return(BadWindow); len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); if (len != Ones(stuff->valueMask)) return BadLength; result = ChangeWindowAttributes(pWin, stuff->valueMask, (XID *) &stuff[1], client); if (client->noClientException != Success) return(client->noClientException); else return(result); } int -ProcGetWindowAttributes(client) - register ClientPtr client; +ProcGetWindowAttributes(register ClientPtr client) { register WindowPtr pWin; REQUEST(xResourceReq); xGetWindowAttributesReply wa; REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); GetWindowAttributes(pWin, client, &wa); WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa); return(client->noClientException); } int -ProcDestroyWindow(client) - register ClientPtr client; +ProcDestroyWindow(register ClientPtr client) { register WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, SecurityDestroyAccess); if (!pWin) return(BadWindow); if (pWin->parent) FreeResource(stuff->id, RT_NONE); return(client->noClientException); } int -ProcDestroySubwindows(client) - register ClientPtr client; +ProcDestroySubwindows(register ClientPtr client) { register WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, SecurityDestroyAccess); if (!pWin) return(BadWindow); DestroySubwindows(pWin, client); return(client->noClientException); } int -ProcChangeSaveSet(client) - register ClientPtr client; +ProcChangeSaveSet(register ClientPtr client) { register WindowPtr pWin; REQUEST(xChangeSaveSetReq); register int result; REQUEST_SIZE_MATCH(xChangeSaveSetReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityReadAccess); if (!pWin) return(BadWindow); if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) return BadMatch; if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete)) { result = AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE); if (client->noClientException != Success) return(client->noClientException); else return(result); } else { client->errorValue = stuff->mode; return( BadValue ); } } int -ProcReparentWindow(client) - register ClientPtr client; +ProcReparentWindow(register ClientPtr client) { register WindowPtr pWin, pParent; REQUEST(xReparentWindowReq); register int result; REQUEST_SIZE_MATCH(xReparentWindowReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityWriteAccess); if (!pWin) return(BadWindow); pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, SecurityWriteAccess); if (!pParent) return(BadWindow); if (SAME_SCREENS(pWin->drawable, pParent->drawable)) { if ((pWin->backgroundState == ParentRelative) && (pParent->drawable.depth != pWin->drawable.depth)) return BadMatch; if ((pWin->drawable.class != InputOnly) && (pParent->drawable.class == InputOnly)) return BadMatch; result = ReparentWindow(pWin, pParent, (short)stuff->x, (short)stuff->y, client); if (client->noClientException != Success) return(client->noClientException); else return(result); } else return (BadMatch); } int -ProcMapWindow(client) - register ClientPtr client; +ProcMapWindow(register ClientPtr client) { register WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); MapWindow(pWin, client); /* update cache to say it is mapped */ return(client->noClientException); } int -ProcMapSubwindows(client) - register ClientPtr client; +ProcMapSubwindows(register ClientPtr client) { register WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); MapSubwindows(pWin, client); /* update cache to say it is mapped */ return(client->noClientException); } int -ProcUnmapWindow(client) - register ClientPtr client; +ProcUnmapWindow(register ClientPtr client) { register WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); UnmapWindow(pWin, FALSE); /* update cache to say it is mapped */ return(client->noClientException); } int -ProcUnmapSubwindows(client) - register ClientPtr client; +ProcUnmapSubwindows(register ClientPtr client) { register WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); UnmapSubwindows(pWin); return(client->noClientException); } int -ProcConfigureWindow(client) - register ClientPtr client; +ProcConfigureWindow(register ClientPtr client) { register WindowPtr pWin; REQUEST(xConfigureWindowReq); register int result; int len; REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client, SecurityWriteAccess); if (!pWin) return(BadWindow); len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); if (Ones((Mask)stuff->mask) != len) return BadLength; result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1], client); if (client->noClientException != Success) return(client->noClientException); else return(result); } int -ProcCirculateWindow(client) - register ClientPtr client; +ProcCirculateWindow(register ClientPtr client) { register WindowPtr pWin; REQUEST(xCirculateWindowReq); REQUEST_SIZE_MATCH(xCirculateWindowReq); if ((stuff->direction != RaiseLowest) && (stuff->direction != LowerHighest)) { client->errorValue = stuff->direction; return BadValue; } pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityWriteAccess); if (!pWin) return(BadWindow); CirculateWindow(pWin, (int)stuff->direction, client); return(client->noClientException); } int -GetGeometry(client, rep) - register ClientPtr client; - xGetGeometryReply *rep; +GetGeometry(register ClientPtr client, xGetGeometryReply *rep) { register DrawablePtr pDraw; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess); rep->type = X_Reply; rep->length = 0; rep->sequenceNumber = client->sequence; rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id; rep->depth = pDraw->depth; rep->width = pDraw->width; rep->height = pDraw->height; /* XXX - Because the pixmap-implementation of the multibuffer extension * may have the buffer-id's drawable resource value be a pointer * to the buffer's window instead of the buffer itself * (this happens if the buffer is the displayed buffer), * we also have to check that the id matches before we can * truly say that it is a DRAWABLE_WINDOW. */ if ((pDraw->type == UNDRAWABLE_WINDOW) || ((pDraw->type == DRAWABLE_WINDOW) && (stuff->id == pDraw->id))) { register WindowPtr pWin = (WindowPtr)pDraw; rep->x = pWin->origin.x - wBorderWidth (pWin); rep->y = pWin->origin.y - wBorderWidth (pWin); rep->borderWidth = pWin->borderWidth; } else /* DRAWABLE_PIXMAP or DRAWABLE_BUFFER */ { rep->x = rep->y = rep->borderWidth = 0; } return Success; } int -ProcGetGeometry(client) - register ClientPtr client; +ProcGetGeometry(register ClientPtr client) { xGetGeometryReply rep; int status; if ((status = GetGeometry(client, &rep)) != Success) return status; WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); return(client->noClientException); } int -ProcQueryTree(client) - register ClientPtr client; +ProcQueryTree(register ClientPtr client) { xQueryTreeReply reply; int numChildren = 0; register WindowPtr pChild, pWin, pHead; Window *childIDs = (Window *)NULL; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); reply.type = X_Reply; reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; reply.sequenceNumber = client->sequence; if (pWin->parent) reply.parent = pWin->parent->drawable.id; else reply.parent = (Window)None; pHead = RealChildHead(pWin); @@ -890,104 +865,101 @@ return BadAlloc; for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) childIDs[curChild++] = pChild->drawable.id; } reply.nChildren = numChildren; reply.length = (numChildren * sizeof(Window)) >> 2; WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); if (numChildren) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); DEALLOCATE_LOCAL(childIDs); } return(client->noClientException); } int -ProcInternAtom(client) - register ClientPtr client; +ProcInternAtom(register ClientPtr client) { Atom atom; char *tchar; REQUEST(xInternAtomReq); REQUEST_FIXED_SIZE(xInternAtomReq, stuff->nbytes); if ((stuff->onlyIfExists != xTrue) && (stuff->onlyIfExists != xFalse)) { client->errorValue = stuff->onlyIfExists; return(BadValue); } tchar = (char *) &stuff[1]; atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists); if (atom != BAD_RESOURCE) { xInternAtomReply reply; reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; reply.atom = atom; WriteReplyToClient(client, sizeof(xInternAtomReply), &reply); return(client->noClientException); } else return (BadAlloc); } int -ProcGetAtomName(client) - register ClientPtr client; +ProcGetAtomName(register ClientPtr client) { char *str; xGetAtomNameReply reply; int len; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); if ( (str = NameForAtom(stuff->id)) ) { len = strlen(str); reply.type = X_Reply; reply.length = (len + 3) >> 2; reply.sequenceNumber = client->sequence; reply.nameLength = len; WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); (void)WriteToClient(client, len, str); return(client->noClientException); } else { client->errorValue = stuff->id; return (BadAtom); } } #ifdef K5AUTH extern int k5_bad(); #endif int -ProcSetSelectionOwner(client) - register ClientPtr client; +ProcSetSelectionOwner(register ClientPtr client) { WindowPtr pWin; TimeStamp time; REQUEST(xSetSelectionOwnerReq); REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); UpdateCurrentTime(); time = ClientTimeToServerTime(stuff->time); /* If the client's time stamp is in the future relative to the server's time stamp, do not set the selection, just return success. */ if (CompareTimeStamps(time, currentTime) == LATER) return Success; if (stuff->window != None) { pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityReadAccess); if (!pWin) return(BadWindow); } @@ -1049,74 +1021,72 @@ CurrentSelections[i].pWin = pWin; CurrentSelections[i].client = (pWin ? client : NullClient); if (SelectionCallback) { SelectionInfoRec info; info.selection = &CurrentSelections[i]; info.kind= SelectionSetOwner; CallCallbacks(&SelectionCallback, &info); } return (client->noClientException); } else { client->errorValue = stuff->selection; return (BadAtom); } } int -ProcGetSelectionOwner(client) - register ClientPtr client; +ProcGetSelectionOwner(register ClientPtr client) { REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); if (ValidAtom(stuff->id)) { int i; xGetSelectionOwnerReply reply; i = 0; while ((i < NumCurrentSelections) && CurrentSelections[i].selection != stuff->id) i++; reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; if (i < NumCurrentSelections) reply.owner = CurrentSelections[i].window; else reply.owner = None; WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); return(client->noClientException); } else { client->errorValue = stuff->id; return (BadAtom); } } int -ProcConvertSelection(client) - register ClientPtr client; +ProcConvertSelection(register ClientPtr client) { Bool paramsOkay; xEvent event; WindowPtr pWin; REQUEST(xConvertSelectionReq); REQUEST_SIZE_MATCH(xConvertSelectionReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client, SecurityReadAccess); if (!pWin) return(BadWindow); paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target)); if (stuff->property != None) paramsOkay &= ValidAtom(stuff->property); if (paramsOkay) { int i; i = 0; @@ -1146,42 +1116,41 @@ return (client->noClientException); } event.u.u.type = SelectionNotify; event.u.selectionNotify.time = stuff->time; event.u.selectionNotify.requestor = stuff->requestor; event.u.selectionNotify.selection = stuff->selection; event.u.selectionNotify.target = stuff->target; event.u.selectionNotify.property = None; (void) TryClientEvents(client, &event, 1, NoEventMask, NoEventMask /* CantBeFiltered */, NullGrab); return (client->noClientException); } else { client->errorValue = stuff->property; return (BadAtom); } } int -ProcGrabServer(client) - register ClientPtr client; +ProcGrabServer(register ClientPtr client) { REQUEST_SIZE_MATCH(xReq); if (grabState != GrabNone && client != grabClient) { ResetCurrentRequest(client); client->sequence--; BITSET(grabWaiters, client->index); IgnoreClient(client); return(client->noClientException); } OnlyListenToOneClient(client); grabState = GrabKickout; grabClient = client; if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_GRABBED; CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo); @@ -1201,51 +1170,49 @@ ; if (i >= 0) { i <<= 5; while (!GETBIT(grabWaiters, i)) i++; BITCLEAR(grabWaiters, i); AttendClient(clients[i]); } if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_UNGRABBED; CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo); } } int -ProcUngrabServer(client) - register ClientPtr client; +ProcUngrabServer(register ClientPtr client) { REQUEST_SIZE_MATCH(xReq); UngrabServer(client); return(client->noClientException); } int -ProcTranslateCoords(client) - register ClientPtr client; +ProcTranslateCoords(register ClientPtr client) { REQUEST(xTranslateCoordsReq); register WindowPtr pWin, pDst; xTranslateCoordsReply rep; REQUEST_SIZE_MATCH(xTranslateCoordsReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, SecurityReadAccess); if (!pWin) return(BadWindow); pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); if (!pDst) return(BadWindow); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) { @@ -1283,84 +1250,81 @@ POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box)) #endif ) { rep.child = pWin->drawable.id; pWin = (WindowPtr) NULL; } else pWin = pWin->nextSib; } /* adjust to destination coordinates */ rep.dstX = x - pDst->drawable.x; rep.dstY = y - pDst->drawable.y; } WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); return(client->noClientException); } int -ProcOpenFont(client) - register ClientPtr client; +ProcOpenFont(register ClientPtr client) { int err; REQUEST(xOpenFontReq); REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes); client->errorValue = stuff->fid; LEGAL_NEW_RESOURCE(stuff->fid, client); err = OpenFont(client, stuff->fid, (Mask) 0, stuff->nbytes, (char *)&stuff[1]); if (err == Success) { return(client->noClientException); } else return err; } int -ProcCloseFont(client) - register ClientPtr client; +ProcCloseFont(register ClientPtr client) { FontPtr pFont; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, SecurityDestroyAccess); if ( pFont != (FontPtr)NULL) /* id was valid */ { FreeResource(stuff->id, RT_NONE); return(client->noClientException); } else { client->errorValue = stuff->id; return (BadFont); } } int -ProcQueryFont(client) - register ClientPtr client; +ProcQueryFont(register ClientPtr client) { xQueryFontReply *reply; FontPtr pFont; register GC *pGC; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; /* EITHER font or gc */ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, SecurityReadAccess); if (!pFont) { /* can't use VERIFY_GC because it might return BadGC */ pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, SecurityReadAccess); if (!pGC) { client->errorValue = stuff->id; return(BadFont); /* procotol spec says only error is BadFont */ } @@ -1385,42 +1349,41 @@ FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + nprotoxcistructs * sizeof(xCharInfo); reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength); if(!reply) { return(BadAlloc); } reply->type = X_Reply; reply->length = (rlength - sizeof(xGenericReply)) >> 2; reply->sequenceNumber = client->sequence; QueryFont( pFont, reply, nprotoxcistructs); WriteReplyToClient(client, rlength, reply); DEALLOCATE_LOCAL(reply); return(client->noClientException); } } int -ProcQueryTextExtents(client) - register ClientPtr client; +ProcQueryTextExtents(register ClientPtr client) { REQUEST(xQueryTextExtentsReq); xQueryTextExtentsReply reply; FontPtr pFont; GC *pGC; ExtentInfoRec info; unsigned long length; REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT, SecurityReadAccess); if (!pFont) { pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC, SecurityReadAccess); if (!pGC) { client->errorValue = stuff->fid; return(BadFont); @@ -1436,76 +1399,74 @@ length--; } if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info)) return(BadAlloc); reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; reply.drawDirection = info.drawDirection; reply.fontAscent = info.fontAscent; reply.fontDescent = info.fontDescent; reply.overallAscent = info.overallAscent; reply.overallDescent = info.overallDescent; reply.overallWidth = info.overallWidth; reply.overallLeft = info.overallLeft; reply.overallRight = info.overallRight; WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply); return(client->noClientException); } int -ProcListFonts(client) - register ClientPtr client; +ProcListFonts(register ClientPtr client) { REQUEST(xListFontsReq); REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes); return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, stuff->maxNames); } int -ProcListFontsWithInfo(client) - register ClientPtr client; +ProcListFontsWithInfo(register ClientPtr client) { REQUEST(xListFontsWithInfoReq); REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes); return StartListFontsWithInfo(client, stuff->nbytes, (unsigned char *) &stuff[1], stuff->maxNames); } -/*ARGSUSED*/ +/** + * + * \param value must conform to DeleteType + */ int -dixDestroyPixmap(value, pid) - pointer value; /* must conform to DeleteType */ - XID pid; +dixDestroyPixmap(pointer value, XID pid) { PixmapPtr pPixmap = (PixmapPtr)value; return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap); } int -ProcCreatePixmap(client) - register ClientPtr client; +ProcCreatePixmap(register ClientPtr client) { PixmapPtr pMap; register DrawablePtr pDraw; REQUEST(xCreatePixmapReq); DepthPtr pDepth; register int i; REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; LEGAL_NEW_RESOURCE(stuff->pid, client); SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, SecurityReadAccess); if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; } if (stuff->depth != 1) { pDepth = pDraw->pScreen->allowedDepths; @@ -1513,282 +1474,272 @@ if (pDepth->depth == stuff->depth) goto CreatePmap; client->errorValue = stuff->depth; return BadValue; } CreatePmap: pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap) (pDraw->pScreen, stuff->width, stuff->height, stuff->depth); if (pMap) { pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) return(client->noClientException); } return (BadAlloc); } int -ProcFreePixmap(client) - register ClientPtr client; +ProcFreePixmap(register ClientPtr client) { PixmapPtr pMap; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP, SecurityDestroyAccess); if (pMap) { FreeResource(stuff->id, RT_NONE); return(client->noClientException); } else { client->errorValue = stuff->id; return (BadPixmap); } } int -ProcCreateGC(client) - register ClientPtr client; +ProcCreateGC(register ClientPtr client) { int error; GC *pGC; register DrawablePtr pDraw; unsigned len; REQUEST(xCreateGCReq); REQUEST_AT_LEAST_SIZE(xCreateGCReq); client->errorValue = stuff->gc; LEGAL_NEW_RESOURCE(stuff->gc, client); SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client, SecurityReadAccess); len = client->req_len - (sizeof(xCreateGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error); if (error != Success) return error; if (!AddResource(stuff->gc, RT_GC, (pointer)pGC)) return (BadAlloc); return(client->noClientException); } int -ProcChangeGC(client) - register ClientPtr client; +ProcChangeGC(register ClientPtr client) { GC *pGC; REQUEST(xChangeGCReq); int result; unsigned len; REQUEST_AT_LEAST_SIZE(xChangeGCReq); SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess); len = client->req_len - (sizeof(xChangeGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; result = dixChangeGC(client, pGC, stuff->mask, (CARD32 *) &stuff[1], 0); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(result); } } int -ProcCopyGC(client) - register ClientPtr client; +ProcCopyGC(register ClientPtr client) { register GC *dstGC; register GC *pGC; int result; REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess); SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess); if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) return (BadMatch); result = CopyGC(pGC, dstGC, stuff->mask); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(result); } } int -ProcSetDashes(client) - register ClientPtr client; +ProcSetDashes(register ClientPtr client) { register GC *pGC; int result; REQUEST(xSetDashesReq); REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); if (stuff->nDashes == 0) { client->errorValue = 0; return BadValue; } SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess); result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes, (unsigned char *)&stuff[1]); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(result); } } int -ProcSetClipRectangles(client) - register ClientPtr client; +ProcSetClipRectangles(register ClientPtr client) { int nr; int result; register GC *pGC; REQUEST(xSetClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) && (stuff->ordering != YXSorted) && (stuff->ordering != YXBanded)) { client->errorValue = stuff->ordering; return BadValue; } SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess); nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq); if (nr & 4) return(BadLength); nr >>= 3; result = SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin, nr, (xRectangle *)&stuff[1], (int)stuff->ordering); if (client->noClientException != Success) return(client->noClientException); else return(result); } int -ProcFreeGC(client) - register ClientPtr client; +ProcFreeGC(register ClientPtr client) { register GC *pGC; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); SECURITY_VERIFY_GC(pGC, stuff->id, client, SecurityDestroyAccess); FreeResource(stuff->id, RT_NONE); return(client->noClientException); } int -ProcClearToBackground(client) - register ClientPtr client; +ProcClearToBackground(register ClientPtr client) { REQUEST(xClearAreaReq); register WindowPtr pWin; REQUEST_SIZE_MATCH(xClearAreaReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityWriteAccess); if (!pWin) return(BadWindow); if (pWin->drawable.class == InputOnly) { client->errorValue = stuff->window; return (BadMatch); } if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) { client->errorValue = stuff->exposures; return(BadValue); } (*pWin->drawable.pScreen->ClearToBackground)(pWin, stuff->x, stuff->y, stuff->width, stuff->height, (Bool)stuff->exposures); return(client->noClientException); } int -ProcCopyArea(client) - register ClientPtr client; +ProcCopyArea(register ClientPtr client) { register DrawablePtr pDst; register DrawablePtr pSrc; register GC *pGC; REQUEST(xCopyAreaReq); RegionPtr pRgn; REQUEST_SIZE_MATCH(xCopyAreaReq); VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client, SecurityReadAccess); if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; return (BadMatch); } } else pSrc = pDst; SET_DBE_SRCBUF(pSrc, stuff->srcDrawable); pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY, stuff->width, stuff->height, stuff->dstX, stuff->dstY); if (pGC->graphicsExposures) { (*pDst->pScreen->SendGraphicsExpose) (client, pRgn, stuff->dstDrawable, X_CopyArea, 0); if (pRgn) REGION_DESTROY(pDst->pScreen, pRgn); } return(client->noClientException); } int -ProcCopyPlane(client) - register ClientPtr client; +ProcCopyPlane(register ClientPtr client) { register DrawablePtr psrcDraw, pdstDraw; register GC *pGC; REQUEST(xCopyPlaneReq); RegionPtr pRgn; REQUEST_SIZE_MATCH(xCopyPlaneReq); VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client); if (stuff->dstDrawable != stuff->srcDrawable) { SECURITY_VERIFY_DRAWABLE(psrcDraw, stuff->srcDrawable, client, SecurityReadAccess); if (pdstDraw->pScreen != psrcDraw->pScreen) { client->errorValue = stuff->dstDrawable; return (BadMatch); } } else @@ -1801,205 +1752,197 @@ (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) { client->errorValue = stuff->bitPlane; return(BadValue); } pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY, stuff->width, stuff->height, stuff->dstX, stuff->dstY, stuff->bitPlane); if (pGC->graphicsExposures) { (*pdstDraw->pScreen->SendGraphicsExpose) (client, pRgn, stuff->dstDrawable, X_CopyPlane, 0); if (pRgn) REGION_DESTROY(pdstDraw->pScreen, pRgn); } return(client->noClientException); } int -ProcPolyPoint(client) - register ClientPtr client; +ProcPolyPoint(register ClientPtr client) { int npoint; register GC *pGC; register DrawablePtr pDraw; REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2; if (npoint) (*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint, (xPoint *) &stuff[1]); return (client->noClientException); } int -ProcPolyLine(client) - register ClientPtr client; +ProcPolyLine(register ClientPtr client) { int npoint; register GC *pGC; register DrawablePtr pDraw; REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2; if (npoint > 1) (*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint, (DDXPointPtr) &stuff[1]); return(client->noClientException); } int -ProcPolySegment(client) - register ClientPtr client; +ProcPolySegment(register ClientPtr client) { int nsegs; register GC *pGC; register DrawablePtr pDraw; REQUEST(xPolySegmentReq); REQUEST_AT_LEAST_SIZE(xPolySegmentReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); if (nsegs & 4) return(BadLength); nsegs >>= 3; if (nsegs) (*pGC->ops->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]); return (client->noClientException); } int -ProcPolyRectangle (client) - register ClientPtr client; +ProcPolyRectangle (register ClientPtr client) { int nrects; register GC *pGC; register DrawablePtr pDraw; REQUEST(xPolyRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); if (nrects & 4) return(BadLength); nrects >>= 3; if (nrects) (*pGC->ops->PolyRectangle)(pDraw, pGC, nrects, (xRectangle *) &stuff[1]); return(client->noClientException); } int -ProcPolyArc(client) - register ClientPtr client; +ProcPolyArc(register ClientPtr client) { int narcs; register GC *pGC; register DrawablePtr pDraw; REQUEST(xPolyArcReq); REQUEST_AT_LEAST_SIZE(xPolyArcReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); narcs = (client->req_len << 2) - sizeof(xPolyArcReq); if (narcs % sizeof(xArc)) return(BadLength); narcs /= sizeof(xArc); if (narcs) (*pGC->ops->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]); return (client->noClientException); } int -ProcFillPoly(client) - register ClientPtr client; +ProcFillPoly(register ClientPtr client) { int things; register GC *pGC; register DrawablePtr pDraw; REQUEST(xFillPolyReq); REQUEST_AT_LEAST_SIZE(xFillPolyReq); if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) && (stuff->shape != Convex)) { client->errorValue = stuff->shape; return BadValue; } if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2; if (things) (*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape, stuff->coordMode, things, (DDXPointPtr) &stuff[1]); return(client->noClientException); } int -ProcPolyFillRectangle(client) - register ClientPtr client; +ProcPolyFillRectangle(register ClientPtr client) { int things; register GC *pGC; register DrawablePtr pDraw; REQUEST(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); if (things & 4) return(BadLength); things >>= 3; if (things) (*pGC->ops->PolyFillRect) (pDraw, pGC, things, (xRectangle *) &stuff[1]); return (client->noClientException); } int -ProcPolyFillArc(client) - register ClientPtr client; +ProcPolyFillArc(register ClientPtr client) { int narcs; register GC *pGC; register DrawablePtr pDraw; REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); if (narcs % sizeof(xArc)) return(BadLength); narcs /= sizeof(xArc); if (narcs) (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]); return (client->noClientException); } #ifdef MATCH_CLIENT_ENDIAN int @@ -2038,42 +1981,41 @@ FourByteSwap ((unsigned char *) base, nbytes); break; } } #else #define ReformatImage(b,n,bpp,o) #endif /* 64-bit server notes: the protocol restricts padding of images to * 8-, 16-, or 32-bits. We would like to have 64-bits for the server * to use internally. Removes need for internal alignment checking. * All of the PutImage functions could be changed individually, but * as currently written, they call other routines which require things * to be 64-bit padded on scanlines, so we changed things here. * If an image would be padded differently for 64- versus 32-, then * copy each scanline to a 64-bit padded scanline. * Also, we need to make sure that the image is aligned on a 64-bit * boundary, even if the scanlines are padded to our satisfaction. */ int -ProcPutImage(client) - register ClientPtr client; +ProcPutImage(register ClientPtr client) { register GC *pGC; register DrawablePtr pDraw; long length; /* length of scanline server padded */ long lengthProto; /* length of scanline protocol padded */ char *tmpImage; REQUEST(xPutImageReq); REQUEST_AT_LEAST_SIZE(xPutImageReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); if (stuff->format == XYBitmap) { if ((stuff->depth != 1) || (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad)) return BadMatch; length = BitmapBytePad(stuff->width + stuff->leftPad); } else if (stuff->format == XYPixmap) { if ((pDraw->depth != stuff->depth) || @@ -2097,47 +2039,43 @@ tmpImage = (char *)&stuff[1]; lengthProto = length; if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) + (sizeof(xPutImageReq) >> 2)) != client->req_len) return BadLength; ReformatImage (tmpImage, lengthProto * stuff->height, stuff->format == ZPixmap ? BitsPerPixel (stuff->depth) : 1, ClientOrder(client)); (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY, stuff->width, stuff->height, stuff->leftPad, stuff->format, tmpImage); return (client->noClientException); } int -DoGetImage(client, format, drawable, x, y, width, height, planemask, im_return) - register ClientPtr client; - Drawable drawable; - int format; - int x, y, width, height; - Mask planemask; - xGetImageReply **im_return; +DoGetImage(register ClientPtr client, int format, Drawable drawable, + int x, int y, int width, int height, + Mask planemask, xGetImageReply **im_return) { register DrawablePtr pDraw; int nlines, linesPerBuf; register int linesDone; long widthBytesLine, length; Mask plane = 0; char *pBuf; xGetImageReply xgi; #ifdef XCSECURITY RegionPtr pVisibleRegion = NULL; #endif if ((format != XYPixmap) && (format != ZPixmap)) { client->errorValue = format; return(BadValue); } SECURITY_VERIFY_DRAWABLE(pDraw, drawable, client, SecurityReadAccess); if(pDraw->type == DRAWABLE_WINDOW) { @@ -2327,149 +2265,144 @@ /* Don't split me, gcc pukes when you do */ (void)WriteToClient(client, (int)(nlines * widthBytesLine), pBuf); } linesDone += nlines; } } } } #ifdef XCSECURITY if (pVisibleRegion) REGION_DESTROY(pDraw->pScreen, pVisibleRegion); #endif if (!im_return) DEALLOCATE_LOCAL(pBuf); return (client->noClientException); } int -ProcGetImage(client) - register ClientPtr client; +ProcGetImage(register ClientPtr client) { REQUEST(xGetImageReq); REQUEST_SIZE_MATCH(xGetImageReq); return DoGetImage(client, stuff->format, stuff->drawable, stuff->x, stuff->y, (int)stuff->width, (int)stuff->height, stuff->planeMask, (xGetImageReply **)NULL); } int -ProcPolyText(client) - register ClientPtr client; +ProcPolyText(register ClientPtr client) { int err; REQUEST(xPolyTextReq); DrawablePtr pDraw; GC *pGC; REQUEST_AT_LEAST_SIZE(xPolyTextReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); err = PolyText(client, pDraw, pGC, (unsigned char *)&stuff[1], ((unsigned char *) stuff) + (client->req_len << 2), stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return(client->noClientException); } else return err; } int -ProcImageText8(client) - register ClientPtr client; +ProcImageText8(register ClientPtr client) { int err; register DrawablePtr pDraw; register GC *pGC; REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); err = ImageText(client, pDraw, pGC, stuff->nChars, (unsigned char *)&stuff[1], stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return(client->noClientException); } else return err; } int -ProcImageText16(client) - register ClientPtr client; +ProcImageText16(register ClientPtr client) { int err; register DrawablePtr pDraw; register GC *pGC; REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); err = ImageText(client, pDraw, pGC, stuff->nChars, (unsigned char *)&stuff[1], stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return(client->noClientException); } else return err; } int -ProcCreateColormap(client) - register ClientPtr client; +ProcCreateColormap(register ClientPtr client) { VisualPtr pVisual; ColormapPtr pmap; Colormap mid; register WindowPtr pWin; ScreenPtr pScreen; REQUEST(xCreateColormapReq); int i, result; REQUEST_SIZE_MATCH(xCreateColormapReq); if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll)) { client->errorValue = stuff->alloc; return(BadValue); } mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityReadAccess); @@ -2478,176 +2411,170 @@ pScreen = pWin->drawable.pScreen; for (i = 0, pVisual = pScreen->visuals; i < pScreen->numVisuals; i++, pVisual++) { if (pVisual->vid != stuff->visual) continue; result = CreateColormap(mid, pScreen, pVisual, &pmap, (int)stuff->alloc, client->index); if (client->noClientException != Success) return(client->noClientException); else return(result); } client->errorValue = stuff->visual; return(BadValue); } int -ProcFreeColormap(client) - register ClientPtr client; +ProcFreeColormap(register ClientPtr client) { ColormapPtr pmap; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP, SecurityDestroyAccess); if (pmap) { /* Freeing a default colormap is a no-op */ if (!(pmap->flags & IsDefault)) FreeResource(stuff->id, RT_NONE); return (client->noClientException); } else { client->errorValue = stuff->id; return (BadColor); } } int -ProcCopyColormapAndFree(client) - register ClientPtr client; +ProcCopyColormapAndFree(register ClientPtr client) { Colormap mid; ColormapPtr pSrcMap; REQUEST(xCopyColormapAndFreeReq); int result; REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap, RT_COLORMAP, SecurityReadAccess|SecurityWriteAccess)) ) { result = CopyColormapAndFree(mid, pSrcMap, client->index); if (client->noClientException != Success) return(client->noClientException); else return(result); } else { client->errorValue = stuff->srcCmap; return(BadColor); } } int -ProcInstallColormap(client) - register ClientPtr client; +ProcInstallColormap(register ClientPtr client) { ColormapPtr pcmp; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id, RT_COLORMAP, SecurityReadAccess); if (pcmp) { (*(pcmp->pScreen->InstallColormap)) (pcmp); return (client->noClientException); } else { client->errorValue = stuff->id; return (BadColor); } } int -ProcUninstallColormap(client) - register ClientPtr client; +ProcUninstallColormap(register ClientPtr client) { ColormapPtr pcmp; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id, RT_COLORMAP, SecurityReadAccess); if (pcmp) { if(pcmp->mid != pcmp->pScreen->defColormap) (*(pcmp->pScreen->UninstallColormap)) (pcmp); return (client->noClientException); } else { client->errorValue = stuff->id; return (BadColor); } } int -ProcListInstalledColormaps(client) - register ClientPtr client; +ProcListInstalledColormaps(register ClientPtr client) { xListInstalledColormapsReply *preply; int nummaps; WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); preply = (xListInstalledColormapsReply *) ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) + pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap)); if(!preply) return(BadAlloc); preply->type = X_Reply; preply->sequenceNumber = client->sequence; nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps) (pWin->drawable.pScreen, (Colormap *)&preply[1]); preply->nColormaps = nummaps; preply->length = nummaps; WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); DEALLOCATE_LOCAL(preply); return(client->noClientException); } int -ProcAllocColor(client) - register ClientPtr client; +ProcAllocColor (register ClientPtr client) { ColormapPtr pmap; int retval; xAllocColorReply acr; REQUEST(xAllocColorReq); REQUEST_SIZE_MATCH(xAllocColorReq); pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityWriteAccess); if (pmap) { #ifdef LBX /* * If the colormap is grabbed by a proxy, the server will have * to regain control over the colormap. This AllocColor request * will be handled after the server gets back the colormap control. */ if (LbxCheckColorRequest (client, pmap, (xReq *) stuff)) return Success; #endif @@ -2664,42 +2591,41 @@ if (client->noClientException != Success) return(client->noClientException); else return (retval); } #ifdef PANORAMIX if (noPanoramiXExtension || !pmap->pScreen->myNum) #endif WriteReplyToClient(client, sizeof(xAllocColorReply), &acr); return (client->noClientException); } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcAllocNamedColor (client) - register ClientPtr client; +ProcAllocNamedColor (register ClientPtr client) { ColormapPtr pcmp; REQUEST(xAllocNamedColorReq); REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityWriteAccess); if (pcmp) { int retval; xAllocNamedColorReply ancr; #ifdef LBX /* * If the colormap is grabbed by a proxy, the server will have * to regain control over the colormap. This AllocNamedColor request * will be handled after the server gets back the colormap control. */ if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff)) @@ -2726,42 +2652,41 @@ return(retval); } #ifdef PANORAMIX if (noPanoramiXExtension || !pcmp->pScreen->myNum) #endif WriteReplyToClient(client, sizeof (xAllocNamedColorReply), &ancr); return (client->noClientException); } else return(BadName); } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcAllocColorCells (client) - register ClientPtr client; +ProcAllocColorCells (register ClientPtr client) { ColormapPtr pcmp; REQUEST(xAllocColorCellsReq); REQUEST_SIZE_MATCH(xAllocColorCellsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityWriteAccess); if (pcmp) { xAllocColorCellsReply accr; int npixels, nmasks, retval; long length; Pixel *ppixels, *pmasks; #ifdef LBX /* * If the colormap is grabbed by a proxy, the server will have * to regain control over the colormap. This AllocColorCells request * will be handled after the server gets back the colormap control. */ @@ -2802,42 +2727,41 @@ accr.type = X_Reply; accr.length = length >> 2; accr.sequenceNumber = client->sequence; accr.nPixels = npixels; accr.nMasks = nmasks; WriteReplyToClient(client, sizeof (xAllocColorCellsReply), &accr); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, length, ppixels); } DEALLOCATE_LOCAL(ppixels); return (client->noClientException); } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcAllocColorPlanes(client) - register ClientPtr client; +ProcAllocColorPlanes(register ClientPtr client) { ColormapPtr pcmp; REQUEST(xAllocColorPlanesReq); REQUEST_SIZE_MATCH(xAllocColorPlanesReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityWriteAccess); if (pcmp) { xAllocColorPlanesReply acpr; int npixels, retval; long length; Pixel *ppixels; #ifdef LBX /* * If the colormap is grabbed by a proxy, the server will have * to regain control over the colormap. This AllocColorPlanes request * will be handled after the server gets back the colormap control. */ @@ -2876,148 +2800,144 @@ acpr.length = length >> 2; #ifdef PANORAMIX if (noPanoramiXExtension || !pcmp->pScreen->myNum) #endif { WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, length, ppixels); } DEALLOCATE_LOCAL(ppixels); return (client->noClientException); } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcFreeColors (client) - register ClientPtr client; +ProcFreeColors(register ClientPtr client) { ColormapPtr pcmp; REQUEST(xFreeColorsReq); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityWriteAccess); if (pcmp) { int count; int retval; if(pcmp->flags & AllAllocated) return(BadAccess); count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2; retval = FreeColors(pcmp, client->index, count, (Pixel *)&stuff[1], (Pixel)stuff->planeMask); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(retval); } } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcStoreColors (client) - register ClientPtr client; +ProcStoreColors (ClientPtr client) { ColormapPtr pcmp; REQUEST(xStoreColorsReq); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityWriteAccess); if (pcmp) { int count; int retval; count = (client->req_len << 2) - sizeof(xStoreColorsReq); if (count % sizeof(xColorItem)) return(BadLength); count /= sizeof(xColorItem); retval = StoreColors(pcmp, count, (xColorItem *)&stuff[1]); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(retval); } } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcStoreNamedColor (client) - register ClientPtr client; +ProcStoreNamedColor (register ClientPtr client) { ColormapPtr pcmp; REQUEST(xStoreNamedColorReq); REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityWriteAccess); if (pcmp) { xColorItem def; int retval; if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes, &def.red, &def.green, &def.blue)) { def.flags = stuff->flags; def.pixel = stuff->pixel; retval = StoreColors(pcmp, 1, &def); if (client->noClientException != Success) return(client->noClientException); else return(retval); } return (BadName); } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcQueryColors(client) - register ClientPtr client; +ProcQueryColors(register ClientPtr client) { ColormapPtr pcmp; REQUEST(xQueryColorsReq); REQUEST_AT_LEAST_SIZE(xQueryColorsReq); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityReadAccess); if (pcmp) { int count, retval; xrgb *prgbs; xQueryColorsReply qcr; count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2; prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb)); if(!prgbs && count) return(BadAlloc); if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) ) { if (prgbs) DEALLOCATE_LOCAL(prgbs); @@ -3034,81 +2954,79 @@ qcr.sequenceNumber = client->sequence; qcr.nColors = count; WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr); if (count) { client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend; WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs); } if (prgbs) DEALLOCATE_LOCAL(prgbs); return(client->noClientException); } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcLookupColor(client) - register ClientPtr client; +ProcLookupColor(register ClientPtr client) { ColormapPtr pcmp; REQUEST(xLookupColorReq); REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes); pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap, RT_COLORMAP, SecurityReadAccess); if (pcmp) { xLookupColorReply lcr; if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes, &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue)) { lcr.type = X_Reply; lcr.length = 0; lcr.sequenceNumber = client->sequence; lcr.screenRed = lcr.exactRed; lcr.screenGreen = lcr.exactGreen; lcr.screenBlue = lcr.exactBlue; (*pcmp->pScreen->ResolveColor)(&lcr.screenRed, &lcr.screenGreen, &lcr.screenBlue, pcmp->pVisual); WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr); return(client->noClientException); } return (BadName); } else { client->errorValue = stuff->cmap; return (BadColor); } } int -ProcCreateCursor( client) - register ClientPtr client; +ProcCreateCursor (register ClientPtr client) { CursorPtr pCursor; register PixmapPtr src; register PixmapPtr msk; unsigned char * srcbits; unsigned char * mskbits; unsigned short width, height; long n; CursorMetricRec cm; REQUEST(xCreateCursorReq); REQUEST_SIZE_MATCH(xCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source, RT_PIXMAP, SecurityReadAccess); msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask, @@ -3164,123 +3082,119 @@ { /* zeroing the (pad) bits helps some ddx cursor handling */ bzero((char *)mskbits, n); (* msk->drawable.pScreen->GetImage)( (DrawablePtr)msk, 0, 0, width, height, XYPixmap, 1, (pointer)mskbits); } cm.width = width; cm.height = height; cm.xhot = stuff->x; cm.yhot = stuff->y; pCursor = AllocCursor( srcbits, mskbits, &cm, stuff->foreRed, stuff->foreGreen, stuff->foreBlue, stuff->backRed, stuff->backGreen, stuff->backBlue); if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) return (client->noClientException); return BadAlloc; } int -ProcCreateGlyphCursor( client) - register ClientPtr client; +ProcCreateGlyphCursor (register ClientPtr client) { CursorPtr pCursor; int res; REQUEST(xCreateGlyphCursorReq); REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); res = AllocGlyphCursor(stuff->source, stuff->sourceChar, stuff->mask, stuff->maskChar, stuff->foreRed, stuff->foreGreen, stuff->foreBlue, stuff->backRed, stuff->backGreen, stuff->backBlue, &pCursor, client); if (res != Success) return res; if (AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) return client->noClientException; return BadAlloc; } int -ProcFreeCursor(client) - register ClientPtr client; +ProcFreeCursor (register ClientPtr client) { CursorPtr pCursor; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id, RT_CURSOR, SecurityDestroyAccess); if (pCursor) { FreeResource(stuff->id, RT_NONE); return (client->noClientException); } else { client->errorValue = stuff->id; return (BadCursor); } } int -ProcQueryBestSize (client) - register ClientPtr client; +ProcQueryBestSize (register ClientPtr client) { xQueryBestSizeReply reply; register DrawablePtr pDraw; ScreenPtr pScreen; REQUEST(xQueryBestSizeReq); REQUEST_SIZE_MATCH(xQueryBestSizeReq); if ((stuff->class != CursorShape) && (stuff->class != TileShape) && (stuff->class != StippleShape)) { client->errorValue = stuff->class; return(BadValue); } SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, SecurityReadAccess); if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return (BadMatch); pScreen = pDraw->pScreen; (* pScreen->QueryBestSize)(stuff->class, &stuff->width, &stuff->height, pScreen); reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; reply.width = stuff->width; reply.height = stuff->height; WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply); return (client->noClientException); } int -ProcSetScreenSaver (client) - register ClientPtr client; +ProcSetScreenSaver (register ClientPtr client) { int blankingOption, exposureOption; REQUEST(xSetScreenSaverReq); REQUEST_SIZE_MATCH(xSetScreenSaverReq); blankingOption = stuff->preferBlank; if ((blankingOption != DontPreferBlanking) && (blankingOption != PreferBlanking) && (blankingOption != DefaultBlanking)) { client->errorValue = blankingOption; return BadValue; } exposureOption = stuff->allowExpose; if ((exposureOption != DontAllowExposures) && (exposureOption != AllowExposures) && (exposureOption != DefaultExposures)) { client->errorValue = exposureOption; return BadValue; @@ -3302,270 +3216,260 @@ ScreenSaverBlanking = blankingOption; if (exposureOption == DefaultExposures) ScreenSaverAllowExposures = defaultScreenSaverAllowExposures; else ScreenSaverAllowExposures = exposureOption; if (stuff->timeout >= 0) ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND; else ScreenSaverTime = defaultScreenSaverTime; if (stuff->interval >= 0) ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND; else ScreenSaverInterval = defaultScreenSaverInterval; SetScreenSaverTimer(); return (client->noClientException); } int -ProcGetScreenSaver(client) - register ClientPtr client; +ProcGetScreenSaver(register ClientPtr client) { xGetScreenSaverReply rep; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; rep.timeout = ScreenSaverTime / MILLI_PER_SECOND; rep.interval = ScreenSaverInterval / MILLI_PER_SECOND; rep.preferBlanking = ScreenSaverBlanking; rep.allowExposures = ScreenSaverAllowExposures; WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep); return (client->noClientException); } int -ProcChangeHosts(client) - register ClientPtr client; +ProcChangeHosts(register ClientPtr client) { REQUEST(xChangeHostsReq); int result; REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength); if(stuff->mode == HostInsert) result = AddHost(client, (int)stuff->hostFamily, stuff->hostLength, (pointer)&stuff[1]); else if (stuff->mode == HostDelete) result = RemoveHost(client, (int)stuff->hostFamily, stuff->hostLength, (pointer)&stuff[1]); else { client->errorValue = stuff->mode; return BadValue; } if (!result) result = client->noClientException; return (result); } int -ProcListHosts(client) - register ClientPtr client; +ProcListHosts(register ClientPtr client) { xListHostsReply reply; int len, nHosts, result; pointer pdata; /* REQUEST(xListHostsReq); */ REQUEST_SIZE_MATCH(xListHostsReq); #ifdef XCSECURITY /* untrusted clients can't list hosts */ if (client->trustLevel != XSecurityClientTrusted) { SecurityAudit("client %d attempted to list hosts\n", client->index); return BadAccess; } #endif result = GetHosts(&pdata, &nHosts, &len, &reply.enabled); if (result != Success) return(result); reply.type = X_Reply; reply.sequenceNumber = client->sequence; reply.nHosts = nHosts; reply.length = len >> 2; WriteReplyToClient(client, sizeof(xListHostsReply), &reply); if (nHosts) { client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend; WriteSwappedDataToClient(client, len, pdata); } xfree(pdata); return (client->noClientException); } int -ProcChangeAccessControl(client) - register ClientPtr client; +ProcChangeAccessControl(register ClientPtr client) { int result; REQUEST(xSetAccessControlReq); REQUEST_SIZE_MATCH(xSetAccessControlReq); if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess)) { client->errorValue = stuff->mode; return BadValue; } result = ChangeAccessControl(client, stuff->mode == EnableAccess); if (!result) result = client->noClientException; return (result); } int -ProcKillClient(client) - register ClientPtr client; +ProcKillClient(register ClientPtr client) { REQUEST(xResourceReq); ClientPtr killclient; REQUEST_SIZE_MATCH(xResourceReq); if (stuff->id == AllTemporary) { CloseDownRetainedResources(); return (client->noClientException); } if ((killclient = LookupClient(stuff->id, client))) { CloseDownClient(killclient); /* if an LBX proxy gets killed, isItTimeToYield will be set */ if (isItTimeToYield || (client == killclient)) { /* force yield and return Success, so that Dispatch() * doesn't try to touch client */ isItTimeToYield = TRUE; return (Success); } return (client->noClientException); } else { client->errorValue = stuff->id; return (BadValue); } } int -ProcSetFontPath(client) - register ClientPtr client; +ProcSetFontPath(register ClientPtr client) { unsigned char *ptr; unsigned long nbytes, total; long nfonts; int n, result; int error; REQUEST(xSetFontPathReq); REQUEST_AT_LEAST_SIZE(xSetFontPathReq); nbytes = (client->req_len << 2) - sizeof(xSetFontPathReq); total = nbytes; ptr = (unsigned char *)&stuff[1]; nfonts = stuff->nFonts; while (--nfonts >= 0) { if ((total == 0) || (total < (n = (*ptr + 1)))) return(BadLength); total -= n; ptr += n; } if (total >= 4) return(BadLength); result = SetFontPath(client, stuff->nFonts, (unsigned char *)&stuff[1], &error); if (!result) { result = client->noClientException; client->errorValue = error; } return (result); } int -ProcGetFontPath(client) - register ClientPtr client; +ProcGetFontPath(register ClientPtr client) { xGetFontPathReply reply; int stringLens, numpaths; unsigned char *bufferStart; /* REQUEST (xReq); */ REQUEST_SIZE_MATCH(xReq); bufferStart = GetFontPath(&numpaths, &stringLens); reply.type = X_Reply; reply.sequenceNumber = client->sequence; reply.length = (stringLens + numpaths + 3) >> 2; reply.nPaths = numpaths; WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply); if (stringLens || numpaths) (void)WriteToClient(client, stringLens + numpaths, (char *)bufferStart); return(client->noClientException); } int -ProcChangeCloseDownMode(client) - register ClientPtr client; +ProcChangeCloseDownMode(register ClientPtr client) { REQUEST(xSetCloseDownModeReq); REQUEST_SIZE_MATCH(xSetCloseDownModeReq); if ((stuff->mode == AllTemporary) || (stuff->mode == RetainPermanent) || (stuff->mode == RetainTemporary)) { client->closeDownMode = stuff->mode; return (client->noClientException); } else { client->errorValue = stuff->mode; return (BadValue); } } -int ProcForceScreenSaver(client) - register ClientPtr client; +int ProcForceScreenSaver(register ClientPtr client) { REQUEST(xForceScreenSaverReq); REQUEST_SIZE_MATCH(xForceScreenSaverReq); if ((stuff->mode != ScreenSaverReset) && (stuff->mode != ScreenSaverActive)) { client->errorValue = stuff->mode; return BadValue; } SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode); return client->noClientException; } -int ProcNoOperation(client) - register ClientPtr client; +int ProcNoOperation(register ClientPtr client) { REQUEST_AT_LEAST_SIZE(xReq); /* noop -- don't do anything */ return(client->noClientException); } void InitProcVectors(void) { int i; for (i = 0; i<256; i++) { if(!ProcVector[i]) { ProcVector[i] = SwappedProcVector[i] = ProcBadRequest; ReplySwapVector[i] = ReplyNotSwappd; } #ifdef K5AUTH if (!k5_Vector[i]) @@ -3574,42 +3478,41 @@ } #endif } for(i = LASTEvent; i < 128; i++) { EventSwapVector[i] = NotImplemented; } } /********************** * CloseDownClient * * Client can either mark his resources destroy or retain. If retained and * then killed again, the client is really destroyed. *********************/ char dispatchExceptionAtReset = DE_RESET; void -CloseDownClient(client) - register ClientPtr client; +CloseDownClient(register ClientPtr client) { Bool really_close_down = client->clientGone || client->closeDownMode == DestroyAll; if (!client->clientGone) { /* ungrab server if grabbing client dies */ if (grabState != GrabNone && grabClient == client) { UngrabServer(client); } BITCLEAR(grabWaiters, client->index); DeleteClientFromAnySelections(client); ReleaseActiveGrabs(client); DeleteClientFontStuff(client); if (!really_close_down) { /* This frees resources that should never be retained * no matter what the close down mode is. Actually we * could do this unconditionally, but it's probably @@ -3697,44 +3600,41 @@ * * Find all clients that are gone and have terminated in RetainTemporary * and destroy their resources. *********************/ void CloseDownRetainedResources() { register int i; register ClientPtr client; for (i=1; icloseDownMode == RetainTemporary) && (client->clientGone)) CloseDownClient(client); } } -void InitClient(client, i, ospriv) - ClientPtr client; - int i; - pointer ospriv; +void InitClient(ClientPtr client, int i, pointer ospriv) { client->index = i; client->sequence = 0; client->clientAsMask = ((Mask)i) << CLIENTOFFSET; client->clientGone = FALSE; if (i) { client->closeDownMode = DestroyAll; client->lastDrawable = (DrawablePtr)WindowTable[0]; client->lastDrawableID = WindowTable[0]->drawable.id; } else { client->closeDownMode = RetainPermanent; client->lastDrawable = (DrawablePtr)NULL; client->lastDrawableID = INVALID; } client->lastGC = (GCPtr) NULL; client->lastGCID = INVALID; client->numSaved = 0; @@ -3765,85 +3665,82 @@ client->CheckAccess = NULL; client->authId = 0; #endif #ifdef XAPPGROUP client->appgroup = NULL; #endif client->fontResFunc = NULL; #ifdef SMART_SCHEDULE client->smart_priority = 0; client->smart_start_tick = SmartScheduleTime; client->smart_stop_tick = SmartScheduleTime; client->smart_check_tick = SmartScheduleTime; #endif } extern int clientPrivateLen; extern unsigned *clientPrivateSizes; extern unsigned totalClientSize; int -InitClientPrivates(client) - ClientPtr client; +InitClientPrivates(ClientPtr client) { register char *ptr; DevUnion *ppriv; register unsigned *sizes; register unsigned size; register int i; if (totalClientSize == sizeof(ClientRec)) ppriv = (DevUnion *)NULL; else if (client->index) ppriv = (DevUnion *)(client + 1); else { ppriv = (DevUnion *)xalloc(totalClientSize - sizeof(ClientRec)); if (!ppriv) return 0; } client->devPrivates = ppriv; sizes = clientPrivateSizes; ptr = (char *)(ppriv + clientPrivateLen); for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++) { if ( (size = *sizes) ) { ppriv->ptr = (pointer)ptr; ptr += size; } else ppriv->ptr = (pointer)NULL; } return 1; } /************************ * int NextAvailableClient(ospriv) * * OS dependent portion can't assign client id's because of CloseDownModes. * Returns NULL if there are no free clients. *************************/ -ClientPtr -NextAvailableClient(ospriv) - pointer ospriv; +ClientPtr NextAvailableClient(pointer ospriv) { register int i; register ClientPtr client; xReq data; i = nextFreeClientID; if (i == MAXCLIENTS) return (ClientPtr)NULL; clients[i] = client = (ClientPtr)xalloc(totalClientSize); if (!client) return (ClientPtr)NULL; InitClient(client, i, ospriv); InitClientPrivates(client); if (!InitClientResources(client)) { xfree(client); return (ClientPtr)NULL; } data.reqType = 1; data.length = (sz_xReq + sz_xConnClientPrefix) >> 2; @@ -3853,79 +3750,76 @@ xfree(client); return (ClientPtr)NULL; } if (i == currentMaxClients) currentMaxClients++; while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID]) nextFreeClientID++; if (ClientStateCallback) { NewClientInfoRec clientinfo; clientinfo.client = client; clientinfo.prefix = (xConnSetupPrefix *)NULL; clientinfo.setup = (xConnSetup *) NULL; CallCallbacks((&ClientStateCallback), (pointer)&clientinfo); } return(client); } int -ProcInitialConnection(client) - register ClientPtr client; +ProcInitialConnection(register ClientPtr client) { REQUEST(xReq); register xConnClientPrefix *prefix; int whichbyte = 1; prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq); if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B')) return (client->noClientException = -1); if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) || (!(*(char *) &whichbyte) && (prefix->byteOrder == 'l'))) { client->swapped = TRUE; SwapConnClientPrefix(prefix); } stuff->reqType = 2; stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) + ((prefix->nbytesAuthString + (unsigned)3) >> 2); if (client->swapped) { swaps(&stuff->length, whichbyte); } ResetCurrentRequest(client); return (client->noClientException); } #ifdef LBX void IncrementClientCount() { nClients++; } #endif int -SendConnSetup(client, reason) - register ClientPtr client; - char *reason; +SendConnSetup(register ClientPtr client, char *reason) { register xWindowRoot *root; register int i; int numScreens; char* lConnectionInfo; xConnSetupPrefix* lconnSetupPrefix; if (reason) { xConnSetupPrefix csp; csp.success = xFalse; csp.lengthReason = strlen(reason); csp.length = (csp.lengthReason + (unsigned)3) >> 2; csp.majorVersion = X_PROTOCOL; csp.minorVersion = X_PROTOCOL_REVISION; if (client->swapped) WriteSConnSetupPrefix(client, &csp); else (void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp); @@ -3991,126 +3885,118 @@ { (void)WriteToClient(client, sizeof(xConnSetupPrefix), (char *) lconnSetupPrefix); (void)WriteToClient(client, (int)(lconnSetupPrefix->length << 2), lConnectionInfo); } client->clientState = ClientStateRunning; if (ClientStateCallback) { NewClientInfoRec clientinfo; clientinfo.client = client; clientinfo.prefix = lconnSetupPrefix; clientinfo.setup = (xConnSetup *)lConnectionInfo; CallCallbacks((&ClientStateCallback), (pointer)&clientinfo); } return (client->noClientException); } int -ProcEstablishConnection(client) - register ClientPtr client; +ProcEstablishConnection(register ClientPtr client) { char *reason, *auth_proto, *auth_string; register xConnClientPrefix *prefix; REQUEST(xReq); prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq); auth_proto = (char *)prefix + sz_xConnClientPrefix; auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3); if ((prefix->majorVersion != X_PROTOCOL) || (prefix->minorVersion != X_PROTOCOL_REVISION)) reason = "Protocol version mismatch"; else reason = ClientAuthorized(client, (unsigned short)prefix->nbytesAuthProto, auth_proto, (unsigned short)prefix->nbytesAuthString, auth_string); /* * If Kerberos is being used for this client, the clientState * will be set to ClientStateAuthenticating at this point. * More messages need to be exchanged among the X server, Kerberos * server, and client to figure out if everyone is authorized. * So we don't want to send the connection setup info yet, since * the auth step isn't really done. */ if (client->clientState == ClientStateCheckingSecurity) client->clientState = ClientStateCheckedSecurity; else if (client->clientState != ClientStateAuthenticating) return(SendConnSetup(client, reason)); return(client->noClientException); } void -SendErrorToClient(client, majorCode, minorCode, resId, errorCode) - ClientPtr client; - unsigned int majorCode; - unsigned int minorCode; - XID resId; - int errorCode; +SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, + XID resId, int errorCode) { xError rep; rep.type = X_Error; rep.sequenceNumber = client->sequence; rep.errorCode = errorCode; rep.majorCode = majorCode; rep.minorCode = minorCode; rep.resourceID = resId; WriteEventsToClient (client, 1, (xEvent *)&rep); } void -DeleteWindowFromAnySelections(pWin) - WindowPtr pWin; +DeleteWindowFromAnySelections(WindowPtr pWin) { register int i; for (i = 0; i< NumCurrentSelections; i++) if (CurrentSelections[i].pWin == pWin) { if (SelectionCallback) { SelectionInfoRec info; info.selection = &CurrentSelections[i]; info.kind = SelectionWindowDestroy; CallCallbacks(&SelectionCallback, &info); } CurrentSelections[i].pWin = (WindowPtr)NULL; CurrentSelections[i].window = None; CurrentSelections[i].client = NullClient; } } static void -DeleteClientFromAnySelections(client) - ClientPtr client; +DeleteClientFromAnySelections(ClientPtr client) { register int i; for (i = 0; i< NumCurrentSelections; i++) if (CurrentSelections[i].client == client) { if (SelectionCallback) { SelectionInfoRec info; info.selection = &CurrentSelections[i]; info.kind = SelectionWindowDestroy; CallCallbacks(&SelectionCallback, &info); } CurrentSelections[i].pWin = (WindowPtr)NULL; CurrentSelections[i].window = None; CurrentSelections[i].client = NullClient; } } void -MarkClientException(client) - ClientPtr client; +MarkClientException(ClientPtr client) { client->noClientException = -1; } Index: xc/programs/Xserver/dix/dixfonts.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/dixfonts.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 dixfonts.c --- xc/programs/Xserver/dix/dixfonts.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/dixfonts.c 7 Mar 2005 22:55:12 -0000 @@ -106,122 +106,115 @@ case Successful: return Success; case AllocError: return BadAlloc; case BadFontName: return BadName; case BadFontPath: case BadFontFormat: /* is there something better? */ case BadCharRange: return BadValue; default: return err; } } /* * adding RT_FONT prevents conflict with default cursor font */ Bool -SetDefaultFont(defaultfontname) - char *defaultfontname; +SetDefaultFont(char *defaultfontname) { int err; FontPtr pf; XID fid; fid = FakeClientID(0); err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync, (unsigned) strlen(defaultfontname), defaultfontname); if (err != Success) return FALSE; pf = (FontPtr) LookupIDByType(fid, RT_FONT); if (pf == (FontPtr) NULL) return FALSE; defaultFont = pf; return TRUE; } /* * note that the font wakeup queue is not refcounted. this is because * an fpe needs to be added when it's inited, and removed when it's finally * freed, in order to handle any data that isn't requested, like FS events. * * since the only thing that should call these routines is the renderer's * init_fpe() and free_fpe(), there shouldn't be any problem in using * freed data. */ void -QueueFontWakeup(fpe) - FontPathElementPtr fpe; +QueueFontWakeup(FontPathElementPtr fpe) { int i; FontPathElementPtr *new; for (i = 0; i < num_slept_fpes; i++) { if (slept_fpes[i] == fpe) { #ifdef DEBUG fprintf(stderr, "re-queueing fpe wakeup\n"); #endif return; } } if (num_slept_fpes == size_slept_fpes) { new = (FontPathElementPtr *) xrealloc(slept_fpes, sizeof(FontPathElementPtr) * (size_slept_fpes + 4)); if (!new) return; slept_fpes = new; size_slept_fpes += 4; } slept_fpes[num_slept_fpes] = fpe; num_slept_fpes++; } void -RemoveFontWakeup(fpe) - FontPathElementPtr fpe; +RemoveFontWakeup(FontPathElementPtr fpe) { int i, j; for (i = 0; i < num_slept_fpes; i++) { if (slept_fpes[i] == fpe) { for (j = i; j < num_slept_fpes; j++) { slept_fpes[j] = slept_fpes[j + 1]; } num_slept_fpes--; return; } } } -/* ARGSUSED */ void -FontWakeup(data, count, LastSelectMask) - pointer data; - int count; - pointer LastSelectMask; +FontWakeup(pointer data, int count, pointer LastSelectMask) { int i; FontPathElementPtr fpe; if (count < 0) return; /* wake up any fpe's that may be waiting for information */ for (i = 0; i < num_slept_fpes; i++) { fpe = slept_fpes[i]; (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); } } /* XXX -- these two funcs may want to be broken into macros */ static void UseFPE(FontPathElementPtr fpe) { fpe->refcount++; } @@ -364,46 +357,41 @@ if (patternCache && pfont != c->non_cachable_font) CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, pfont); bail: if (err != Successful && c->client != serverClient) { SendErrorToClient(c->client, X_OpenFont, 0, c->fontid, FontToXError(err)); } if (c->slept) ClientWakeup(c->client); for (i = 0; i < c->num_fpes; i++) { FreeFPE(c->fpe_list[i]); } xfree(c->fpe_list); xfree(c->fontname); xfree(c); return TRUE; } int -OpenFont(client, fid, flags, lenfname, pfontname) - ClientPtr client; - XID fid; - Mask flags; - unsigned lenfname; - char *pfontname; +OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname) { OFclosurePtr c; int i; FontPtr cached = (FontPtr)0; #ifdef FONTDEBUG char *f; f = (char *)xalloc(lenfname + 1); memmove(f, pfontname, lenfname); f[lenfname] = '\0'; ErrorF("OpenFont: fontname is \"%s\"\n", f); xfree(f); #endif if (!lenfname || lenfname > XLFDMAXFONTNAMELEN) return BadName; if (patternCache) { /* ** Check name cache. If we find a cached version of this font that @@ -453,96 +441,93 @@ return BadAlloc; } memmove(c->fontname, pfontname, lenfname); for (i = 0; i < num_fpes; i++) { c->fpe_list[i] = font_path_elements[i]; UseFPE(c->fpe_list[i]); } c->client = client; c->fontid = fid; c->current_fpe = 0; c->num_fpes = num_fpes; c->fnamelen = lenfname; c->slept = FALSE; c->flags = flags; c->non_cachable_font = cached; (void) doOpenFont(client, c); return Success; } -/* +/** * Decrement font's ref count, and free storage if ref count equals zero + * + * \param value must conform to DeleteType */ -/*ARGSUSED*/ int -CloseFont(value, fid) - pointer value; /* must conform to DeleteType */ - XID fid; +CloseFont(pointer value, XID fid) { int nscr; ScreenPtr pscr; FontPathElementPtr fpe; FontPtr pfont = (FontPtr)value; if (pfont == NullFont) return (Success); if (--pfont->refcnt == 0) { if (patternCache) RemoveCachedFontPattern (patternCache, pfont); /* * since the last reference is gone, ask each screen to free any * storage it may have allocated locally for it. */ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; if (pscr->UnrealizeFont) (*pscr->UnrealizeFont) (pscr, pfont); } if (pfont == defaultFont) defaultFont = NULL; #ifdef LBX LbxFreeFontTag(pfont); #endif #ifdef XF86BIGFONT XF86BigfontFreeFontShm(pfont); #endif fpe = pfont->fpe; (*fpe_functions[fpe->type].close_font) (fpe, pfont); FreeFPE(fpe); } return (Success); } /***====================================================================***/ - /* - * \ Sets up pReply as the correct QueryFontReply for pFont with the first - * nProtoCCIStructs char infos. \ +/** + * Sets up pReply as the correct QueryFontReply for pFont with the first + * nProtoCCIStructs char infos. + * + * \param pReply caller must allocate this storage */ - void -QueryFont(pFont, pReply, nProtoCCIStructs) - FontPtr pFont; - xQueryFontReply *pReply; /* caller must allocate this storage */ - int nProtoCCIStructs; +QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs) { FontPropPtr pFP; int r, c, i; xFontProp *prFP; xCharInfo *prCI; xCharInfo *charInfos[256]; unsigned char chars[512]; int ninfos; unsigned long ncols; unsigned long count; /* pr->length set in dispatch */ pReply->minCharOrByte2 = pFont->info.firstCol; pReply->defaultChar = pFont->info.defaultCh; pReply->maxCharOrByte2 = pFont->info.lastCol; pReply->drawDirection = pFont->info.drawDirection; pReply->allCharsExist = pFont->info.allExist; pReply->minByte1 = pFont->info.firstRow; @@ -826,45 +811,42 @@ reply.length = (stringLens + nnames + 3) >> 2; client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); (void) WriteToClient(client, stringLens + nnames, bufferStart); DEALLOCATE_LOCAL(bufferStart); bail: if (c->slept) ClientWakeup(client); for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); xfree(c->fpe_list); if (c->savedName) xfree(c->savedName); FreeFontNames(names); xfree(c); if (resolved) xfree(resolved); return TRUE; } int -ListFonts(client, pattern, length, max_names) - ClientPtr client; - unsigned char *pattern; - unsigned int length; - unsigned int max_names; +ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, + unsigned max_names) { int i; LFclosurePtr c; /* * The right error to return here would be BadName, however the * specification does not allow for a Name error on this request. * Perhaps a better solution would be to return a nil list, i.e. * a list containing zero fontnames. */ if (length > XLFDMAXFONTNAMELEN) return BadAlloc; if (!(c = (LFclosurePtr) xalloc(sizeof *c))) return BadAlloc; c->fpe_list = (FontPathElementPtr *) xalloc(sizeof(FontPathElementPtr) * num_fpes); if (!c->fpe_list) { xfree(c); return BadAlloc; @@ -879,43 +861,41 @@ memmove( c->current.pattern, pattern, length); for (i = 0; i < num_fpes; i++) { c->fpe_list[i] = font_path_elements[i]; UseFPE(c->fpe_list[i]); } c->client = client; c->num_fpes = num_fpes; c->current.patlen = length; c->current.current_fpe = 0; c->current.max_names = max_names; c->current.list_started = FALSE; c->current.private = 0; c->haveSaved = FALSE; c->slept = FALSE; c->savedName = 0; doListFontsAndAliases(client, c); return Success; } int -doListFontsWithInfo(client, c) - ClientPtr client; - LFWIclosurePtr c; +doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) { FontPathElementPtr fpe; int err = Successful; char *name; int namelen; int numFonts; FontInfoRec fontInfo, *pFontInfo; xListFontsWithInfoReply *reply; int length; xFontProp *pFP; int i; int aliascount = 0; xListFontsWithInfoReply finalReply; if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; @@ -1103,45 +1083,42 @@ length = sizeof(xListFontsWithInfoReply); bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply)); finalReply.type = X_Reply; finalReply.sequenceNumber = client->sequence; finalReply.length = (sizeof(xListFontsWithInfoReply) - sizeof(xGenericReply)) >> 2; WriteSwappedDataToClient(client, length, &finalReply); bail: if (c->slept) ClientWakeup(client); for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); xfree(c->reply); xfree(c->fpe_list); if (c->savedName) xfree(c->savedName); xfree(c); return TRUE; } int -StartListFontsWithInfo(client, length, pattern, max_names) - ClientPtr client; - int length; - unsigned char *pattern; - int max_names; +StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, + int max_names) { int i; LFWIclosurePtr c; /* * The right error to return here would be BadName, however the * specification does not allow for a Name error on this request. * Perhaps a better solution would be to return a nil list, i.e. * a list containing zero fontnames. */ if (length > XLFDMAXFONTNAMELEN) return BadAlloc; if (!(c = (LFWIclosurePtr) xalloc(sizeof *c))) goto badAlloc; c->fpe_list = (FontPathElementPtr *) xalloc(sizeof(FontPathElementPtr) * num_fpes); if (!c->fpe_list) { xfree(c); @@ -1161,43 +1138,41 @@ c->current.current_fpe = 0; c->current.max_names = max_names; c->current.list_started = FALSE; c->current.private = 0; c->savedNumFonts = 0; c->haveSaved = FALSE; c->slept = FALSE; c->savedName = 0; doListFontsWithInfo(client, c); return Success; badAlloc: return BadAlloc; } #define TextEltHeader 2 #define FontShiftSize 5 static XID clearGC[] = { CT_NONE }; #define clearGCmask (GCClipMask) int -doPolyText(client, c) - ClientPtr client; - register PTclosurePtr c; +doPolyText(ClientPtr client, register PTclosurePtr c) { register FontPtr pFont = c->pGC->font, oldpFont; Font fid, oldfid; int err = Success, lgerr; /* err is in X error, not font error, space */ enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT; FontPathElementPtr fpe; GC *origGC = NULL; if (client->clientGone) { fpe = c->pGC->font->fpe; (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); if (c->slept) { /* Client has died, but we cannot bail out right now. We need to clean up after the work we did when going to sleep. Setting the drawable pointer to 0 makes this happen without any attempts to render or perform other unnecessary activities. */ @@ -1430,86 +1405,76 @@ #endif SendErrorToClient(c->client, c->reqType, 0, 0, err); } if (c->slept) { ClientWakeup(c->client); ChangeGC(c->pGC, clearGCmask, clearGC); /* Unreference the font from the scratch GC */ CloseFont(c->pGC->font, (Font)0); c->pGC->font = NullFont; FreeScratchGC(c->pGC); xfree(c->data); xfree(c); } return TRUE; } int -PolyText(client, pDraw, pGC, pElt, endReq, xorg, yorg, reqType, did) - ClientPtr client; - DrawablePtr pDraw; - GC *pGC; - unsigned char *pElt; - unsigned char *endReq; - int xorg; - int yorg; - int reqType; - XID did; +PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt, + unsigned char *endReq, int xorg, int yorg, int reqType, XID did) { PTclosureRec local_closure; local_closure.pElt = pElt; local_closure.endReq = endReq; local_closure.client = client; local_closure.pDraw = pDraw; local_closure.xorg = xorg; local_closure.yorg = yorg; if ((local_closure.reqType = reqType) == X_PolyText8) { local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8; local_closure.itemSize = 1; } else { local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText16; local_closure.itemSize = 2; } local_closure.pGC = pGC; local_closure.did = did; local_closure.err = Success; local_closure.slept = FALSE; (void) doPolyText(client, &local_closure); return Success; } #undef TextEltHeader #undef FontShiftSize int -doImageText(client, c) - ClientPtr client; - register ITclosurePtr c; +doImageText(ClientPtr client, register ITclosurePtr c) { int err = Success, lgerr; /* err is in X error, not font error, space */ FontPathElementPtr fpe; if (client->clientGone) { fpe = c->pGC->font->fpe; (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); err = Success; goto bail; } /* Make sure our drawable hasn't disappeared while we slept. */ if (c->slept && c->pDraw && c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did, RC_DRAWABLE, SecurityWriteAccess)) { /* Our drawable has disappeared. Treat like client died... ask the FPE code to clean up after client. */ @@ -1596,50 +1561,42 @@ if (err != Success && c->client != serverClient) { SendErrorToClient(c->client, c->reqType, 0, 0, err); } if (c->slept) { ClientWakeup(c->client); ChangeGC(c->pGC, clearGCmask, clearGC); /* Unreference the font from the scratch GC */ CloseFont(c->pGC->font, (Font)0); c->pGC->font = NullFont; FreeScratchGC(c->pGC); xfree(c->data); xfree(c); } return TRUE; } int -ImageText(client, pDraw, pGC, nChars, data, xorg, yorg, reqType, did) - ClientPtr client; - DrawablePtr pDraw; - GC *pGC; - int nChars; - unsigned char *data; - int xorg; - int yorg; - int reqType; - XID did; +ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars, + unsigned char *data, int xorg, int yorg, int reqType, XID did) { ITclosureRec local_closure; local_closure.client = client; local_closure.pDraw = pDraw; local_closure.pGC = pGC; local_closure.nChars = nChars; local_closure.data = data; local_closure.xorg = xorg; local_closure.yorg = yorg; if ((local_closure.reqType = reqType) == X_ImageText8) { local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8; local_closure.itemSize = 1; } else { local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16; local_closure.itemSize = 2; } @@ -1805,149 +1762,136 @@ cp += len; } FreeFontPath(font_path_elements, num_fpes, FALSE); font_path_elements = fplist; if (patternCache) EmptyFontPatternCache(patternCache); num_fpes = valid_paths; return Success; bail: *bad = i; while (--valid_paths >= 0) FreeFPE(fplist[valid_paths]); xfree(fplist); return FontToXError(err); } /* XXX -- do we need to pass error down to each renderer? */ int -SetFontPath(client, npaths, paths, error) - ClientPtr client; - int npaths; - unsigned char *paths; - int *error; +SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error) { int err = Success; if (npaths == 0) { if (SetDefaultFontPath(defaultFontPath) != Success) return BadValue; } else { err = SetFontPathElements(npaths, paths, error, FALSE); } return err; } int -SetDefaultFontPath(path) - char *path; +SetDefaultFontPath(char *path) { unsigned char *cp, *pp, *nump, *newpath; int num = 1, len, err, size = 0, bad; /* get enough for string, plus values -- use up commas */ len = strlen(path) + 1; nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len); if (!newpath) return BadAlloc; pp = (unsigned char *) path; cp++; while (*pp) { if (*pp == ',') { *nump = (unsigned char) size; nump = cp++; pp++; num++; size = 0; } else { *cp++ = *pp++; size++; } } *nump = (unsigned char) size; err = SetFontPathElements(num, newpath, &bad, TRUE); DEALLOCATE_LOCAL(newpath); return err; } unsigned char * -GetFontPath(count, length) - int *count; - int *length; +GetFontPath(int *count, int *length) { int i; unsigned char *c; int len; FontPathElementPtr fpe; len = 0; for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; len += fpe->name_length + 1; } font_path_string = (unsigned char *) xrealloc(font_path_string, len); if (!font_path_string) return NULL; c = font_path_string; *length = 0; for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; *c = fpe->name_length; *length += *c++; memmove(c, fpe->name, fpe->name_length); c += fpe->name_length; } *count = num_fpes; return font_path_string; } int -LoadGlyphs(client, pfont, nchars, item_size, data) - ClientPtr client; - FontPtr pfont; - unsigned nchars; - int item_size; - unsigned char *data; +LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, unsigned char *data) { if (fpe_functions[pfont->fpe->type].load_glyphs) return (*fpe_functions[pfont->fpe->type].load_glyphs) (client, pfont, 0, nchars, item_size, data); else return Successful; } void -DeleteClientFontStuff(client) - ClientPtr client; +DeleteClientFontStuff(ClientPtr client) { int i; FontPathElementPtr fpe; for (i = 0; i < num_fpes; i++) { fpe = font_path_elements[i]; if (fpe_functions[fpe->type].client_died) (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); } } void InitFonts () { patternCache = MakeFontPatternCache(); #ifndef KDRIVESERVER if (screenInfo.numScreens > screenInfo.numVideoScreens) { PrinterFontRegisterFpeFunctions(); @@ -1957,42 +1901,41 @@ #endif { #ifdef KDRIVESERVER BuiltinRegisterFpeFunctions(); #endif FontFileRegisterFpeFunctions(); #ifndef NOFONTSERVERACCESS fs_register_fpe_functions(); #endif } } int GetDefaultPointSize () { return 120; } FontResolutionPtr -GetClientResolutions (num) - int *num; +GetClientResolutions (int *num) { if (requestingClient && requestingClient->fontResFunc != NULL && !requestingClient->clientGone) { return (*requestingClient->fontResFunc)(requestingClient, num); } else { static struct _FontResolution res; ScreenPtr pScreen; pScreen = screenInfo.screens[0]; res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth; /* * XXX - we'll want this as long as bitmap instances are prevalent so that we can match them from scalable fonts */ if (res.x_resolution < 88) res.x_resolution = 75; else res.x_resolution = 100; @@ -2063,137 +2006,127 @@ } void FreeFonts() { if (patternCache) { FreeFontPatternCache(patternCache); patternCache = 0; } FreeFontPath(font_path_elements, num_fpes, TRUE); font_path_elements = 0; num_fpes = 0; xfree(fpe_functions); num_fpe_types = 0; fpe_functions = (FPEFunctions *) 0; } /* convenience functions for FS interface */ FontPtr -find_old_font(id) - XID id; +find_old_font(XID id) { return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, SecurityUnknownAccess); } Font GetNewFontClientID() { return FakeClientID(0); } int -StoreFontClientFont(pfont, id) - FontPtr pfont; - Font id; +StoreFontClientFont(FontPtr pfont, Font id) { return AddResource(id, RT_NONE, (pointer) pfont); } void -DeleteFontClientID(id) - Font id; +DeleteFontClientID(Font id) { FreeResource(id, RT_NONE); } int -client_auth_generation(client) - ClientPtr client; +client_auth_generation(ClientPtr client) { return 0; } static int fs_handlers_installed = 0; static unsigned int last_server_gen; int -init_fs_handlers(fpe, block_handler) - FontPathElementPtr fpe; - BlockHandlerProcPtr block_handler; +init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) { /* if server has reset, make sure the b&w handlers are reinstalled */ if (last_server_gen < serverGeneration) { last_server_gen = serverGeneration; fs_handlers_installed = 0; } if (fs_handlers_installed == 0) { #ifdef DEBUG fprintf(stderr, "adding FS b & w handlers\n"); #endif if (!RegisterBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0)) return AllocError; fs_handlers_installed++; } QueueFontWakeup(fpe); return Successful; } void -remove_fs_handlers(fpe, block_handler, all) - FontPathElementPtr fpe; - BlockHandlerProcPtr block_handler; - Bool all; +remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) { if (all) { /* remove the handlers if no one else is using them */ if (--fs_handlers_installed == 0) { #ifdef DEBUG fprintf(stderr, "removing FS b & w handlers\n"); #endif RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, (pointer) 0); } } RemoveFontWakeup(fpe); } #ifdef DEBUG #define GLWIDTHBYTESPADDED(bits,nbytes) \ ((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \ :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \ :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \ :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \ : 0) #define GLYPH_SIZE(ch, nbytes) \ GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \ (ch)->metrics.leftSideBearing, (nbytes)) -dump_char_ascii(cip) - CharInfoPtr cip; +void +dump_char_ascii(CharInfoPtr cip) { int r, l; int bpr; int byte; static unsigned maskTab[] = { (1 << 7), (1 << 6), (1 << 5), (1 << 4), (1 << 3), (1 << 2), (1 << 1), (1 << 0), }; bpr = GLYPH_SIZE(cip, 4); for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) { pointer row = (pointer) cip->bits + r * bpr; byte = 0; for (l = 0; l <= (cip->metrics.rightSideBearing - cip->metrics.leftSideBearing); l++) { if (maskTab[l & 7] & row[l >> 3]) putchar('X'); else Index: xc/programs/Xserver/dix/dixutils.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/dixutils.c,v retrieving revision 1.5 diff -u -2 -0 -r1.5 dixutils.c --- xc/programs/Xserver/dix/dixutils.c 30 Jul 2004 01:15:57 -0000 1.5 +++ xc/programs/Xserver/dix/dixutils.c 7 Mar 2005 22:55:12 -0000 @@ -87,62 +87,60 @@ #include "X.h" #include "Xmd.h" #include "misc.h" #include "windowstr.h" #include "dixstruct.h" #include "pixmapstr.h" #include "scrnintstr.h" #define XK_LATIN1 #include "keysymdef.h" #ifdef XCSECURITY #define _SECURITY_SERVER #include "security.h" #endif /* * CompareTimeStamps returns -1, 0, or +1 depending on if the first * argument is less than, equal to or greater than the second argument. */ int -CompareTimeStamps(a, b) - TimeStamp a, b; +CompareTimeStamps(TimeStamp a, TimeStamp b) { if (a.months < b.months) return EARLIER; if (a.months > b.months) return LATER; if (a.milliseconds < b.milliseconds) return EARLIER; if (a.milliseconds > b.milliseconds) return LATER; return SAMETIME; } /* * convert client times to server TimeStamps */ #define HALFMONTH ((unsigned long) 1<<31) TimeStamp -ClientTimeToServerTime(c) - CARD32 c; +ClientTimeToServerTime(CARD32 c) { TimeStamp ts; if (c == CurrentTime) return currentTime; ts.months = currentTime.months; ts.milliseconds = c; if (c > currentTime.milliseconds) { if (((unsigned long) c - currentTime.milliseconds) > HALFMONTH) ts.months -= 1; } else if (c < currentTime.milliseconds) { if (((unsigned long)currentTime.milliseconds - c) > HALFMONTH) ts.months += 1; } return ts; } /* @@ -152,223 +150,202 @@ * beware of too-small buffers */ static unsigned char ISOLatin1ToLower (unsigned char source) { unsigned char dest; if ((source >= XK_A) && (source <= XK_Z)) dest = source + (XK_a - XK_A); else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis)) dest = source + (XK_agrave - XK_Agrave); else if ((source >= XK_Ooblique) && (source <= XK_Thorn)) dest = source + (XK_oslash - XK_Ooblique); else dest = source; return dest; } void -CopyISOLatin1Lowered(dest, source, length) - register unsigned char *dest, *source; - int length; +CopyISOLatin1Lowered(unsigned char *dest, unsigned char *source, int length) { register int i; for (i = 0; i < length; i++, source++, dest++) *dest = ISOLatin1ToLower (*source); *dest = '\0'; } int CompareISOLatin1Lowered(unsigned char *s1, int s1len, unsigned char *s2, int s2len) { unsigned char c1, c2; for (;;) { /* note -- compare against zero so that -1 ignores len */ c1 = s1len-- ? *s1++ : '\0'; c2 = s2len-- ? *s2++ : '\0'; if (!c1 || (c1 != c2 && (c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2)))) break; } return (int) c1 - (int) c2; } #ifdef XCSECURITY /* SecurityLookupWindow and SecurityLookupDrawable: * Look up the window/drawable taking into account the client doing * the lookup and the type of access desired. Return the window/drawable * if it exists and the client is allowed access, else return NULL. * Most Proc* functions should be calling these instead of * LookupWindow and LookupDrawable, which do no access checks. */ WindowPtr -SecurityLookupWindow(rid, client, access_mode) - XID rid; - ClientPtr client; - Mask access_mode; +SecurityLookupWindow(XID rid, ClientPtr client, Mask access_mode) { WindowPtr pWin; client->errorValue = rid; if(rid == INVALID) return NULL; if (client->trustLevel != XSecurityClientTrusted) return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode); if (client->lastDrawableID == rid) { if (client->lastDrawable->type == DRAWABLE_WINDOW) return ((WindowPtr) client->lastDrawable); return (WindowPtr) NULL; } pWin = (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode); if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) { client->lastDrawable = (DrawablePtr) pWin; client->lastDrawableID = rid; client->lastGCID = INVALID; client->lastGC = (GCPtr)NULL; } return pWin; } pointer -SecurityLookupDrawable(rid, client, access_mode) - XID rid; - ClientPtr client; - Mask access_mode; +SecurityLookupDrawable(XID rid, ClientPtr client, Mask access_mode) { register DrawablePtr pDraw; if(rid == INVALID) return (pointer) NULL; if (client->trustLevel != XSecurityClientTrusted) return (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE, access_mode); if (client->lastDrawableID == rid) return ((pointer) client->lastDrawable); pDraw = (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE, access_mode); if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW)) return (pointer)pDraw; return (pointer)NULL; } /* We can't replace the LookupWindow and LookupDrawable functions with * macros because of compatibility with loadable servers. */ WindowPtr -LookupWindow(rid, client) - XID rid; - ClientPtr client; +LookupWindow(XID rid, ClientPtr client) { return SecurityLookupWindow(rid, client, SecurityUnknownAccess); } pointer -LookupDrawable(rid, client) - XID rid; - ClientPtr client; +LookupDrawable(XID rid, ClientPtr client) { return SecurityLookupDrawable(rid, client, SecurityUnknownAccess); } #else /* not XCSECURITY */ WindowPtr -LookupWindow(rid, client) - XID rid; - ClientPtr client; +LookupWindow(XID rid, ClientPtr client) { WindowPtr pWin; client->errorValue = rid; if(rid == INVALID) return NULL; if (client->lastDrawableID == rid) { if (client->lastDrawable->type == DRAWABLE_WINDOW) return ((WindowPtr) client->lastDrawable); return (WindowPtr) NULL; } pWin = (WindowPtr)LookupIDByType(rid, RT_WINDOW); if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) { client->lastDrawable = (DrawablePtr) pWin; client->lastDrawableID = rid; client->lastGCID = INVALID; client->lastGC = (GCPtr)NULL; } return pWin; } pointer -LookupDrawable(rid, client) - XID rid; - ClientPtr client; +LookupDrawable(XID rid, ClientPtr client) { register DrawablePtr pDraw; if(rid == INVALID) return (pointer) NULL; if (client->lastDrawableID == rid) return ((pointer) client->lastDrawable); pDraw = (DrawablePtr)LookupIDByClass(rid, RC_DRAWABLE); if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW)) return (pointer)pDraw; return (pointer)NULL; } #endif /* XCSECURITY */ ClientPtr -LookupClient(rid, client) - XID rid; - ClientPtr client; +LookupClient(XID rid, ClientPtr client) { pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY, SecurityReadAccess); int clientIndex = CLIENT_ID(rid); if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) { return clients[clientIndex]; } return (ClientPtr)NULL; } int -AlterSaveSetForClient(ClientPtr client, - WindowPtr pWin, - unsigned mode, - Bool toRoot, - Bool remap) +AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode, + Bool toRoot, Bool remap) { int numnow; SaveSetElt *pTmp = NULL; int j; numnow = client->numSaved; j = 0; if (numnow) { pTmp = client->saveSet; while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (pointer)pWin)) j++; } if (mode == SetModeInsert) { if (j < numnow) /* duplicate */ return(Success); numnow++; pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow); if (!pTmp) @@ -389,174 +366,176 @@ } numnow--; if (numnow) { pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow); if (pTmp) client->saveSet = pTmp; } else { xfree(client->saveSet); client->saveSet = (SaveSetElt *)NULL; } client->numSaved = numnow; return(Success); } return(Success); } void -DeleteWindowFromAnySaveSet(pWin) - WindowPtr pWin; +DeleteWindowFromAnySaveSet(WindowPtr pWin) { register int i; register ClientPtr client; for (i = 0; i< currentMaxClients; i++) { client = clients[i]; if (client && client->numSaved) (void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE); } } /* No-op Don't Do Anything : sometimes we need to be able to call a procedure * that doesn't do anything. For example, on screen with only static * colormaps, if someone calls install colormap, it's easier to have a dummy * procedure to call than to check if there's a procedure */ void NoopDDA(void) { } typedef struct _BlockHandler { BlockHandlerProcPtr BlockHandler; WakeupHandlerProcPtr WakeupHandler; pointer blockData; Bool deleted; } BlockHandlerRec, *BlockHandlerPtr; static BlockHandlerPtr handlers; static int numHandlers; static int sizeHandlers; static Bool inHandler; static Bool handlerDeleted; -/* called from the OS layer */ +/** + * + * \param pTimeout DIX doesn't want to know how OS represents time + * \param pReadMask nor how it represents the det of descriptors + */ void -BlockHandler(pTimeout, pReadmask) -pointer pTimeout; /* DIX doesn't want to know how OS represents time */ -pointer pReadmask; /* nor how it represents the set of descriptors */ +BlockHandler(pointer pTimeout, pointer pReadmask) { register int i, j; ++inHandler; for (i = 0; i < screenInfo.numScreens; i++) (* screenInfo.screens[i]->BlockHandler)(i, screenInfo.screens[i]->blockData, pTimeout, pReadmask); for (i = 0; i < numHandlers; i++) (*handlers[i].BlockHandler) (handlers[i].blockData, pTimeout, pReadmask); if (handlerDeleted) { for (i = 0; i < numHandlers;) if (handlers[i].deleted) { for (j = i; j < numHandlers - 1; j++) handlers[j] = handlers[j+1]; numHandlers--; } else i++; handlerDeleted = FALSE; } --inHandler; } +/** + * + * \param result 32 bits of undefined result from the wait + * \param pReadmask the resulting descriptor mask + */ void -WakeupHandler(result, pReadmask) -int result; /* 32 bits of undefined result from the wait */ -pointer pReadmask; /* the resulting descriptor mask */ +WakeupHandler(int result, pointer pReadmask) { register int i, j; ++inHandler; for (i = numHandlers - 1; i >= 0; i--) (*handlers[i].WakeupHandler) (handlers[i].blockData, result, pReadmask); for (i = 0; i < screenInfo.numScreens; i++) (* screenInfo.screens[i]->WakeupHandler)(i, screenInfo.screens[i]->wakeupData, result, pReadmask); if (handlerDeleted) { for (i = 0; i < numHandlers;) if (handlers[i].deleted) { for (j = i; j < numHandlers - 1; j++) handlers[j] = handlers[j+1]; numHandlers--; } else i++; handlerDeleted = FALSE; } --inHandler; } -/* Reentrant with BlockHandler and WakeupHandler, except wakeup won't +/** + * Reentrant with BlockHandler and WakeupHandler, except wakeup won't * get called until next time */ - Bool -RegisterBlockAndWakeupHandlers (blockHandler, wakeupHandler, blockData) - BlockHandlerProcPtr blockHandler; - WakeupHandlerProcPtr wakeupHandler; - pointer blockData; +RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, + WakeupHandlerProcPtr wakeupHandler, + pointer blockData) { BlockHandlerPtr new; if (numHandlers >= sizeHandlers) { new = (BlockHandlerPtr) xrealloc (handlers, (numHandlers + 1) * sizeof (BlockHandlerRec)); if (!new) return FALSE; handlers = new; sizeHandlers = numHandlers + 1; } handlers[numHandlers].BlockHandler = blockHandler; handlers[numHandlers].WakeupHandler = wakeupHandler; handlers[numHandlers].blockData = blockData; handlers[numHandlers].deleted = FALSE; numHandlers = numHandlers + 1; return TRUE; } void -RemoveBlockAndWakeupHandlers (blockHandler, wakeupHandler, blockData) - BlockHandlerProcPtr blockHandler; - WakeupHandlerProcPtr wakeupHandler; - pointer blockData; +RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, + WakeupHandlerProcPtr wakeupHandler, + pointer blockData) { int i; for (i = 0; i < numHandlers; i++) if (handlers[i].BlockHandler == blockHandler && handlers[i].WakeupHandler == wakeupHandler && handlers[i].blockData == blockData) { if (inHandler) { handlerDeleted = TRUE; handlers[i].deleted = TRUE; } else { for (; i < numHandlers - 1; i++) handlers[i] = handlers[i+1]; numHandlers--; } break; @@ -616,143 +595,133 @@ p = &workQueue; while ((q = *p)) { if (q->client && q->client->clientGone) { (void) (*q->function) (q->client, q->closure); /* remove q from the list */ *p = q->next; /* don't fetch until after func called */ xfree (q); } else { p = &q->next; /* don't fetch until after func called */ } } workQueueLast = p; } Bool QueueWorkProc ( - Bool (*function)( - ClientPtr /* pClient */, - pointer /* closure */ - ), - ClientPtr client, - pointer closure) + Bool (*function)(ClientPtr /* pClient */, pointer /* closure */), + ClientPtr client, pointer closure) { WorkQueuePtr q; q = (WorkQueuePtr) xalloc (sizeof *q); if (!q) return FALSE; q->function = function; q->client = client; q->closure = closure; q->next = NULL; *workQueueLast = q; workQueueLast = &q->next; return TRUE; } /* * Manage a queue of sleeping clients, awakening them * when requested, by using the OS functions IgnoreClient * and AttendClient. Note that this *ignores* the troubles * with request data interleaving itself with events, but * we'll leave that until a later time. */ typedef struct _SleepQueue { struct _SleepQueue *next; ClientPtr client; ClientSleepProcPtr function; pointer closure; } SleepQueueRec, *SleepQueuePtr; static SleepQueuePtr sleepQueue = NULL; Bool -ClientSleep (client, function, closure) - ClientPtr client; - ClientSleepProcPtr function; - pointer closure; +ClientSleep (ClientPtr client, ClientSleepProcPtr function, pointer closure) { SleepQueuePtr q; q = (SleepQueuePtr) xalloc (sizeof *q); if (!q) return FALSE; IgnoreClient (client); q->next = sleepQueue; q->client = client; q->function = function; q->closure = closure; sleepQueue = q; return TRUE; } Bool -ClientSignal (client) - ClientPtr client; +ClientSignal (ClientPtr client) { SleepQueuePtr q; for (q = sleepQueue; q; q = q->next) if (q->client == client) { return QueueWorkProc (q->function, q->client, q->closure); } return FALSE; } void -ClientWakeup (client) - ClientPtr client; +ClientWakeup (ClientPtr client) { SleepQueuePtr q, *prev; prev = &sleepQueue; while ( (q = *prev) ) { if (q->client == client) { *prev = q->next; xfree (q); if (client->clientGone) /* Oops -- new zombie cleanup code ensures this only * happens from inside CloseDownClient; don't want to * recurse here... */ /* CloseDownClient(client) */; else AttendClient (client); break; } prev = &q->next; } } Bool -ClientIsAsleep (client) - ClientPtr client; +ClientIsAsleep (ClientPtr client) { SleepQueuePtr q; for (q = sleepQueue; q; q = q->next) if (q->client == client) return TRUE; return FALSE; } /* * Generic Callback Manager */ /* ===== Private Procedures ===== */ static int numCallbackListsToCleanup = 0; static CallbackListPtr **listsToCleanup = NULL; static Bool _AddCallback( @@ -892,109 +861,98 @@ for (cbr = cbl->list; cbr != NULL; cbr = nextcbr) { nextcbr = cbr->next; xfree(cbr); } xfree(cbl); *pcbl = NULL; } static CallbackFuncsRec default_cbfuncs = { _AddCallback, _DeleteCallback, _CallCallbacks, _DeleteCallbackList }; /* ===== Public Procedures ===== */ Bool -CreateCallbackList(pcbl, cbfuncs) - CallbackListPtr *pcbl; - CallbackFuncsPtr cbfuncs; +CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs) { CallbackListPtr cbl; int i; if (!pcbl) return FALSE; cbl = (CallbackListPtr) xalloc(sizeof(CallbackListRec)); if (!cbl) return FALSE; cbl->funcs = cbfuncs ? *cbfuncs : default_cbfuncs; cbl->inCallback = 0; cbl->deleted = FALSE; cbl->numDeleted = 0; cbl->list = NULL; *pcbl = cbl; for (i = 0; i < numCallbackListsToCleanup; i++) { if (!listsToCleanup[i]) { listsToCleanup[i] = pcbl; return TRUE; } } listsToCleanup = (CallbackListPtr **)xnfrealloc(listsToCleanup, sizeof(CallbackListPtr *) * (numCallbackListsToCleanup+1)); listsToCleanup[numCallbackListsToCleanup] = pcbl; numCallbackListsToCleanup++; return TRUE; } Bool -AddCallback(pcbl, callback, data) - CallbackListPtr *pcbl; - CallbackProcPtr callback; - pointer data; +AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data) { if (!pcbl) return FALSE; if (!*pcbl) { /* list hasn't been created yet; go create it */ if (!CreateCallbackList(pcbl, (CallbackFuncsPtr)NULL)) return FALSE; } return ((*(*pcbl)->funcs.AddCallback) (pcbl, callback, data)); } Bool -DeleteCallback(pcbl, callback, data) - CallbackListPtr *pcbl; - CallbackProcPtr callback; - pointer data; +DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data) { if (!pcbl || !*pcbl) return FALSE; return ((*(*pcbl)->funcs.DeleteCallback) (pcbl, callback, data)); } void -CallCallbacks(pcbl, call_data) - CallbackListPtr *pcbl; - pointer call_data; +CallCallbacks(CallbackListPtr *pcbl, pointer call_data) { if (!pcbl || !*pcbl) return; (*(*pcbl)->funcs.CallCallbacks) (pcbl, call_data); } void -DeleteCallbackList(pcbl) - CallbackListPtr *pcbl; +DeleteCallbackList(CallbackListPtr *pcbl) { if (!pcbl || !*pcbl) return; (*(*pcbl)->funcs.DeleteCallbackList) (pcbl); } void InitCallbackManager() { int i; for (i = 0; i < numCallbackListsToCleanup; i++) { DeleteCallbackList(listsToCleanup[i]); } if (listsToCleanup) xfree(listsToCleanup); numCallbackListsToCleanup = 0; listsToCleanup = NULL; } Index: xc/programs/Xserver/dix/events.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/events.c,v retrieving revision 1.6 diff -u -2 -0 -r1.6 events.c --- xc/programs/Xserver/dix/events.c 9 Aug 2004 02:08:35 -0000 1.6 +++ xc/programs/Xserver/dix/events.c 7 Mar 2005 22:55:14 -0000 @@ -205,48 +205,48 @@ #endif BoxRec physLimits; /* physical constraints of hot spot */ WindowPtr win; /* window of logical position */ HotSpot hot; /* logical pointer position */ HotSpot hotPhys; /* physical pointer position */ #ifdef PANORAMIX ScreenPtr screen; /* all others are in Screen 0 coordinates */ RegionRec Reg1; /* Region 1 for confining motion */ RegionRec Reg2; /* Region 2 for confining virtual motion */ WindowPtr windows[MAXSCREENS]; WindowPtr confineWin; /* confine window */ #endif } sprite; /* info about the cursor sprite */ #ifdef XEVIE WindowPtr xeviewin; HotSpot xeviehot; #endif static void DoEnterLeaveEvents( - WindowPtr /*fromWin*/, - WindowPtr /*toWin*/, - int /*mode*/ + WindowPtr fromWin, + WindowPtr toWin, + int mode ); static WindowPtr XYToWindow( - int /*x*/, - int /*y*/ + int x, + int y ); extern int lastEvent; static Mask lastEventMask; #ifdef XINPUT extern int DeviceMotionNotify; #endif #define CantBeFiltered NoEventMask static Mask filters[128] = { NoSuchEvent, /* 0 */ NoSuchEvent, /* 1 */ KeyPressMask, /* KeyPress */ KeyReleaseMask, /* KeyRelease */ ButtonPressMask, /* ButtonPress */ ButtonReleaseMask, /* ButtonRelease */ PointerMotionMask, /* MotionNotify (initial state) */ @@ -591,52 +591,49 @@ } static void XineramaChangeToCursor(CursorPtr cursor) { if (cursor != sprite.current) { if ((sprite.current->bits->xhot != cursor->bits->xhot) || (sprite.current->bits->yhot != cursor->bits->yhot)) XineramaCheckPhysLimits(cursor, FALSE); (*sprite.screen->DisplayCursor)(sprite.screen, cursor); sprite.current = cursor; } } #endif /* PANORAMIX */ void -SetMaskForEvent(mask, event) - Mask mask; - int event; +SetMaskForEvent(Mask mask, int event) { if ((event < LASTEvent) || (event >= 128)) FatalError("SetMaskForEvent: bogus event number"); filters[event] = mask; } void -SetCriticalEvent(event) - int event; +SetCriticalEvent(int event) { if (event >= 128) FatalError("SetCriticalEvent: bogus event number"); criticalEvents[event >> 3] |= 1 << (event & 7); } static void SyntheticMotion(int x, int y) { xEvent xE; #ifdef PANORAMIX /* Translate back to the sprite screen since processInputProc will translate from sprite screen to screen 0 upon reentry to the DIX layer */ if(!noPanoramiXExtension) { x += panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x; y += panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y; } #endif @@ -826,42 +823,41 @@ if(!noPanoramiXExtension) { XineramaChangeToCursor(cursor); return; } #endif if (cursor != sprite.current) { if ((sprite.current->bits->xhot != cursor->bits->xhot) || (sprite.current->bits->yhot != cursor->bits->yhot)) CheckPhysLimits(cursor, FALSE, sprite.confined, (ScreenPtr)NULL); (*sprite.hotPhys.pScreen->DisplayCursor) (sprite.hotPhys.pScreen, cursor); sprite.current = cursor; } } /* returns true if b is a descendent of a */ Bool -IsParent(a, b) - register WindowPtr a, b; +IsParent(register WindowPtr a, register WindowPtr b) { for (b = b->parent; b; b = b->parent) if (b == a) return TRUE; return FALSE; } static void PostNewCursor(void) { register WindowPtr win; register GrabPtr grab = inputInfo.pointer->grab; if (syncEvents.playingEvents) return; if (grab) { if (grab->cursor) { ChangeToCursor(grab->cursor); return; @@ -883,97 +879,92 @@ WindowPtr GetCurrentRootWindow() { return ROOT; } WindowPtr GetSpriteWindow() { return sprite.win; } CursorPtr GetSpriteCursor() { return sprite.current; } void -GetSpritePosition(px, py) - int *px, *py; +GetSpritePosition(int *px, int *py) { *px = sprite.hotPhys.x; *py = sprite.hotPhys.y; } #ifdef PANORAMIX int XineramaGetCursorScreen() { if(!noPanoramiXExtension) { return sprite.screen->myNum; } else { return 0; } } #endif /* PANORAMIX */ #define TIMESLOP (5 * 60 * 1000) /* 5 minutes */ static void MonthChangedOrBadTime(register xEvent *xE) { /* If the ddx/OS is careless about not processing timestamped events from * different sources in sorted order, then it's possible for time to go * backwards when it should not. Here we ensure a decent time. */ if ((currentTime.milliseconds - XE_KBPTR.time) > TIMESLOP) currentTime.months++; else XE_KBPTR.time = currentTime.milliseconds; } #define NoticeTime(xE) { \ if ((xE)->u.keyButtonPointer.time < currentTime.milliseconds) \ MonthChangedOrBadTime(xE); \ currentTime.milliseconds = (xE)->u.keyButtonPointer.time; \ lastDeviceEventTime = currentTime; } void -NoticeEventTime(xE) - register xEvent *xE; +NoticeEventTime(register xEvent *xE) { if (!syncEvents.playingEvents) NoticeTime(xE); } /************************************************************************** * The following procedures deal with synchronous events * **************************************************************************/ void -EnqueueEvent(xE, device, count) - xEvent *xE; - DeviceIntPtr device; - int count; +EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count) { register QdEventPtr tail = *syncEvents.pendtail; register QdEventPtr qe; xEvent *qxE; NoticeTime(xE); #ifdef XKB /* Fix for key repeating bug. */ if (device->key != NULL && device->key->xkbInfo != NULL && xE->u.u.type == KeyRelease) AccessXCancelRepeatKey(device->key->xkbInfo, xE->u.u.detail); #endif if (DeviceEventCallback) { DeviceEventInfoRec eventinfo; /* The RECORD spec says that the root window field of motion events * must be valid. At this point, it hasn't been filled in yet, so * we do it here. The long expression below is necessary to get @@ -1155,192 +1146,177 @@ #ifdef RANDR void ScreenRestructured (ScreenPtr pScreen) { GrabPtr grab; if ((grab = inputInfo.pointer->grab) && grab->confineTo) { if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen) sprite.hotPhys.x = sprite.hotPhys.y = 0; ConfineCursorToWindow(grab->confineTo, TRUE, TRUE); } else ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum], TRUE, FALSE); } #endif void -CheckGrabForSyncs(thisDev, thisMode, otherMode) - register DeviceIntPtr thisDev; - Bool thisMode, otherMode; +CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) { register GrabPtr grab = thisDev->grab; register DeviceIntPtr dev; if (thisMode == GrabModeSync) thisDev->sync.state = FROZEN_NO_EVENT; else { /* free both if same client owns both */ thisDev->sync.state = THAWED; if (thisDev->sync.other && (CLIENT_BITS(thisDev->sync.other->resource) == CLIENT_BITS(grab->resource))) thisDev->sync.other = NullGrab; } for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev != thisDev) { if (otherMode == GrabModeSync) dev->sync.other = grab; else { /* free both if same client owns both */ if (dev->sync.other && (CLIENT_BITS(dev->sync.other->resource) == CLIENT_BITS(grab->resource))) dev->sync.other = NullGrab; } } } ComputeFreezes(); } void -ActivatePointerGrab(mouse, grab, time, autoGrab) - register GrabPtr grab; - register DeviceIntPtr mouse; - TimeStamp time; - Bool autoGrab; +ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, + TimeStamp time, Bool autoGrab) { WindowPtr oldWin = (mouse->grab) ? mouse->grab->window : sprite.win; if (grab->confineTo) { if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen) sprite.hotPhys.x = sprite.hotPhys.y = 0; ConfineCursorToWindow(grab->confineTo, FALSE, TRUE); } DoEnterLeaveEvents(oldWin, grab->window, NotifyGrab); mouse->valuator->motionHintWindow = NullWindow; if (syncEvents.playingEvents) mouse->grabTime = syncEvents.time; else mouse->grabTime = time; if (grab->cursor) grab->cursor->refcnt++; mouse->activeGrab = *grab; mouse->grab = &mouse->activeGrab; mouse->fromPassiveGrab = autoGrab; PostNewCursor(); CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode); } void -DeactivatePointerGrab(mouse) - register DeviceIntPtr mouse; +DeactivatePointerGrab(register DeviceIntPtr mouse) { register GrabPtr grab = mouse->grab; register DeviceIntPtr dev; mouse->valuator->motionHintWindow = NullWindow; mouse->grab = NullGrab; mouse->sync.state = NOT_GRABBED; mouse->fromPassiveGrab = FALSE; for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev->sync.other == grab) dev->sync.other = NullGrab; } DoEnterLeaveEvents(grab->window, sprite.win, NotifyUngrab); if (grab->confineTo) ConfineCursorToWindow(ROOT, FALSE, FALSE); PostNewCursor(); if (grab->cursor) FreeCursor(grab->cursor, (Cursor)0); ComputeFreezes(); } void -ActivateKeyboardGrab(keybd, grab, time, passive) - register DeviceIntPtr keybd; - GrabPtr grab; - TimeStamp time; - Bool passive; +ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive) { WindowPtr oldWin; if (keybd->grab) oldWin = keybd->grab->window; else if (keybd->focus) oldWin = keybd->focus->win; else oldWin = sprite.win; if (oldWin == FollowKeyboardWin) oldWin = inputInfo.keyboard->focus->win; if (keybd->valuator) keybd->valuator->motionHintWindow = NullWindow; DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab); if (syncEvents.playingEvents) keybd->grabTime = syncEvents.time; else keybd->grabTime = time; keybd->activeGrab = *grab; keybd->grab = &keybd->activeGrab; keybd->fromPassiveGrab = passive; CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode); } void -DeactivateKeyboardGrab(keybd) - register DeviceIntPtr keybd; +DeactivateKeyboardGrab(register DeviceIntPtr keybd) { register GrabPtr grab = keybd->grab; register DeviceIntPtr dev; register WindowPtr focusWin = keybd->focus ? keybd->focus->win : sprite.win; if (focusWin == FollowKeyboardWin) focusWin = inputInfo.keyboard->focus->win; if (keybd->valuator) keybd->valuator->motionHintWindow = NullWindow; keybd->grab = NullGrab; keybd->sync.state = NOT_GRABBED; keybd->fromPassiveGrab = FALSE; for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev->sync.other == grab) dev->sync.other = NullGrab; } DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab); ComputeFreezes(); } void -AllowSome(client, time, thisDev, newState) - ClientPtr client; - TimeStamp time; - register DeviceIntPtr thisDev; - int newState; +AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) { Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced; TimeStamp grabTime; register DeviceIntPtr dev; thisGrabbed = thisDev->grab && SameClient(thisDev->grab, client); thisSynced = FALSE; otherGrabbed = FALSE; othersFrozen = TRUE; grabTime = thisDev->grabTime; for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev == thisDev) continue; if (dev->grab && SameClient(dev->grab, client)) { if (!(thisGrabbed || otherGrabbed) || (CompareTimeStamps(dev->grabTime, grabTime) == LATER)) grabTime = dev->grabTime; otherGrabbed = TRUE; @@ -1414,42 +1390,41 @@ break; case THAW_OTHERS: /* AsyncOthers */ if (othersFrozen) { for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev == thisDev) continue; if (dev->grab && SameClient(dev->grab, client)) dev->sync.state = THAWED; if (dev->sync.other && SameClient(dev->sync.other, client)) dev->sync.other = NullGrab; } ComputeFreezes(); } break; } } int -ProcAllowEvents(client) - register ClientPtr client; +ProcAllowEvents(register ClientPtr client) { TimeStamp time; DeviceIntPtr mouse = inputInfo.pointer; DeviceIntPtr keybd = inputInfo.keyboard; REQUEST(xAllowEventsReq); REQUEST_SIZE_MATCH(xAllowEventsReq); time = ClientTimeToServerTime(stuff->time); switch (stuff->mode) { case ReplayPointer: AllowSome(client, time, mouse, NOT_GRABBED); break; case SyncPointer: AllowSome(client, time, mouse, FREEZE_NEXT_EVENT); break; case AsyncPointer: AllowSome(client, time, mouse, THAWED); break; case ReplayKeyboard: @@ -1458,73 +1433,68 @@ case SyncKeyboard: AllowSome(client, time, keybd, FREEZE_NEXT_EVENT); break; case AsyncKeyboard: AllowSome(client, time, keybd, THAWED); break; case SyncBoth: AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT); break; case AsyncBoth: AllowSome(client, time, keybd, THAWED_BOTH); break; default: client->errorValue = stuff->mode; return BadValue; } return Success; } void -ReleaseActiveGrabs(client) - ClientPtr client; +ReleaseActiveGrabs(ClientPtr client) { register DeviceIntPtr dev; Bool done; /* XXX CloseDownClient should remove passive grabs before * releasing active grabs. */ do { done = TRUE; for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev->grab && SameClient(dev->grab, client)) { (*dev->DeactivateGrab)(dev); done = FALSE; } } } while (!done); } /************************************************************************** * The following procedures deal with delivering events * **************************************************************************/ int -TryClientEvents (client, pEvents, count, mask, filter, grab) - ClientPtr client; - GrabPtr grab; - xEvent *pEvents; - int count; - Mask mask, filter; +TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, + Mask filter, GrabPtr grab) { int i; int type; #ifdef DEBUG if (debug_events) ErrorF( "Event([%d, %d], mask=0x%x), client=%d", pEvents->u.u.type, pEvents->u.u.detail, mask, client->index); #endif if ((client) && (client != serverClient) && (!client->clientGone) && ((filter == CantBeFiltered) || (mask & filter))) { if (grab && !SameClient(grab, client)) return -1; /* don't send, but notify caller */ type = pEvents->u.u.type; if (type == MotionNotify) { if (mask & PointerMotionHintMask) { if (WID(inputInfo.pointer->valuator->motionHintWindow) == @@ -1568,47 +1538,42 @@ #endif SetCriticalOutputPending(); } WriteEventsToClient(client, count, pEvents); #ifdef DEBUG if (debug_events) ErrorF( " delivered\n"); #endif return 1; } else { #ifdef DEBUG if (debug_events) ErrorF("\n"); #endif return 0; } } int -DeliverEventsToWindow(pWin, pEvents, count, filter, grab, mskidx) - register WindowPtr pWin; - GrabPtr grab; - xEvent *pEvents; - int count; - Mask filter; - int mskidx; +DeliverEventsToWindow(register WindowPtr pWin, xEvent *pEvents, int count, + Mask filter, GrabPtr grab, int mskidx) { int deliveries = 0, nondeliveries = 0; int attempt; register InputClients *other; ClientPtr client = NullClient; Mask deliveryMask = 0; /* If a grab occurs due to a button press, then this mask is the mask of the grab. */ int type = pEvents->u.u.type; /* CantBeFiltered means only window owner gets the event */ if ((filter == CantBeFiltered) || !(type & EXTENSION_EVENT_BASE)) { /* if nobody ever wants to see this event, skip some work */ if (filter != CantBeFiltered && !((wOtherEventMasks(pWin)|pWin->eventMask) & filter)) return 0; if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count, pWin->eventMask, filter, grab)) ) { if (attempt > 0) @@ -1692,46 +1657,42 @@ #ifdef PANORAMIX static int XineramaTryClientEventsResult( ClientPtr client, GrabPtr grab, Mask mask, Mask filter ){ if ((client) && (client != serverClient) && (!client->clientGone) && ((filter == CantBeFiltered) || (mask & filter))) { if (grab && !SameClient(grab, client)) return -1; else return 1; } return 0; } #endif int -MaybeDeliverEventsToClient(pWin, pEvents, count, filter, dontClient) - register WindowPtr pWin; - xEvent *pEvents; - int count; - Mask filter; - ClientPtr dontClient; +MaybeDeliverEventsToClient(register WindowPtr pWin, xEvent *pEvents, + int count, Mask filter, ClientPtr dontClient) { register OtherClients *other; if (pWin->eventMask & filter) { if (wClient(pWin) == dontClient) return 0; #ifdef PANORAMIX if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return XineramaTryClientEventsResult( wClient(pWin), NullGrab, pWin->eventMask, filter); #endif return TryClientEvents(wClient(pWin), pEvents, count, pWin->eventMask, filter, NullGrab); } for (other = wOtherClients(pWin); other; other = other->next) { if (other->mask & filter) { @@ -1787,46 +1748,42 @@ XE_KBPTR.event = pWin->drawable.id; if (sprite.hot.pScreen == pWin->drawable.pScreen) { XE_KBPTR.sameScreen = xTrue; XE_KBPTR.child = child; XE_KBPTR.eventX = XE_KBPTR.rootX - pWin->drawable.x; XE_KBPTR.eventY = XE_KBPTR.rootY - pWin->drawable.y; } else { XE_KBPTR.sameScreen = xFalse; XE_KBPTR.child = None; XE_KBPTR.eventX = 0; XE_KBPTR.eventY = 0; } } int -DeliverDeviceEvents(pWin, xE, grab, stopAt, dev, count) - register WindowPtr pWin, stopAt; - register xEvent *xE; - GrabPtr grab; - DeviceIntPtr dev; - int count; +DeliverDeviceEvents(register WindowPtr pWin, register xEvent *xE, GrabPtr grab, + register WindowPtr stopAt, DeviceIntPtr dev, int count) { Window child = None; int type = xE->u.u.type; Mask filter = filters[type]; int deliveries = 0; if (type & EXTENSION_EVENT_BASE) { register OtherInputMasks *inputMasks; int mskidx = dev->id; inputMasks = wOtherInputMasks(pWin); if (inputMasks && !(filter & inputMasks->deliverableEvents[mskidx])) return 0; while (pWin) { if (inputMasks && (inputMasks->inputEvents[mskidx] & filter)) { FixUpEventFromWindow(xE, pWin, child, FALSE); deliveries = DeliverEventsToWindow(pWin, xE, count, filter, @@ -1855,44 +1812,42 @@ { FixUpEventFromWindow(xE, pWin, child, FALSE); deliveries = DeliverEventsToWindow(pWin, xE, count, filter, grab, 0); if (deliveries > 0) return deliveries; } if ((deliveries < 0) || (pWin == stopAt) || (filter & wDontPropagateMask(pWin))) return 0; child = pWin->drawable.id; pWin = pWin->parent; } } return 0; } /* not useful for events that propagate up the tree or extension events */ int -DeliverEvents(pWin, xE, count, otherParent) - register WindowPtr pWin, otherParent; - register xEvent *xE; - int count; +DeliverEvents(register WindowPtr pWin, register xEvent *xE, int count, + register WindowPtr otherParent) { Mask filter; int deliveries; #ifdef PANORAMIX if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return count; #endif if (!count) return 0; filter = filters[xE->u.u.type]; if ((filter & SubstructureNotifyMask) && (xE->u.u.type != CreateNotify)) xE->u.destroyNotify.event = pWin->drawable.id; if (filter != StructureAndSubMask) return DeliverEventsToWindow(pWin, xE, count, filter, NullGrab, 0); deliveries = DeliverEventsToWindow(pWin, xE, count, StructureNotifyMask, NullGrab, 0); if (pWin->parent) { @@ -2074,42 +2029,41 @@ sprite.hotLimits.x2 -= xoff; sprite.hotLimits.y2 -= yoff; if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg1)) REGION_TRANSLATE(sprite.screen, &sprite.Reg1, xoff, yoff); if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg2)) REGION_TRANSLATE(sprite.screen, &sprite.Reg2, xoff, yoff); /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */ if ((grab = inputInfo.pointer->grab) && grab->confineTo) { if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen) sprite.hotPhys.x = sprite.hotPhys.y = 0; ConfineCursorToWindow(grab->confineTo, TRUE, TRUE); } else ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum], TRUE, FALSE); } #endif void -DefineInitialRootWindow(win) - register WindowPtr win; +DefineInitialRootWindow(register WindowPtr win) { register ScreenPtr pScreen = win->drawable.pScreen; sprite.hotPhys.pScreen = pScreen; sprite.hotPhys.x = pScreen->width / 2; sprite.hotPhys.y = pScreen->height / 2; sprite.hot = sprite.hotPhys; sprite.hotLimits.x2 = pScreen->width; sprite.hotLimits.y2 = pScreen->height; sprite.win = win; sprite.current = wCursor (win); spriteTraceGood = 1; ROOT = win; (*pScreen->CursorLimits) ( pScreen, sprite.current, &sprite.hotLimits, &sprite.physLimits); sprite.confined = FALSE; (*pScreen->ConstrainCursor) (pScreen, &sprite.physLimits); (*pScreen->SetCursorPosition) (pScreen, sprite.hot.x, sprite.hot.y, FALSE); (*pScreen->DisplayCursor) (pScreen, sprite.current); @@ -2122,52 +2076,48 @@ sprite.physLimits = sprite.hotLimits; sprite.confineWin = NullWindow; #ifdef SHAPE sprite.hotShape = NullRegion; #endif sprite.screen = pScreen; /* gotta UNINIT these someplace */ REGION_NULL(pScreen, &sprite.Reg1); REGION_NULL(pScreen, &sprite.Reg2); } #endif } /* * This does not take any shortcuts, and even ignores its argument, since * it does not happen very often, and one has to walk up the tree since * this might be a newly instantiated cursor for an intermediate window * between the one the pointer is in and the one that the last cursor was * instantiated from. */ -/*ARGSUSED*/ void -WindowHasNewCursor(pWin) - WindowPtr pWin; +WindowHasNewCursor(WindowPtr pWin) { PostNewCursor(); } void -NewCurrentScreen(newScreen, x, y) - ScreenPtr newScreen; - int x,y; +NewCurrentScreen(ScreenPtr newScreen, int x, int y) { sprite.hotPhys.x = x; sprite.hotPhys.y = y; #ifdef PANORAMIX if(!noPanoramiXExtension) { sprite.hotPhys.x += panoramiXdataPtr[newScreen->myNum].x - panoramiXdataPtr[0].x; sprite.hotPhys.y += panoramiXdataPtr[newScreen->myNum].y - panoramiXdataPtr[0].y; if (newScreen != sprite.screen) { sprite.screen = newScreen; /* Make sure we tell the DDX to update its copy of the screen */ if(sprite.confineWin) XineramaConfineCursorToWindow(sprite.confineWin, TRUE); else XineramaConfineCursorToWindow(WindowTable[0], TRUE); /* if the pointer wasn't confined, the DDX won't get told of the pointer warp so we reposition it here */ if(!syncEvents.playingEvents) (*sprite.screen->SetCursorPosition)(sprite.screen, @@ -2276,42 +2226,41 @@ if (x < sprite.physLimits.x1) x = sprite.physLimits.x1; else if (x >= sprite.physLimits.x2) x = sprite.physLimits.x2 - 1; if (y < sprite.physLimits.y1) y = sprite.physLimits.y1; else if (y >= sprite.physLimits.y2) y = sprite.physLimits.y2 - 1; if (sprite.hotShape) ConfineToShape(sprite.hotShape, &x, &y); XineramaSetCursorPosition(x, y, TRUE); return Success; } #endif int -ProcWarpPointer(client) - ClientPtr client; +ProcWarpPointer(ClientPtr client) { WindowPtr dest = NULL; int x, y; ScreenPtr newScreen; REQUEST(xWarpPointerReq); REQUEST_SIZE_MATCH(xWarpPointerReq); #ifdef PANORAMIX if(!noPanoramiXExtension) return XineramaWarpPointer(client); #endif if (stuff->dstWid != None) { dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); if (!dest) return BadWindow; } @@ -2480,59 +2429,56 @@ { if (device->sync.evcount < count) { Must_have_memory = TRUE; /* XXX */ device->sync.event = (xEvent *)xrealloc(device->sync.event, count* sizeof(xEvent)); Must_have_memory = FALSE; /* XXX */ } device->sync.evcount = count; for (dxE = device->sync.event; --count >= 0; dxE++, xE++) *dxE = *xE; device->sync.state = FROZEN_WITH_EVENT; } return TRUE; } } return FALSE; } -/* +/** "CheckDeviceGrabs" handles both keyboard and pointer events that may cause a passive grab to be activated. If the event is a keyboard event, the ancestors of the focus window are traced down and tried to see if they have any passive grabs to be activated. If the focus window itself is reached and it's descendants contain they pointer, the ancestors of the window that the pointer is in are then traced down starting at the focus window, otherwise no grabs are activated. If the event is a pointer event, the ancestors of the window that the pointer is in are traced down starting at the root until CheckPassiveGrabs causes a passive grab to activate or all the windows are tried. PRH */ Bool -CheckDeviceGrabs(device, xE, checkFirst, count) - register DeviceIntPtr device; - register xEvent *xE; - int checkFirst; - int count; +CheckDeviceGrabs(register DeviceIntPtr device, register xEvent *xE, + int checkFirst, int count) { register int i; register WindowPtr pWin = NULL; register FocusClassPtr focus = device->focus; if (((xE->u.u.type == ButtonPress) #if defined(XINPUT) && defined(XKB) || (xE->u.u.type == DeviceButtonPress) #endif ) && (device->button->buttonsDown != 1)) return FALSE; i = checkFirst; if (focus) { for (; i < focus->traceGood; i++) { pWin = focus->trace[i]; if (pWin->optional && @@ -2541,77 +2487,70 @@ } if ((focus->win == NoneWin) || (i >= spriteTraceGood) || ((i > checkFirst) && (pWin != spriteTrace[i-1]))) return FALSE; } for (; i < spriteTraceGood; i++) { pWin = spriteTrace[i]; if (pWin->optional && CheckPassiveGrabsOnWindow(pWin, device, xE, count)) return TRUE; } return FALSE; } void -DeliverFocusedEvent(keybd, xE, window, count) - xEvent *xE; - DeviceIntPtr keybd; - WindowPtr window; - int count; +DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count) { WindowPtr focus = keybd->focus->win; int mskidx = 0; if (focus == FollowKeyboardWin) focus = inputInfo.keyboard->focus->win; if (!focus) return; if (focus == PointerRootWin) { DeliverDeviceEvents(window, xE, NullGrab, NullWindow, keybd, count); return; } if ((focus == window) || IsParent(focus, window)) { if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count)) return; } /* just deliver it to the focus window */ FixUpEventFromWindow(xE, focus, None, FALSE); if (xE->u.u.type & EXTENSION_EVENT_BASE) mskidx = keybd->id; (void)DeliverEventsToWindow(focus, xE, count, filters[xE->u.u.type], NullGrab, mskidx); } void -DeliverGrabbedEvent(xE, thisDev, deactivateGrab, count) - register xEvent *xE; - register DeviceIntPtr thisDev; - Bool deactivateGrab; - int count; +DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev, + Bool deactivateGrab, int count) { register GrabPtr grab = thisDev->grab; int deliveries = 0; register DeviceIntPtr dev; register xEvent *dxE; if (grab->ownerEvents) { WindowPtr focus; if (thisDev->focus) { focus = thisDev->focus->win; if (focus == FollowKeyboardWin) focus = inputInfo.keyboard->focus->win; } else focus = PointerRootWin; if (focus == PointerRootWin) deliveries = DeliverDeviceEvents(sprite.win, xE, grab, NullWindow, @@ -2659,47 +2598,44 @@ /* fall through */ case FREEZE_NEXT_EVENT: thisDev->sync.state = FROZEN_WITH_EVENT; FreezeThaw(thisDev, TRUE); if (thisDev->sync.evcount < count) { Must_have_memory = TRUE; /* XXX */ thisDev->sync.event = (xEvent *)xrealloc(thisDev->sync.event, count*sizeof(xEvent)); Must_have_memory = FALSE; /* XXX */ } thisDev->sync.evcount = count; for (dxE = thisDev->sync.event; --count >= 0; dxE++, xE++) *dxE = *xE; break; } } void #ifdef XKB -CoreProcessKeyboardEvent (xE, keybd, count) +CoreProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count) #else -ProcessKeyboardEvent (xE, keybd, count) +ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count) #endif - register xEvent *xE; - register DeviceIntPtr keybd; - int count; { int key, bit; register BYTE *kptr; register int i; register CARD8 modifiers; register CARD16 mask; GrabPtr grab = keybd->grab; Bool deactivateGrab = FALSE; register KeyClassPtr keyc = keybd->key; #ifdef XEVIE static Window rootWin = 0; if(!xeviegrabState && xevieFlag && clients[xevieClientIndex] && (xevieMask & xevieFilters[xE->u.u.type])) { key = xE->u.u.detail; kptr = &keyc->down[key >> 3]; bit = 1 << (key & 7); if((xE->u.u.type == KeyPress && (*kptr & bit)) || (xE->u.u.type == KeyRelease && !(*kptr & bit))) {} else { @@ -2818,81 +2754,76 @@ if (keybd->fromPassiveGrab && (key == keybd->activatingKey)) deactivateGrab = TRUE; break; default: FatalError("Impossible keyboard event"); } if (grab) DeliverGrabbedEvent(xE, keybd, deactivateGrab, count); else DeliverFocusedEvent(keybd, xE, sprite.win, count); if (deactivateGrab) (*keybd->DeactivateGrab)(keybd); } #ifdef XKB /* This function is used to set the key pressed or key released state - this is only used when the pressing of keys does not cause CoreProcessKeyEvent to be called, as in for example Mouse Keys. */ void -FixKeyState (xE, keybd) - register xEvent *xE; - register DeviceIntPtr keybd; +FixKeyState (register xEvent *xE, register DeviceIntPtr keybd) { int key, bit; register BYTE *kptr; register KeyClassPtr keyc = keybd->key; key = xE->u.u.detail; kptr = &keyc->down[key >> 3]; bit = 1 << (key & 7); #ifdef DEBUG if ((xkbDebugFlags&0x4)&& ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) { ErrorF("FixKeyState: Key %d %s\n",key, (xE->u.u.type==KeyPress?"down":"up")); } #endif switch (xE->u.u.type) { case KeyPress: *kptr |= bit; break; case KeyRelease: *kptr &= ~bit; break; default: FatalError("Impossible keyboard event"); } } #endif void #ifdef XKB -CoreProcessPointerEvent (xE, mouse, count) +CoreProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count) #else -ProcessPointerEvent (xE, mouse, count) +ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count) #endif - register xEvent *xE; - register DeviceIntPtr mouse; - int count; { register GrabPtr grab = mouse->grab; Bool deactivateGrab = FALSE; register ButtonClassPtr butc = mouse->button; #ifdef XKB XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo; #endif #ifdef XEVIE if(xevieFlag && clients[xevieClientIndex] && !xeviegrabState && (xevieMask & xevieFilters[xE->u.u.type])) { if(xevieEventSent) xevieEventSent = 0; else { xeviemouse = mouse; WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE); return; } } #endif @@ -3009,76 +2940,75 @@ } pChild->deliverableEvents = pChild->eventMask| wOtherEventMasks(pChild); if (pChild->parent) pChild->deliverableEvents |= (pChild->parent->deliverableEvents & ~wDontPropagateMask(pChild) & PropagateMask); if (pChild->firstChild) { pChild = pChild->firstChild; continue; } while (!pChild->nextSib && (pChild != pWin)) pChild = pChild->parent; if (pChild == pWin) break; pChild = pChild->nextSib; } } +/** + * + * \param value must conform to DeleteType + */ int -OtherClientGone(value, id) - pointer value; /* must conform to DeleteType */ - XID id; +OtherClientGone(pointer value, XID id) { register OtherClientsPtr other, prev; register WindowPtr pWin = (WindowPtr)value; prev = 0; for (other = wOtherClients(pWin); other; other = other->next) { if (other->resource == id) { if (prev) prev->next = other->next; else { if (!(pWin->optional->otherClients = other->next)) CheckWindowOptionalNeed (pWin); } xfree(other); RecalculateDeliverableEvents(pWin); return(Success); } prev = other; } FatalError("client not on event list"); /*NOTREACHED*/ return -1; /* make compiler happy */ } int -EventSelectForWindow(pWin, client, mask) - register WindowPtr pWin; - register ClientPtr client; - Mask mask; +EventSelectForWindow(register WindowPtr pWin, register ClientPtr client, Mask mask) { Mask check; OtherClients * others; if (mask & ~AllEventMasks) { client->errorValue = mask; return BadValue; } check = (mask & AtMostOneClient); if (check & (pWin->eventMask|wOtherEventMasks(pWin))) { /* It is illegal for two different clients to select on any of the events for AtMostOneClient. However, it is OK, for some client to continue selecting on one of those events. */ if ((wClient(pWin) != client) && (check & pWin->eventMask)) return BadAccess; for (others = wOtherClients (pWin); others; others = others->next) @@ -3123,47 +3053,43 @@ others = (OtherClients *) xalloc(sizeof(OtherClients)); if (!others) return BadAlloc; others->mask = mask; others->resource = FakeClientID(client->index); others->next = pWin->optional->otherClients; pWin->optional->otherClients = others; if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer)pWin)) return BadAlloc; } maskSet: if ((inputInfo.pointer->valuator->motionHintWindow == pWin) && (mask & PointerMotionHintMask) && !(check & PointerMotionHintMask) && !inputInfo.pointer->grab) inputInfo.pointer->valuator->motionHintWindow = NullWindow; RecalculateDeliverableEvents(pWin); return Success; } -/*ARGSUSED*/ int -EventSuppressForWindow(pWin, client, mask, checkOptional) - register WindowPtr pWin; - register ClientPtr client; - Mask mask; - Bool *checkOptional; +EventSuppressForWindow(register WindowPtr pWin, register ClientPtr client, + Mask mask, Bool *checkOptional) { register int i, free; if ((mask & ~PropagateMask) && !permitOldBugs) { client->errorValue = mask; return BadValue; } if (pWin->dontPropagate) DontPropagateRefCnts[pWin->dontPropagate]--; if (!mask) i = 0; else { for (i = DNPMCOUNT, free = 0; --i > 0; ) { if (!DontPropagateRefCnts[i]) free = i; else if (mask == DontPropagateMasks[i]) break; @@ -3415,44 +3341,41 @@ return FALSE; } /* dies horribly if ancestor is not an ancestor of child */ static void FocusOutEvents( DeviceIntPtr dev, WindowPtr child, WindowPtr ancestor, int mode, int detail, Bool doAncestor) { register WindowPtr pWin; for (pWin = child; pWin != ancestor; pWin = pWin->parent) FocusEvent(dev, FocusOut, mode, detail, pWin); if (doAncestor) FocusEvent(dev, FocusOut, mode, detail, ancestor); } void -DoFocusEvents(dev, fromWin, toWin, mode) - DeviceIntPtr dev; - WindowPtr fromWin, toWin; - int mode; +DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode) { int out, in; /* for holding details for to/from PointerRoot/None */ int i; if (fromWin == toWin) return; out = (fromWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot; in = (toWin == NoneWin) ? NotifyDetailNone : NotifyPointerRoot; /* wrong values if neither, but then not referenced */ if ((toWin == NullWindow) || (toWin == PointerRootWin)) { if ((fromWin == NullWindow) || (fromWin == PointerRootWin)) { if (fromWin == PointerRootWin) FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer, TRUE); /* Notify all the roots */ #ifdef PANORAMIX @@ -3637,64 +3560,62 @@ } return Success; } int ProcSetInputFocus(client) ClientPtr client; { REQUEST(xSetInputFocusReq); REQUEST_SIZE_MATCH(xSetInputFocusReq); #ifdef XCSECURITY if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE)) return Success; #endif return SetInputFocus(client, inputInfo.keyboard, stuff->focus, stuff->revertTo, stuff->time, FALSE); } int -ProcGetInputFocus(client) - ClientPtr client; +ProcGetInputFocus(ClientPtr client) { xGetInputFocusReply rep; /* REQUEST(xReq); */ FocusClassPtr focus = inputInfo.keyboard->focus; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; if (focus->win == NoneWin) rep.focus = None; else if (focus->win == PointerRootWin) rep.focus = PointerRoot; else rep.focus = focus->win->drawable.id; rep.revertTo = focus->revert; WriteReplyToClient(client, sizeof(xGetInputFocusReply), &rep); return Success; } int -ProcGrabPointer(client) - ClientPtr client; +ProcGrabPointer(ClientPtr client) { xGrabPointerReply rep; DeviceIntPtr device = inputInfo.pointer; GrabPtr grab; WindowPtr pWin, confineTo; CursorPtr cursor, oldCursor; REQUEST(xGrabPointerReq); TimeStamp time; REQUEST_SIZE_MATCH(xGrabPointerReq); UpdateCurrentTime(); if ((stuff->pointerMode != GrabModeSync) && (stuff->pointerMode != GrabModeAsync)) { client->errorValue = stuff->pointerMode; return BadValue; } if ((stuff->keyboardMode != GrabModeSync) && (stuff->keyboardMode != GrabModeAsync)) { @@ -3766,42 +3687,41 @@ } tempGrab.cursor = cursor; tempGrab.resource = client->clientAsMask; tempGrab.ownerEvents = stuff->ownerEvents; tempGrab.eventMask = stuff->eventMask; tempGrab.confineTo = confineTo; tempGrab.window = pWin; tempGrab.keyboardMode = stuff->keyboardMode; tempGrab.pointerMode = stuff->pointerMode; tempGrab.device = device; (*device->ActivateGrab)(device, &tempGrab, time, FALSE); if (oldCursor) FreeCursor (oldCursor, (Cursor)0); rep.status = GrabSuccess; } WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep); return Success; } int -ProcChangeActivePointerGrab(client) - ClientPtr client; +ProcChangeActivePointerGrab(ClientPtr client) { DeviceIntPtr device = inputInfo.pointer; register GrabPtr grab = device->grab; CursorPtr newCursor, oldCursor; REQUEST(xChangeActivePointerGrabReq); TimeStamp time; REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq); if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs) { client->errorValue = stuff->eventMask; return BadValue; } if (stuff->cursor == None) newCursor = NullCursor; else { newCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, RT_CURSOR, SecurityReadAccess); if (!newCursor) @@ -3813,71 +3733,62 @@ if (!grab) return Success; if (!SameClient(grab, client)) return Success; time = ClientTimeToServerTime(stuff->time); if ((CompareTimeStamps(time, currentTime) == LATER) || (CompareTimeStamps(time, device->grabTime) == EARLIER)) return Success; oldCursor = grab->cursor; grab->cursor = newCursor; if (newCursor) newCursor->refcnt++; PostNewCursor(); if (oldCursor) FreeCursor(oldCursor, (Cursor)0); grab->eventMask = stuff->eventMask; return Success; } int -ProcUngrabPointer(client) - ClientPtr client; +ProcUngrabPointer(ClientPtr client) { DeviceIntPtr device = inputInfo.pointer; GrabPtr grab; TimeStamp time; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); UpdateCurrentTime(); grab = device->grab; time = ClientTimeToServerTime(stuff->id); if ((CompareTimeStamps(time, currentTime) != LATER) && (CompareTimeStamps(time, device->grabTime) != EARLIER) && (grab) && SameClient(grab, client)) (*device->DeactivateGrab)(device); return Success; } int -GrabDevice(client, dev, this_mode, other_mode, grabWindow, ownerEvents, ctime, - mask, status) - register ClientPtr client; - register DeviceIntPtr dev; - unsigned this_mode; - unsigned other_mode; - Window grabWindow; - unsigned ownerEvents; - Time ctime; - Mask mask; - CARD8 *status; +GrabDevice(register ClientPtr client, register DeviceIntPtr dev, + unsigned this_mode, unsigned other_mode, Window grabWindow, + unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status) { register WindowPtr pWin; register GrabPtr grab; TimeStamp time; UpdateCurrentTime(); if ((this_mode != GrabModeSync) && (this_mode != GrabModeAsync)) { client->errorValue = this_mode; return BadValue; } if ((other_mode != GrabModeSync) && (other_mode != GrabModeAsync)) { client->errorValue = other_mode; return BadValue; } if ((ownerEvents != xFalse) && (ownerEvents != xTrue)) { client->errorValue = ownerEvents; return BadValue; @@ -3898,92 +3809,89 @@ dev->sync.other && !SameClient(dev->sync.other, client)) *status = GrabFrozen; else { GrabRec tempGrab; tempGrab.window = pWin; tempGrab.resource = client->clientAsMask; tempGrab.ownerEvents = ownerEvents; tempGrab.keyboardMode = this_mode; tempGrab.pointerMode = other_mode; tempGrab.eventMask = mask; tempGrab.device = dev; (*dev->ActivateGrab)(dev, &tempGrab, time, FALSE); *status = GrabSuccess; } return Success; } int -ProcGrabKeyboard(client) - ClientPtr client; +ProcGrabKeyboard(ClientPtr client) { xGrabKeyboardReply rep; REQUEST(xGrabKeyboardReq); int result; REQUEST_SIZE_MATCH(xGrabKeyboardReq); #ifdef XCSECURITY if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard, TRUE)) { result = Success; rep.status = AlreadyGrabbed; } else #endif result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode, stuff->pointerMode, stuff->grabWindow, stuff->ownerEvents, stuff->time, KeyPressMask | KeyReleaseMask, &rep.status); if (result != Success) return result; rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.length = 0; WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep); return Success; } int -ProcUngrabKeyboard(client) - ClientPtr client; +ProcUngrabKeyboard(ClientPtr client) { DeviceIntPtr device = inputInfo.keyboard; GrabPtr grab; TimeStamp time; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); UpdateCurrentTime(); grab = device->grab; time = ClientTimeToServerTime(stuff->id); if ((CompareTimeStamps(time, currentTime) != LATER) && (CompareTimeStamps(time, device->grabTime) != EARLIER) && (grab) && SameClient(grab, client)) (*device->DeactivateGrab)(device); return Success; } int -ProcQueryPointer(client) - ClientPtr client; +ProcQueryPointer(ClientPtr client) { xQueryPointerReply rep; WindowPtr pWin, t; REQUEST(xResourceReq); DeviceIntPtr mouse = inputInfo.pointer; REQUEST_SIZE_MATCH(xResourceReq); pWin = SecurityLookupWindow(stuff->id, client, SecurityReadAccess); if (!pWin) return BadWindow; if (mouse->valuator->motionHintWindow) MaybeStopHint(mouse, client); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.mask = mouse->button->state | inputInfo.keyboard->key->state; rep.length = 0; rep.root = (ROOT)->drawable.id; rep.rootX = sprite.hot.x; rep.rootY = sprite.hot.y; rep.child = None; @@ -4064,42 +3972,41 @@ syncEvents.time.milliseconds = 0; /* hardly matters */ currentTime.months = 0; currentTime.milliseconds = GetTimeInMillis(); lastDeviceEventTime = currentTime; for (i = 0; i < DNPMCOUNT; i++) { DontPropagateMasks[i] = 0; DontPropagateRefCnts[i] = 0; } } void CloseDownEvents(void) { xfree(spriteTrace); spriteTrace = NULL; spriteTraceSize = 0; } int -ProcSendEvent(client) - ClientPtr client; +ProcSendEvent(ClientPtr client) { WindowPtr pWin; WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */ REQUEST(xSendEventReq); REQUEST_SIZE_MATCH(xSendEventReq); /* The client's event type must be a core event type or one defined by an extension. */ if ( ! ((stuff->event.u.u.type > X_Reply && stuff->event.u.u.type < LASTEvent) || (stuff->event.u.u.type >= EXTENSION_EVENT_BASE && stuff->event.u.u.type < (unsigned)lastEvent))) { client->errorValue = stuff->event.u.u.type; return BadValue; } if (stuff->event.u.u.type == ClientMessage && stuff->event.u.u.detail != 8 && @@ -4153,84 +4060,82 @@ { for (;pWin; pWin = pWin->parent) { if (DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask, NullGrab, 0)) return Success; if (pWin == effectiveFocus) return Success; stuff->eventMask &= ~wDontPropagateMask(pWin); if (!stuff->eventMask) break; } } else (void)DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask, NullGrab, 0); return Success; } int -ProcUngrabKey(client) - ClientPtr client; +ProcUngrabKey(ClientPtr client) { REQUEST(xUngrabKeyReq); WindowPtr pWin; GrabRec tempGrab; DeviceIntPtr keybd = inputInfo.keyboard; REQUEST_SIZE_MATCH(xUngrabKeyReq); pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); if (!pWin) return BadWindow; if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) || (stuff->key < keybd->key->curKeySyms.minKeyCode)) && (stuff->key != AnyKey)) { client->errorValue = stuff->key; return BadValue; } if ((stuff->modifiers != AnyModifier) && (stuff->modifiers & ~AllModifiersMask)) { client->errorValue = stuff->modifiers; return BadValue; } tempGrab.resource = client->clientAsMask; tempGrab.device = keybd; tempGrab.window = pWin; tempGrab.modifiersDetail.exact = stuff->modifiers; tempGrab.modifiersDetail.pMask = NULL; tempGrab.modifierDevice = inputInfo.keyboard; tempGrab.type = KeyPress; tempGrab.detail.exact = stuff->key; tempGrab.detail.pMask = NULL; if (!DeletePassiveGrabFromList(&tempGrab)) return(BadAlloc); return(Success); } int -ProcGrabKey(client) - ClientPtr client; +ProcGrabKey(ClientPtr client) { WindowPtr pWin; REQUEST(xGrabKeyReq); GrabPtr grab; DeviceIntPtr keybd = inputInfo.keyboard; REQUEST_SIZE_MATCH(xGrabKeyReq); if ((stuff->ownerEvents != xTrue) && (stuff->ownerEvents != xFalse)) { client->errorValue = stuff->ownerEvents; return(BadValue); } if ((stuff->pointerMode != GrabModeSync) && (stuff->pointerMode != GrabModeAsync)) { client->errorValue = stuff->pointerMode; return BadValue; } if ((stuff->keyboardMode != GrabModeSync) && (stuff->keyboardMode != GrabModeAsync)) @@ -4250,42 +4155,41 @@ { client->errorValue = stuff->modifiers; return BadValue; } pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); if (!pWin) return BadWindow; grab = CreateGrab(client->index, keybd, pWin, (Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents, (Bool)stuff->keyboardMode, (Bool)stuff->pointerMode, keybd, stuff->modifiers, KeyPress, stuff->key, NullWindow, NullCursor); if (!grab) return BadAlloc; return AddPassiveGrabToList(grab); } int -ProcGrabButton(client) - ClientPtr client; +ProcGrabButton(ClientPtr client) { WindowPtr pWin, confineTo; REQUEST(xGrabButtonReq); CursorPtr cursor; GrabPtr grab; REQUEST_SIZE_MATCH(xGrabButtonReq); if ((stuff->pointerMode != GrabModeSync) && (stuff->pointerMode != GrabModeAsync)) { client->errorValue = stuff->pointerMode; return BadValue; } if ((stuff->keyboardMode != GrabModeSync) && (stuff->keyboardMode != GrabModeAsync)) { client->errorValue = stuff->keyboardMode; return BadValue; } if ((stuff->modifiers != AnyModifier) && @@ -4325,76 +4229,73 @@ { client->errorValue = stuff->cursor; return BadCursor; } } grab = CreateGrab(client->index, inputInfo.pointer, pWin, permitOldBugs ? (Mask)(stuff->eventMask | ButtonPressMask | ButtonReleaseMask) : (Mask)stuff->eventMask, (Bool)stuff->ownerEvents, (Bool) stuff->keyboardMode, (Bool)stuff->pointerMode, inputInfo.keyboard, stuff->modifiers, ButtonPress, stuff->button, confineTo, cursor); if (!grab) return BadAlloc; return AddPassiveGrabToList(grab); } int -ProcUngrabButton(client) - ClientPtr client; +ProcUngrabButton(ClientPtr client) { REQUEST(xUngrabButtonReq); WindowPtr pWin; GrabRec tempGrab; REQUEST_SIZE_MATCH(xUngrabButtonReq); if ((stuff->modifiers != AnyModifier) && (stuff->modifiers & ~AllModifiersMask)) { client->errorValue = stuff->modifiers; return BadValue; } pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); if (!pWin) return BadWindow; tempGrab.resource = client->clientAsMask; tempGrab.device = inputInfo.pointer; tempGrab.window = pWin; tempGrab.modifiersDetail.exact = stuff->modifiers; tempGrab.modifiersDetail.pMask = NULL; tempGrab.modifierDevice = inputInfo.keyboard; tempGrab.type = ButtonPress; tempGrab.detail.exact = stuff->button; tempGrab.detail.pMask = NULL; if (!DeletePassiveGrabFromList(&tempGrab)) return(BadAlloc); return(Success); } void -DeleteWindowFromAnyEvents(pWin, freeResources) - WindowPtr pWin; - Bool freeResources; +DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources) { WindowPtr parent; DeviceIntPtr mouse = inputInfo.pointer; DeviceIntPtr keybd = inputInfo.keyboard; FocusClassPtr focus = keybd->focus; OtherClientsPtr oc; GrabPtr passive; /* Deactivate any grabs performed on this window, before making any input focus changes. */ if (mouse->grab && ((mouse->grab->window == pWin) || (mouse->grab->confineTo == pWin))) (*mouse->DeactivateGrab)(mouse); /* Deactivating a keyboard grab should cause focus events. */ if (keybd->grab && (keybd->grab->window == pWin)) (*keybd->DeactivateGrab)(keybd); @@ -4447,127 +4348,120 @@ } } if (mouse->valuator->motionHintWindow == pWin) mouse->valuator->motionHintWindow = NullWindow; if (freeResources) { if (pWin->dontPropagate) DontPropagateRefCnts[pWin->dontPropagate]--; while ( (oc = wOtherClients(pWin)) ) FreeResource(oc->resource, RT_NONE); while ( (passive = wPassiveGrabs(pWin)) ) FreeResource(passive->resource, RT_NONE); } #ifdef XINPUT DeleteWindowFromAnyExtEvents(pWin, freeResources); #endif } -/* Call this whenever some window at or below pWin has changed geometry */ - -/*ARGSUSED*/ +/** + * Call this whenever some window at or below pWin has changed geometry + */ void -CheckCursorConfinement(pWin) - WindowPtr pWin; +CheckCursorConfinement(WindowPtr pWin) { GrabPtr grab = inputInfo.pointer->grab; WindowPtr confineTo; #ifdef PANORAMIX if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) return; #endif if (grab && (confineTo = grab->confineTo)) { if (!BorderSizeNotEmpty(confineTo)) (*inputInfo.pointer->DeactivateGrab)(inputInfo.pointer); else if ((pWin == confineTo) || IsParent(pWin, confineTo)) ConfineCursorToWindow(confineTo, TRUE, TRUE); } } Mask -EventMaskForClient(pWin, client) - WindowPtr pWin; - ClientPtr client; +EventMaskForClient(WindowPtr pWin, ClientPtr client) { register OtherClientsPtr other; if (wClient (pWin) == client) return pWin->eventMask; for (other = wOtherClients(pWin); other; other = other->next) { if (SameClient(other, client)) return other->mask; } return 0; } int -ProcRecolorCursor(client) - ClientPtr client; +ProcRecolorCursor(ClientPtr client) { CursorPtr pCursor; int nscr; ScreenPtr pscr; Bool displayed; REQUEST(xRecolorCursorReq); REQUEST_SIZE_MATCH(xRecolorCursorReq); pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, RT_CURSOR, SecurityWriteAccess); if ( !pCursor) { client->errorValue = stuff->cursor; return (BadCursor); } pCursor->foreRed = stuff->foreRed; pCursor->foreGreen = stuff->foreGreen; pCursor->foreBlue = stuff->foreBlue; pCursor->backRed = stuff->backRed; pCursor->backGreen = stuff->backGreen; pCursor->backBlue = stuff->backBlue; for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { pscr = screenInfo.screens[nscr]; #ifdef PANORAMIX if(!noPanoramiXExtension) displayed = (pscr == sprite.screen); else #endif displayed = (pscr == sprite.hotPhys.pScreen); ( *pscr->RecolorCursor)(pscr, pCursor, (pCursor == sprite.current) && displayed); } return (Success); } void -WriteEventsToClient(pClient, count, events) - ClientPtr pClient; - int count; - xEvent *events; +WriteEventsToClient(ClientPtr pClient, int count, xEvent *events) { #ifdef PANORAMIX xEvent eventCopy; #endif xEvent eventTo, *eventFrom; int i; #ifdef XKB if ((!noXkbExtension)&&(!XkbFilterEvents(pClient, count, events))) return; #endif #ifdef PANORAMIX if(!noPanoramiXExtension && (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y)) { switch(events->u.u.type) { case MotionNotify: case ButtonPress: case ButtonRelease: Index: xc/programs/Xserver/dix/extension.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/extension.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 extension.c --- xc/programs/Xserver/dix/extension.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/extension.c 7 Mar 2005 22:55:14 -0000 @@ -139,43 +139,41 @@ { ext->errorBase = lastError; ext->errorLast = lastError + NumErrors; lastError += NumErrors; } else { ext->errorBase = 0; ext->errorLast = 0; } #ifdef XCSECURITY ext->secure = FALSE; #endif #ifdef LBX (void) LbxAddExtension(name, ext->base, ext->eventBase, ext->errorBase); #endif return(ext); } -Bool AddExtensionAlias(alias, ext) - char *alias; - ExtensionEntry *ext; +Bool AddExtensionAlias(char *alias, ExtensionEntry *ext) { char *name; char **aliases; aliases = (char **)xrealloc(ext->aliases, (ext->num_aliases + 1) * sizeof(char *)); if (!aliases) return FALSE; ext->aliases = aliases; name = (char *)xalloc(strlen(alias) + 1); if (!name) return FALSE; strcpy(name, alias); ext->aliases[ext->num_aliases] = name; ext->num_aliases++; #ifdef LBX return LbxAddExtensionAlias(ext->index, alias); #else return TRUE; #endif @@ -202,77 +200,73 @@ return ((i == NumExtensions) ? -1 : i); } /* * CheckExtension returns the extensions[] entry for the requested * extension name. Maybe this could just return a Bool instead? */ ExtensionEntry * CheckExtension(const char *extname) { int n; n = FindExtension((char*)extname, strlen(extname)); if (n != -1) return extensions[n]; else return NULL; } void -DeclareExtensionSecurity(extname, secure) - char *extname; - Bool secure; +DeclareExtensionSecurity(char *extname, Bool secure) { #ifdef XCSECURITY int i = FindExtension(extname, strlen(extname)); if (i >= 0) { int majorop = extensions[i]->base; extensions[i]->secure = secure; if (secure) { UntrustedProcVector[majorop] = ProcVector[majorop]; SwappedUntrustedProcVector[majorop] = SwappedProcVector[majorop]; } else { UntrustedProcVector[majorop] = ProcBadRequest; SwappedUntrustedProcVector[majorop] = ProcBadRequest; } } #endif #ifdef LBX LbxDeclareExtensionSecurity(extname, secure); #endif } unsigned short -StandardMinorOpcode(client) - ClientPtr client; +StandardMinorOpcode(ClientPtr client) { return ((xReq *)client->requestBuffer)->data; } unsigned short -MinorOpcodeOfRequest(client) - ClientPtr client; +MinorOpcodeOfRequest(ClientPtr client) { unsigned char major; major = ((xReq *)client->requestBuffer)->reqType; if (major < EXTENSION_BASE) return 0; major -= EXTENSION_BASE; if (major >= NumExtensions) return 0; return (*extensions[major]->MinorOpcode)(client); } void CloseDownExtensions() { register int i,j; #ifdef LBX LbxCloseDownExtensions(); #endif @@ -290,82 +284,80 @@ xfree(extensions); extensions = (ExtensionEntry **)NULL; lastEvent = EXTENSION_EVENT_BASE; lastError = FirstExtensionError; for (i=0; inum) { spentry->num--; xfree(spentry->procList[spentry->num].name); } xfree(spentry->procList); spentry->procList = (ProcEntryPtr)NULL; } } int -ProcQueryExtension(client) - ClientPtr client; +ProcQueryExtension(ClientPtr client) { xQueryExtensionReply reply; int i; REQUEST(xQueryExtensionReq); REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes); reply.type = X_Reply; reply.length = 0; reply.major_opcode = 0; reply.sequenceNumber = client->sequence; if ( ! NumExtensions ) reply.present = xFalse; else { i = FindExtension((char *)&stuff[1], stuff->nbytes); if (i < 0 #ifdef XCSECURITY /* don't show insecure extensions to untrusted clients */ || (client->trustLevel == XSecurityClientUntrusted && !extensions[i]->secure) #endif ) reply.present = xFalse; else { reply.present = xTrue; reply.major_opcode = extensions[i]->base; reply.first_event = extensions[i]->eventBase; reply.first_error = extensions[i]->errorBase; } } WriteReplyToClient(client, sizeof(xQueryExtensionReply), &reply); return(client->noClientException); } int -ProcListExtensions(client) - ClientPtr client; +ProcListExtensions(ClientPtr client) { xListExtensionsReply reply; char *bufptr, *buffer; int total_length = 0; REQUEST_SIZE_MATCH(xReq); reply.type = X_Reply; reply.nExtensions = 0; reply.length = 0; reply.sequenceNumber = client->sequence; buffer = NULL; if ( NumExtensions ) { register int i, j; for (i=0; inum_aliases; --j >= 0;) { *bufptr++ = len = strlen(extensions[i]->aliases[j]); memmove(bufptr, extensions[i]->aliases[j], len); bufptr += len; } } } WriteReplyToClient(client, sizeof(xListExtensionsReply), &reply); if (reply.length) { WriteToClient(client, total_length, buffer); DEALLOCATE_LOCAL(buffer); } return(client->noClientException); } ExtensionLookupProc -LookupProc(name, pGC) - char *name; - GCPtr pGC; +LookupProc(char *name, GCPtr pGC) { register int i; register ScreenProcEntry *spentry; spentry = &AuxillaryScreenProcs[pGC->pScreen->myNum]; if (spentry->num) { for (i = 0; i < spentry->num; i++) if (strcmp(name, spentry->procList[i].name) == 0) return(spentry->procList[i].proc); } return (ExtensionLookupProc)NULL; } Bool -RegisterProc(name, pGC, proc) - char *name; - GC *pGC; - ExtensionLookupProc proc; +RegisterProc(char *name, GC *pGC, ExtensionLookupProc proc) { return RegisterScreenProc(name, pGC->pScreen, proc); } Bool -RegisterScreenProc(name, pScreen, proc) - char *name; - ScreenPtr pScreen; - ExtensionLookupProc proc; +RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc) { register ScreenProcEntry *spentry; register ProcEntryPtr procEntry = (ProcEntryPtr)NULL; char *newname; int i; spentry = &AuxillaryScreenProcs[pScreen->myNum]; /* first replace duplicates */ if (spentry->num) { for (i = 0; i < spentry->num; i++) if (strcmp(name, spentry->procList[i].name) == 0) { procEntry = &spentry->procList[i]; break; } } if (procEntry) procEntry->proc = proc; else Index: xc/programs/Xserver/dix/gc.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/gc.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 gc.c --- xc/programs/Xserver/dix/gc.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/gc.c 7 Mar 2005 22:55:15 -0000 @@ -48,50 +48,46 @@ /* $Xorg: gc.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ #include "X.h" #include "Xmd.h" #include "Xproto.h" #include "misc.h" #include "resource.h" #include "gcstruct.h" #include "pixmapstr.h" #include "dixfontstr.h" #include "scrnintstr.h" #include "region.h" #include "dix.h" #include extern XID clientErrorValue; extern FontPtr defaultFont; -static Bool CreateDefaultTile( - GCPtr /*pGC*/ -); +static Bool CreateDefaultTile(GCPtr pGC); unsigned char DefaultDash[2] = {4, 4}; void -ValidateGC(pDraw, pGC) - DrawablePtr pDraw; - GC *pGC; +ValidateGC(DrawablePtr pDraw, GC *pGC) { (*pGC->funcs->ValidateGC) (pGC, pGC->stateChanges, pDraw); pGC->stateChanges = 0; pGC->serialNumber = pDraw->serialNumber; } /* dixChangeGC(client, pGC, mask, pC32, pUnion) * * This function was created as part of the Security extension * implementation. The client performing the gc change must be passed so * that access checks can be performed on any tiles, stipples, or fonts * that are specified. ddxen can call this too; they should normally * pass NullClient for the client since any access checking should have * already been done at a higher level. * * Since we had to create a new function anyway, we decided to change the * way the list of gc values is passed to eliminate the compiler warnings * caused by the DoChangeGC interface. You can pass the values via pC32 * or pUnion, but not both; one of them must be NULL. If you don't need @@ -129,46 +125,41 @@ * * Ideally, we'd change all the DoChangeGC calls to dixChangeGC, but this * is far too many changes to consider at this time, so we've only * changed the ones that caused compiler warnings. New code should use * dixChangeGC. * * dpw */ #define NEXTVAL(_type, _var) { \ if (pC32) _var = (_type)*pC32++; \ else { \ _var = (_type)(pUnion->val); pUnion++; \ } \ } #define NEXT_PTR(_type, _var) { \ assert(pUnion); _var = (_type)pUnion->ptr; pUnion++; } int -dixChangeGC(client, pGC, mask, pC32, pUnion) - ClientPtr client; - register GC *pGC; - register BITS32 mask; - CARD32 *pC32; - ChangeGCValPtr pUnion; +dixChangeGC(ClientPtr client, register GC *pGC, register BITS32 mask, CARD32 *pC32, ChangeGCValPtr pUnion) { register BITS32 index2; register int error = 0; PixmapPtr pPixmap; BITS32 maskQ; assert( (pC32 && !pUnion) || (!pC32 && pUnion) ); pGC->serialNumber |= GC_CHANGE_SERIAL_BIT; maskQ = mask; /* save these for when we walk the GCque */ while (mask && !error) { index2 = (BITS32) lowbit (mask); mask &= ~index2; pGC->stateChanges |= index2; switch (index2) { case GCFunction: { CARD8 newalu; @@ -512,74 +503,67 @@ } /* end while mask && !error */ if (pGC->fillStyle == FillTiled && pGC->tileIsPixel) { if (!CreateDefaultTile (pGC)) { pGC->fillStyle = FillSolid; error = BadAlloc; } } (*pGC->funcs->ChangeGC)(pGC, maskQ); return error; } #undef NEXTVAL #undef NEXT_PTR /* Publically defined entry to ChangeGC. Just calls dixChangeGC and tells * it that all of the entries are constants or IDs */ int -ChangeGC(pGC, mask, pval) - register GC *pGC; - register BITS32 mask; - XID *pval; +ChangeGC(register GC *pGC, register BITS32 mask, XID *pval) { return (dixChangeGC(NullClient, pGC, mask, pval, NULL)); } /* DoChangeGC(pGC, mask, pval, fPointer) mask is a set of bits indicating which values to change. pval contains an appropriate value for each mask. fPointer is true if the values for tiles, stipples, fonts or clipmasks are pointers instead of IDs. Note: if you are passing pointers you MUST declare the array of values as type pointer! Other data types may not be large enough to hold pointers on some machines. Yes, this means you have to cast to (XID *) when you pass the array to DoChangeGC. Similarly, if you are not passing pointers (fPointer = 0) you MUST declare the array as type XID (not unsigned long!), or again the wrong size data type may be used. To avoid this cruftiness, use dixChangeGC above. if there is an error, the value is marked as changed anyway, which is probably wrong, but infrequent. NOTE: all values sent over the protocol for ChangeGC requests are 32 bits long */ int -DoChangeGC(pGC, mask, pval, fPointer) - register GC *pGC; - register BITS32 mask; - XID *pval; - int fPointer; +DoChangeGC(register GC *pGC, register BITS32 mask, XID *pval, int fPointer) { if (fPointer) /* XXX might be a problem on 64 bit big-endian servers */ return dixChangeGC(NullClient, pGC, mask, NULL, (ChangeGCValPtr)pval); else return dixChangeGC(NullClient, pGC, mask, pval, NULL); } /* CreateGC(pDrawable, mask, pval, pStatus) creates a default GC for the given drawable, using mask to fill in any non-default values. Returns a pointer to the new GC on success, NULL otherwise. returns status of non-default fields in pStatus BUG: should check for failure to create default tile */ static GCPtr @@ -597,45 +581,41 @@ { ppriv = (DevUnion *)(pGC + 1); pGC->devPrivates = ppriv; sizes = pScreen->GCPrivateSizes; ptr = (char *)(ppriv + pScreen->GCPrivateLen); for (i = pScreen->GCPrivateLen; --i >= 0; ppriv++, sizes++) { if ( (size = *sizes) ) { ppriv->ptr = (pointer)ptr; ptr += size; } else ppriv->ptr = (pointer)NULL; } } return pGC; } GCPtr -CreateGC(pDrawable, mask, pval, pStatus) - DrawablePtr pDrawable; - BITS32 mask; - XID *pval; - int *pStatus; +CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) { register GCPtr pGC; pGC = AllocateGC(pDrawable->pScreen); if (!pGC) { *pStatus = BadAlloc; return (GCPtr)NULL; } pGC->pScreen = pDrawable->pScreen; pGC->depth = pDrawable->depth; pGC->alu = GXcopy; /* dst <- src */ pGC->planemask = ~0; pGC->serialNumber = GC_CHANGE_SERIAL_BIT; pGC->funcs = 0; pGC->fgPixel = 0; pGC->bgPixel = 1; pGC->lineWidth = 0; @@ -682,42 +662,41 @@ pGC->stateChanges = (1 << (GCLastBit+1)) - 1; if (!(*pGC->pScreen->CreateGC)(pGC)) *pStatus = BadAlloc; else if (mask) *pStatus = ChangeGC(pGC, mask, pval); else *pStatus = Success; if (*pStatus != Success) { if (!pGC->tileIsPixel && !pGC->tile.pixmap) pGC->tileIsPixel = TRUE; /* undo special case */ FreeGC(pGC, (XID)0); pGC = (GCPtr)NULL; } return (pGC); } static Bool -CreateDefaultTile (pGC) - GCPtr pGC; +CreateDefaultTile (GCPtr pGC) { XID tmpval[3]; PixmapPtr pTile; GCPtr pgcScratch; xRectangle rect; CARD16 w, h; w = 1; h = 1; (*pGC->pScreen->QueryBestSize)(TileShape, &w, &h, pGC->pScreen); pTile = (PixmapPtr) (*pGC->pScreen->CreatePixmap)(pGC->pScreen, w, h, pGC->depth); pgcScratch = GetScratchGC(pGC->depth, pGC->pScreen); if (!pTile || !pgcScratch) { if (pTile) (*pTile->drawable.pScreen->DestroyPixmap)(pTile); if (pgcScratch) FreeScratchGC(pgcScratch); @@ -726,44 +705,41 @@ tmpval[0] = GXcopy; tmpval[1] = pGC->tile.pixel; tmpval[2] = FillSolid; (void)ChangeGC(pgcScratch, GCFunction | GCForeground | GCFillStyle, tmpval); ValidateGC((DrawablePtr)pTile, pgcScratch); rect.x = 0; rect.y = 0; rect.width = w; rect.height = h; (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pTile, pgcScratch, 1, &rect); /* Always remember to free the scratch graphics context after use. */ FreeScratchGC(pgcScratch); pGC->tileIsPixel = FALSE; pGC->tile.pixmap = pTile; return TRUE; } int -CopyGC(pgcSrc, pgcDst, mask) - register GC *pgcSrc; - register GC *pgcDst; - register BITS32 mask; +CopyGC(register GC *pgcSrc, register GC *pgcDst, register BITS32 mask) { register BITS32 index2; BITS32 maskQ; int error = 0; if (pgcSrc == pgcDst) return Success; pgcDst->serialNumber |= GC_CHANGE_SERIAL_BIT; pgcDst->stateChanges |= mask; maskQ = mask; while (mask) { index2 = (BITS32) lowbit (mask); mask &= ~index2; switch (index2) { case GCFunction: pgcDst->alu = pgcSrc->alu; break; case GCPlaneMask: @@ -887,99 +863,91 @@ pgcDst->arcMode = pgcSrc->arcMode; break; default: clientErrorValue = maskQ; error = BadValue; break; } } if (pgcDst->fillStyle == FillTiled && pgcDst->tileIsPixel) { if (!CreateDefaultTile (pgcDst)) { pgcDst->fillStyle = FillSolid; error = BadAlloc; } } (*pgcDst->funcs->CopyGC) (pgcSrc, maskQ, pgcDst); return error; } -/***************** - * FreeGC - * does the diX part of freeing the characteristics in the GC - ***************/ - -/*ARGSUSED*/ +/** + * does the diX part of freeing the characteristics in the GC. + * + * \param value must conform to DeleteType + */ int -FreeGC(value, gid) - pointer value; /* must conform to DeleteType */ - XID gid; +FreeGC(pointer value, XID gid) { GCPtr pGC = (GCPtr)value; CloseFont(pGC->font, (Font)0); (* pGC->funcs->DestroyClip)(pGC); if (!pGC->tileIsPixel) (* pGC->pScreen->DestroyPixmap)(pGC->tile.pixmap); if (pGC->stipple) (* pGC->pScreen->DestroyPixmap)(pGC->stipple); (*pGC->funcs->DestroyGC) (pGC); if (pGC->dash != DefaultDash) xfree(pGC->dash); xfree(pGC); return(Success); } void -SetGCMask(pGC, selectMask, newDataMask) - GCPtr pGC; - Mask selectMask; - Mask newDataMask; +SetGCMask(GCPtr pGC, Mask selectMask, Mask newDataMask) { pGC->stateChanges = (~selectMask & pGC->stateChanges) | (selectMask & newDataMask); if (selectMask & newDataMask) pGC->serialNumber |= GC_CHANGE_SERIAL_BIT; } /* CreateScratchGC(pScreen, depth) like CreateGC, but doesn't do the default tile or stipple, since we can't create them without already having a GC. any code using the tile or stipple has to set them explicitly anyway, since the state of the scratch gc is unknown. This is OK because ChangeGC() has to be able to deal with NULL tiles and stipples anyway (in case the CreateGC() call has provided a value for them -- we can't set the default tile until the client-supplied attributes are installed, since the fgPixel is what fills the default tile. (maybe this comment should go with CreateGC() or ChangeGC().) */ GCPtr -CreateScratchGC(pScreen, depth) - ScreenPtr pScreen; - unsigned depth; +CreateScratchGC(ScreenPtr pScreen, unsigned depth) { register GCPtr pGC; pGC = AllocateGC(pScreen); if (!pGC) return (GCPtr)NULL; pGC->pScreen = pScreen; pGC->depth = depth; pGC->alu = GXcopy; /* dst <- src */ pGC->planemask = ~0; pGC->serialNumber = 0; pGC->fgPixel = 0; pGC->bgPixel = 1; pGC->lineWidth = 0; pGC->lineStyle = LineSolid; pGC->capStyle = CapButt; pGC->joinStyle = JoinMiter; pGC->fillStyle = FillSolid; @@ -997,139 +965,131 @@ pGC->graphicsExposures = TRUE; pGC->clipOrg.x = 0; pGC->clipOrg.y = 0; pGC->clientClipType = CT_NONE; pGC->dashOffset = 0; pGC->numInDashList = 2; pGC->dash = DefaultDash; pGC->lastWinOrg.x = 0; pGC->lastWinOrg.y = 0; pGC->stateChanges = (1 << (GCLastBit+1)) - 1; if (!(*pScreen->CreateGC)(pGC)) { FreeGC(pGC, (XID)0); pGC = (GCPtr)NULL; } return pGC; } void -FreeGCperDepth(screenNum) - int screenNum; +FreeGCperDepth(int screenNum) { register int i; register ScreenPtr pScreen; GCPtr *ppGC; pScreen = screenInfo.screens[screenNum]; ppGC = pScreen->GCperDepth; for (i = 0; i <= pScreen->numDepths; i++) (void)FreeGC(ppGC[i], (XID)0); pScreen->rgf = ~0L; } Bool -CreateGCperDepth(screenNum) - int screenNum; +CreateGCperDepth(int screenNum) { register int i; register ScreenPtr pScreen; DepthPtr pDepth; GCPtr *ppGC; pScreen = screenInfo.screens[screenNum]; pScreen->rgf = 0; ppGC = pScreen->GCperDepth; /* do depth 1 separately because it's not included in list */ if (!(ppGC[0] = CreateScratchGC(pScreen, 1))) return FALSE; ppGC[0]->graphicsExposures = FALSE; pDepth = pScreen->allowedDepths; for (i=0; inumDepths; i++, pDepth++) { if (!(ppGC[i+1] = CreateScratchGC(pScreen, pDepth->depth))) { for (; i >= 0; i--) (void)FreeGC(ppGC[i], (XID)0); return FALSE; } ppGC[i+1]->graphicsExposures = FALSE; } return TRUE; } Bool -CreateDefaultStipple(screenNum) - int screenNum; +CreateDefaultStipple(int screenNum) { register ScreenPtr pScreen; XID tmpval[3]; xRectangle rect; CARD16 w, h; GCPtr pgcScratch; pScreen = screenInfo.screens[screenNum]; w = 16; h = 16; (* pScreen->QueryBestSize)(StippleShape, &w, &h, pScreen); if (!(pScreen->PixmapPerDepth[0] = (*pScreen->CreatePixmap)(pScreen, w, h, 1))) return FALSE; /* fill stipple with 1 */ tmpval[0] = GXcopy; tmpval[1] = 1; tmpval[2] = FillSolid; pgcScratch = GetScratchGC(1, pScreen); if (!pgcScratch) { (*pScreen->DestroyPixmap)(pScreen->PixmapPerDepth[0]); return FALSE; } (void)ChangeGC(pgcScratch, GCFunction|GCForeground|GCFillStyle, tmpval); ValidateGC((DrawablePtr)pScreen->PixmapPerDepth[0], pgcScratch); rect.x = 0; rect.y = 0; rect.width = w; rect.height = h; (*pgcScratch->ops->PolyFillRect)((DrawablePtr)pScreen->PixmapPerDepth[0], pgcScratch, 1, &rect); FreeScratchGC(pgcScratch); return TRUE; } void -FreeDefaultStipple(screenNum) - int screenNum; +FreeDefaultStipple(int screenNum) { ScreenPtr pScreen = screenInfo.screens[screenNum]; (*pScreen->DestroyPixmap)(pScreen->PixmapPerDepth[0]); } int -SetDashes(pGC, offset, ndash, pdash) -register GCPtr pGC; -unsigned offset; -register unsigned ndash; -register unsigned char *pdash; +SetDashes(register GCPtr pGC, unsigned offset, unsigned ndash, unsigned char *pdash) { register long i; register unsigned char *p, *indash; BITS32 maskQ = 0; i = ndash; p = pdash; while (i--) { if (!*p++) { /* dash segment must be > 0 */ clientErrorValue = 0; return BadValue; } } if (ndash & 1) p = (unsigned char *)xalloc(2 * ndash * sizeof(unsigned char)); else @@ -1151,44 +1111,41 @@ pGC->dash = p; if (ndash & 1) { pGC->numInDashList += ndash; indash = pdash; i = ndash; while (i--) *p++ = *indash++; } while(ndash--) *p++ = *pdash++; pGC->stateChanges |= GCDashList; maskQ |= GCDashList; if (pGC->funcs->ChangeGC) (*pGC->funcs->ChangeGC) (pGC, maskQ); return Success; } int -VerifyRectOrder(nrects, prects, ordering) - int nrects; - xRectangle *prects; - int ordering; +VerifyRectOrder(int nrects, xRectangle *prects, int ordering) { register xRectangle *prectP, *prectN; register int i; switch(ordering) { case Unsorted: return CT_UNSORTED; case YSorted: if(nrects > 1) { for(i = 1, prectP = prects, prectN = prects + 1; i < nrects; i++, prectP++, prectN++) if(prectN->y < prectP->y) return -1; } return CT_YSORTED; case YXSorted: if(nrects > 1) @@ -1204,84 +1161,78 @@ return CT_YXSORTED; case YXBanded: if(nrects > 1) { for(i = 1, prectP = prects, prectN = prects + 1; i < nrects; i++, prectP++, prectN++) if((prectN->y != prectP->y && prectN->y < prectP->y + (int) prectP->height) || ((prectN->y == prectP->y) && (prectN->height != prectP->height || prectN->x < prectP->x + (int) prectP->width))) return -1; } return CT_YXBANDED; } return -1; } int -SetClipRects(pGC, xOrigin, yOrigin, nrects, prects, ordering) - GCPtr pGC; - int xOrigin, yOrigin; - int nrects; - xRectangle *prects; - int ordering; +SetClipRects(GCPtr pGC, int xOrigin, int yOrigin, int nrects, + xRectangle *prects, int ordering) { int newct, size; xRectangle *prectsNew; newct = VerifyRectOrder(nrects, prects, ordering); if (newct < 0) return(BadMatch); size = nrects * sizeof(xRectangle); prectsNew = (xRectangle *) xalloc(size); if (!prectsNew && size) return BadAlloc; pGC->serialNumber |= GC_CHANGE_SERIAL_BIT; pGC->clipOrg.x = xOrigin; pGC->stateChanges |= GCClipXOrigin; pGC->clipOrg.y = yOrigin; pGC->stateChanges |= GCClipYOrigin; if (size) memmove((char *)prectsNew, (char *)prects, size); (*pGC->funcs->ChangeClip)(pGC, newct, (pointer)prectsNew, nrects); if (pGC->funcs->ChangeGC) (*pGC->funcs->ChangeGC) (pGC, GCClipXOrigin|GCClipYOrigin|GCClipMask); return Success; } /* sets reasonable defaults if we can get a pre-allocated one, use it and mark it as used. if we can't, create one out of whole cloth (The Velveteen GC -- if you use it often enough it will become real.) */ GCPtr -GetScratchGC(depth, pScreen) - register unsigned depth; - register ScreenPtr pScreen; +GetScratchGC(register unsigned depth, register ScreenPtr pScreen) { register int i; register GCPtr pGC; for (i=0; i<=pScreen->numDepths; i++) if ( pScreen->GCperDepth[i]->depth == depth && !(pScreen->rgf & (1L << (i+1))) ) { pScreen->rgf |= (1L << (i+1)); pGC = (pScreen->GCperDepth[i]); pGC->alu = GXcopy; pGC->planemask = ~0; pGC->serialNumber = 0; pGC->fgPixel = 0; pGC->bgPixel = 1; pGC->lineWidth = 0; pGC->lineStyle = LineSolid; pGC->capStyle = CapButt; @@ -1296,36 +1247,35 @@ pGC->clipOrg.x = 0; pGC->clipOrg.y = 0; if (pGC->clientClipType != CT_NONE) (*pGC->funcs->ChangeClip) (pGC, CT_NONE, NULL, 0); pGC->stateChanges = (1 << (GCLastBit+1)) - 1; return pGC; } /* if we make it this far, need to roll our own */ pGC = CreateScratchGC(pScreen, depth); if (pGC) pGC->graphicsExposures = FALSE; return pGC; } /* if the gc to free is in the table of pre-existing ones, mark it as available. if not, free it for real */ void -FreeScratchGC(pGC) - register GCPtr pGC; +FreeScratchGC(register GCPtr pGC) { register ScreenPtr pScreen = pGC->pScreen; register int i; for (i=0; i<=pScreen->numDepths; i++) { if ( pScreen->GCperDepth[i] == pGC) { pScreen->rgf &= ~(1L << (i+1)); return; } } (void)FreeGC(pGC, (GContext)0); } Index: xc/programs/Xserver/dix/glyphcurs.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/glyphcurs.c,v retrieving revision 1.1.1.1 diff -u -2 -0 -r1.1.1.1 glyphcurs.c --- xc/programs/Xserver/dix/glyphcurs.c 14 Nov 2003 16:48:54 -0000 1.1.1.1 +++ xc/programs/Xserver/dix/glyphcurs.c 7 Mar 2005 22:55:15 -0000 @@ -54,45 +54,41 @@ #include "gcstruct.h" #include "resource.h" #include "dix.h" #include "cursorstr.h" #include "opaque.h" #include "servermd.h" /* get the bits out of the font in a portable way. to avoid dealing with padding and such-like, we draw the glyph into a bitmap, then read the bits out with GetImage, which uses server-natural format. since all screens return the same bitmap format, we'll just use the first one we find. the character origin lines up with the hotspot in the cursor metrics. */ int -ServerBitsFromGlyph(pfont, ch, cm, ppbits) - FontPtr pfont; - unsigned int ch; - register CursorMetricPtr cm; - unsigned char **ppbits; +ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, unsigned char **ppbits) { register ScreenPtr pScreen; register GCPtr pGC; xRectangle rect; PixmapPtr ppix; long nby; char *pbits; ChangeGCVal gcval[3]; unsigned char char2b[2]; /* turn glyph index into a protocol-format char2b */ char2b[0] = (unsigned char)(ch >> 8); char2b[1] = (unsigned char)(ch & 0xff); pScreen = screenInfo.screens[0]; nby = BitmapBytePad(cm->width) * (long)cm->height; pbits = (char *)xalloc(nby); if (!pbits) return BadAlloc; /* zeroing the (pad) bits seems to help some ddx cursor handling */ @@ -124,44 +120,41 @@ NULL, gcval); ValidateGC((DrawablePtr)ppix, pGC); (*pGC->ops->PolyFillRect)((DrawablePtr)ppix, pGC, 1, &rect); /* draw the glyph */ gcval[0].val = 1; dixChangeGC(NullClient, pGC, GCForeground, NULL, gcval); ValidateGC((DrawablePtr)ppix, pGC); (*pGC->ops->PolyText16)((DrawablePtr)ppix, pGC, cm->xhot, cm->yhot, 1, (unsigned short *)char2b); (*pScreen->GetImage)((DrawablePtr)ppix, 0, 0, cm->width, cm->height, XYPixmap, 1, pbits); *ppbits = (unsigned char *)pbits; FreeScratchGC(pGC); (*pScreen->DestroyPixmap)(ppix); return Success; } Bool -CursorMetricsFromGlyph( pfont, ch, cm) - register FontPtr pfont; - unsigned ch; - register CursorMetricPtr cm; +CursorMetricsFromGlyph(register FontPtr pfont, unsigned ch, register CursorMetricPtr cm) { CharInfoPtr pci; unsigned long nglyphs; CARD8 chs[2]; FontEncoding encoding; chs[0] = ch >> 8; chs[1] = ch; encoding = (FONTLASTROW(pfont) == 0) ? Linear16Bit : TwoD16Bit; if (encoding == Linear16Bit) { if (ch < pfont->info.firstCol || pfont->info.lastCol < ch) return FALSE; } else { if (chs[0] < pfont->info.firstRow || pfont->info.lastRow < chs[0]) return FALSE; if (chs[1] < pfont->info.firstCol || pfont->info.lastCol < chs[1]) return FALSE; Index: xc/programs/Xserver/dix/grabs.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/grabs.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 grabs.c --- xc/programs/Xserver/dix/grabs.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/grabs.c 7 Mar 2005 22:55:15 -0000 @@ -106,45 +106,42 @@ cursor->refcnt++; return grab; } static void FreeGrab(GrabPtr pGrab) { if (pGrab->modifiersDetail.pMask != NULL) xfree(pGrab->modifiersDetail.pMask); if (pGrab->detail.pMask != NULL) xfree(pGrab->detail.pMask); if (pGrab->cursor) FreeCursor(pGrab->cursor, (Cursor)0); xfree(pGrab); } -/*ARGSUSED*/ int -DeletePassiveGrab(value, id) - pointer value; - XID id; +DeletePassiveGrab(pointer value, XID id) { register GrabPtr g, prev; GrabPtr pGrab = (GrabPtr)value; /* it is OK if the grab isn't found */ prev = 0; for (g = (wPassiveGrabs (pGrab->window)); g; g = g->next) { if (pGrab == g) { if (prev) prev->next = g->next; else if (!(pGrab->window->optional->passiveGrabs = g->next)) CheckWindowOptionalNeed (pGrab->window); break; } prev = g; } FreeGrab(pGrab); @@ -223,108 +220,105 @@ return FALSE; } static Bool GrabSupersedesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) { if (!DetailSupersedesSecond(pFirstGrab->modifiersDetail, pSecondGrab->modifiersDetail, (unsigned short)AnyModifier)) return FALSE; if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail, (unsigned short)AnyKey)) return TRUE; return FALSE; } Bool -GrabMatchesSecond(pFirstGrab, pSecondGrab) - GrabPtr pFirstGrab, pSecondGrab; +GrabMatchesSecond(GrabPtr pFirstGrab, GrabPtr pSecondGrab) { if ((pFirstGrab->device != pSecondGrab->device) || (pFirstGrab->modifierDevice != pSecondGrab->modifierDevice) || (pFirstGrab->type != pSecondGrab->type)) return FALSE; if (GrabSupersedesSecond(pFirstGrab, pSecondGrab) || GrabSupersedesSecond(pSecondGrab, pFirstGrab)) return TRUE; if (DetailSupersedesSecond(pSecondGrab->detail, pFirstGrab->detail, (unsigned short)AnyKey) && DetailSupersedesSecond(pFirstGrab->modifiersDetail, pSecondGrab->modifiersDetail, (unsigned short)AnyModifier)) return TRUE; if (DetailSupersedesSecond(pFirstGrab->detail, pSecondGrab->detail, (unsigned short)AnyKey) && DetailSupersedesSecond(pSecondGrab->modifiersDetail, pFirstGrab->modifiersDetail, (unsigned short)AnyModifier)) return TRUE; return FALSE; } int -AddPassiveGrabToList(pGrab) - GrabPtr pGrab; +AddPassiveGrabToList(GrabPtr pGrab) { GrabPtr grab; for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next) { if (GrabMatchesSecond(pGrab, grab)) { if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource)) { FreeGrab(pGrab); return BadAccess; } } } if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window)) { FreeGrab(pGrab); return BadAlloc; } pGrab->next = pGrab->window->optional->passiveGrabs; pGrab->window->optional->passiveGrabs = pGrab; if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (pointer)pGrab)) return Success; return BadAlloc; } /* the following is kinda complicated, because we need to be able to back out * if any allocation fails */ Bool -DeletePassiveGrabFromList(pMinuendGrab) - GrabPtr pMinuendGrab; +DeletePassiveGrabFromList(GrabPtr pMinuendGrab) { register GrabPtr grab; GrabPtr *deletes, *adds; Mask ***updates, **details; int i, ndels, nadds, nups; Bool ok; #define UPDATE(mask,exact) \ if (!(details[nups] = DeleteDetailFromMask(mask, exact))) \ ok = FALSE; \ else \ updates[nups++] = &(mask) i = 0; for (grab = wPassiveGrabs(pMinuendGrab->window); grab; grab = grab->next) i++; if (!i) return TRUE; deletes = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr)); adds = (GrabPtr *)ALLOCATE_LOCAL(i * sizeof(GrabPtr)); Index: xc/programs/Xserver/dix/main.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/main.c,v retrieving revision 1.4 diff -u -2 -0 -r1.4 main.c --- xc/programs/Xserver/dix/main.c 18 Sep 2004 23:18:35 -0000 1.4 +++ xc/programs/Xserver/dix/main.c 7 Mar 2005 22:55:16 -0000 @@ -96,80 +96,76 @@ #include "cursorstr.h" #include "font.h" #include "opaque.h" #include "servermd.h" #include "site.h" #include "dixfont.h" #include "extnsionst.h" #ifdef PANORAMIX #include "panoramiXsrv.h" #else #include "dixevents.h" /* InitEvents() */ #include "dispatch.h" /* InitProcVectors() */ #endif #ifdef DPMSExtension #define DPMS_SERVER #include "dpms.h" #include "dpmsproc.h" #endif -extern int InitClientPrivates( - ClientPtr /*client*/ -); - -extern void Dispatch( - void -); +extern int InitClientPrivates(ClientPtr client); + +extern void Dispatch(void); char *ConnectionInfo; xConnSetupPrefix connSetupPrefix; extern FontPtr defaultFont; extern int screenPrivateCount; extern void InitProcVectors(void); extern Bool CreateGCperDepthArray(void); #ifndef PANORAMIX static #endif Bool CreateConnectionBlock(void); static void FreeScreen(ScreenPtr); PaddingInfo PixmapWidthPaddingInfo[33]; int connBlockScreenStart; static int restart = 0; void NotImplemented(xEvent *from, xEvent *to) { FatalError("Not implemented"); } /* * Dummy entry for ReplySwapVector[] */ -/*ARGSUSED*/ + void ReplyNotSwappd( ClientPtr pClient , int size , void * pbuf ) { FatalError("Not implemented"); } /* * This array encodes the answer to the question "what is the log base 2 * of the number of pixels that fit in a scanline pad unit?" * Note that ~0 is an invalid entry (mostly for the benefit of the reader). */ static int answer[6][4] = { /* pad pad pad pad*/ /* 8 16 32 64 */ { 3, 4, 5 , 6 }, /* 1 bit per pixel */ @@ -763,31 +759,30 @@ This is also where the default colormap should be allocated and also pixel values for blackPixel, whitePixel, and the cursor Note that InitScreen is NOT allowed to modify argc, argv, or any of the strings pointed to by argv. They may be passed to multiple screens. */ pScreen->rgf = ~0L; /* there are no scratch GCs yet*/ WindowTable[i] = NullWindow; screenInfo.screens[i] = pScreen; screenInfo.numScreens++; if (!(*pfnInit)(i, pScreen, argc, argv)) { FreeScreen(pScreen); screenInfo.numScreens--; return -1; } return i; } static void -FreeScreen(pScreen) - ScreenPtr pScreen; +FreeScreen(ScreenPtr pScreen) { xfree(pScreen->WindowPrivateSizes); xfree(pScreen->GCPrivateSizes); #ifdef PIXPRIV xfree(pScreen->PixmapPrivateSizes); #endif xfree(pScreen->devPrivates); xfree(pScreen); } Index: xc/programs/Xserver/dix/pixmap.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/pixmap.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 pixmap.c --- xc/programs/Xserver/dix/pixmap.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/pixmap.c 7 Mar 2005 22:55:16 -0000 @@ -31,109 +31,97 @@ #include "X.h" #include "scrnintstr.h" #include "misc.h" #include "os.h" #include "windowstr.h" #include "resource.h" #include "dixstruct.h" #include "gcstruct.h" #include "servermd.h" #include "site.h" /* * Scratch pixmap management and device independent pixmap allocation * function. */ /* callable by ddx */ PixmapPtr -GetScratchPixmapHeader(pScreen, width, height, depth, bitsPerPixel, devKind, - pPixData) - ScreenPtr pScreen; - int width; - int height; - int depth; - int bitsPerPixel; - int devKind; - pointer pPixData; +GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth, + int bitsPerPixel, int devKind, pointer pPixData) { PixmapPtr pPixmap = pScreen->pScratchPixmap; if (pPixmap) pScreen->pScratchPixmap = NULL; else /* width and height of 0 means don't allocate any pixmap data */ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth); if (pPixmap) { if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData)) return pPixmap; (*pScreen->DestroyPixmap)(pPixmap); } return NullPixmap; } /* callable by ddx */ void -FreeScratchPixmapHeader(pPixmap) - PixmapPtr pPixmap; +FreeScratchPixmapHeader(PixmapPtr pPixmap) { if (pPixmap) { ScreenPtr pScreen = pPixmap->drawable.pScreen; pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */ if (pScreen->pScratchPixmap) (*pScreen->DestroyPixmap)(pPixmap); else pScreen->pScratchPixmap = pPixmap; } } Bool -CreateScratchPixmapsForScreen(scrnum) - int scrnum; +CreateScratchPixmapsForScreen(int scrnum) { /* let it be created on first use */ screenInfo.screens[scrnum]->pScratchPixmap = NULL; return TRUE; } void -FreeScratchPixmapsForScreen(scrnum) - int scrnum; +FreeScratchPixmapsForScreen(int scrnum) { FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap); } /* callable by ddx */ PixmapPtr -AllocatePixmap(pScreen, pixDataSize) - ScreenPtr pScreen; - int pixDataSize; +AllocatePixmap(ScreenPtr pScreen, int pixDataSize) { PixmapPtr pPixmap; #ifdef PIXPRIV char *ptr; DevUnion *ppriv; unsigned *sizes; unsigned size; int i; pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize); if (!pPixmap) return NullPixmap; ppriv = (DevUnion *)(pPixmap + 1); pPixmap->devPrivates = ppriv; sizes = pScreen->PixmapPrivateSizes; ptr = (char *)(ppriv + pScreen->PixmapPrivateLen); for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++) { if ((size = *sizes) != 0) { Index: xc/programs/Xserver/dix/privates.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/privates.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 privates.c --- xc/programs/Xserver/dix/privates.c 30 Jul 2004 21:10:45 -0000 1.3 +++ xc/programs/Xserver/dix/privates.c 7 Mar 2005 22:55:16 -0000 @@ -56,43 +56,41 @@ unsigned totalClientSize; void ResetClientPrivates() { clientPrivateCount = 0; clientPrivateLen = 0; xfree(clientPrivateSizes); clientPrivateSizes = (unsigned *)NULL; totalClientSize = ((sizeof(ClientRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); } int AllocateClientPrivateIndex() { return clientPrivateCount++; } Bool -AllocateClientPrivate(index2, amount) - int index2; - unsigned amount; +AllocateClientPrivate(int index2, unsigned amount) { unsigned oldamount; /* Round up sizes for proper alignment */ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); if (index2 >= clientPrivateLen) { unsigned *nsizes; nsizes = (unsigned *)xrealloc(clientPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; while (clientPrivateLen <= index2) { nsizes[clientPrivateLen++] = 0; totalClientSize += sizeof(DevUnion); } clientPrivateSizes = nsizes; } @@ -149,44 +147,41 @@ /* * window private machinery */ static int windowPrivateCount; void ResetWindowPrivates() { windowPrivateCount = 0; } int AllocateWindowPrivateIndex() { return windowPrivateCount++; } Bool -AllocateWindowPrivate(pScreen, index2, amount) - register ScreenPtr pScreen; - int index2; - unsigned amount; +AllocateWindowPrivate(register ScreenPtr pScreen, int index2, unsigned amount) { unsigned oldamount; /* Round up sizes for proper alignment */ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); if (index2 >= pScreen->WindowPrivateLen) { unsigned *nsizes; nsizes = (unsigned *)xrealloc(pScreen->WindowPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; while (pScreen->WindowPrivateLen <= index2) { nsizes[pScreen->WindowPrivateLen++] = 0; pScreen->totalWindowSize += sizeof(DevUnion); } pScreen->WindowPrivateSizes = nsizes; } @@ -202,44 +197,41 @@ /* * gc private machinery */ static int gcPrivateCount; void ResetGCPrivates() { gcPrivateCount = 0; } int AllocateGCPrivateIndex() { return gcPrivateCount++; } Bool -AllocateGCPrivate(pScreen, index2, amount) - register ScreenPtr pScreen; - int index2; - unsigned amount; +AllocateGCPrivate(register ScreenPtr pScreen, int index2, unsigned amount) { unsigned oldamount; /* Round up sizes for proper alignment */ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); if (index2 >= pScreen->GCPrivateLen) { unsigned *nsizes; nsizes = (unsigned *)xrealloc(pScreen->GCPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; while (pScreen->GCPrivateLen <= index2) { nsizes[pScreen->GCPrivateLen++] = 0; pScreen->totalGCSize += sizeof(DevUnion); } pScreen->GCPrivateSizes = nsizes; } @@ -255,44 +247,41 @@ /* * pixmap private machinery */ #ifdef PIXPRIV static int pixmapPrivateCount; void ResetPixmapPrivates() { pixmapPrivateCount = 0; } int AllocatePixmapPrivateIndex() { return pixmapPrivateCount++; } Bool -AllocatePixmapPrivate(pScreen, index2, amount) - register ScreenPtr pScreen; - int index2; - unsigned amount; +AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount) { unsigned oldamount; /* Round up sizes for proper alignment */ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); if (index2 >= pScreen->PixmapPrivateLen) { unsigned *nsizes; nsizes = (unsigned *)xrealloc(pScreen->PixmapPrivateSizes, (index2 + 1) * sizeof(unsigned)); if (!nsizes) return FALSE; while (pScreen->PixmapPrivateLen <= index2) { nsizes[pScreen->PixmapPrivateLen++] = 0; pScreen->totalPixmapSize += sizeof(DevUnion); } pScreen->PixmapPrivateSizes = nsizes; } @@ -305,44 +294,41 @@ pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8); return TRUE; } #endif /* * colormap private machinery */ int colormapPrivateCount; void ResetColormapPrivates() { colormapPrivateCount = 0; } int -AllocateColormapPrivateIndex (initPrivFunc) - -InitCmapPrivFunc initPrivFunc; - +AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc) { int index; int i; ColormapPtr pColormap; DevUnion *privs; index = colormapPrivateCount++; for (i = 0; i < screenInfo.numScreens; i++) { /* * AllocateColormapPrivateIndex may be called after the * default colormap has been created on each screen! * * We must resize the devPrivates array for the default * colormap on each screen, making room for this new private. * We also call the initialization function 'initPrivFunc' on * the new private allocated for each default colormap. */ Index: xc/programs/Xserver/dix/property.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/property.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 property.c --- xc/programs/Xserver/dix/property.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/property.c 7 Mar 2005 22:55:16 -0000 @@ -70,62 +70,60 @@ int fWriteToClient(ClientPtr client, int len, char *buf) { return WriteToClient(client, len, buf); } #endif #endif /***************************************************************** * Property Stuff * * ChangeProperty, DeleteProperty, GetProperties, * ListProperties * * Properties below to windows. A allocate slots each time * a property is added. No fancy searching done. * *****************************************************************/ #ifdef notdef static void -PrintPropertys(pWin) - WindowPtr pWin; +PrintPropertys(WindowPtr pWin) { PropertyPtr pProp; register int j; pProp = pWin->userProps; while (pProp) { ErrorF( "%x %x\n", pProp->propertyName, pProp->type); ErrorF("property format: %d\n", pProp->format); ErrorF("property data: \n"); for (j=0; j<(pProp->format/8)*pProp->size; j++) ErrorF("%c\n", pProp->data[j]); pProp = pProp->next; } } #endif int -ProcRotateProperties(client) - ClientPtr client; +ProcRotateProperties(ClientPtr client) { int i, j, delta; REQUEST(xRotatePropertiesReq); WindowPtr pWin; register Atom * atoms; PropertyPtr * props; /* array of pointer */ PropertyPtr pProp; xEvent event; REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2); UpdateCurrentTime(); pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client, SecurityWriteAccess); if (!pWin) return(BadWindow); if (!stuff->nAtoms) return(Success); atoms = (Atom *) & stuff[1]; props = (PropertyPtr *)ALLOCATE_LOCAL(stuff->nAtoms * sizeof(PropertyPtr)); if (!props) @@ -183,42 +181,41 @@ for (i = 0; i < stuff->nAtoms; i++) { /* Generate a PropertyNotify event for each property whose value is changed in the order in which they appear in the request. */ event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyNewValue; event.u.property.atom = props[i]->propertyName; event.u.property.time = currentTime.milliseconds; DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); props[i]->propertyName = atoms[(i + delta) % stuff->nAtoms]; } } DEALLOCATE_LOCAL(props); return Success; } int -ProcChangeProperty(client) - ClientPtr client; +ProcChangeProperty(ClientPtr client) { WindowPtr pWin; char format, mode; unsigned long len; int sizeInBytes; int totalSize; int err; REQUEST(xChangePropertyReq); REQUEST_AT_LEAST_SIZE(xChangePropertyReq); UpdateCurrentTime(); format = stuff->format; mode = stuff->mode; if ((mode != PropModeReplace) && (mode != PropModeAppend) && (mode != PropModePrepend)) { client->errorValue = mode; return BadValue; } if ((format != 8) && (format != 16) && (format != 32)) @@ -257,47 +254,43 @@ return BadAtom; case SecurityIgnoreOperation: return Success; } #endif #ifdef LBX err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type, (int)format, (int)mode, len, TRUE, (pointer)&stuff[1], TRUE, NULL); #else err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format, (int)mode, len, (pointer)&stuff[1], TRUE); #endif if (err != Success) return err; else return client->noClientException; } int -ChangeWindowProperty(pWin, property, type, format, mode, len, value, sendevent) - WindowPtr pWin; - Atom property, type; - int format, mode; - unsigned long len; - pointer value; - Bool sendevent; +ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, + int mode, unsigned long len, pointer value, + Bool sendevent) { #ifdef LBX return LbxChangeWindowProperty(NULL, pWin, property, type, format, mode, len, TRUE, value, sendevent, NULL); #else PropertyPtr pProp; xEvent event; int sizeInBytes; int totalSize; pointer data; sizeInBytes = format>>3; totalSize = len * sizeInBytes; /* first see if property already exists */ pProp = wUserProps (pWin); while (pProp) { @@ -380,43 +373,41 @@ memmove((char *)data, (char *)value, totalSize); xfree(pProp->data); pProp->data = data; pProp->size += len; } } if (sendevent) { event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyNewValue; event.u.property.atom = pProp->propertyName; event.u.property.time = currentTime.milliseconds; DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); } return(Success); #endif } int -DeleteProperty(pWin, propName) - WindowPtr pWin; - Atom propName; +DeleteProperty(WindowPtr pWin, Atom propName) { PropertyPtr pProp, prevProp; xEvent event; if (!(pProp = wUserProps (pWin))) return(Success); prevProp = (PropertyPtr)NULL; while (pProp) { if (pProp->propertyName == propName) break; prevProp = pProp; pProp = pProp->next; } if (pProp) { if (prevProp == (PropertyPtr)NULL) /* takes care of head */ { if (!(pWin->optional->userProps = pProp->next)) CheckWindowOptionalNeed (pWin); @@ -425,42 +416,41 @@ { prevProp->next = pProp->next; } #ifdef LBX if (pProp->tag_id) TagDeleteTag(pProp->tag_id); #endif event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyDelete; event.u.property.atom = pProp->propertyName; event.u.property.time = currentTime.milliseconds; DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); xfree(pProp->data); xfree(pProp); } return(Success); } void -DeleteAllWindowProperties(pWin) - WindowPtr pWin; +DeleteAllWindowProperties(WindowPtr pWin) { PropertyPtr pProp, pNextProp; xEvent event; pProp = wUserProps (pWin); while (pProp) { #ifdef LBX if (pProp->tag_id) TagDeleteTag(pProp->tag_id); #endif event.u.u.type = PropertyNotify; event.u.property.window = pWin->drawable.id; event.u.property.state = PropertyDelete; event.u.property.atom = pProp->propertyName; event.u.property.time = currentTime.milliseconds; DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); pNextProp = pProp->next; xfree(pProp->data); xfree(pProp); @@ -478,42 +468,41 @@ reply->nItems = 0; reply->length = 0; reply->bytesAfter = 0; reply->propertyType = propertyType; reply->format = format; WriteReplyToClient(client, sizeof(xGenericReply), reply); return(client->noClientException); } /***************** * GetProperty * If type Any is specified, returns the property from the specified * window regardless of its type. If a type is specified, returns the * property only if its type equals the specified type. * If delete is True and a property is returned, the property is also * deleted from the window and a PropertyNotify event is generated on the * window. *****************/ int -ProcGetProperty(client) - ClientPtr client; +ProcGetProperty(ClientPtr client) { PropertyPtr pProp, prevProp; unsigned long n, len, ind; WindowPtr pWin; xGetPropertyReply reply; REQUEST(xGetPropertyReq); REQUEST_SIZE_MATCH(xGetPropertyReq); if (stuff->delete) UpdateCurrentTime(); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityReadAccess); if (!pWin) return BadWindow; if (!ValidAtom(stuff->property)) { client->errorValue = stuff->property; return(BadAtom); } @@ -634,42 +623,41 @@ if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */ #ifdef LBX if (pProp->tag_id) TagDeleteTag(pProp->tag_id); #endif if (prevProp == (PropertyPtr)NULL) /* takes care of head */ { if (!(pWin->optional->userProps = pProp->next)) CheckWindowOptionalNeed (pWin); } else prevProp->next = pProp->next; xfree(pProp->data); xfree(pProp); } return(client->noClientException); } int -ProcListProperties(client) - ClientPtr client; +ProcListProperties(ClientPtr client) { Atom *pAtoms = NULL, *temppAtoms; xListPropertiesReply xlpr; int numProps = 0; WindowPtr pWin; PropertyPtr pProp; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, SecurityReadAccess); if (!pWin) return(BadWindow); pProp = wUserProps (pWin); while (pProp) { pProp = pProp->next; numProps++; } @@ -682,42 +670,41 @@ xlpr.length = (numProps * sizeof(Atom)) >> 2; xlpr.sequenceNumber = client->sequence; pProp = wUserProps (pWin); temppAtoms = pAtoms; while (pProp) { *temppAtoms++ = pProp->propertyName; pProp = pProp->next; } WriteReplyToClient(client, sizeof(xGenericReply), &xlpr); if (numProps) { client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); DEALLOCATE_LOCAL(pAtoms); } return(client->noClientException); } int -ProcDeleteProperty(client) - register ClientPtr client; +ProcDeleteProperty(register ClientPtr client) { WindowPtr pWin; REQUEST(xDeletePropertyReq); int result; REQUEST_SIZE_MATCH(xDeletePropertyReq); UpdateCurrentTime(); pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, SecurityWriteAccess); if (!pWin) return(BadWindow); if (!ValidAtom(stuff->property)) { client->errorValue = stuff->property; return (BadAtom); } #ifdef XCSECURITY switch(SecurityCheckPropertyAccess(client, pWin, stuff->property, SecurityDestroyAccess)) Index: xc/programs/Xserver/dix/resource.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/resource.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 resource.c --- xc/programs/Xserver/dix/resource.c 25 Apr 2004 22:42:09 -0000 1.3 +++ xc/programs/Xserver/dix/resource.c 7 Mar 2005 22:55:17 -0000 @@ -150,42 +150,41 @@ } ClientResourceRec; RESTYPE lastResourceType; static RESTYPE lastResourceClass; RESTYPE TypeMask; static DeleteType *DeleteFuncs = (DeleteType *)NULL; #ifdef XResExtension Atom * ResourceNames = NULL; void RegisterResourceName (RESTYPE type, char *name) { ResourceNames[type & TypeMask] = MakeAtom(name, strlen(name), TRUE); } #endif RESTYPE -CreateNewResourceType(deleteFunc) - DeleteType deleteFunc; +CreateNewResourceType(DeleteType deleteFunc) { RESTYPE next = lastResourceType + 1; DeleteType *funcs; if (next & lastResourceClass) return 0; funcs = (DeleteType *)xrealloc(DeleteFuncs, (next + 1) * sizeof(DeleteType)); if (!funcs) return 0; #ifdef XResExtension { Atom *newnames; newnames = xrealloc(ResourceNames, (next + 1) * sizeof(Atom)); if(!newnames) return 0; ResourceNames = newnames; ResourceNames[next] = 0; } @@ -201,42 +200,41 @@ CreateNewResourceClass() { RESTYPE next = lastResourceClass >> 1; if (next & lastResourceType) return 0; lastResourceClass = next; TypeMask = next - 1; return next; } ClientResourceRec clientTable[MAXCLIENTS]; /***************** * InitClientResources * When a new client is created, call this to allocate space * in resource table *****************/ Bool -InitClientResources(client) - ClientPtr client; +InitClientResources(ClientPtr client) { register int i, j; if (client == serverClient) { lastResourceType = RT_LASTPREDEF; lastResourceClass = RC_LASTPREDEF; TypeMask = RC_LASTPREDEF - 1; if (DeleteFuncs) xfree(DeleteFuncs); DeleteFuncs = (DeleteType *)xalloc((lastResourceType + 1) * sizeof(DeleteType)); if (!DeleteFuncs) return FALSE; DeleteFuncs[RT_NONE & TypeMask] = (DeleteType)NoopDDA; DeleteFuncs[RT_WINDOW & TypeMask] = DeleteWindow; DeleteFuncs[RT_PIXMAP & TypeMask] = dixDestroyPixmap; DeleteFuncs[RT_GC & TypeMask] = FreeGC; DeleteFuncs[RT_FONT & TypeMask] = CloseFont; DeleteFuncs[RT_CURSOR & TypeMask] = FreeCursor; @@ -305,186 +303,176 @@ register XID id, register XID maxid, register XID goodid) { register ResourcePtr res; if ((goodid >= id) && (goodid <= maxid)) return goodid; for (; id <= maxid; id++) { res = clientTable[client].resources[Hash(client, id)]; while (res && (res->id != id)) res = res->next; if (!res) return id; } return 0; } void -GetXIDRange(client, server, minp, maxp) - int client; - Bool server; - XID *minp, *maxp; +GetXIDRange(int client, Bool server, XID *minp, XID *maxp) { register XID id, maxid; register ResourcePtr *resp; register ResourcePtr res; register int i; XID goodid; id = (Mask)client << CLIENTOFFSET; if (server) id |= client ? SERVER_BIT : SERVER_MINID; maxid = id | RESOURCE_ID_MASK; goodid = 0; for (resp = clientTable[client].resources, i = clientTable[client].buckets; --i >= 0;) { for (res = *resp++; res; res = res->next) { if ((res->id < id) || (res->id > maxid)) continue; if (((res->id - id) >= (maxid - res->id)) ? (goodid = AvailableID(client, id, res->id - 1, goodid)) : !(goodid = AvailableID(client, res->id + 1, maxid, goodid))) maxid = res->id - 1; else id = res->id + 1; } } if (id > maxid) id = maxid = 0; *minp = id; *maxp = maxid; } -/* GetXIDList is called by the XC-MISC extension's MiscGetXIDList function. +/** + * GetXIDList is called by the XC-MISC extension's MiscGetXIDList function. * This function tries to find count unused XIDs for the given client. It * puts the IDs in the array pids and returns the number found, which should * almost always be the number requested. * * The circumstances that lead to a call to this function are very rare. * Xlib must run out of IDs while trying to generate a request that wants * multiple ID's, like the Multi-buffering CreateImageBuffers request. * * No rocket science in the implementation; just iterate over all * possible IDs for the given client and pick the first count IDs * that aren't in use. A more efficient algorithm could probably be * invented, but this will be used so rarely that this should suffice. */ unsigned int -GetXIDList(pClient, count, pids) - ClientPtr pClient; - unsigned int count; - XID *pids; +GetXIDList(ClientPtr pClient, unsigned count, XID *pids) { unsigned int found = 0; XID id = pClient->clientAsMask; XID maxid; maxid = id | RESOURCE_ID_MASK; while ( (found < count) && (id <= maxid) ) { if (!LookupIDByClass(id, RC_ANY)) { pids[found++] = id; } id++; } return found; } /* * Return the next usable fake client ID. * * Normally this is just the next one in line, but if we've used the last * in the range, we need to find a new range of safe IDs to avoid * over-running another client. */ XID -FakeClientID(client) - register int client; +FakeClientID(register int client) { XID id, maxid; id = clientTable[client].fakeID++; if (id != clientTable[client].endFakeID) return id; GetXIDRange(client, TRUE, &id, &maxid); if (!id) { if (!client) FatalError("FakeClientID: server internal ids exhausted\n"); MarkClientException(clients[client]); id = ((Mask)client << CLIENTOFFSET) | (SERVER_BIT * 3); maxid = id | RESOURCE_ID_MASK; } clientTable[client].fakeID = id + 1; clientTable[client].endFakeID = maxid + 1; return id; } Bool -AddResource(id, type, value) - XID id; - RESTYPE type; - pointer value; +AddResource(XID id, RESTYPE type, pointer value) { int client; register ClientResourceRec *rrec; register ResourcePtr res, *head; client = CLIENT_ID(id); rrec = &clientTable[client]; if (!rrec->buckets) { ErrorF("AddResource(%lx, %lx, %lx), client=%d \n", (unsigned long)id, type, (unsigned long)value, client); FatalError("client not in use\n"); } if ((rrec->elements >= 4*rrec->buckets) && (rrec->hashsize < MAXHASHSIZE)) RebuildTable(client); head = &rrec->resources[Hash(client, id)]; res = (ResourcePtr)xalloc(sizeof(ResourceRec)); if (!res) { (*DeleteFuncs[type & TypeMask])(value, id); return FALSE; } res->next = *head; res->id = id; res->type = type; res->value = value; *head = res; rrec->elements++; if (!(id & SERVER_BIT) && (id >= rrec->expectID)) rrec->expectID = id + 1; return TRUE; } static void -RebuildTable(client) - int client; +RebuildTable(int client) { register int j; register ResourcePtr res, next; ResourcePtr **tails, *resources; register ResourcePtr **tptr, *rptr; /* * For now, preserve insertion order, since some ddx layers depend * on resources being free in the opposite order they are added. */ j = 2 * clientTable[client].buckets; tails = (ResourcePtr **)ALLOCATE_LOCAL(j * sizeof(ResourcePtr *)); if (!tails) return; resources = (ResourcePtr *)xalloc(j * sizeof(ResourcePtr)); if (!resources) { DEALLOCATE_LOCAL(tails); return; @@ -499,43 +487,41 @@ rptr = clientTable[client].resources; --j >= 0; rptr++) { for (res = *rptr; res; res = next) { next = res->next; res->next = NullResource; tptr = &tails[Hash(client, res->id)]; **tptr = res; *tptr = &res->next; } } DEALLOCATE_LOCAL(tails); clientTable[client].buckets *= 2; xfree(clientTable[client].resources); clientTable[client].resources = resources; } void -FreeResource(id, skipDeleteFuncType) - XID id; - RESTYPE skipDeleteFuncType; +FreeResource(XID id, RESTYPE skipDeleteFuncType) { int cid; register ResourcePtr res; register ResourcePtr *prev, *head; register int *eltptr; int elements; Bool gotOne = FALSE; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { head = &clientTable[cid].resources[Hash(cid, id)]; eltptr = &clientTable[cid].elements; prev = head; while ( (res = *prev) ) { if (res->id == id) { RESTYPE rtype = res->type; *prev = res->next; @@ -548,87 +534,81 @@ if (*eltptr != elements) prev = head; /* prev may no longer be valid */ gotOne = TRUE; } else prev = &res->next; } if(clients[cid] && (id == clients[cid]->lastDrawableID)) { clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0]; clients[cid]->lastDrawableID = WindowTable[0]->drawable.id; } } if (!gotOne) ErrorF("Freeing resource id=%lX which isn't there.\n", (unsigned long)id); } void -FreeResourceByType(id, type, skipFree) - XID id; - RESTYPE type; - Bool skipFree; +FreeResourceByType(XID id, RESTYPE type, Bool skipFree) { int cid; register ResourcePtr res; register ResourcePtr *prev, *head; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { head = &clientTable[cid].resources[Hash(cid, id)]; prev = head; while ( (res = *prev) ) { if (res->id == id && res->type == type) { *prev = res->next; if (type & RC_CACHED) FlushClientCaches(res->id); if (!skipFree) (*DeleteFuncs[type & TypeMask])(res->value, res->id); xfree(res); break; } else prev = &res->next; } if(clients[cid] && (id == clients[cid]->lastDrawableID)) { clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0]; clients[cid]->lastDrawableID = WindowTable[0]->drawable.id; } } } /* * Change the value associated with a resource id. Caller * is responsible for "doing the right thing" with the old * data */ Bool -ChangeResourceValue (id, rtype, value) - XID id; - RESTYPE rtype; - pointer value; +ChangeResourceValue (XID id, RESTYPE rtype, pointer value) { int cid; register ResourcePtr res; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { res = clientTable[cid].resources[Hash(cid, id)]; for (; res; res = res->next) if ((res->id == id) && (res->type == rtype)) { if (rtype & RC_CACHED) FlushClientCaches(res->id); res->value = value; return TRUE; } } return FALSE; } @@ -743,42 +723,41 @@ { prev = &resources[j]; while ( (this = *prev) ) { RESTYPE rtype = this->type; if (rtype & RC_NEVERRETAIN) { *prev = this->next; if (rtype & RC_CACHED) FlushClientCaches(this->id); (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); xfree(this); } else prev = &this->next; } } } void -FreeClientResources(client) - ClientPtr client; +FreeClientResources(ClientPtr client) { register ResourcePtr *resources; register ResourcePtr this; int j; /* This routine shouldn't be called with a null client, but just in case ... */ if (!client) return; HandleSaveSet(client); resources = clientTable[client->index].resources; for (j=0; j < clientTable[client->index].buckets; j++) { /* It may seem silly to update the head of this resource list as we delete the members, since the entire list will be deleted any way, but there are some resource deletion functions "FreeClientPixels" for one which do a LookupID on another resource id (a Colormap id in this @@ -802,188 +781,170 @@ } } xfree(clientTable[client->index].resources); clientTable[client->index].resources = NULL; clientTable[client->index].buckets = 0; } void FreeAllResources() { int i; for (i = currentMaxClients; --i >= 0; ) { if (clientTable[i].buckets) FreeClientResources(clients[i]); } } Bool -LegalNewID(id, client) - XID id; - register ClientPtr client; +LegalNewID(XID id, register ClientPtr client) { #ifdef PANORAMIX XID minid, maxid; if (!noPanoramiXExtension) { minid = client->clientAsMask | (client->index ? SERVER_BIT : SERVER_MINID); maxid = (clientTable[client->index].fakeID | RESOURCE_ID_MASK) + 1; if ((id >= minid) && (id <= maxid)) return TRUE; } #endif /* PANORAMIX */ return ((client->clientAsMask == (id & ~RESOURCE_ID_MASK)) && ((clientTable[client->index].expectID <= id) || !LookupIDByClass(id, RC_ANY))); } #ifdef XCSECURITY /* SecurityLookupIDByType and SecurityLookupIDByClass: * These are the heart of the resource ID security system. They take * two additional arguments compared to the old LookupID functions: * the client doing the lookup, and the access mode (see resource.h). * The resource is returned if it exists and the client is allowed access, * else NULL is returned. */ pointer -SecurityLookupIDByType(client, id, rtype, mode) - ClientPtr client; - XID id; - RESTYPE rtype; - Mask mode; +SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) { int cid; register ResourcePtr res; pointer retval = NULL; assert(client == NullClient || (client->index <= currentMaxClients && clients[client->index] == client)); assert( (rtype & TypeMask) <= lastResourceType); if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { res = clientTable[cid].resources[Hash(cid, id)]; for (; res; res = res->next) if ((res->id == id) && (res->type == rtype)) { retval = res->value; break; } } if (retval && client && client->CheckAccess) retval = (* client->CheckAccess)(client, id, rtype, mode, retval); return retval; } pointer -SecurityLookupIDByClass(client, id, classes, mode) - ClientPtr client; - XID id; - RESTYPE classes; - Mask mode; +SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) { int cid; register ResourcePtr res = NULL; pointer retval = NULL; assert(client == NullClient || (client->index <= currentMaxClients && clients[client->index] == client)); assert (classes >= lastResourceClass); if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { res = clientTable[cid].resources[Hash(cid, id)]; for (; res; res = res->next) if ((res->id == id) && (res->type & classes)) { retval = res->value; break; } } if (retval && client && client->CheckAccess) retval = (* client->CheckAccess)(client, id, res->type, mode, retval); return retval; } /* We can't replace the LookupIDByType and LookupIDByClass functions with * macros because of compatibility with loadable servers. */ pointer -LookupIDByType(id, rtype) - XID id; - RESTYPE rtype; +LookupIDByType(XID id, RESTYPE rtype) { return SecurityLookupIDByType(NullClient, id, rtype, SecurityUnknownAccess); } pointer -LookupIDByClass(id, classes) - XID id; - RESTYPE classes; +LookupIDByClass(XID id, RESTYPE classes) { return SecurityLookupIDByClass(NullClient, id, classes, SecurityUnknownAccess); } #else /* not XCSECURITY */ /* * LookupIDByType returns the object with the given id and type, else NULL. */ pointer -LookupIDByType(id, rtype) - XID id; - RESTYPE rtype; +LookupIDByType(XID id, RESTYPE rtype) { int cid; register ResourcePtr res; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { res = clientTable[cid].resources[Hash(cid, id)]; for (; res; res = res->next) if ((res->id == id) && (res->type == rtype)) return res->value; } return (pointer)NULL; } /* * LookupIDByClass returns the object with the given id and any one of the * given classes, else NULL. */ pointer -LookupIDByClass(id, classes) - XID id; - RESTYPE classes; +LookupIDByClass(XID id, RESTYPE classes) { int cid; register ResourcePtr res; if (((cid = CLIENT_ID(id)) < MAXCLIENTS) && clientTable[cid].buckets) { res = clientTable[cid].resources[Hash(cid, id)]; for (; res; res = res->next) if ((res->id == id) && (res->type & classes)) return res->value; } return (pointer)NULL; } #endif /* XCSECURITY */ Index: xc/programs/Xserver/dix/swaprep.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/swaprep.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 swaprep.c --- xc/programs/Xserver/dix/swaprep.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/swaprep.c 7 Mar 2005 22:55:17 -0000 @@ -42,80 +42,75 @@ 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. ********************************************************/ /* $Xorg: swaprep.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */ #include "X.h" #define NEED_REPLIES #define NEED_EVENTS #include "Xproto.h" #include "misc.h" #include "dixstruct.h" #include "fontstruct.h" #include "scrnintstr.h" #include "swaprep.h" #include "globals.h" -static void SwapFontInfo( - xQueryFontReply * /* pr */ -); +static void SwapFontInfo(xQueryFontReply *pr); #ifndef LBX -static void SwapCharInfo( - xCharInfo * /* pInfo */ - ); - -static void SwapFont( - xQueryFontReply * /* pr */, - Bool /* hasGlyphs */ - ); +static void SwapCharInfo(xCharInfo *pInfo); + +static void SwapFont(xQueryFontReply *pr, Bool hasGlyphs); #endif -/* Thanks to Jack Palevich for testing and subsequently rewriting all this */ +/** + * Thanks to Jack Palevich for testing and subsequently rewriting all this + * + * \param size size in bytes + */ void -Swap32Write(pClient, size, pbuf) - ClientPtr pClient; - int size; /* in bytes */ - register CARD32 *pbuf; +Swap32Write(ClientPtr pClient, int size, register CARD32 *pbuf) { register int i; register char n; size >>= 2; for(i = 0; i < size; i++) /* brackets are mandatory here, because "swapl" macro expands to several statements */ { swapl(&pbuf[i], n); } (void)WriteToClient(pClient, size << 2, (char *) pbuf); } +/** + * + * \param size size in bytes + */ void -CopySwap32Write(pClient, size, pbuf) - ClientPtr pClient; - int size; /* in bytes */ - CARD32 *pbuf; +CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf) { int bufsize = size; CARD32 *pbufT; register CARD32 *from, *to, *fromLast, *toLast; CARD32 tmpbuf[1]; /* Allocate as big a buffer as we can... */ while (!(pbufT = (CARD32 *) ALLOCATE_LOCAL(bufsize))) { bufsize >>= 1; if (bufsize == 4) { pbufT = tmpbuf; break; } } /* convert lengths from # of bytes to # of longs */ size >>= 2; bufsize >>= 2; @@ -124,45 +119,46 @@ fromLast = from + size; while (from < fromLast) { int nbytes; to = pbufT; toLast = to + min (bufsize, fromLast - from); nbytes = (toLast - to) << 2; while (to < toLast) { /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro that evaulates its args more than once */ cpswapl(*from, *to); from++; to++; } (void)WriteToClient (pClient, nbytes, (char *) pbufT); } if (pbufT != tmpbuf) DEALLOCATE_LOCAL ((char *) pbufT); } +/** + * + * \param size size in bytes + */ void -CopySwap16Write(pClient, size, pbuf) - ClientPtr pClient; - int size; /* in bytes */ - short *pbuf; +CopySwap16Write(ClientPtr pClient, int size, short *pbuf) { int bufsize = size; short *pbufT; register short *from, *to, *fromLast, *toLast; short tmpbuf[2]; /* Allocate as big a buffer as we can... */ while (!(pbufT = (short *) ALLOCATE_LOCAL(bufsize))) { bufsize >>= 1; if (bufsize == 4) { pbufT = tmpbuf; break; } } /* convert lengths from # of bytes to # of shorts */ size >>= 1; bufsize >>= 1; @@ -174,1100 +170,961 @@ to = pbufT; toLast = to + min (bufsize, fromLast - from); nbytes = (toLast - to) << 1; while (to < toLast) { /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro that evaulates its args more than once */ cpswaps(*from, *to); from++; to++; } (void)WriteToClient (pClient, nbytes, (char *) pbufT); } if (pbufT != tmpbuf) DEALLOCATE_LOCAL ((char *) pbufT); } /* Extra-small reply */ void -SGenericReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGenericReply *pRep; +SGenericReply(ClientPtr pClient, int size, xGenericReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); (void)WriteToClient(pClient, size, (char *) pRep); } /* Extra-large reply */ void -SGetWindowAttributesReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetWindowAttributesReply *pRep; +SGetWindowAttributesReply(ClientPtr pClient, int size, + xGetWindowAttributesReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swapl(&pRep->visualID, n); swaps(&pRep->class, n); swapl(&pRep->backingBitPlanes, n); swapl(&pRep->backingPixel, n); swapl(&pRep->colormap, n); swapl(&pRep->allEventMasks, n); swapl(&pRep->yourEventMask, n); swaps(&pRep->doNotPropagateMask, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetGeometryReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetGeometryReply *pRep; +SGetGeometryReply(ClientPtr pClient, int size, xGetGeometryReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->root, n); swaps(&pRep->x, n); swaps(&pRep->y, n); swaps(&pRep->width, n); swaps(&pRep->height, n); swaps(&pRep->borderWidth, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SQueryTreeReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xQueryTreeReply *pRep; +SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swapl(&pRep->root, n); swapl(&pRep->parent, n); swaps(&pRep->nChildren, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SInternAtomReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xInternAtomReply *pRep; +SInternAtomReply(ClientPtr pClient, int size, xInternAtomReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->atom, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetAtomNameReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetAtomNameReply *pRep; +SGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nameLength, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetPropertyReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetPropertyReply *pRep; +SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swapl(&pRep->propertyType, n); swapl(&pRep->bytesAfter, n); swapl(&pRep->nItems, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SListPropertiesReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xListPropertiesReply *pRep; +SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nProperties, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetSelectionOwnerReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetSelectionOwnerReply *pRep; +SGetSelectionOwnerReply(ClientPtr pClient, int size, + xGetSelectionOwnerReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->owner, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SQueryPointerReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xQueryPointerReply *pRep; +SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->root, n); swapl(&pRep->child, n); swaps(&pRep->rootX, n); swaps(&pRep->rootY, n); swaps(&pRep->winX, n); swaps(&pRep->winY, n); swaps(&pRep->mask, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SwapTimecoord(pCoord) - xTimecoord *pCoord; +SwapTimecoord(xTimecoord* pCoord) { register char n; swapl(&pCoord->time, n); swaps(&pCoord->x, n); swaps(&pCoord->y, n); } void -SwapTimeCoordWrite(pClient, size, pRep) - ClientPtr pClient; - int size; - xTimecoord *pRep; +SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord *pRep) { int i, n; xTimecoord *pRepT; n = size / sizeof(xTimecoord); pRepT = pRep; for(i = 0; i < n; i++) { SwapTimecoord(pRepT); pRepT++; } (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetMotionEventsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetMotionEventsReply *pRep; +SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swapl(&pRep->nEvents, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -STranslateCoordsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xTranslateCoordsReply *pRep; +STranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->child, n); swaps(&pRep->dstX, n); swaps(&pRep->dstY, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetInputFocusReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetInputFocusReply *pRep; +SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->focus, n); (void)WriteToClient(pClient, size, (char *) pRep); } /* extra long reply */ void -SQueryKeymapReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xQueryKeymapReply *pRep; +SQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); (void)WriteToClient(pClient, size, (char *) pRep); } #ifndef LBX static #endif void -SwapCharInfo(pInfo) - xCharInfo *pInfo; +SwapCharInfo(xCharInfo *pInfo) { register char n; swaps(&pInfo->leftSideBearing, n); swaps(&pInfo->rightSideBearing, n); swaps(&pInfo->characterWidth, n); swaps(&pInfo->ascent, n); swaps(&pInfo->descent, n); swaps(&pInfo->attributes, n); } static void -SwapFontInfo(pr) - xQueryFontReply *pr; +SwapFontInfo(xQueryFontReply *pr) { register char n; swaps(&pr->minCharOrByte2, n); swaps(&pr->maxCharOrByte2, n); swaps(&pr->defaultChar, n); swaps(&pr->nFontProps, n); swaps(&pr->fontAscent, n); swaps(&pr->fontDescent, n); SwapCharInfo( &pr->minBounds); SwapCharInfo( &pr->maxBounds); swapl(&pr->nCharInfos, n); } #ifndef LBX static #endif void -SwapFont( pr, hasGlyphs) - xQueryFontReply * pr; - Bool hasGlyphs; +SwapFont(xQueryFontReply *pr, Bool hasGlyphs) { unsigned i; xCharInfo * pxci; unsigned nchars, nprops; char *pby; register char n; swaps(&pr->sequenceNumber, n); swapl(&pr->length, n); nchars = pr->nCharInfos; nprops = pr->nFontProps; SwapFontInfo(pr); pby = (char *) &pr[1]; /* Font properties are an atom and either an int32 or a CARD32, so * they are always 2 4 byte values */ for(i = 0; i < nprops; i++) { swapl(pby, n); pby += 4; swapl(pby, n); pby += 4; } if (hasGlyphs) { pxci = (xCharInfo *)pby; for(i = 0; i< nchars; i++, pxci++) SwapCharInfo(pxci); } } void -SQueryFontReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xQueryFontReply *pRep; +SQueryFontReply(ClientPtr pClient, int size, xQueryFontReply *pRep) { SwapFont(pRep, TRUE); (void)WriteToClient(pClient, size, (char *) pRep); } void -SQueryTextExtentsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xQueryTextExtentsReply *pRep; +SQueryTextExtentsReply(ClientPtr pClient, int size, xQueryTextExtentsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swaps(&pRep->fontAscent, n); swaps(&pRep->fontDescent, n); swaps(&pRep->overallAscent, n); swaps(&pRep->overallDescent, n); swapl(&pRep->overallWidth, n); swapl(&pRep->overallLeft, n); swapl(&pRep->overallRight, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SListFontsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xListFontsReply *pRep; +SListFontsReply(ClientPtr pClient, int size, xListFontsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nFonts, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SListFontsWithInfoReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xListFontsWithInfoReply *pRep; +SListFontsWithInfoReply(ClientPtr pClient, int size, + xListFontsWithInfoReply *pRep) { SwapFont((xQueryFontReply *)pRep, FALSE); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetFontPathReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetFontPathReply *pRep; +SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nPaths, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetImageReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetImageReply *pRep; +SGetImageReply(ClientPtr pClient, int size, xGetImageReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swapl(&pRep->visual, n); (void)WriteToClient(pClient, size, (char *) pRep); /* Fortunately, image doesn't need swapping */ } void -SListInstalledColormapsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xListInstalledColormapsReply *pRep; +SListInstalledColormapsReply(ClientPtr pClient, int size, + xListInstalledColormapsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nColormaps, n); (void)WriteToClient(pClient, size, (char *) pRep); } void SAllocColorReply(pClient, size, pRep) ClientPtr pClient; int size; xAllocColorReply *pRep; { register char n; swaps(&pRep->sequenceNumber, n); swaps(&pRep->red, n); swaps(&pRep->green, n); swaps(&pRep->blue, n); swapl(&pRep->pixel, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SAllocNamedColorReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xAllocNamedColorReply *pRep; +SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->pixel, n); swaps(&pRep->exactRed, n); swaps(&pRep->exactGreen, n); swaps(&pRep->exactBlue, n); swaps(&pRep->screenRed, n); swaps(&pRep->screenGreen, n); swaps(&pRep->screenBlue, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SAllocColorCellsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xAllocColorCellsReply *pRep; +SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nPixels, n); swaps(&pRep->nMasks, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SAllocColorPlanesReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xAllocColorPlanesReply *pRep; +SAllocColorPlanesReply(ClientPtr pClient, int size, xAllocColorPlanesReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nPixels, n); swapl(&pRep->redMask, n); swapl(&pRep->greenMask, n); swapl(&pRep->blueMask, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SwapRGB(prgb) - xrgb *prgb; +SwapRGB(xrgb *prgb) { register char n; swaps(&prgb->red, n); swaps(&prgb->green, n); swaps(&prgb->blue, n); } void -SQColorsExtend(pClient, size, prgb) - ClientPtr pClient; - int size; - xrgb *prgb; +SQColorsExtend(ClientPtr pClient, int size, xrgb *prgb) { int i, n; xrgb *prgbT; n = size / sizeof(xrgb); prgbT = prgb; for(i = 0; i < n; i++) { SwapRGB(prgbT); prgbT++; } (void)WriteToClient(pClient, size, (char *) prgb); } void -SQueryColorsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xQueryColorsReply *pRep; +SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply* pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nColors, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SLookupColorReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xLookupColorReply *pRep; +SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swaps(&pRep->exactRed, n); swaps(&pRep->exactGreen, n); swaps(&pRep->exactBlue, n); swaps(&pRep->screenRed, n); swaps(&pRep->screenGreen, n); swaps(&pRep->screenBlue, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SQueryBestSizeReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xQueryBestSizeReply *pRep; +SQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swaps(&pRep->width, n); swaps(&pRep->height, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SListExtensionsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xListExtensionsReply *pRep; +SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetKeyboardMappingReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetKeyboardMappingReply *pRep; +SGetKeyboardMappingReply(ClientPtr pClient, int size, + xGetKeyboardMappingReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetPointerMappingReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetPointerMappingReply *pRep; +SGetPointerMappingReply(ClientPtr pClient, int size, + xGetPointerMappingReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetModifierMappingReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetModifierMappingReply *pRep; +SGetModifierMappingReply(ClientPtr pClient, int size, + xGetModifierMappingReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetKeyboardControlReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetKeyboardControlReply *pRep; +SGetKeyboardControlReply(ClientPtr pClient, int size, xGetKeyboardControlReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swapl(&pRep->ledMask, n); swaps(&pRep->bellPitch, n); swaps(&pRep->bellDuration, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetPointerControlReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetPointerControlReply *pRep; +SGetPointerControlReply(ClientPtr pClient, int size, xGetPointerControlReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swaps(&pRep->accelNumerator, n); swaps(&pRep->accelDenominator, n); swaps(&pRep->threshold, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SGetScreenSaverReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xGetScreenSaverReply *pRep; +SGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swaps(&pRep->timeout, n); swaps(&pRep->interval, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SLHostsExtend(pClient, size, buf) - ClientPtr pClient; - int size; - char *buf; +SLHostsExtend(ClientPtr pClient, int size, char *buf) { char *bufT = buf; char *endbuf = buf + size; while (bufT < endbuf) { xHostEntry *host = (xHostEntry *) bufT; int len = host->length; register char n; swaps (&host->length, n); bufT += sizeof (xHostEntry) + (((len + 3) >> 2) << 2); } (void)WriteToClient (pClient, size, buf); } void -SListHostsReply(pClient, size, pRep) - ClientPtr pClient; - int size; - xListHostsReply *pRep; +SListHostsReply(ClientPtr pClient, int size, xListHostsReply *pRep) { register char n; swaps(&pRep->sequenceNumber, n); swapl(&pRep->length, n); swaps(&pRep->nHosts, n); (void)WriteToClient(pClient, size, (char *) pRep); } void -SErrorEvent(from, to) - xError *from, *to; +SErrorEvent(xError *from, xError *to) { to->type = X_Error; to->errorCode = from->errorCode; cpswaps(from->sequenceNumber, to->sequenceNumber); cpswapl(from->resourceID, to->resourceID); cpswaps(from->minorCode, to->minorCode); to->majorCode = from->majorCode; } void -SKeyButtonPtrEvent(from, to) - xEvent *from, *to; +SKeyButtonPtrEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; to->u.u.detail = from->u.u.detail; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.keyButtonPointer.time, to->u.keyButtonPointer.time); cpswapl(from->u.keyButtonPointer.root, to->u.keyButtonPointer.root); cpswapl(from->u.keyButtonPointer.event, to->u.keyButtonPointer.event); cpswapl(from->u.keyButtonPointer.child, to->u.keyButtonPointer.child); cpswaps(from->u.keyButtonPointer.rootX, to->u.keyButtonPointer.rootX); cpswaps(from->u.keyButtonPointer.rootY, to->u.keyButtonPointer.rootY); cpswaps(from->u.keyButtonPointer.eventX, to->u.keyButtonPointer.eventX); cpswaps(from->u.keyButtonPointer.eventY, to->u.keyButtonPointer.eventY); cpswaps(from->u.keyButtonPointer.state, to->u.keyButtonPointer.state); to->u.keyButtonPointer.sameScreen = from->u.keyButtonPointer.sameScreen; } void -SEnterLeaveEvent(from, to) - xEvent *from, *to; +SEnterLeaveEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; to->u.u.detail = from->u.u.detail; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.enterLeave.time, to->u.enterLeave.time); cpswapl(from->u.enterLeave.root, to->u.enterLeave.root); cpswapl(from->u.enterLeave.event, to->u.enterLeave.event); cpswapl(from->u.enterLeave.child, to->u.enterLeave.child); cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX); cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY); cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX); cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY); cpswaps(from->u.enterLeave.state, to->u.enterLeave.state); to->u.enterLeave.mode = from->u.enterLeave.mode; to->u.enterLeave.flags = from->u.enterLeave.flags; } void -SFocusEvent(from, to) - xEvent *from, *to; +SFocusEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; to->u.u.detail = from->u.u.detail; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.focus.window, to->u.focus.window); to->u.focus.mode = from->u.focus.mode; } void -SExposeEvent(from, to) - xEvent *from, *to; +SExposeEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.expose.window, to->u.expose.window); cpswaps(from->u.expose.x, to->u.expose.x); cpswaps(from->u.expose.y, to->u.expose.y); cpswaps(from->u.expose.width, to->u.expose.width); cpswaps(from->u.expose.height, to->u.expose.height); cpswaps(from->u.expose.count, to->u.expose.count); } void -SGraphicsExposureEvent(from, to) - xEvent *from, *to; +SGraphicsExposureEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.graphicsExposure.drawable, to->u.graphicsExposure.drawable); cpswaps(from->u.graphicsExposure.x, to->u.graphicsExposure.x); cpswaps(from->u.graphicsExposure.y, to->u.graphicsExposure.y); cpswaps(from->u.graphicsExposure.width, to->u.graphicsExposure.width); cpswaps(from->u.graphicsExposure.height, to->u.graphicsExposure.height); cpswaps(from->u.graphicsExposure.minorEvent, to->u.graphicsExposure.minorEvent); cpswaps(from->u.graphicsExposure.count, to->u.graphicsExposure.count); to->u.graphicsExposure.majorEvent = from->u.graphicsExposure.majorEvent; } void -SNoExposureEvent(from, to) - xEvent *from, *to; +SNoExposureEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable); cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent); to->u.noExposure.majorEvent = from->u.noExposure.majorEvent; } void -SVisibilityEvent(from, to) - xEvent *from, *to; +SVisibilityEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.visibility.window, to->u.visibility.window); to->u.visibility.state = from->u.visibility.state; } void -SCreateNotifyEvent(from, to) - xEvent *from, *to; +SCreateNotifyEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.createNotify.window, to->u.createNotify.window); cpswapl(from->u.createNotify.parent, to->u.createNotify.parent); cpswaps(from->u.createNotify.x, to->u.createNotify.x); cpswaps(from->u.createNotify.y, to->u.createNotify.y); cpswaps(from->u.createNotify.width, to->u.createNotify.width); cpswaps(from->u.createNotify.height, to->u.createNotify.height); cpswaps(from->u.createNotify.borderWidth, to->u.createNotify.borderWidth); to->u.createNotify.override = from->u.createNotify.override; } void -SDestroyNotifyEvent(from, to) - xEvent *from, *to; +SDestroyNotifyEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event); cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window); } void -SUnmapNotifyEvent(from, to) - xEvent *from, *to; +SUnmapNotifyEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event); cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window); to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure; } void -SMapNotifyEvent(from, to) - xEvent *from, *to; +SMapNotifyEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.mapNotify.event, to->u.mapNotify.event); cpswapl(from->u.mapNotify.window, to->u.mapNotify.window); to->u.mapNotify.override = from->u.mapNotify.override; } void -SMapRequestEvent(from, to) - xEvent *from, *to; +SMapRequestEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent); cpswapl(from->u.mapRequest.window, to->u.mapRequest.window); } void -SReparentEvent(from, to) - xEvent *from, *to; +SReparentEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.reparent.event, to->u.reparent.event); cpswapl(from->u.reparent.window, to->u.reparent.window); cpswapl(from->u.reparent.parent, to->u.reparent.parent); cpswaps(from->u.reparent.x, to->u.reparent.x); cpswaps(from->u.reparent.y, to->u.reparent.y); to->u.reparent.override = from->u.reparent.override; } void -SConfigureNotifyEvent(from, to) - xEvent *from, *to; +SConfigureNotifyEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.configureNotify.event, to->u.configureNotify.event); cpswapl(from->u.configureNotify.window, to->u.configureNotify.window); cpswapl(from->u.configureNotify.aboveSibling, to->u.configureNotify.aboveSibling); cpswaps(from->u.configureNotify.x, to->u.configureNotify.x); cpswaps(from->u.configureNotify.y, to->u.configureNotify.y); cpswaps(from->u.configureNotify.width, to->u.configureNotify.width); cpswaps(from->u.configureNotify.height, to->u.configureNotify.height); cpswaps(from->u.configureNotify.borderWidth, to->u.configureNotify.borderWidth); to->u.configureNotify.override = from->u.configureNotify.override; } void -SConfigureRequestEvent(from, to) - xEvent *from, *to; +SConfigureRequestEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; to->u.u.detail = from->u.u.detail; /* actually stack-mode */ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.configureRequest.parent, to->u.configureRequest.parent); cpswapl(from->u.configureRequest.window, to->u.configureRequest.window); cpswapl(from->u.configureRequest.sibling, to->u.configureRequest.sibling); cpswaps(from->u.configureRequest.x, to->u.configureRequest.x); cpswaps(from->u.configureRequest.y, to->u.configureRequest.y); cpswaps(from->u.configureRequest.width, to->u.configureRequest.width); cpswaps(from->u.configureRequest.height, to->u.configureRequest.height); cpswaps(from->u.configureRequest.borderWidth, to->u.configureRequest.borderWidth); cpswaps(from->u.configureRequest.valueMask, to->u.configureRequest.valueMask); } void -SGravityEvent(from, to) - xEvent *from, *to; +SGravityEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.gravity.event, to->u.gravity.event); cpswapl(from->u.gravity.window, to->u.gravity.window); cpswaps(from->u.gravity.x, to->u.gravity.x); cpswaps(from->u.gravity.y, to->u.gravity.y); } void -SResizeRequestEvent(from, to) - xEvent *from, *to; +SResizeRequestEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window); cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width); cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height); } void -SCirculateEvent(from, to) - xEvent *from, *to; +SCirculateEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; to->u.u.detail = from->u.u.detail; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.circulate.event, to->u.circulate.event); cpswapl(from->u.circulate.window, to->u.circulate.window); cpswapl(from->u.circulate.parent, to->u.circulate.parent); to->u.circulate.place = from->u.circulate.place; } void -SPropertyEvent(from, to) - xEvent *from, *to; +SPropertyEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.property.window, to->u.property.window); cpswapl(from->u.property.atom, to->u.property.atom); cpswapl(from->u.property.time, to->u.property.time); to->u.property.state = from->u.property.state; } void -SSelectionClearEvent(from, to) - xEvent *from, *to; +SSelectionClearEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.selectionClear.time, to->u.selectionClear.time); cpswapl(from->u.selectionClear.window, to->u.selectionClear.window); cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom); } void -SSelectionRequestEvent(from, to) - xEvent *from, *to; +SSelectionRequestEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time); cpswapl(from->u.selectionRequest.owner, to->u.selectionRequest.owner); cpswapl(from->u.selectionRequest.requestor, to->u.selectionRequest.requestor); cpswapl(from->u.selectionRequest.selection, to->u.selectionRequest.selection); cpswapl(from->u.selectionRequest.target, to->u.selectionRequest.target); cpswapl(from->u.selectionRequest.property, to->u.selectionRequest.property); } void -SSelectionNotifyEvent(from, to) - xEvent *from, *to; +SSelectionNotifyEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time); cpswapl(from->u.selectionNotify.requestor, to->u.selectionNotify.requestor); cpswapl(from->u.selectionNotify.selection, to->u.selectionNotify.selection); cpswapl(from->u.selectionNotify.target, to->u.selectionNotify.target); cpswapl(from->u.selectionNotify.property, to->u.selectionNotify.property); } void -SColormapEvent(from, to) - xEvent *from, *to; +SColormapEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.colormap.window, to->u.colormap.window); cpswapl(from->u.colormap.colormap, to->u.colormap.colormap); to->u.colormap.new = from->u.colormap.new; to->u.colormap.state = from->u.colormap.state; } void -SMappingEvent(from, to) - xEvent *from, *to; +SMappingEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); to->u.mappingNotify.request = from->u.mappingNotify.request; to->u.mappingNotify.firstKeyCode = from->u.mappingNotify.firstKeyCode; to->u.mappingNotify.count = from->u.mappingNotify.count; } void -SClientMessageEvent(from, to) - xEvent *from, *to; +SClientMessageEvent(xEvent *from, xEvent *to) { to->u.u.type = from->u.u.type; to->u.u.detail = from->u.u.detail; /* actually format */ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); cpswapl(from->u.clientMessage.window, to->u.clientMessage.window); cpswapl(from->u.clientMessage.u.l.type, to->u.clientMessage.u.l.type); switch (from->u.u.detail) { case 8: memmove(to->u.clientMessage.u.b.bytes, from->u.clientMessage.u.b.bytes,20); break; case 16: cpswaps(from->u.clientMessage.u.s.shorts0, to->u.clientMessage.u.s.shorts0); cpswaps(from->u.clientMessage.u.s.shorts1, to->u.clientMessage.u.s.shorts1); cpswaps(from->u.clientMessage.u.s.shorts2, to->u.clientMessage.u.s.shorts2); cpswaps(from->u.clientMessage.u.s.shorts3, @@ -1284,42 +1141,41 @@ to->u.clientMessage.u.s.shorts8); cpswaps(from->u.clientMessage.u.s.shorts9, to->u.clientMessage.u.s.shorts9); break; case 32: cpswapl(from->u.clientMessage.u.l.longs0, to->u.clientMessage.u.l.longs0); cpswapl(from->u.clientMessage.u.l.longs1, to->u.clientMessage.u.l.longs1); cpswapl(from->u.clientMessage.u.l.longs2, to->u.clientMessage.u.l.longs2); cpswapl(from->u.clientMessage.u.l.longs3, to->u.clientMessage.u.l.longs3); cpswapl(from->u.clientMessage.u.l.longs4, to->u.clientMessage.u.l.longs4); break; } } void -SKeymapNotifyEvent(from, to) - xEvent *from, *to; +SKeymapNotifyEvent(xEvent *from, xEvent *to) { /* Keymap notify events are special; they have no sequence number field, and contain entirely 8-bit data */ *to = *from; } void SwapConnSetupInfo( char *pInfo, char *pInfoT ) { int i, j, k; xConnSetup *pConnSetup = (xConnSetup *)pInfo; xDepth *depth; xWindowRoot *root; SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT); pInfo += sizeof(xConnSetup); pInfoT += sizeof(xConnSetup); @@ -1345,115 +1201,105 @@ for(j = 0; j < root->nDepths; j++) { depth = (xDepth*)pInfo; ((xDepth *)pInfoT)->depth = depth->depth; cpswaps(depth->nVisuals, ((xDepth *)pInfoT)->nVisuals); pInfo += sizeof(xDepth); pInfoT += sizeof(xDepth); for(k = 0; k < depth->nVisuals; k++) { SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT); pInfo += sizeof(xVisualType); pInfoT += sizeof(xVisualType); } } } } void -WriteSConnectionInfo(pClient, size, pInfo) - ClientPtr pClient; - unsigned long size; - char *pInfo; +WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo) { char *pInfoTBase; pInfoTBase = (char *) ALLOCATE_LOCAL(size); if (!pInfoTBase) { pClient->noClientException = -1; return; } SwapConnSetupInfo(pInfo, pInfoTBase); (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase); DEALLOCATE_LOCAL(pInfoTBase); } void -SwapConnSetup(pConnSetup, pConnSetupT) - xConnSetup *pConnSetup, *pConnSetupT; +SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT) { cpswapl(pConnSetup->release, pConnSetupT->release); cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase); cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask); cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize); cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor); cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize); pConnSetupT->minKeyCode = pConnSetup->minKeyCode; pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode; pConnSetupT->numRoots = pConnSetup->numRoots; pConnSetupT->numFormats = pConnSetup->numFormats; pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder; pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder; pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit; pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad; } void -SwapWinRoot(pRoot, pRootT) - xWindowRoot *pRoot, *pRootT; +SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT) { cpswapl(pRoot->windowId, pRootT->windowId); cpswapl(pRoot->defaultColormap, pRootT->defaultColormap); cpswapl(pRoot->whitePixel, pRootT->whitePixel); cpswapl(pRoot->blackPixel, pRootT->blackPixel); cpswapl(pRoot->currentInputMask, pRootT->currentInputMask); cpswaps(pRoot->pixWidth, pRootT->pixWidth); cpswaps(pRoot->pixHeight, pRootT->pixHeight); cpswaps(pRoot->mmWidth, pRootT->mmWidth); cpswaps(pRoot->mmHeight, pRootT->mmHeight); cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps); cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps); cpswapl(pRoot->rootVisualID, pRootT->rootVisualID); pRootT->backingStore = pRoot->backingStore; pRootT->saveUnders = pRoot->saveUnders; pRootT->rootDepth = pRoot->rootDepth; pRootT->nDepths = pRoot->nDepths; } void -SwapVisual(pVis, pVisT) - xVisualType *pVis, *pVisT; +SwapVisual(xVisualType *pVis, xVisualType *pVisT) { cpswapl(pVis->visualID, pVisT->visualID); pVisT->class = pVis->class; pVisT->bitsPerRGB = pVis->bitsPerRGB; cpswaps(pVis->colormapEntries, pVisT->colormapEntries); cpswapl(pVis->redMask, pVisT->redMask); cpswapl(pVis->greenMask, pVisT->greenMask); cpswapl(pVis->blueMask, pVisT->blueMask); } void -SwapConnSetupPrefix(pcspFrom, pcspTo) - xConnSetupPrefix *pcspFrom; - xConnSetupPrefix *pcspTo; +SwapConnSetupPrefix(xConnSetupPrefix *pcspFrom, xConnSetupPrefix *pcspTo) { pcspTo->success = pcspFrom->success; pcspTo->lengthReason = pcspFrom->lengthReason; cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion); cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion); cpswaps(pcspFrom->length, pcspTo->length); } void -WriteSConnSetupPrefix(pClient, pcsp) - ClientPtr pClient; - xConnSetupPrefix *pcsp; +WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix *pcsp) { xConnSetupPrefix cspT; SwapConnSetupPrefix(pcsp, &cspT); (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT); } Index: xc/programs/Xserver/dix/swapreq.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/swapreq.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 swapreq.c --- xc/programs/Xserver/dix/swapreq.c 23 Apr 2004 19:04:44 -0000 1.2 +++ xc/programs/Xserver/dix/swapreq.c 7 Mar 2005 22:55:18 -0000 @@ -45,1129 +45,1056 @@ SOFTWARE. ********************************************************/ /* $Xorg: swapreq.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */ #include "X.h" #define NEED_EVENTS #include "Xproto.h" #include "Xprotostr.h" #include "misc.h" #include "dixstruct.h" #include "extnsionst.h" /* for SendEvent */ #include "swapreq.h" /* Thanks to Jack Palevich for testing and subsequently rewriting all this */ /* Byte swap a list of longs */ void -SwapLongs (list, count) - register CARD32 *list; - register unsigned long count; +SwapLongs (register CARD32 *list, register unsigned long count) { register char n; while (count >= 8) { swapl(list+0, n); swapl(list+1, n); swapl(list+2, n); swapl(list+3, n); swapl(list+4, n); swapl(list+5, n); swapl(list+6, n); swapl(list+7, n); list += 8; count -= 8; } if (count != 0) { do { swapl(list, n); list++; } while (--count != 0); } } /* Byte swap a list of shorts */ void -SwapShorts (list, count) - register short *list; - register unsigned long count; +SwapShorts (register short *list, register unsigned long count) { register char n; while (count >= 16) { swaps(list+0, n); swaps(list+1, n); swaps(list+2, n); swaps(list+3, n); swaps(list+4, n); swaps(list+5, n); swaps(list+6, n); swaps(list+7, n); swaps(list+8, n); swaps(list+9, n); swaps(list+10, n); swaps(list+11, n); swaps(list+12, n); swaps(list+13, n); swaps(list+14, n); swaps(list+15, n); list += 16; count -= 16; } if (count != 0) { do { swaps(list, n); list++; } while (--count != 0); } } /* The following is used for all requests that have no fields to be swapped (except "length") */ int -SProcSimpleReq(client) - register ClientPtr client; +SProcSimpleReq(register ClientPtr client) { register char n; REQUEST(xReq); swaps(&stuff->length, n); return(*ProcVector[stuff->reqType])(client); } /* The following is used for all requests that have only a single 32-bit field to be swapped, coming right after the "length" field */ int -SProcResourceReq(client) - register ClientPtr client; +SProcResourceReq(register ClientPtr client) { register char n; REQUEST(xResourceReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */ swapl(&stuff->id, n); return(*ProcVector[stuff->reqType])(client); } int -SProcCreateWindow(client) - register ClientPtr client; +SProcCreateWindow(register ClientPtr client) { register char n; REQUEST(xCreateWindowReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xCreateWindowReq); swapl(&stuff->wid, n); swapl(&stuff->parent, n); swaps(&stuff->x, n); swaps(&stuff->y, n); swaps(&stuff->width, n); swaps(&stuff->height, n); swaps(&stuff->borderWidth, n); swaps(&stuff->class, n); swapl(&stuff->visual, n); swapl(&stuff->mask, n); SwapRestL(stuff); return((* ProcVector[X_CreateWindow])(client)); } int -SProcChangeWindowAttributes(client) - register ClientPtr client; +SProcChangeWindowAttributes(register ClientPtr client) { register char n; REQUEST(xChangeWindowAttributesReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); swapl(&stuff->window, n); swapl(&stuff->valueMask, n); SwapRestL(stuff); return((* ProcVector[X_ChangeWindowAttributes])(client)); } int -SProcReparentWindow(client) - register ClientPtr client; +SProcReparentWindow(register ClientPtr client) { register char n; REQUEST(xReparentWindowReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xReparentWindowReq); swapl(&stuff->window, n); swapl(&stuff->parent, n); swaps(&stuff->x, n); swaps(&stuff->y, n); return((* ProcVector[X_ReparentWindow])(client)); } int -SProcConfigureWindow(client) - register ClientPtr client; +SProcConfigureWindow(register ClientPtr client) { register char n; REQUEST(xConfigureWindowReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); swapl(&stuff->window, n); swaps(&stuff->mask, n); SwapRestL(stuff); return((* ProcVector[X_ConfigureWindow])(client)); } int -SProcInternAtom(client) - register ClientPtr client; +SProcInternAtom(register ClientPtr client) { register char n; REQUEST(xInternAtomReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xInternAtomReq); swaps(&stuff->nbytes, n); return((* ProcVector[X_InternAtom])(client)); } int -SProcChangeProperty(client) - register ClientPtr client; +SProcChangeProperty(register ClientPtr client) { register char n; REQUEST(xChangePropertyReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangePropertyReq); swapl(&stuff->window, n); swapl(&stuff->property, n); swapl(&stuff->type, n); swapl(&stuff->nUnits, n); switch ( stuff->format ) { case 8 : break; case 16: SwapRestS(stuff); break; case 32: SwapRestL(stuff); break; } return((* ProcVector[X_ChangeProperty])(client)); } int -SProcDeleteProperty(client) - register ClientPtr client; +SProcDeleteProperty(register ClientPtr client) { register char n; REQUEST(xDeletePropertyReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xDeletePropertyReq); swapl(&stuff->window, n); swapl(&stuff->property, n); return((* ProcVector[X_DeleteProperty])(client)); } int -SProcGetProperty(client) - register ClientPtr client; +SProcGetProperty(register ClientPtr client) { register char n; REQUEST(xGetPropertyReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xGetPropertyReq); swapl(&stuff->window, n); swapl(&stuff->property, n); swapl(&stuff->type, n); swapl(&stuff->longOffset, n); swapl(&stuff->longLength, n); return((* ProcVector[X_GetProperty])(client)); } int -SProcSetSelectionOwner(client) - register ClientPtr client; +SProcSetSelectionOwner(register ClientPtr client) { register char n; REQUEST(xSetSelectionOwnerReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); swapl(&stuff->window, n); swapl(&stuff->selection, n); swapl(&stuff->time, n); return((* ProcVector[X_SetSelectionOwner])(client)); } int -SProcConvertSelection(client) - register ClientPtr client; +SProcConvertSelection(register ClientPtr client) { register char n; REQUEST(xConvertSelectionReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xConvertSelectionReq); swapl(&stuff->requestor, n); swapl(&stuff->selection, n); swapl(&stuff->target, n); swapl(&stuff->property, n); swapl(&stuff->time, n); return((* ProcVector[X_ConvertSelection])(client)); } int -SProcSendEvent(client) - register ClientPtr client; +SProcSendEvent(register ClientPtr client) { register char n; xEvent eventT; EventSwapPtr proc; REQUEST(xSendEventReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xSendEventReq); swapl(&stuff->destination, n); swapl(&stuff->eventMask, n); /* Swap event */ proc = EventSwapVector[stuff->event.u.u.type & 0177]; if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */ return (BadValue); (*proc)(&stuff->event, &eventT); stuff->event = eventT; return((* ProcVector[X_SendEvent])(client)); } int -SProcGrabPointer(client) - register ClientPtr client; +SProcGrabPointer(register ClientPtr client) { register char n; REQUEST(xGrabPointerReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xGrabPointerReq); swapl(&stuff->grabWindow, n); swaps(&stuff->eventMask, n); swapl(&stuff->confineTo, n); swapl(&stuff->cursor, n); swapl(&stuff->time, n); return((* ProcVector[X_GrabPointer])(client)); } int -SProcGrabButton(client) - register ClientPtr client; +SProcGrabButton(register ClientPtr client) { register char n; REQUEST(xGrabButtonReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xGrabButtonReq); swapl(&stuff->grabWindow, n); swaps(&stuff->eventMask, n); swapl(&stuff->confineTo, n); swapl(&stuff->cursor, n); swaps(&stuff->modifiers, n); return((* ProcVector[X_GrabButton])(client)); } int -SProcUngrabButton(client) - register ClientPtr client; +SProcUngrabButton(register ClientPtr client) { register char n; REQUEST(xUngrabButtonReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xUngrabButtonReq); swapl(&stuff->grabWindow, n); swaps(&stuff->modifiers, n); return((* ProcVector[X_UngrabButton])(client)); } int -SProcChangeActivePointerGrab(client) - register ClientPtr client; +SProcChangeActivePointerGrab(register ClientPtr client) { register char n; REQUEST(xChangeActivePointerGrabReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq); swapl(&stuff->cursor, n); swapl(&stuff->time, n); swaps(&stuff->eventMask, n); return((* ProcVector[X_ChangeActivePointerGrab])(client)); } int -SProcGrabKeyboard(client) - register ClientPtr client; +SProcGrabKeyboard(register ClientPtr client) { register char n; REQUEST(xGrabKeyboardReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xGrabKeyboardReq); swapl(&stuff->grabWindow, n); swapl(&stuff->time, n); return((* ProcVector[X_GrabKeyboard])(client)); } int -SProcGrabKey(client) - register ClientPtr client; +SProcGrabKey(register ClientPtr client) { register char n; REQUEST(xGrabKeyReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xGrabKeyReq); swapl(&stuff->grabWindow, n); swaps(&stuff->modifiers, n); return((* ProcVector[X_GrabKey])(client)); } int -SProcUngrabKey(client) - register ClientPtr client; +SProcUngrabKey(register ClientPtr client) { register char n; REQUEST(xUngrabKeyReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xUngrabKeyReq); swapl(&stuff->grabWindow, n); swaps(&stuff->modifiers, n); return((* ProcVector[X_UngrabKey])(client)); } int -SProcGetMotionEvents(client) - register ClientPtr client; +SProcGetMotionEvents(register ClientPtr client) { register char n; REQUEST(xGetMotionEventsReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xGetMotionEventsReq); swapl(&stuff->window, n); swapl(&stuff->start, n); swapl(&stuff->stop, n); return((* ProcVector[X_GetMotionEvents])(client)); } int -SProcTranslateCoords(client) - register ClientPtr client; +SProcTranslateCoords(register ClientPtr client) { register char n; REQUEST(xTranslateCoordsReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xTranslateCoordsReq); swapl(&stuff->srcWid, n); swapl(&stuff->dstWid, n); swaps(&stuff->srcX, n); swaps(&stuff->srcY, n); return((* ProcVector[X_TranslateCoords])(client)); } int -SProcWarpPointer(client) - register ClientPtr client; +SProcWarpPointer(register ClientPtr client) { register char n; REQUEST(xWarpPointerReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xWarpPointerReq); swapl(&stuff->srcWid, n); swapl(&stuff->dstWid, n); swaps(&stuff->srcX, n); swaps(&stuff->srcY, n); swaps(&stuff->srcWidth, n); swaps(&stuff->srcHeight, n); swaps(&stuff->dstX, n); swaps(&stuff->dstY, n); return((* ProcVector[X_WarpPointer])(client)); } int -SProcSetInputFocus(client) - register ClientPtr client; +SProcSetInputFocus(register ClientPtr client) { register char n; REQUEST(xSetInputFocusReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xSetInputFocusReq); swapl(&stuff->focus, n); swapl(&stuff->time, n); return((* ProcVector[X_SetInputFocus])(client)); } int -SProcOpenFont(client) - register ClientPtr client; +SProcOpenFont(register ClientPtr client) { register char n; REQUEST(xOpenFontReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xOpenFontReq); swapl(&stuff->fid, n); swaps(&stuff->nbytes, n); return((* ProcVector[X_OpenFont])(client)); } int -SProcListFonts(client) - register ClientPtr client; +SProcListFonts(register ClientPtr client) { register char n; REQUEST(xListFontsReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xListFontsReq); swaps(&stuff->maxNames, n); swaps(&stuff->nbytes, n); return((* ProcVector[X_ListFonts])(client)); } int -SProcListFontsWithInfo(client) - register ClientPtr client; +SProcListFontsWithInfo(register ClientPtr client) { register char n; REQUEST(xListFontsWithInfoReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq); swaps(&stuff->maxNames, n); swaps(&stuff->nbytes, n); return((* ProcVector[X_ListFontsWithInfo])(client)); } int -SProcSetFontPath(client) - register ClientPtr client; +SProcSetFontPath(register ClientPtr client) { register char n; REQUEST(xSetFontPathReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xSetFontPathReq); swaps(&stuff->nFonts, n); return((* ProcVector[X_SetFontPath])(client)); } int -SProcCreatePixmap(client) - register ClientPtr client; +SProcCreatePixmap(register ClientPtr client) { register char n; REQUEST(xCreatePixmapReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCreatePixmapReq); swapl(&stuff->pid, n); swapl(&stuff->drawable, n); swaps(&stuff->width, n); swaps(&stuff->height, n); return((* ProcVector[X_CreatePixmap])(client)); } int -SProcCreateGC(client) - register ClientPtr client; +SProcCreateGC(register ClientPtr client) { register char n; REQUEST(xCreateGCReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xCreateGCReq); swapl(&stuff->gc, n); swapl(&stuff->drawable, n); swapl(&stuff->mask, n); SwapRestL(stuff); return((* ProcVector[X_CreateGC])(client)); } int -SProcChangeGC(client) - register ClientPtr client; +SProcChangeGC(register ClientPtr client) { register char n; REQUEST(xChangeGCReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangeGCReq); swapl(&stuff->gc, n); swapl(&stuff->mask, n); SwapRestL(stuff); return((* ProcVector[X_ChangeGC])(client)); } int -SProcCopyGC(client) - register ClientPtr client; +SProcCopyGC(register ClientPtr client) { register char n; REQUEST(xCopyGCReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCopyGCReq); swapl(&stuff->srcGC, n); swapl(&stuff->dstGC, n); swapl(&stuff->mask, n); return((* ProcVector[X_CopyGC])(client)); } int -SProcSetDashes(client) - register ClientPtr client; +SProcSetDashes(register ClientPtr client) { register char n; REQUEST(xSetDashesReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xSetDashesReq); swapl(&stuff->gc, n); swaps(&stuff->dashOffset, n); swaps(&stuff->nDashes, n); return((* ProcVector[X_SetDashes])(client)); } int -SProcSetClipRectangles(client) - register ClientPtr client; +SProcSetClipRectangles(register ClientPtr client) { register char n; REQUEST(xSetClipRectanglesReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); swapl(&stuff->gc, n); swaps(&stuff->xOrigin, n); swaps(&stuff->yOrigin, n); SwapRestS(stuff); return((* ProcVector[X_SetClipRectangles])(client)); } int -SProcClearToBackground(client) - register ClientPtr client; +SProcClearToBackground(register ClientPtr client) { register char n; REQUEST(xClearAreaReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xClearAreaReq); swapl(&stuff->window, n); swaps(&stuff->x, n); swaps(&stuff->y, n); swaps(&stuff->width, n); swaps(&stuff->height, n); return((* ProcVector[X_ClearArea])(client)); } int -SProcCopyArea(client) - register ClientPtr client; +SProcCopyArea(register ClientPtr client) { register char n; REQUEST(xCopyAreaReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCopyAreaReq); swapl(&stuff->srcDrawable, n); swapl(&stuff->dstDrawable, n); swapl(&stuff->gc, n); swaps(&stuff->srcX, n); swaps(&stuff->srcY, n); swaps(&stuff->dstX, n); swaps(&stuff->dstY, n); swaps(&stuff->width, n); swaps(&stuff->height, n); return((* ProcVector[X_CopyArea])(client)); } int -SProcCopyPlane(client) - register ClientPtr client; +SProcCopyPlane(register ClientPtr client) { register char n; REQUEST(xCopyPlaneReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCopyPlaneReq); swapl(&stuff->srcDrawable, n); swapl(&stuff->dstDrawable, n); swapl(&stuff->gc, n); swaps(&stuff->srcX, n); swaps(&stuff->srcY, n); swaps(&stuff->dstX, n); swaps(&stuff->dstY, n); swaps(&stuff->width, n); swaps(&stuff->height, n); swapl(&stuff->bitPlane, n); return((* ProcVector[X_CopyPlane])(client)); } /* The following routine is used for all Poly drawing requests (except FillPoly, which uses a different request format) */ int -SProcPoly(client) - register ClientPtr client; +SProcPoly(register ClientPtr client) { register char n; REQUEST(xPolyPointReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xPolyPointReq); swapl(&stuff->drawable, n); swapl(&stuff->gc, n); SwapRestS(stuff); return((* ProcVector[stuff->reqType])(client)); } /* cannot use SProcPoly for this one, because xFillPolyReq is longer than xPolyPointReq, and we don't want to swap the difference as shorts! */ int -SProcFillPoly(client) - register ClientPtr client; +SProcFillPoly(register ClientPtr client) { register char n; REQUEST(xFillPolyReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xFillPolyReq); swapl(&stuff->drawable, n); swapl(&stuff->gc, n); SwapRestS(stuff); return((* ProcVector[X_FillPoly])(client)); } int -SProcPutImage(client) - register ClientPtr client; +SProcPutImage(register ClientPtr client) { register char n; REQUEST(xPutImageReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xPutImageReq); swapl(&stuff->drawable, n); swapl(&stuff->gc, n); swaps(&stuff->width, n); swaps(&stuff->height, n); swaps(&stuff->dstX, n); swaps(&stuff->dstY, n); /* Image should already be swapped */ return((* ProcVector[X_PutImage])(client)); } int -SProcGetImage(client) - register ClientPtr client; +SProcGetImage(register ClientPtr client) { register char n; REQUEST(xGetImageReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xGetImageReq); swapl(&stuff->drawable, n); swaps(&stuff->x, n); swaps(&stuff->y, n); swaps(&stuff->width, n); swaps(&stuff->height, n); swapl(&stuff->planeMask, n); return((* ProcVector[X_GetImage])(client)); } /* ProcPolyText used for both PolyText8 and PolyText16 */ int -SProcPolyText(client) - register ClientPtr client; +SProcPolyText(register ClientPtr client) { register char n; REQUEST(xPolyTextReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xPolyTextReq); swapl(&stuff->drawable, n); swapl(&stuff->gc, n); swaps(&stuff->x, n); swaps(&stuff->y, n); return((* ProcVector[stuff->reqType])(client)); } /* ProcImageText used for both ImageText8 and ImageText16 */ int -SProcImageText(client) - register ClientPtr client; +SProcImageText(register ClientPtr client) { register char n; REQUEST(xImageTextReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xImageTextReq); swapl(&stuff->drawable, n); swapl(&stuff->gc, n); swaps(&stuff->x, n); swaps(&stuff->y, n); return((* ProcVector[stuff->reqType])(client)); } int -SProcCreateColormap(client) - register ClientPtr client; +SProcCreateColormap(register ClientPtr client) { register char n; REQUEST(xCreateColormapReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCreateColormapReq); swapl(&stuff->mid, n); swapl(&stuff->window, n); swapl(&stuff->visual, n); return((* ProcVector[X_CreateColormap])(client)); } int -SProcCopyColormapAndFree(client) - register ClientPtr client; +SProcCopyColormapAndFree(register ClientPtr client) { register char n; REQUEST(xCopyColormapAndFreeReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); swapl(&stuff->mid, n); swapl(&stuff->srcCmap, n); return((* ProcVector[X_CopyColormapAndFree])(client)); } int -SProcAllocColor (client) - register ClientPtr client; +SProcAllocColor(register ClientPtr client) { register char n; REQUEST(xAllocColorReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xAllocColorReq); swapl(&stuff->cmap, n); swaps(&stuff->red, n); swaps(&stuff->green, n); swaps(&stuff->blue, n); return((* ProcVector[X_AllocColor])(client)); } int -SProcAllocNamedColor (client) - register ClientPtr client; +SProcAllocNamedColor(register ClientPtr client) { register char n; REQUEST(xAllocNamedColorReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq); swapl(&stuff->cmap, n); swaps(&stuff->nbytes, n); return((* ProcVector[X_AllocNamedColor])(client)); } int -SProcAllocColorCells (client) - register ClientPtr client; +SProcAllocColorCells(register ClientPtr client) { register char n; REQUEST(xAllocColorCellsReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xAllocColorCellsReq); swapl(&stuff->cmap, n); swaps(&stuff->colors, n); swaps(&stuff->planes, n); return((* ProcVector[X_AllocColorCells])(client)); } int -SProcAllocColorPlanes(client) - register ClientPtr client; +SProcAllocColorPlanes(register ClientPtr client) { register char n; REQUEST(xAllocColorPlanesReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xAllocColorPlanesReq); swapl(&stuff->cmap, n); swaps(&stuff->colors, n); swaps(&stuff->red, n); swaps(&stuff->green, n); swaps(&stuff->blue, n); return((* ProcVector[X_AllocColorPlanes])(client)); } int -SProcFreeColors (client) - register ClientPtr client; +SProcFreeColors(register ClientPtr client) { register char n; REQUEST(xFreeColorsReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); swapl(&stuff->cmap, n); swapl(&stuff->planeMask, n); SwapRestL(stuff); return((* ProcVector[X_FreeColors])(client)); } void -SwapColorItem(pItem) - xColorItem *pItem; +SwapColorItem(xColorItem *pItem) { register char n; swapl(&pItem->pixel, n); swaps(&pItem->red, n); swaps(&pItem->green, n); swaps(&pItem->blue, n); } int -SProcStoreColors (client) - register ClientPtr client; +SProcStoreColors(register ClientPtr client) { register char n; long count; xColorItem *pItem; REQUEST(xStoreColorsReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); swapl(&stuff->cmap, n); pItem = (xColorItem *) &stuff[1]; for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; ) SwapColorItem(pItem++); return((* ProcVector[X_StoreColors])(client)); } int -SProcStoreNamedColor (client) - register ClientPtr client; +SProcStoreNamedColor (register ClientPtr client) { register char n; REQUEST(xStoreNamedColorReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq); swapl(&stuff->cmap, n); swapl(&stuff->pixel, n); swaps(&stuff->nbytes, n); return((* ProcVector[X_StoreNamedColor])(client)); } int -SProcQueryColors(client) - register ClientPtr client; +SProcQueryColors (register ClientPtr client) { register char n; REQUEST(xQueryColorsReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xQueryColorsReq); swapl(&stuff->cmap, n); SwapRestL(stuff); return((* ProcVector[X_QueryColors])(client)); } int -SProcLookupColor(client) - register ClientPtr client; +SProcLookupColor (register ClientPtr client) { register char n; REQUEST(xLookupColorReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xLookupColorReq); swapl(&stuff->cmap, n); swaps(&stuff->nbytes, n); return((* ProcVector[X_LookupColor])(client)); } int -SProcCreateCursor( client) - register ClientPtr client; +SProcCreateCursor (register ClientPtr client) { register char n; REQUEST(xCreateCursorReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCreateCursorReq); swapl(&stuff->cid, n); swapl(&stuff->source, n); swapl(&stuff->mask, n); swaps(&stuff->foreRed, n); swaps(&stuff->foreGreen, n); swaps(&stuff->foreBlue, n); swaps(&stuff->backRed, n); swaps(&stuff->backGreen, n); swaps(&stuff->backBlue, n); swaps(&stuff->x, n); swaps(&stuff->y, n); return((* ProcVector[X_CreateCursor])(client)); } int -SProcCreateGlyphCursor( client) - register ClientPtr client; +SProcCreateGlyphCursor (register ClientPtr client) { register char n; REQUEST(xCreateGlyphCursorReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); swapl(&stuff->cid, n); swapl(&stuff->source, n); swapl(&stuff->mask, n); swaps(&stuff->sourceChar, n); swaps(&stuff->maskChar, n); swaps(&stuff->foreRed, n); swaps(&stuff->foreGreen, n); swaps(&stuff->foreBlue, n); swaps(&stuff->backRed, n); swaps(&stuff->backGreen, n); swaps(&stuff->backBlue, n); return((* ProcVector[X_CreateGlyphCursor])(client)); } int -SProcRecolorCursor(client) - register ClientPtr client; +SProcRecolorCursor (register ClientPtr client) { register char n; REQUEST(xRecolorCursorReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xRecolorCursorReq); swapl(&stuff->cursor, n); swaps(&stuff->foreRed, n); swaps(&stuff->foreGreen, n); swaps(&stuff->foreBlue, n); swaps(&stuff->backRed, n); swaps(&stuff->backGreen, n); swaps(&stuff->backBlue, n); return((* ProcVector[X_RecolorCursor])(client)); } int -SProcQueryBestSize (client) - register ClientPtr client; +SProcQueryBestSize (register ClientPtr client) { register char n; REQUEST(xQueryBestSizeReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xQueryBestSizeReq); swapl(&stuff->drawable, n); swaps(&stuff->width, n); swaps(&stuff->height, n); return((* ProcVector[X_QueryBestSize])(client)); } int -SProcQueryExtension (client) - register ClientPtr client; +SProcQueryExtension (register ClientPtr client) { register char n; REQUEST(xQueryExtensionReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xQueryExtensionReq); swaps(&stuff->nbytes, n); return((* ProcVector[X_QueryExtension])(client)); } int -SProcChangeKeyboardMapping (client) - register ClientPtr client; +SProcChangeKeyboardMapping (register ClientPtr client) { register char n; REQUEST(xChangeKeyboardMappingReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); SwapRestL(stuff); return((* ProcVector[X_ChangeKeyboardMapping])(client)); } int -SProcChangeKeyboardControl (client) - register ClientPtr client; +SProcChangeKeyboardControl (register ClientPtr client) { register char n; REQUEST(xChangeKeyboardControlReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); swapl(&stuff->mask, n); SwapRestL(stuff); return((* ProcVector[X_ChangeKeyboardControl])(client)); } int -SProcChangePointerControl (client) - register ClientPtr client; +SProcChangePointerControl (register ClientPtr client) { register char n; REQUEST(xChangePointerControlReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xChangePointerControlReq); swaps(&stuff->accelNum, n); swaps(&stuff->accelDenum, n); swaps(&stuff->threshold, n); return((* ProcVector[X_ChangePointerControl])(client)); } int -SProcSetScreenSaver (client) - register ClientPtr client; +SProcSetScreenSaver (register ClientPtr client) { register char n; REQUEST(xSetScreenSaverReq); swaps(&stuff->length, n); REQUEST_SIZE_MATCH(xSetScreenSaverReq); swaps(&stuff->timeout, n); swaps(&stuff->interval, n); return((* ProcVector[X_SetScreenSaver])(client)); } int -SProcChangeHosts(client) - register ClientPtr client; +SProcChangeHosts (register ClientPtr client) { register char n; REQUEST(xChangeHostsReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xChangeHostsReq); swaps(&stuff->hostLength, n); return((* ProcVector[X_ChangeHosts])(client)); } -int SProcRotateProperties(client) - register ClientPtr client; +int SProcRotateProperties (register ClientPtr client) { register char n; REQUEST(xRotatePropertiesReq); swaps(&stuff->length, n); REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq); swapl(&stuff->window, n); swaps(&stuff->nAtoms, n); swaps(&stuff->nPositions, n); SwapRestL(stuff); return ((* ProcVector[X_RotateProperties])(client)); } -/*ARGSUSED*/ int -SProcNoOperation(client) - ClientPtr client; +SProcNoOperation(register ClientPtr client) { register char n; REQUEST(xReq); swaps(&stuff->length, n); return ((* ProcVector[X_NoOperation])(client)); } void -SwapConnClientPrefix(pCCP) - xConnClientPrefix *pCCP; +SwapConnClientPrefix(xConnClientPrefix *pCCP) { register char n; swaps(&pCCP->majorVersion, n); swaps(&pCCP->minorVersion, n); swaps(&pCCP->nbytesAuthProto, n); swaps(&pCCP->nbytesAuthString, n); } Index: xc/programs/Xserver/dix/window.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/window.c,v retrieving revision 1.6 diff -u -2 -0 -r1.6 window.c --- xc/programs/Xserver/dix/window.c 31 Jul 2004 08:24:13 -0000 1.6 +++ xc/programs/Xserver/dix/window.c 7 Mar 2005 22:55:19 -0000 @@ -115,154 +115,143 @@ * GetWindowAttributes, DeleteWindow, DestroySubWindows, * HandleSaveSet, ReparentWindow, MapWindow, MapSubWindows, * UnmapWindow, UnmapSubWindows, ConfigureWindow, CirculateWindow, * ******/ static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11}; static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88}; int screenIsSaved = SCREEN_SAVER_OFF; ScreenSaverStuffRec savedScreenInfo[MAXSCREENS]; #if 0 extern void DeleteWindowFromAnyEvents(); extern Mask EventMaskForClient(); extern void WindowHasNewCursor(); extern void RecalculateDeliverableEvents(); #endif -static Bool TileScreenSaver( - int /*i*/, - int /*kind*/ -); +static Bool TileScreenSaver(int i, int kind); #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ CWDontPropagate | CWOverrideRedirect | CWCursor ) #define BOXES_OVERLAP(b1, b2) \ (!( ((b1)->x2 <= (b2)->x1) || \ ( ((b1)->x1 >= (b2)->x2)) || \ ( ((b1)->y2 <= (b2)->y1)) || \ ( ((b1)->y1 >= (b2)->y2)) ) ) #define RedirectSend(pWin) \ ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureRedirectMask) #define SubSend(pWin) \ ((pWin->eventMask|wOtherEventMasks(pWin)) & SubstructureNotifyMask) #define StrSend(pWin) \ ((pWin->eventMask|wOtherEventMasks(pWin)) & StructureNotifyMask) #define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent)) int numSaveUndersViewable = 0; int deltaSaveUndersViewable = 0; #ifdef DEBUG /****** * PrintWindowTree * For debugging only ******/ int -PrintChildren(p1, indent) - WindowPtr p1; - int indent; +PrintChildren(WindowPtr p1, int indent) { WindowPtr p2; int i; while (p1) { p2 = p1->firstChild; for (i=0; idrawable.id); miPrintRegion(&p1->clipList); PrintChildren(p2, indent+4); p1 = p1->nextSib; } } PrintWindowTree() { int i; WindowPtr pWin, p1; for (i=0; iclipList); p1 = pWin->firstChild; PrintChildren(p1, 4); } } #endif int -TraverseTree(pWin, func, data) - register WindowPtr pWin; - VisitWindowProcPtr func; - pointer data; +TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, pointer data) { register int result; register WindowPtr pChild; if (!(pChild = pWin)) return(WT_NOMATCH); while (1) { result = (* func)(pChild, data); if (result == WT_STOPWALKING) return(WT_STOPWALKING); if ((result == WT_WALKCHILDREN) && pChild->firstChild) { pChild = pChild->firstChild; continue; } while (!pChild->nextSib && (pChild != pWin)) pChild = pChild->parent; if (pChild == pWin) break; pChild = pChild->nextSib; } return(WT_NOMATCH); } /***** * WalkTree * Walk the window tree, for SCREEN, preforming FUNC(pWin, data) on * each window. If FUNC returns WT_WALKCHILDREN, traverse the children, * if it returns WT_DONTWALKCHILDREN, dont. If it returns WT_STOPWALKING * exit WalkTree. Does depth-first traverse. *****/ int -WalkTree(pScreen, func, data) - ScreenPtr pScreen; - VisitWindowProcPtr func; - pointer data; +WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data) { return(TraverseTree(WindowTable[pScreen->myNum], func, data)); } /* hack for forcing backing store on all windows */ int defaultBackingStore = NotUseful; /* hack to force no backing store */ Bool disableBackingStore = FALSE; Bool enableBackingStore = FALSE; /* hack to force no save unders */ Bool disableSaveUnders = FALSE; static void SetWindowToDefaults(register WindowPtr pWin) { pWin->prevSib = NullWindow; pWin->firstChild = NullWindow; pWin->lastChild = NullWindow; pWin->valdata = (ValidatePtr)NULL; @@ -326,79 +315,77 @@ ValidateGC((DrawablePtr)pWin->background.pixmap, pGC); from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb; to = back; for (i = 4; i > 0; i--, from++) for (j = len; j > 0; j--) *to++ = *from; if (blackRoot) bzero(back, sizeof(back)); (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1, 0, 0, len, 4, 0, XYBitmap, (char *)back); FreeScratchGC(pGC); } WindowPtr -AllocateWindow(pScreen) - ScreenPtr pScreen; +AllocateWindow(ScreenPtr pScreen) { WindowPtr pWin; register char *ptr; register DevUnion *ppriv; register unsigned *sizes; register unsigned size; register int i; pWin = (WindowPtr)xalloc(pScreen->totalWindowSize); if (pWin) { ppriv = (DevUnion *)(pWin + 1); pWin->devPrivates = ppriv; sizes = pScreen->WindowPrivateSizes; ptr = (char *)(ppriv + pScreen->WindowPrivateLen); for (i = pScreen->WindowPrivateLen; --i >= 0; ppriv++, sizes++) { if ( (size = *sizes) ) { ppriv->ptr = (pointer)ptr; ptr += size; } else ppriv->ptr = (pointer)NULL; } } return pWin; } /***** * CreateRootWindow * Makes a window at initialization time for specified screen *****/ Bool -CreateRootWindow(pScreen) - ScreenPtr pScreen; +CreateRootWindow(ScreenPtr pScreen) { WindowPtr pWin; BoxRec box; PixmapFormatRec *format; pWin = AllocateWindow(pScreen); if (!pWin) return FALSE; savedScreenInfo[pScreen->myNum].pWindow = NULL; savedScreenInfo[pScreen->myNum].wid = FakeClientID(0); savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL; screenIsSaved = SCREEN_SAVER_OFF; WindowTable[pScreen->myNum] = pWin; pWin->drawable.pScreen = pScreen; pWin->drawable.type = DRAWABLE_WINDOW; pWin->drawable.depth = pScreen->rootDepth; @@ -472,128 +459,114 @@ #ifdef DO_SAVE_UNDERS if ((pScreen->backingStoreSupport != NotUseful) && (pScreen->saveUnderSupport == NotUseful)) { /* * If the screen has backing-store but no save-unders, let the * clients know we can support save-unders using backing-store. */ pScreen->saveUnderSupport = USE_DIX_SAVE_UNDERS; } #endif /* DO_SAVE_UNDERS */ if (disableSaveUnders) pScreen->saveUnderSupport = NotUseful; return TRUE; } void -InitRootWindow(pWin) - WindowPtr pWin; +InitRootWindow(WindowPtr pWin) { ScreenPtr pScreen = pWin->drawable.pScreen; if (!(*pScreen->CreateWindow)(pWin)) return; /* XXX */ (*pScreen->PositionWindow)(pWin, 0, 0); pWin->cursorIsNone = FALSE; pWin->optional->cursor = rootCursor; rootCursor->refcnt++; MakeRootTile(pWin); pWin->backingStore = defaultBackingStore; pWin->forcedBS = (defaultBackingStore != NotUseful); /* We SHOULD check for an error value here XXX */ (*pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap|CWBorderPixel|CWCursor|CWBackingStore); MapWindow(pWin, serverClient); } /* Set the region to the intersection of the rectangle and the * window's winSize. The window is typically the parent of the * window from which the region came. */ void -ClippedRegionFromBox(pWin, Rgn, x, y, w, h) - register WindowPtr pWin; - RegionPtr Rgn; - register int x, y; - int w, h; +ClippedRegionFromBox(register WindowPtr pWin, RegionPtr Rgn, + register int x, register int y, + register int w, register int h) { ScreenPtr pScreen = pWin->drawable.pScreen; BoxRec box; box = *(REGION_EXTENTS(pScreen, &pWin->winSize)); /* we do these calculations to avoid overflows */ if (x > box.x1) box.x1 = x; if (y > box.y1) box.y1 = y; x += w; if (x < box.x2) box.x2 = x; y += h; if (y < box.y2) box.y2 = y; if (box.x1 > box.x2) box.x2 = box.x1; if (box.y1 > box.y2) box.y2 = box.y1; REGION_RESET(pScreen, Rgn, &box); REGION_INTERSECT(pScreen, Rgn, Rgn, &pWin->winSize); } WindowPtr -RealChildHead(pWin) - register WindowPtr pWin; +RealChildHead(register WindowPtr pWin) { if (!pWin->parent && (screenIsSaved == SCREEN_SAVER_ON) && (HasSaverWindow (pWin->drawable.pScreen->myNum))) return (pWin->firstChild); else return (NullWindow); } /***** * CreateWindow * Makes a window in response to client request *****/ WindowPtr -CreateWindow(wid, pParent, x, y, w, h, bw, class, vmask, vlist, - depth, client, visual, error) - Window wid; - register WindowPtr pParent; - int x,y; - unsigned int w, h, bw; - unsigned int class; - register Mask vmask; - XID *vlist; - int depth; - ClientPtr client; - VisualID visual; - int *error; +CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, + unsigned h, unsigned bw, unsigned class, register Mask vmask, XID *vlist, + int depth, ClientPtr client, VisualID visual, int *error) { register WindowPtr pWin; WindowPtr pHead; register ScreenPtr pScreen; xEvent event; int idepth, ivisual; Bool fOK; DepthPtr pDepth; PixmapFormatRec *format; register WindowOptPtr ancwopt; if (class == CopyFromParent) class = pParent->drawable.class; if ((class != InputOutput) && (class != InputOnly)) { *error = BadValue; client->errorValue = class; return NullWindow; } @@ -879,114 +852,104 @@ } FreeWindowResources(pChild); xfree(pChild); if ( (pChild = pSib) ) break; pChild = pParent; pChild->firstChild = NullWindow; pChild->lastChild = NullWindow; if (pChild == pWin) return; } } } /***** * DeleteWindow * Deletes child of window then window itself * If wid is None, don't send any events *****/ -/*ARGSUSED*/ int -DeleteWindow(value, wid) - pointer value; - XID wid; +DeleteWindow(pointer value, XID wid) { register WindowPtr pParent; register WindowPtr pWin = (WindowPtr)value; xEvent event; UnmapWindow(pWin, FALSE); CrushTree(pWin); pParent = pWin->parent; if (wid && pParent && SubStrSend(pWin, pParent)) { event.u.u.type = DestroyNotify; event.u.destroyNotify.window = pWin->drawable.id; DeliverEvents(pWin, &event, 1, NullWindow); } FreeWindowResources(pWin); if (pParent) { if (pParent->firstChild == pWin) pParent->firstChild = pWin->nextSib; if (pParent->lastChild == pWin) pParent->lastChild = pWin->prevSib; if (pWin->nextSib) pWin->nextSib->prevSib = pWin->prevSib; if (pWin->prevSib) pWin->prevSib->nextSib = pWin->nextSib; } xfree(pWin); return Success; } -/*ARGSUSED*/ void -DestroySubwindows(pWin, client) - register WindowPtr pWin; - ClientPtr client; +DestroySubwindows(register WindowPtr pWin, ClientPtr client) { /* XXX * The protocol is quite clear that each window should be * destroyed in turn, however, unmapping all of the first * eliminates most of the calls to ValidateTree. So, * this implementation is incorrect in that all of the * UnmapNotifies occur before all of the DestroyNotifies. * If you care, simply delete the call to UnmapSubwindows. */ UnmapSubwindows(pWin); while (pWin->lastChild) FreeResource(pWin->lastChild->drawable.id, RT_NONE); } #define DeviceEventMasks (KeyPressMask | KeyReleaseMask | ButtonPressMask | \ ButtonReleaseMask | PointerMotionMask) /***** * ChangeWindowAttributes * * The value-mask specifies which attributes are to be changed; the * value-list contains one value for each one bit in the mask, from least * to most significant bit in the mask. *****/ int -ChangeWindowAttributes(pWin, vmask, vlist, client) - register WindowPtr pWin; - Mask vmask; - XID *vlist; - ClientPtr client; +ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client) { register Mask index2; register XID *pVlist; PixmapPtr pPixmap; Pixmap pixID; CursorPtr pCursor, pOldCursor; Cursor cursorID; WindowPtr pChild; Colormap cmap; ColormapPtr pCmap; xEvent xE; int result; register ScreenPtr pScreen; Mask vmaskCopy = 0; register Mask tmask; unsigned int val; int error; Bool checkOptional = FALSE; Bool borderRelative = FALSE; WindowPtr pLayerWin; @@ -1492,81 +1455,77 @@ if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative) && pWin->viewable && HasBorder (pWin)) { RegionRec exposed; REGION_NULL(pScreen, &exposed); REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize); (*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER); REGION_UNINIT(pScreen, &exposed); } return error; } /***** * GetWindowAttributes * Notice that this is different than ChangeWindowAttributes *****/ void -GetWindowAttributes(pWin, client, wa) - register WindowPtr pWin; - ClientPtr client; - xGetWindowAttributesReply *wa; +GetWindowAttributes(register WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply *wa) { wa->type = X_Reply; wa->bitGravity = pWin->bitGravity; wa->winGravity = pWin->winGravity; if (pWin->forcedBS && pWin->backingStore != Always) wa->backingStore = NotUseful; else wa->backingStore = pWin->backingStore; wa->length = (sizeof(xGetWindowAttributesReply) - sizeof(xGenericReply)) >> 2; wa->sequenceNumber = client->sequence; wa->backingBitPlanes = wBackingBitPlanes (pWin); wa->backingPixel = wBackingPixel (pWin); wa->saveUnder = (BOOL)pWin->saveUnder; wa->override = pWin->overrideRedirect; if (!pWin->mapped) wa->mapState = IsUnmapped; else if (pWin->realized) wa->mapState = IsViewable; else wa->mapState = IsUnviewable; wa->colormap = wColormap (pWin); wa->mapInstalled = (wa->colormap == None) ? xFalse : IsMapInstalled(wa->colormap, pWin); wa->yourEventMask = EventMaskForClient(pWin, client); wa->allEventMasks = pWin->eventMask | wOtherEventMasks (pWin); wa->doNotPropagateMask = wDontPropagateMask (pWin); wa->class = pWin->drawable.class; wa->visualID = wVisual (pWin); } WindowPtr -MoveWindowInStack(pWin, pNextSib) - register WindowPtr pWin, pNextSib; +MoveWindowInStack(register WindowPtr pWin, register WindowPtr pNextSib) { register WindowPtr pParent = pWin->parent; WindowPtr pFirstChange = pWin; /* highest window where list changes */ if (pWin->nextSib != pNextSib) { WindowPtr pOldNextSib = pWin->nextSib; if (!pNextSib) /* move to bottom */ { if (pParent->firstChild == pWin) pParent->firstChild = pWin->nextSib; /* if (pWin->nextSib) */ /* is always True: pNextSib == NULL * and pWin->nextSib != pNextSib * therefore pWin->nextSib != NULL */ pFirstChange = pWin->nextSib; pWin->nextSib->prevSib = pWin->prevSib; if (pWin->prevSib) pWin->prevSib->nextSib = pWin->nextSib; pParent->lastChild->nextSib = pWin; @@ -1616,109 +1575,106 @@ } if(pWin->drawable.pScreen->RestackWindow) (*pWin->drawable.pScreen->RestackWindow)(pWin, pOldNextSib); } #ifdef ROOTLESS /* * In rootless mode we can't optimize away window restacks. * There may be non-X windows around, so even if the window * is in the correct position from X's point of view, * the underlying window system may want to reorder it. */ else if (pWin->drawable.pScreen->RestackWindow) (*pWin->drawable.pScreen->RestackWindow)(pWin, pWin->nextSib); #endif return( pFirstChange ); } RegionPtr -CreateUnclippedWinSize (pWin) - register WindowPtr pWin; +CreateUnclippedWinSize (register WindowPtr pWin) { RegionPtr pRgn; BoxRec box; box.x1 = pWin->drawable.x; box.y1 = pWin->drawable.y; box.x2 = pWin->drawable.x + (int) pWin->drawable.width; box.y2 = pWin->drawable.y + (int) pWin->drawable.height; pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1); #ifdef SHAPE if (wBoundingShape (pWin) || wClipShape (pWin)) { ScreenPtr pScreen = pWin->drawable.pScreen; REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x, - pWin->drawable.y); if (wBoundingShape (pWin)) REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin)); if (wClipShape (pWin)) REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin)); REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y); } #endif return pRgn; } void -SetWinSize (pWin) - register WindowPtr pWin; +SetWinSize (register WindowPtr pWin) { #ifdef COMPOSITE if (pWin->redirectDraw) { BoxRec box; box.x1 = pWin->drawable.x; box.y1 = pWin->drawable.y; box.x2 = pWin->drawable.x + pWin->drawable.width; box.y2 = pWin->drawable.y + pWin->drawable.height; REGION_RESET (pScreen, &pWin->winSize, &box); } else #endif ClippedRegionFromBox(pWin->parent, &pWin->winSize, pWin->drawable.x, pWin->drawable.y, (int)pWin->drawable.width, (int)pWin->drawable.height); #ifdef SHAPE if (wBoundingShape (pWin) || wClipShape (pWin)) { ScreenPtr pScreen = pWin->drawable.pScreen; REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x, - pWin->drawable.y); if (wBoundingShape (pWin)) REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize, wBoundingShape (pWin)); if (wClipShape (pWin)) REGION_INTERSECT(pScreen, &pWin->winSize, &pWin->winSize, wClipShape (pWin)); REGION_TRANSLATE(pScreen, &pWin->winSize, pWin->drawable.x, pWin->drawable.y); } #endif } void -SetBorderSize (pWin) - register WindowPtr pWin; +SetBorderSize (register WindowPtr pWin) { int bw; if (HasBorder (pWin)) { bw = wBorderWidth (pWin); #ifdef COMPOSITE if (pWin->redirectDraw) { BoxRec box; box.x1 = pWin->drawable.x - bw; box.y1 = pWin->drawable.y - bw; box.x2 = pWin->drawable.x + pWin->drawable.width + bw; box.y2 = pWin->drawable.y + pWin->drawable.height + bw; REGION_RESET (pScreen, &pWin->borderSize, &box); } else #endif ClippedRegionFromBox(pWin->parent, &pWin->borderSize, pWin->drawable.x - bw, pWin->drawable.y - bw, @@ -1727,47 +1683,51 @@ #ifdef SHAPE if (wBoundingShape (pWin)) { ScreenPtr pScreen = pWin->drawable.pScreen; REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x, - pWin->drawable.y); REGION_INTERSECT(pScreen, &pWin->borderSize, &pWin->borderSize, wBoundingShape (pWin)); REGION_TRANSLATE(pScreen, &pWin->borderSize, pWin->drawable.x, pWin->drawable.y); REGION_UNION(pScreen, &pWin->borderSize, &pWin->borderSize, &pWin->winSize); } #endif } else { REGION_COPY(pWin->drawable.pScreen, &pWin->borderSize, &pWin->winSize); } } +/** + * + * \param x,y new window position + * \param oldx,oldy old window position + * \param destx,desty position relative to gravity + */ + void -GravityTranslate (x, y, oldx, oldy, dw, dh, gravity, destx, desty) - register int x, y; /* new window position */ - int oldx, oldy; /* old window position */ - int dw, dh; - unsigned gravity; - register int *destx, *desty; /* position relative to gravity */ +GravityTranslate (register int x, register int y, int oldx, int oldy, + int dw, int dh, unsigned gravity, + register int *destx, register int *desty) { switch (gravity) { case NorthGravity: *destx = x + dw / 2; *desty = y; break; case NorthEastGravity: *destx = x + dw; *desty = y; break; case WestGravity: *destx = x; *desty = y + dh / 2; break; case CenterGravity: *destx = x + dw / 2; *desty = y + dh / 2; break; case EastGravity: *destx = x + dw; @@ -1781,43 +1741,41 @@ *destx = x + dw / 2; *desty = y + dh; break; case SouthEastGravity: *destx = x + dw; *desty = y + dh; break; case StaticGravity: *destx = oldx; *desty = oldy; break; default: *destx = x; *desty = y; break; } } /* XXX need to retile border on each window with ParentRelative origin */ void -ResizeChildrenWinSize(pWin, dx, dy, dw, dh) - register WindowPtr pWin; - int dx, dy, dw, dh; +ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) { register ScreenPtr pScreen; register WindowPtr pSib, pChild; Bool resized = (dw || dh); pScreen = pWin->drawable.pScreen; for (pSib = pWin->firstChild; pSib; pSib = pSib->nextSib) { if (resized && (pSib->winGravity > NorthWestGravity)) { int cwsx, cwsy; cwsx = pSib->origin.x; cwsy = pSib->origin.y; GravityTranslate (cwsx, cwsy, cwsx - dx, cwsy - dy, dw, dh, pSib->winGravity, &cwsx, &cwsy); if (cwsx != pSib->origin.x || cwsy != pSib->origin.y) { xEvent event; @@ -2195,45 +2153,41 @@ { (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind); (*pScreen->HandleExposures)(pLayerWin->parent); } #ifdef DO_SAVE_UNDERS if (dosave) (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange); #endif /* DO_SAVE_UNDERS */ if (anyMarked && pWin->drawable.pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind); } if (pWin->realized) WindowsRestructured (); } /***** * ConfigureWindow *****/ int -ConfigureWindow(pWin, mask, vlist, client) - register WindowPtr pWin; - register Mask mask; - XID *vlist; - ClientPtr client; +ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientPtr client) { #define RESTACK_WIN 0 #define MOVE_WIN 1 #define RESIZE_WIN 2 #define REBORDER_WIN 3 register WindowPtr pSib = NullWindow; register WindowPtr pParent = pWin->parent; Window sibwid = 0; Mask index2, tmask; register XID *pVlist; short x, y, beforeX, beforeY; unsigned short w = pWin->drawable.width, h = pWin->drawable.height, bw = pWin->borderWidth; int action, smode = Above; #ifdef XAPPGROUP ClientPtr win_owner; ClientPtr ag_leader = NULL; #endif xEvent event; @@ -2484,44 +2438,41 @@ CheckCursorConfinement(pWin); return(Success); #undef RESTACK_WIN #undef MOVE_WIN #undef RESIZE_WIN #undef REBORDER_WIN } /****** * * CirculateWindow * For RaiseLowest, raises the lowest mapped child (if any) that is * obscured by another child to the top of the stack. For LowerHighest, * lowers the highest mapped child (if any) that is obscuring another * child to the bottom of the stack. Exposure processing is performed * ******/ int -CirculateWindow(pParent, direction, client) - WindowPtr pParent; - int direction; - ClientPtr client; +CirculateWindow(WindowPtr pParent, int direction, ClientPtr client) { register WindowPtr pWin, pHead, pFirst; xEvent event; BoxRec box; pHead = RealChildHead(pParent); pFirst = pHead ? pHead->nextSib : pParent->firstChild; if (direction == RaiseLowest) { for (pWin = pParent->lastChild; (pWin != pHead) && !(pWin->mapped && AnyWindowOverlapsMe(pWin, pHead, WindowExtents(pWin, &box))); pWin = pWin->prevSib) ; if (pWin == pHead) return Success; } else { for (pWin = pFirst; @@ -2559,44 +2510,42 @@ } static int CompareWIDs( WindowPtr pWin, pointer value) /* must conform to VisitWindowProcPtr */ { Window *wid = (Window *)value; if (pWin->drawable.id == *wid) return(WT_STOPWALKING); else return(WT_WALKCHILDREN); } /***** * ReparentWindow *****/ int -ReparentWindow(pWin, pParent, x, y, client) - register WindowPtr pWin, pParent; - int x,y; - ClientPtr client; +ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, + int x, int y, ClientPtr client) { WindowPtr pPrev, pPriorParent; Bool WasMapped = (Bool)(pWin->mapped); xEvent event; int bw = wBorderWidth (pWin); register ScreenPtr pScreen; pScreen = pWin->drawable.pScreen; if (TraverseTree(pWin, CompareWIDs, (pointer)&pParent->drawable.id) == WT_STOPWALKING) return(BadMatch); if (!MakeWindowOptional(pWin)) return(BadAlloc); if (WasMapped) UnmapWindow(pWin, FALSE); event.u.u.type = ReparentNotify; event.u.reparent.window = pWin->drawable.id; event.u.reparent.parent = pParent->drawable.id; event.u.reparent.x = x; @@ -2694,43 +2643,41 @@ continue; } } while (!pChild->nextSib && (pChild != pWin)) pChild = pChild->parent; if (pChild == pWin) return; pChild = pChild->nextSib; } } /***** * MapWindow * If some other client has selected SubStructureReDirect on the parent * and override-redirect is xFalse, then a MapRequest event is generated, * but the window remains unmapped. Otherwise, the window is mapped and a * MapNotify event is generated. *****/ int -MapWindow(pWin, client) - register WindowPtr pWin; - ClientPtr client; +MapWindow(register WindowPtr pWin, ClientPtr client) { register ScreenPtr pScreen; register WindowPtr pParent; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif WindowPtr pLayerWin; if (pWin->mapped) return(Success); #ifdef XCSECURITY /* don't let an untrusted client map a child-of-trusted-window, InputOnly * window; too easy to steal device input */ if ( (client->trustLevel != XSecurityClientTrusted) && (pWin->drawable.class == InputOnly) && (wClient(pWin->parent)->trustLevel == XSecurityClientTrusted) ) return Success; @@ -2822,43 +2769,41 @@ (*pScreen->ClipNotify) (pWin, 0, 0); if (pScreen->PostValidateTree) (*pScreen->PostValidateTree)(NullWindow, pWin, VTMap); REGION_NULL(pScreen, &temp); REGION_COPY(pScreen, &temp, &pWin->clipList); (*pScreen->WindowExposures) (pWin, &temp, NullRegion); REGION_UNINIT(pScreen, &temp); } return(Success); } /***** * MapSubwindows * Performs a MapWindow all unmapped children of the window, in top * to bottom stacking order. *****/ void -MapSubwindows(pParent, client) - register WindowPtr pParent; - ClientPtr client; +MapSubwindows(register WindowPtr pParent, ClientPtr client) { register WindowPtr pWin; WindowPtr pFirstMapped = NullWindow; #ifdef DO_SAVE_UNDERS WindowPtr pFirstSaveUndered = NullWindow; #endif register ScreenPtr pScreen; register Mask parentRedirect; register Mask parentNotify; xEvent event; Bool anyMarked; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif WindowPtr pLayerWin; pScreen = pParent->drawable.pScreen; parentRedirect = RedirectSend(pParent); parentNotify = SubSend(pParent); anyMarked = FALSE; @@ -3003,43 +2948,41 @@ pChild = pChild->firstChild; continue; } } while (!pChild->nextSib && (pChild != pWin)) pChild = pChild->parent; if (pChild == pWin) return; pChild = pChild->nextSib; } } /***** * UnmapWindow * If the window is already unmapped, this request has no effect. * Otherwise, the window is unmapped and an UnMapNotify event is * generated. Cannot unmap a root window. *****/ int -UnmapWindow(pWin, fromConfigure) - register WindowPtr pWin; - Bool fromConfigure; +UnmapWindow(register WindowPtr pWin, Bool fromConfigure) { register WindowPtr pParent; xEvent event; Bool wasRealized = (Bool)pWin->realized; Bool wasViewable = (Bool)pWin->viewable; ScreenPtr pScreen = pWin->drawable.pScreen; WindowPtr pLayerWin = pWin; if ((!pWin->mapped) || (!(pParent = pWin->parent))) return(Success); if (SubStrSend(pWin, pParent)) { event.u.u.type = UnmapNotify; event.u.unmapNotify.window = pWin->drawable.id; event.u.unmapNotify.fromConfigure = fromConfigure; DeliverEvents(pWin, &event, 1, NullWindow); } if (wasViewable && !fromConfigure) { pWin->valdata = UnmapValData; @@ -3064,42 +3007,41 @@ (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); } } pWin->DIXsaveUnder = FALSE; #endif /* DO_SAVE_UNDERS */ if (!fromConfigure && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap); } if (wasRealized && !fromConfigure) WindowsRestructured (); return(Success); } /***** * UnmapSubwindows * Performs an UnmapWindow request with the specified mode on all mapped * children of the window, in bottom to top stacking order. *****/ void -UnmapSubwindows(pWin) - register WindowPtr pWin; +UnmapSubwindows(register WindowPtr pWin) { register WindowPtr pChild, pHead; xEvent event; Bool wasRealized = (Bool)pWin->realized; Bool wasViewable = (Bool)pWin->viewable; Bool anyMarked = FALSE; Mask parentNotify; WindowPtr pLayerWin = NULL; ScreenPtr pScreen = pWin->drawable.pScreen; if (!pWin->firstChild) return; parentNotify = SubSend(pWin); pHead = RealChildHead(pWin); if (wasViewable) pLayerWin = (*pScreen->GetLayerWindow)(pWin); for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) { @@ -3156,131 +3098,132 @@ } (*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap); (*pScreen->HandleExposures)(pLayerWin->parent); } #ifdef DO_SAVE_UNDERS if (DO_SAVE_UNDERS(pWin)) { if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin)) (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); } #endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap); } if (wasRealized) WindowsRestructured (); } void -HandleSaveSet(client) - register ClientPtr client; +HandleSaveSet(register ClientPtr client) { register WindowPtr pParent, pWin; register int j; for (j=0; jnumSaved; j++) { pWin = SaveSetWindow(client->saveSet[j]); #ifdef XFIXES if (SaveSetToRoot(client->saveSet[j])) pParent = WindowTable[pWin->drawable.pScreen->myNum]; else #endif { pParent = pWin->parent; while (pParent && (wClient (pParent) == client)) pParent = pParent->parent; } if (pParent) { if (pParent != pWin->parent) { ReparentWindow(pWin, pParent, pWin->drawable.x - wBorderWidth (pWin) - pParent->drawable.x, pWin->drawable.y - wBorderWidth (pWin) - pParent->drawable.y, client); if(!pWin->realized && pWin->mapped) pWin->mapped = FALSE; } #ifdef XFIXES if (SaveSetRemap (client->saveSet[j])) #endif MapWindow(pWin, client); } } xfree(client->saveSet); client->numSaved = 0; client->saveSet = (SaveSetElt *)NULL; } +/** + * + * \param x,y in root + * \param box "return" value + */ Bool -VisibleBoundingBoxFromPoint(pWin, x, y, box) - register WindowPtr pWin; - int x, y; /* in root */ - BoxPtr box; /* "return" value */ +VisibleBoundingBoxFromPoint(register WindowPtr pWin, int x, int y, BoxPtr box) { if (!pWin->realized) return (FALSE); if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->clipList, x, y, box)) return(TRUE); return(FALSE); } +/** + * + * \param x,y in root + */ Bool -PointInWindowIsVisible(pWin, x, y) - register WindowPtr pWin; - int x, y; /* in root */ +PointInWindowIsVisible(register WindowPtr pWin, int x, int y) { BoxRec box; if (!pWin->realized) return (FALSE); if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderClip, x, y, &box)) return(TRUE); return(FALSE); } RegionPtr -NotClippedByChildren(pWin) - register WindowPtr pWin; +NotClippedByChildren(register WindowPtr pWin) { register ScreenPtr pScreen; RegionPtr pReg; pScreen = pWin->drawable.pScreen; pReg = REGION_CREATE(pScreen, NullBox, 1); if (pWin->parent || screenIsSaved != SCREEN_SAVER_ON || !HasSaverWindow (pWin->drawable.pScreen->myNum)) { REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize); } return(pReg); } void -SendVisibilityNotify(pWin) - WindowPtr pWin; +SendVisibilityNotify(WindowPtr pWin) { xEvent event; #ifndef NO_XINERAMA_PORT unsigned int visibility = pWin->visibility; #endif #ifdef PANORAMIX /* This is not quite correct yet, but it's close */ if(!noPanoramiXExtension) { PanoramiXRes *win; WindowPtr pWin2; int i, Scrnum; Scrnum = pWin->drawable.pScreen->myNum; win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, Scrnum); if(!win || (win->u.win.visibility == visibility)) return; switch(visibility) { @@ -3318,48 +3261,46 @@ } } break; } win->u.win.visibility = visibility; } #endif event.u.u.type = VisibilityNotify; event.u.visibility.window = pWin->drawable.id; event.u.visibility.state = visibility; DeliverEvents(pWin, &event, 1, NullWindow); } #define RANDOM_WIDTH 32 #ifndef NOLOGOHACK static void DrawLogo( - WindowPtr /*pWin*/ + WindowPtr pWin ); #endif void -SaveScreens(on, mode) - int on; - int mode; +SaveScreens(int on, int mode) { int i; int what; int type; if (on == SCREEN_SAVER_FORCER) { UpdateCurrentTimeIf(); lastDeviceEventTime = currentTime; if (mode == ScreenSaverReset) what = SCREEN_SAVER_OFF; else what = SCREEN_SAVER_ON; type = what; } else { what = on; type = what; if (what == screenIsSaved) @@ -3556,60 +3497,58 @@ MakeRootTile (pWin); (*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap); } MapWindow(pWin, serverClient); #ifndef NOLOGOHACK if (kind == SCREEN_IS_TILED && logoScreenSaver) DrawLogo(pWin); #endif return TRUE; } /* * FindWindowWithOptional * * search ancestors of the given window for an entry containing * a WindowOpt structure. Assumptions: some parent will * contain the structure. */ WindowPtr -FindWindowWithOptional (w) - register WindowPtr w; +FindWindowWithOptional (register WindowPtr w) { do w = w->parent; while (!w->optional); return w; } /* * CheckWindowOptionalNeed * * check each optional entry in the given window to see if * the value is satisfied by the default rules. If so, * release the optional record */ void -CheckWindowOptionalNeed (w) - register WindowPtr w; +CheckWindowOptionalNeed (register WindowPtr w) { register WindowOptPtr optional; register WindowOptPtr parentOptional; if (!w->parent) return; optional = w->optional; if (optional->dontPropagateMask != DontPropagateMasks[w->dontPropagate]) return; if (optional->otherEventMasks != 0) return; if (optional->otherClients != NULL) return; if (optional->passiveGrabs != NULL) return; if (optional->userProps != NULL) return; if (optional->backingBitPlanes != ~0L) return; if (optional->backingPixel != 0) @@ -3627,84 +3566,82 @@ parentOptional = FindWindowWithOptional(w)->optional; if (optional->visual != parentOptional->visual) return; if (optional->cursor != None && (optional->cursor != parentOptional->cursor || w->parent->cursorIsNone)) return; if (optional->colormap != parentOptional->colormap) return; DisposeWindowOptional (w); } /* * MakeWindowOptional * * create an optional record and initialize it with the default * values. */ Bool -MakeWindowOptional (pWin) - register WindowPtr pWin; +MakeWindowOptional (register WindowPtr pWin) { register WindowOptPtr optional; register WindowOptPtr parentOptional; if (pWin->optional) return TRUE; optional = (WindowOptPtr) xalloc (sizeof (WindowOptRec)); if (!optional) return FALSE; optional->dontPropagateMask = DontPropagateMasks[pWin->dontPropagate]; optional->otherEventMasks = 0; optional->otherClients = NULL; optional->passiveGrabs = NULL; optional->userProps = NULL; optional->backingBitPlanes = ~0L; optional->backingPixel = 0; #ifdef SHAPE optional->boundingShape = NULL; optional->clipShape = NULL; #endif #ifdef XINPUT optional->inputMasks = NULL; #endif parentOptional = FindWindowWithOptional(pWin)->optional; optional->visual = parentOptional->visual; if (!pWin->cursorIsNone) { optional->cursor = parentOptional->cursor; optional->cursor->refcnt++; } else { optional->cursor = None; } optional->colormap = parentOptional->colormap; pWin->optional = optional; return TRUE; } void -DisposeWindowOptional (pWin) - register WindowPtr pWin; +DisposeWindowOptional (register WindowPtr pWin) { if (!pWin->optional) return; /* * everything is peachy. Delete the optional record * and clean up */ /* * TOG changed this code to: * * if (pWin->cursorIsNone == FALSE) * FreeCursor (pWin->optional->cursor, (Cursor)0); * pWin->cursorIsNone = TRUE; * * This is blatently wrong; windows without optionals can have * two different cursor values, either None or sharing their * parents cursor. This difference is controlled by the * cursorIsNone value; when TRUE, the window has no cursor, * when false, it shares its cursor with its parent; TOG * made it impossible for a window to have a cursor without