diff options
author | Mihai Moldovan <ionic@ionic.de> | 2016-06-25 01:35:40 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2016-06-25 01:35:40 +0200 |
commit | 975511c875674f097bbd2be33fa947a48d8c77c6 (patch) | |
tree | 207bba2c48054f551f19ed5aa89b9dd9616b8c60 /nx-X11/programs/Xserver/hw | |
parent | 9df153668423af868d0df739188a772fbc3356c6 (diff) | |
parent | a5befd4e20813910022ed771cb599f15bbf4664d (diff) | |
download | nx-libs-975511c875674f097bbd2be33fa947a48d8c77c6.tar.gz nx-libs-975511c875674f097bbd2be33fa947a48d8c77c6.tar.bz2 nx-libs-975511c875674f097bbd2be33fa947a48d8c77c6.zip |
Merge branch 'sunweaver-pr/hw-nxagent-drop-duplicate-Xserver-code_disable-Xserver-code-and-include-in-nxagent' into arctica-3.6.x
Attributes GH PR #120: https://github.com/ArcticaProject/nx-libs/pull/120
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
33 files changed, 502 insertions, 25960 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Composite.c b/nx-X11/programs/Xserver/hw/nxagent/Composite.c index d6239d619..cf736f6c0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Composite.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Composite.c @@ -24,7 +24,7 @@ #include "Options.h" #include "Windows.h" -#include "NXcomposite.h" +#include "X11/include/Xcomposite_nxagent.h" /* * Set here the required log level. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index 121a1c774..905bfa92f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -23,7 +23,6 @@ SRCS = NXwindow.c \ NXmiglyph.c \ NXmiexpose.c \ NXresource.c \ - NXmiwindow.c \ NXdamage.c \ NXmitrap.c \ Args.c \ @@ -85,7 +84,6 @@ OBJS = NXwindow.o \ NXmiglyph.o \ NXmiexpose.o \ NXresource.o \ - NXmiwindow.o \ NXdamage.o \ NXmitrap.o \ Args.o \ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXcomposite.h b/nx-X11/programs/Xserver/hw/nxagent/NXcomposite.h deleted file mode 100644 index 5887ab24b..000000000 --- a/nx-X11/programs/Xserver/hw/nxagent/NXcomposite.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * $Id: Xcomposite.h,v 1.3 2005/07/03 07:00:56 daniels Exp $ - * - * Copyright © 2003 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _XCOMPOSITE_H_ -#define _XCOMPOSITE_H_ - -#ifdef NXAGENT_SERVER - -#define XserverRegion XID - -#include "NXcompositeext.h" - -#else - -#include <nx-X11/extensions/composite.h> -#include "X11/include/Xfixes_nxagent.h" - -#endif - -#include <nx-X11/Xfuncproto.h> - -/* - * This revision number also appears in configure.ac, they have - * to be manually synchronized - */ -#define XCOMPOSITE_MAJOR COMPOSITE_MAJOR -#define XCOMPOSITE_MINOR COMPOSITE_MINOR -#define XCOMPOSITE_REVISION 0 -#define XCOMPOSITE_VERSION ((XCOMPOSITE_MAJOR * 10000) + (XCOMPOSITE_MINOR * 100) + (XCOMPOSITE_REVISION)) - -_XFUNCPROTOBEGIN - -Bool XCompositeQueryExtension (Display *dpy, int *event_basep, int *error_basep); - -Status XCompositeQueryVersion (Display *dpy, - int *major_versionp, - int *minor_versionp); - -int XCompositeVersion (void); - -void -XCompositeRedirectWindow (Display *dpy, Window window, int update); - -void -XCompositeRedirectSubwindows (Display *dpy, Window window, int update); - -void -XCompositeUnredirectWindow (Display *dpy, Window window, int update); - -void -XCompositeUnredirectSubwindows (Display *dpy, Window window, int update); - -XserverRegion -XCompositeCreateRegionFromBorderClip (Display *dpy, Window window); - -Pixmap -XCompositeNameWindowPixmap (Display *dpy, Window window); - -_XFUNCPROTOEND - -#endif /* _XCOMPOSITE_H_ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXcompositeext.h b/nx-X11/programs/Xserver/hw/nxagent/NXcompositeext.h deleted file mode 100644 index 38ac87e9b..000000000 --- a/nx-X11/programs/Xserver/hw/nxagent/NXcompositeext.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * $Id: composite.h,v 1.4 2004/07/08 07:20:55 keithp Exp $ - * - * Copyright © 2003 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _COMPOSITE_H_ -#define _COMPOSITE_H_ - -#ifndef NXAGENT_SERVER - -#include <nx-X11/extensions/xfixeswire.h> - -#endif - -#define COMPOSITE_NAME "Composite" -#define COMPOSITE_MAJOR 0 -#define COMPOSITE_MINOR 4 - -#define CompositeRedirectAutomatic 0 -#define CompositeRedirectManual 1 - -#define X_CompositeQueryVersion 0 -#define X_CompositeRedirectWindow 1 -#define X_CompositeRedirectSubwindows 2 -#define X_CompositeUnredirectWindow 3 -#define X_CompositeUnredirectSubwindows 4 -#define X_CompositeCreateRegionFromBorderClip 5 -#define X_CompositeNameWindowPixmap 6 -#define X_CompositeGetOverlayWindow 7 -#define X_CompositeReleaseOverlayWindow 8 - -#define CompositeNumberRequests (X_CompositeReleaseOverlayWindow + 1) - -#define CompositeNumberEvents 0 - -#endif /* _COMPOSITE_H_ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c b/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c index 278e0727c..1e38722ce 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c @@ -39,1307 +39,51 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#include "scrnintstr.h" -#include "windowstr.h" -#include <X11/fonts/font.h> -#include "dixfontstr.h" -#include <X11/fonts/fontstruct.h> -#include "mi.h" -#include "regionstr.h" -#include "globals.h" -#include "gcstruct.h" -#include "damage.h" -#include "damagestr.h" -#ifdef COMPOSITE -#include "cw.h" -#endif - -#define wrap(priv, real, mem, func) {\ - priv->mem = real->mem; \ - real->mem = func; \ -} - -#define unwrap(priv, real, mem) {\ - real->mem = priv->mem; \ -} - -#define BOX_SAME(a,b) \ - ((a)->x1 == (b)->x1 && \ - (a)->y1 == (b)->y1 && \ - (a)->x2 == (b)->x2 && \ - (a)->y2 == (b)->y2) - -#define DAMAGE_VALIDATE_ENABLE 0 -#define DAMAGE_DEBUG_ENABLE 0 -#if DAMAGE_DEBUG_ENABLE -#define DAMAGE_DEBUG(x) ErrorF x -#else -#define DAMAGE_DEBUG(x) -#endif - -#define getPixmapDamageRef(pPixmap) \ - ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr)) - -#define pixmapDamage(pPixmap) damagePixPriv(pPixmap) - -static DamagePtr * -getDrawableDamageRef (DrawablePtr pDrawable) -{ - PixmapPtr pPixmap; - - if (pDrawable->type == DRAWABLE_WINDOW) - { - ScreenPtr pScreen = pDrawable->pScreen; - - pPixmap = 0; - if (pScreen->GetWindowPixmap -#ifdef ROOTLESS_WORKAROUND - && ((WindowPtr)pDrawable)->viewable -#endif - ) - pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr)pDrawable); - - if (!pPixmap) - { - damageScrPriv(pScreen); - - return &pScrPriv->pScreenDamage; - } - } - else - pPixmap = (PixmapPtr) pDrawable; - return getPixmapDamageRef (pPixmap); -} - -#define getDrawableDamage(pDrawable) (*getDrawableDamageRef (pDrawable)) -#define getWindowDamage(pWin) getDrawableDamage(&(pWin)->drawable) - -#define drawableDamage(pDrawable) \ - DamagePtr pDamage = getDrawableDamage(pDrawable) - -#define windowDamage(pWin) drawableDamage(&(pWin)->drawable) - -#define winDamageRef(pWindow) \ - DamagePtr *pPrev = (DamagePtr *) \ - &(pWindow->devPrivates[damageWinPrivateIndex].ptr) - -#if DAMAGE_DEBUG_ENABLE -static void -_damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where) -#define damageDamageRegion(d,r,c,m) _damageDamageRegion(d,r,c,m,__FUNCTION__) -#else -static void -damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, - int subWindowMode) -#endif -{ - ScreenPtr pScreen = pDrawable->pScreen; - damageScrPriv(pScreen); - drawableDamage(pDrawable); - DamagePtr pNext; - RegionRec clippedRec; - RegionPtr pDamageRegion; - RegionRec pixClip; - Bool was_empty; - RegionRec tmpRegion; - BoxRec tmpBox; - int draw_x, draw_y; -#ifdef COMPOSITE - int screen_x = 0, screen_y = 0; -#endif - - /* short circuit for empty regions */ - if (!RegionNotEmpty(pRegion)) - return; - -#ifdef COMPOSITE - /* - * When drawing to a pixmap which is storing window contents, - * the region presented is in pixmap relative coordinates which - * need to be converted to screen relative coordinates - */ - if (pDrawable->type != DRAWABLE_WINDOW) - { - screen_x = ((PixmapPtr) pDrawable)->screen_x - pDrawable->x; - screen_y = ((PixmapPtr) pDrawable)->screen_y - pDrawable->y; - } - if (screen_x || screen_y) - RegionTranslate(pRegion, screen_x, screen_y); -#endif - - if (pDrawable->type == DRAWABLE_WINDOW && - ((WindowPtr)(pDrawable))->backingStore == NotUseful) - { - if (subWindowMode == ClipByChildren) - { - RegionIntersect(pRegion, pRegion, - &((WindowPtr)(pDrawable))->clipList); - } - else if (subWindowMode == IncludeInferiors) - { - RegionPtr pTempRegion = - NotClippedByChildren((WindowPtr)(pDrawable)); - RegionIntersect(pRegion, pRegion, pTempRegion); - RegionDestroy(pTempRegion); - } - /* If subWindowMode is set to an invalid value, don't perform - * any drawable-based clipping. */ - } - - - RegionNull(&clippedRec); - for (; pDamage; pDamage = pNext) - { - pNext = pDamage->pNext; - /* - * Check for internal damage and don't send events - */ - if (pScrPriv->internalLevel > 0 && !pDamage->isInternal) - { - DAMAGE_DEBUG (("non internal damage, skipping at %d\n", - pScrPriv->internalLevel)); - continue; - } - /* - * Check for unrealized windows - */ - if (pDamage->pDrawable->type == DRAWABLE_WINDOW && - !((WindowPtr) (pDamage->pDrawable))->realized) - { -#if 0 - DAMAGE_DEBUG (("damage while window unrealized\n")); -#endif - continue; - } - - draw_x = pDamage->pDrawable->x; - draw_y = pDamage->pDrawable->y; -#ifdef COMPOSITE - /* - * Need to move everyone to screen coordinates - * XXX what about off-screen pixmaps with non-zero x/y? - */ - if (pDamage->pDrawable->type != DRAWABLE_WINDOW) - { - draw_x += ((PixmapPtr) pDamage->pDrawable)->screen_x; - draw_y += ((PixmapPtr) pDamage->pDrawable)->screen_y; - } -#endif - - /* - * Clip against border or pixmap bounds - */ - - pDamageRegion = pRegion; - if (clip || pDamage->pDrawable != pDrawable) - { - pDamageRegion = &clippedRec; - if (pDamage->pDrawable->type == DRAWABLE_WINDOW) { - RegionIntersect(pDamageRegion, pRegion, - &((WindowPtr)(pDamage->pDrawable))->borderClip); - } else { - BoxRec box; - box.x1 = draw_x; - box.y1 = draw_y; - box.x2 = draw_x + pDamage->pDrawable->width; - box.y2 = draw_y + pDamage->pDrawable->height; - RegionInit(&pixClip, &box, 1); - RegionIntersect(pDamageRegion, pRegion, &pixClip); - RegionUninit(&pixClip); - } - /* - * Short circuit empty results - */ - if (!RegionNotEmpty(pDamageRegion)) - continue; - } - - DAMAGE_DEBUG (("%s %d x %d +%d +%d (target 0x%lx monitor 0x%lx)\n", - where, - pDamageRegion->extents.x2 - pDamageRegion->extents.x1, - pDamageRegion->extents.y2 - pDamageRegion->extents.y1, - pDamageRegion->extents.x1, pDamageRegion->extents.y1, - pDrawable->id, pDamage->pDrawable->id)); - - /* - * Move region to target coordinate space - */ - if (draw_x || draw_y) - RegionTranslate(pDamageRegion, -draw_x, -draw_y); - - switch (pDamage->damageLevel) { - case DamageReportRawRegion: - (*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure); - break; - case DamageReportDeltaRegion: - RegionNull(&tmpRegion); - RegionSubtract(&tmpRegion, pDamageRegion, &pDamage->damage); - if (RegionNotEmpty(&tmpRegion)) - { - RegionUnion(&pDamage->damage, - &pDamage->damage, pDamageRegion); - (*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure); - } - RegionUninit(&tmpRegion); - break; - case DamageReportBoundingBox: - tmpBox = *RegionExtents(&pDamage->damage); - RegionUnion(&pDamage->damage, - &pDamage->damage, pDamageRegion); - if (!BOX_SAME (&tmpBox, RegionExtents(&pDamage->damage))) - (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure); - break; - case DamageReportNonEmpty: - was_empty = !RegionNotEmpty(&pDamage->damage); - RegionUnion(&pDamage->damage, &pDamage->damage, - pDamageRegion); - if (was_empty && RegionNotEmpty(&pDamage->damage)) - (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure); - break; - case DamageReportNone: - RegionUnion(&pDamage->damage, &pDamage->damage, - pDamageRegion); - break; - } - /* - * translate original region back - */ - if (pDamageRegion == pRegion && (draw_x || draw_y)) - RegionTranslate(pDamageRegion, draw_x, draw_y); - } -#ifdef COMPOSITE - if (screen_x || screen_y) - RegionTranslate(pRegion, -screen_x, -screen_y); -#endif - - RegionUninit(&clippedRec); -} - -#if DAMAGE_DEBUG_ENABLE -#define damageDamageBox(d,b,m) _damageDamageBox(d,b,m,__FUNCTION__) -static void -_damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode, const char *where) -#else -static void -damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode) -#endif -{ - RegionRec region; - - RegionInit(®ion, pBox, 1); -#if DAMAGE_DEBUG_ENABLE - _damageDamageRegion (pDrawable, ®ion, TRUE, subWindowMode, where); -#else - damageDamageRegion (pDrawable, ®ion, TRUE, subWindowMode); -#endif - RegionUninit(®ion); -} - -static void damageValidateGC(GCPtr, unsigned long, DrawablePtr); -static void damageChangeGC(GCPtr, unsigned long); -static void damageCopyGC(GCPtr, unsigned long, GCPtr); -static void damageDestroyGC(GCPtr); -static void damageChangeClip(GCPtr, int, void *, int); -static void damageDestroyClip(GCPtr); -static void damageCopyClip(GCPtr, GCPtr); - -GCFuncs damageGCFuncs = { - damageValidateGC, damageChangeGC, damageCopyGC, damageDestroyGC, - damageChangeClip, damageDestroyClip, damageCopyClip -}; - -extern GCOps damageGCOps; - -static Bool -damageCreateGC(GCPtr pGC) -{ - ScreenPtr pScreen = pGC->pScreen; - damageScrPriv(pScreen); - damageGCPriv(pGC); - Bool ret; - - pGC->pCompositeClip = 0; - unwrap (pScrPriv, pScreen, CreateGC); - if((ret = (*pScreen->CreateGC) (pGC))) { - pGCPriv->ops = NULL; - pGCPriv->funcs = pGC->funcs; - pGC->funcs = &damageGCFuncs; - } - wrap (pScrPriv, pScreen, CreateGC, damageCreateGC); - - return ret; -} - -#ifdef NOTUSED -static void -damageWrapGC (GCPtr pGC) -{ - damageGCPriv(pGC); - - pGCPriv->ops = NULL; - pGCPriv->funcs = pGC->funcs; - pGC->funcs = &damageGCFuncs; -} - -static void -damageUnwrapGC (GCPtr pGC) -{ - damageGCPriv(pGC); - - pGC->funcs = pGCPriv->funcs; - if (pGCPriv->ops) - pGC->ops = pGCPriv->ops; -} -#endif - -#define DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable) \ - damageGCPriv(pGC); \ - GCFuncs *oldFuncs = pGC->funcs; \ - unwrap(pGCPriv, pGC, funcs); \ - unwrap(pGCPriv, pGC, ops); \ - -#define DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable) \ - wrap(pGCPriv, pGC, funcs, oldFuncs); \ - wrap(pGCPriv, pGC, ops, &damageGCOps) - -#define DAMAGE_GC_FUNC_PROLOGUE(pGC) \ - damageGCPriv(pGC); \ - unwrap(pGCPriv, pGC, funcs); \ - if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops) - -#define DAMAGE_GC_FUNC_EPILOGUE(pGC) \ - wrap(pGCPriv, pGC, funcs, &damageGCFuncs); \ - if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &damageGCOps) - -static void -damageValidateGC(GCPtr pGC, - unsigned long changes, - DrawablePtr pDrawable) -{ - DAMAGE_GC_FUNC_PROLOGUE (pGC); - (*pGC->funcs->ValidateGC)(pGC, changes, pDrawable); - pGCPriv->ops = pGC->ops; /* just so it's not NULL */ - DAMAGE_GC_FUNC_EPILOGUE (pGC); -} - -static void -damageDestroyGC(GCPtr pGC) -{ - DAMAGE_GC_FUNC_PROLOGUE (pGC); - (*pGC->funcs->DestroyGC)(pGC); - DAMAGE_GC_FUNC_EPILOGUE (pGC); -} - -static void -damageChangeGC (GCPtr pGC, - unsigned long mask) -{ - DAMAGE_GC_FUNC_PROLOGUE (pGC); - (*pGC->funcs->ChangeGC) (pGC, mask); - DAMAGE_GC_FUNC_EPILOGUE (pGC); -} - -static void -damageCopyGC (GCPtr pGCSrc, - unsigned long mask, - GCPtr pGCDst) -{ - DAMAGE_GC_FUNC_PROLOGUE (pGCDst); - (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); - DAMAGE_GC_FUNC_EPILOGUE (pGCDst); -} - -static void -damageChangeClip (GCPtr pGC, - int type, - void *pvalue, - int nrects) -{ - DAMAGE_GC_FUNC_PROLOGUE (pGC); - (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); - DAMAGE_GC_FUNC_EPILOGUE (pGC); -} - -static void -damageCopyClip(GCPtr pgcDst, GCPtr pgcSrc) -{ - DAMAGE_GC_FUNC_PROLOGUE (pgcDst); - (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); - DAMAGE_GC_FUNC_EPILOGUE (pgcDst); -} - -static void -damageDestroyClip(GCPtr pGC) -{ - DAMAGE_GC_FUNC_PROLOGUE (pGC); - (* pGC->funcs->DestroyClip)(pGC); - DAMAGE_GC_FUNC_EPILOGUE (pGC); -} - -#define TRIM_BOX(box, pGC) if (pGC->pCompositeClip) { \ - BoxPtr extents = &pGC->pCompositeClip->extents;\ - if(box.x1 < extents->x1) box.x1 = extents->x1; \ - if(box.x2 > extents->x2) box.x2 = extents->x2; \ - if(box.y1 < extents->y1) box.y1 = extents->y1; \ - if(box.y2 > extents->y2) box.y2 = extents->y2; \ - } - -#define TRANSLATE_BOX(box, pDrawable) { \ - box.x1 += pDrawable->x; \ - box.x2 += pDrawable->x; \ - box.y1 += pDrawable->y; \ - box.y2 += pDrawable->y; \ - } - -#define TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC) { \ - TRANSLATE_BOX(box, pDrawable); \ - TRIM_BOX(box, pGC); \ - } - -#define BOX_NOT_EMPTY(box) \ - (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) - -#define checkGCDamage(d,g) (getDrawableDamage(d) && \ - (!g->pCompositeClip ||\ - RegionNotEmpty(\ - g->pCompositeClip))) - -#ifdef RENDER - -#define TRIM_PICTURE_BOX(box, pDst) { \ - BoxPtr extents = &pDst->pCompositeClip->extents;\ - if(box.x1 < extents->x1) box.x1 = extents->x1; \ - if(box.x2 > extents->x2) box.x2 = extents->x2; \ - if(box.y1 < extents->y1) box.y1 = extents->y1; \ - if(box.y2 > extents->y2) box.y2 = extents->y2; \ - } - -#define checkPictureDamage(p) (getDrawableDamage(p->pDrawable) && \ - RegionNotEmpty(p->pCompositeClip)) - -static void -damageComposite (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - ScreenPtr pScreen = pDst->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - damageScrPriv(pScreen); - - if (checkPictureDamage (pDst)) - { - BoxRec box; - - box.x1 = xDst + pDst->pDrawable->x; - box.y1 = yDst + pDst->pDrawable->y; - box.x2 = box.x1 + width; - box.y2 = box.y1 + height; - TRIM_PICTURE_BOX(box, pDst); - if (BOX_NOT_EMPTY(box)) - damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode); - } - unwrap (pScrPriv, ps, Composite); - (*ps->Composite) (op, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height); - wrap (pScrPriv, ps, Composite, damageComposite); -} - -static void -damageGlyphs (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr list, - GlyphPtr *glyphs) -{ - ScreenPtr pScreen = pDst->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - damageScrPriv(pScreen); - - if (checkPictureDamage (pDst)) - { - int nlistTmp = nlist; - GlyphListPtr listTmp = list; - GlyphPtr *glyphsTmp = glyphs; - int x, y; - int n; - GlyphPtr glyph; - BoxRec box; - int x1, y1, x2, y2; - - box.x1 = 32767; - box.y1 = 32767; - box.x2 = -32767; - box.y2 = -32767; - x = pDst->pDrawable->x; - y = pDst->pDrawable->y; - while (nlistTmp--) - { - x += listTmp->xOff; - y += listTmp->yOff; - n = listTmp->len; - while (n--) - { - glyph = *glyphsTmp++; - x1 = x - glyph->info.x; - y1 = y - glyph->info.y; - x2 = x1 + glyph->info.width; - y2 = y1 + glyph->info.height; - if (x1 < box.x1) - box.x1 = x1; - if (y1 < box.y1) - box.y1 = y1; - if (x2 > box.x2) - box.x2 = x2; - if (y2 > box.y2) - box.y2 = y2; - x += glyph->info.xOff; - y += glyph->info.yOff; - } - listTmp++; - } - TRIM_PICTURE_BOX (box, pDst); - if (BOX_NOT_EMPTY(box)) - damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode); - } - unwrap (pScrPriv, ps, Glyphs); - (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); - wrap (pScrPriv, ps, Glyphs, damageGlyphs); -} -#endif - -/**********************************************************/ - - -static void -damageFillSpans(DrawablePtr pDrawable, - GC *pGC, - int npt, - DDXPointPtr ppt, - int *pwidth, - int fSorted) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); +#include "regionstr.h" +#include "../../miext/damage/damage.h" +#include <X11/fonts/font.h> - if (npt && checkGCDamage (pDrawable, pGC)) - { - int nptTmp = npt; - DDXPointPtr pptTmp = ppt; - int *pwidthTmp = pwidth; - BoxRec box; +/* prototypes */ - box.x1 = pptTmp->x; - box.x2 = box.x1 + *pwidthTmp; - box.y2 = box.y1 = pptTmp->y; - - while(--nptTmp) - { - pptTmp++; - pwidthTmp++; - if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; - if(box.x2 < (pptTmp->x + *pwidthTmp)) - box.x2 = pptTmp->x + *pwidthTmp; - if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; - else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; - } - - box.y2++; - - if(!pGC->miTranslate) { - TRANSLATE_BOX(box, pDrawable); - } - TRIM_BOX(box, pGC); - - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - - (*pGC->ops->FillSpans)(pDrawable, pGC, npt, ppt, pwidth, fSorted); - - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damageSetSpans(DrawablePtr pDrawable, - GCPtr pGC, - char *pcharsrc, - DDXPointPtr ppt, - int *pwidth, - int npt, - int fSorted) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (npt && checkGCDamage (pDrawable, pGC)) - { - DDXPointPtr pptTmp = ppt; - int *pwidthTmp = pwidth; - int nptTmp = npt; - BoxRec box; - - box.x1 = pptTmp->x; - box.x2 = box.x1 + *pwidthTmp; - box.y2 = box.y1 = pptTmp->y; - - while(--nptTmp) - { - pptTmp++; - pwidthTmp++; - if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; - if(box.x2 < (pptTmp->x + *pwidthTmp)) - box.x2 = pptTmp->x + *pwidthTmp; - if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; - else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; - } - - box.y2++; - - if(!pGC->miTranslate) { - TRANSLATE_BOX(box, pDrawable); - } - TRIM_BOX(box, pGC); - - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damagePutImage(DrawablePtr pDrawable, - GCPtr pGC, - int depth, - int x, - int y, - int w, - int h, - int leftPad, - int format, - char *pImage) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - if (checkGCDamage (pDrawable, pGC)) - { - BoxRec box; - - box.x1 = x + pDrawable->x; - box.x2 = box.x1 + w; - box.y1 = y + pDrawable->y; - box.y2 = box.y1 + h; - - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h, - leftPad, format, pImage); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static RegionPtr -damageCopyArea(DrawablePtr pSrc, - DrawablePtr pDst, - GC *pGC, - int srcx, - int srcy, - int width, - int height, - int dstx, - int dsty) -{ - RegionPtr ret; - DAMAGE_GC_OP_PROLOGUE(pGC, pDst); - - /* The driver will only call SourceValidate() when pSrc != pDst, - * but the software sprite (misprite.c) always need to know when a - * drawable is copied so it can remove the sprite. See #1030. */ - if ((pSrc == pDst) && pSrc->pScreen->SourceValidate && - pSrc->type == DRAWABLE_WINDOW && - ((WindowPtr)pSrc)->viewable) - { - (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height); - } - - if (checkGCDamage (pDst, pGC)) - { - BoxRec box; - - box.x1 = dstx + pDst->x; - box.x2 = box.x1 + width; - box.y1 = dsty + pDst->y; - box.y2 = box.y1 + height; - - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDst, &box, pGC->subWindowMode); - } - - ret = (*pGC->ops->CopyArea)(pSrc, pDst, - pGC, srcx, srcy, width, height, dstx, dsty); - DAMAGE_GC_OP_EPILOGUE(pGC, pDst); - return ret; -} - -static RegionPtr -damageCopyPlane(DrawablePtr pSrc, - DrawablePtr pDst, - GCPtr pGC, - int srcx, - int srcy, - int width, - int height, - int dstx, - int dsty, - unsigned long bitPlane) -{ - RegionPtr ret; - DAMAGE_GC_OP_PROLOGUE(pGC, pDst); - - /* The driver will only call SourceValidate() when pSrc != pDst, - * but the software sprite (misprite.c) always need to know when a - * drawable is copied so it can remove the sprite. See #1030. */ - if ((pSrc == pDst) && pSrc->pScreen->SourceValidate && - pSrc->type == DRAWABLE_WINDOW && - ((WindowPtr)pSrc)->viewable) - { - (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height); - } - - if (checkGCDamage (pDst, pGC)) - { - BoxRec box; - - box.x1 = dstx + pDst->x; - box.x2 = box.x1 + width; - box.y1 = dsty + pDst->y; - box.y2 = box.y1 + height; - - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDst, &box, pGC->subWindowMode); - } - - ret = (*pGC->ops->CopyPlane)(pSrc, pDst, - pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); - DAMAGE_GC_OP_EPILOGUE(pGC, pDst); - return ret; -} - -static void -damagePolyPoint(DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - xPoint *ppt) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (npt && checkGCDamage (pDrawable, pGC)) - { - BoxRec box; - int nptTmp = npt; - xPoint *pptTmp = ppt; - - box.x2 = box.x1 = pptTmp->x; - box.y2 = box.y1 = pptTmp->y; - - /* this could be slow if the points were spread out */ - - while(--nptTmp) - { - pptTmp++; - if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; - else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x; - if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; - else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; - } - - box.x2++; - box.y2++; - - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damagePolylines(DrawablePtr pDrawable, +static int +damageText (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned long count, + char *chars, + FontEncoding fontEncoding, + Bool textType); +static int +damagePolyText8(DrawablePtr pDrawable, GCPtr pGC, - int mode, - int npt, - DDXPointPtr ppt) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (npt && checkGCDamage (pDrawable, pGC)) - { - int nptTmp = npt; - DDXPointPtr pptTmp = ppt; - BoxRec box; - int extra = pGC->lineWidth >> 1; - - box.x2 = box.x1 = pptTmp->x; - box.y2 = box.y1 = pptTmp->y; - - if(nptTmp > 1) - { - if(pGC->joinStyle == JoinMiter) - extra = 6 * pGC->lineWidth; - else if(pGC->capStyle == CapProjecting) - extra = pGC->lineWidth; - } - - if(mode == CoordModePrevious) - { - int x = box.x1; - int y = box.y1; - while(--nptTmp) - { - pptTmp++; - x += pptTmp->x; - y += pptTmp->y; - if(box.x1 > x) box.x1 = x; - else if(box.x2 < x) box.x2 = x; - if(box.y1 > y) box.y1 = y; - else if(box.y2 < y) box.y2 = y; - } - } - else - { - while(--nptTmp) - { - pptTmp++; - if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; - else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x; - if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; - else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; - } - } - - box.x2++; - box.y2++; - - if(extra) - { - box.x1 -= extra; - box.x2 += extra; - box.y1 -= extra; - box.y2 += extra; - } - - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damagePolySegment(DrawablePtr pDrawable, - GCPtr pGC, - int nSeg, - xSegment *pSeg) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (nSeg && checkGCDamage (pDrawable, pGC)) - { - BoxRec box; - int extra = pGC->lineWidth; - int nsegTmp = nSeg; - xSegment *pSegTmp = pSeg; - - if(pGC->capStyle != CapProjecting) - extra >>= 1; - - if(pSegTmp->x2 > pSegTmp->x1) { - box.x1 = pSegTmp->x1; - box.x2 = pSegTmp->x2; - } else { - box.x2 = pSegTmp->x1; - box.x1 = pSegTmp->x2; - } - - if(pSegTmp->y2 > pSegTmp->y1) { - box.y1 = pSegTmp->y1; - box.y2 = pSegTmp->y2; - } else { - box.y2 = pSegTmp->y1; - box.y1 = pSegTmp->y2; - } - - while(--nsegTmp) - { - pSegTmp++; - if(pSegTmp->x2 > pSegTmp->x1) - { - if(pSegTmp->x1 < box.x1) box.x1 = pSegTmp->x1; - if(pSegTmp->x2 > box.x2) box.x2 = pSegTmp->x2; - } - else - { - if(pSegTmp->x2 < box.x1) box.x1 = pSegTmp->x2; - if(pSegTmp->x1 > box.x2) box.x2 = pSegTmp->x1; - } - if(pSegTmp->y2 > pSegTmp->y1) - { - if(pSegTmp->y1 < box.y1) box.y1 = pSegTmp->y1; - if(pSegTmp->y2 > box.y2) box.y2 = pSegTmp->y2; - } - else - { - if(pSegTmp->y2 < box.y1) box.y1 = pSegTmp->y2; - if(pSegTmp->y1 > box.y2) box.y2 = pSegTmp->y1; - } - } - - box.x2++; - box.y2++; - - if(extra) - { - box.x1 -= extra; - box.x2 += extra; - box.y1 -= extra; - box.y2 += extra; - } - - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damagePolyRectangle(DrawablePtr pDrawable, - GCPtr pGC, - int nRects, - xRectangle *pRects) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (nRects && checkGCDamage (pDrawable, pGC)) - { - BoxRec box; - int offset1, offset2, offset3; - int nRectsTmp = nRects; - xRectangle *pRectsTmp = pRects; - - offset2 = pGC->lineWidth; - if(!offset2) offset2 = 1; - offset1 = offset2 >> 1; - offset3 = offset2 - offset1; - - while(nRectsTmp--) - { - box.x1 = pRectsTmp->x - offset1; - box.y1 = pRectsTmp->y - offset1; - box.x2 = box.x1 + pRectsTmp->width + offset2; - box.y2 = box.y1 + offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - - box.x1 = pRectsTmp->x - offset1; - box.y1 = pRectsTmp->y + offset3; - box.x2 = box.x1 + offset2; - box.y2 = box.y1 + pRectsTmp->height - offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - - box.x1 = pRectsTmp->x + pRectsTmp->width - offset1; - box.y1 = pRectsTmp->y + offset3; - box.x2 = box.x1 + offset2; - box.y2 = box.y1 + pRectsTmp->height - offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - - box.x1 = pRectsTmp->x - offset1; - box.y1 = pRectsTmp->y + pRectsTmp->height - offset1; - box.x2 = box.x1 + pRectsTmp->width + offset2; - box.y2 = box.y1 + offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - - pRectsTmp++; - } - } - (*pGC->ops->PolyRectangle)(pDrawable, pGC, nRects, pRects); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damagePolyArc(DrawablePtr pDrawable, - GCPtr pGC, - int nArcs, - xArc *pArcs) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (nArcs && checkGCDamage (pDrawable, pGC)) - { - int extra = pGC->lineWidth >> 1; - BoxRec box; - int nArcsTmp = nArcs; - xArc *pArcsTmp = pArcs; - - box.x1 = pArcsTmp->x; - box.x2 = box.x1 + pArcsTmp->width; - box.y1 = pArcsTmp->y; - box.y2 = box.y1 + pArcsTmp->height; - - while(--nArcsTmp) - { - pArcsTmp++; - if(box.x1 > pArcsTmp->x) - box.x1 = pArcsTmp->x; - if(box.x2 < (pArcsTmp->x + pArcsTmp->width)) - box.x2 = pArcsTmp->x + pArcsTmp->width; - if(box.y1 > pArcsTmp->y) - box.y1 = pArcsTmp->y; - if(box.y2 < (pArcsTmp->y + pArcsTmp->height)) - box.y2 = pArcsTmp->y + pArcsTmp->height; - } - - if(extra) - { - box.x1 -= extra; - box.x2 += extra; - box.y1 -= extra; - box.y2 += extra; - } - - box.x2++; - box.y2++; - - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damageFillPolygon(DrawablePtr pDrawable, - GCPtr pGC, - int shape, - int mode, - int npt, - DDXPointPtr ppt) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (npt > 2 && checkGCDamage (pDrawable, pGC)) - { - DDXPointPtr pptTmp = ppt; - int nptTmp = npt; - BoxRec box; - - box.x2 = box.x1 = pptTmp->x; - box.y2 = box.y1 = pptTmp->y; - - if(mode != CoordModeOrigin) - { - int x = box.x1; - int y = box.y1; - while(--nptTmp) - { - pptTmp++; - x += pptTmp->x; - y += pptTmp->y; - if(box.x1 > x) box.x1 = x; - else if(box.x2 < x) box.x2 = x; - if(box.y1 > y) box.y1 = y; - else if(box.y2 < y) box.y2 = y; - } - } - else - { - while(--nptTmp) - { - pptTmp++; - if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; - else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x; - if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; - else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; - } - } - - box.x2++; - box.y2++; - - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - - (*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - - + int x, + int y, + int count, + char *chars); +static int +damagePolyText16(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars); static void -damagePolyFillRect(DrawablePtr pDrawable, - GCPtr pGC, - int nRects, - xRectangle *pRects) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - if (nRects && checkGCDamage (pDrawable, pGC)) - { - BoxRec box; - xRectangle *pRectsTmp = pRects; - int nRectsTmp = nRects; - - box.x1 = pRectsTmp->x; - box.x2 = box.x1 + pRectsTmp->width; - box.y1 = pRectsTmp->y; - box.y2 = box.y1 + pRectsTmp->height; - - while(--nRectsTmp) - { - pRectsTmp++; - if(box.x1 > pRectsTmp->x) box.x1 = pRectsTmp->x; - if(box.x2 < (pRectsTmp->x + pRectsTmp->width)) - box.x2 = pRectsTmp->x + pRectsTmp->width; - if(box.y1 > pRectsTmp->y) box.y1 = pRectsTmp->y; - if(box.y2 < (pRectsTmp->y + pRectsTmp->height)) - box.y2 = pRectsTmp->y + pRectsTmp->height; - } - - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - - +damageImageText8(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + char *chars); static void -damagePolyFillArc(DrawablePtr pDrawable, +damageImageText16(DrawablePtr pDrawable, GCPtr pGC, - int nArcs, - xArc *pArcs) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (nArcs && checkGCDamage (pDrawable, pGC)) - { - BoxRec box; - int nArcsTmp = nArcs; - xArc *pArcsTmp = pArcs; - - box.x1 = pArcsTmp->x; - box.x2 = box.x1 + pArcsTmp->width; - box.y1 = pArcsTmp->y; - box.y2 = box.y1 + pArcsTmp->height; - - while(--nArcsTmp) - { - pArcsTmp++; - if(box.x1 > pArcsTmp->x) - box.x1 = pArcsTmp->x; - if(box.x2 < (pArcsTmp->x + pArcsTmp->width)) - box.x2 = pArcsTmp->x + pArcsTmp->width; - if(box.y1 > pArcsTmp->y) - box.y1 = pArcsTmp->y; - if(box.y2 < (pArcsTmp->y + pArcsTmp->height)) - box.y2 = pArcsTmp->y + pArcsTmp->height; - } - - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -/* - * general Poly/Image text function. Extract glyph information, - * compute bounding box and remove cursor if it is overlapped. - */ - -static void -damageDamageChars (DrawablePtr pDrawable, - FontPtr font, - int x, - int y, - unsigned int n, - CharInfoPtr *charinfo, - Bool imageblt, - int subWindowMode) -{ - ExtentInfoRec extents; - BoxRec box; - - QueryGlyphExtents(font, charinfo, n, &extents); - if (imageblt) - { - if (extents.overallWidth > extents.overallRight) - extents.overallRight = extents.overallWidth; - if (extents.overallWidth < extents.overallLeft) - extents.overallLeft = extents.overallWidth; - if (extents.overallLeft > 0) - extents.overallLeft = 0; - if (extents.fontAscent > extents.overallAscent) - extents.overallAscent = extents.fontAscent; - if (extents.fontDescent > extents.overallDescent) - extents.overallDescent = extents.fontDescent; - } - box.x1 = x + extents.overallLeft; - box.y1 = y - extents.overallAscent; - box.x2 = x + extents.overallRight; - box.y2 = y + extents.overallDescent; - damageDamageBox (pDrawable, &box, subWindowMode); -} + int x, + int y, + int count, + unsigned short *chars); -/* - * values for textType: - */ -#define TT_POLY8 0 -#define TT_IMAGE8 1 -#define TT_POLY16 2 -#define TT_IMAGE16 3 +#include "../../miext/damage/damage.c" static int damageText (DrawablePtr pDrawable, @@ -1391,86 +135,6 @@ damageText (DrawablePtr pDrawable, return x + w; } -#ifndef NXAGENT_SERVER - -static int -damagePolyText8(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - char *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - x = damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, - Linear8Bit, TT_POLY8); - else - x = (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); - return x; -} - -static int -damagePolyText16(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - unsigned short *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - x = damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, - FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, - TT_POLY16); - else - x = (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); - return x; -} - -static void -damageImageText8(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - char *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, - Linear8Bit, TT_IMAGE8); - else - (*pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damageImageText16(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - int count, - unsigned short *chars) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - - if (checkGCDamage (pDrawable, pGC)) - damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, - FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, - TT_IMAGE16); - else - (*pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -#else /* #ifndef NXAGENT_SERVER */ - static int damagePolyText8(DrawablePtr pDrawable, GCPtr pGC, @@ -1551,523 +215,3 @@ damageImageText16(DrawablePtr pDrawable, DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); } -#endif /* #ifndef NXAGENT_SERVER */ - -static void -damageImageGlyphBlt(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppci, - void *pglyphBase) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, - nglyph, ppci, TRUE, pGC->subWindowMode); - (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, - ppci, pglyphBase); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damagePolyGlyphBlt(DrawablePtr pDrawable, - GCPtr pGC, - int x, - int y, - unsigned int nglyph, - CharInfoPtr *ppci, - void *pglyphBase) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, - nglyph, ppci, FALSE, pGC->subWindowMode); - (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, - ppci, pglyphBase); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damagePushPixels(GCPtr pGC, - PixmapPtr pBitMap, - DrawablePtr pDrawable, - int dx, - int dy, - int xOrg, - int yOrg) -{ - DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - if(checkGCDamage (pDrawable, pGC)) - { - BoxRec box; - - box.x1 = xOrg; - box.y1 = yOrg; - - if(!pGC->miTranslate) { - box.x1 += pDrawable->x; - box.y1 += pDrawable->y; - } - - box.x2 = box.x1 + dx; - box.y2 = box.y1 + dy; - - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); - } - (*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg); - DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); -} - -static void -damageRemoveDamage (DamagePtr *pPrev, DamagePtr pDamage) -{ - while (*pPrev) - { - if (*pPrev == pDamage) - { - *pPrev = pDamage->pNext; - return; - } - pPrev = &(*pPrev)->pNext; - } -#if DAMAGE_VALIDATE_ENABLE - ErrorF ("Damage not on list\n"); - abort (); -#endif -} - -static void -damageInsertDamage (DamagePtr *pPrev, DamagePtr pDamage) -{ -#if DAMAGE_VALIDATE_ENABLE - DamagePtr pOld; - - for (pOld = *pPrev; pOld; pOld = pOld->pNext) - if (pOld == pDamage) { - ErrorF ("Damage already on list\n"); - abort (); - } -#endif - pDamage->pNext = *pPrev; - *pPrev = pDamage; -} - -static Bool -damageDestroyPixmap (PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - damageScrPriv(pScreen); - - if (pPixmap->refcnt == 1) - { - DamagePtr *pPrev = getPixmapDamageRef (pPixmap); - DamagePtr pDamage; - - while ((pDamage = *pPrev)) - { - damageRemoveDamage (pPrev, pDamage); - if (!pDamage->isWindow) - DamageDestroy (pDamage); - } - } - unwrap (pScrPriv, pScreen, DestroyPixmap); - (*pScreen->DestroyPixmap) (pPixmap); - wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); - return TRUE; -} - -static void -damagePaintWindow(WindowPtr pWindow, - RegionPtr prgn, - int what) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - damageScrPriv(pScreen); - - /* - * Painting background none doesn't actually *do* anything, so - * no damage is recorded - */ - if ((what != PW_BACKGROUND || pWindow->backgroundState != None) && - getWindowDamage (pWindow)) - damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1); - if(what == PW_BACKGROUND) { - unwrap (pScrPriv, pScreen, PaintWindowBackground); - (*pScreen->PaintWindowBackground) (pWindow, prgn, what); - wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow); - } else { - unwrap (pScrPriv, pScreen, PaintWindowBorder); - (*pScreen->PaintWindowBorder) (pWindow, prgn, what); - wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow); - } -} - - -static void -damageCopyWindow(WindowPtr pWindow, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - damageScrPriv(pScreen); - - if (getWindowDamage (pWindow)) - { - int dx = pWindow->drawable.x - ptOldOrg.x; - int dy = pWindow->drawable.y - ptOldOrg.y; - - /* - * The region comes in source relative, but the damage occurs - * at the destination location. Translate back and forth. - */ - RegionTranslate(prgnSrc, dx, dy); - damageDamageRegion (&pWindow->drawable, prgnSrc, FALSE, -1); - RegionTranslate(prgnSrc, -dx, -dy); - } - unwrap (pScrPriv, pScreen, CopyWindow); - (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); - wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow); -} - -GCOps damageGCOps = { - damageFillSpans, damageSetSpans, - damagePutImage, damageCopyArea, - damageCopyPlane, damagePolyPoint, - damagePolylines, damagePolySegment, - damagePolyRectangle, damagePolyArc, - damageFillPolygon, damagePolyFillRect, - damagePolyFillArc, damagePolyText8, - damagePolyText16, damageImageText8, - damageImageText16, damageImageGlyphBlt, - damagePolyGlyphBlt, damagePushPixels, -#ifdef NEED_LINEHELPER - NULL, -#endif - {NULL} /* devPrivate */ -}; - -static void -damageRestoreAreas (PixmapPtr pPixmap, - RegionPtr prgn, - int xorg, - int yorg, - WindowPtr pWindow) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - damageScrPriv(pScreen); - - damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1); - unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); - (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn, - xorg, yorg, pWindow); - wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, - damageRestoreAreas); -} - -static void -damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) -{ - DamagePtr pDamage; - ScreenPtr pScreen = pWindow->drawable.pScreen; - damageScrPriv(pScreen); - - if ((pDamage = damageGetWinPriv(pWindow))) - { - PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow); - DamagePtr *pPrev = getPixmapDamageRef(pOldPixmap); - - while (pDamage) - { - damageRemoveDamage (pPrev, pDamage); - pDamage = pDamage->pNextWin; - } - } - unwrap (pScrPriv, pScreen, SetWindowPixmap); - (*pScreen->SetWindowPixmap) (pWindow, pPixmap); - wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); - if ((pDamage = damageGetWinPriv(pWindow))) - { - DamagePtr *pPrev = getPixmapDamageRef(pPixmap); - - while (pDamage) - { - damageInsertDamage (pPrev, pDamage); - pDamage = pDamage->pNextWin; - } - } -} - -static Bool -damageDestroyWindow (WindowPtr pWindow) -{ - DamagePtr pDamage; - ScreenPtr pScreen = pWindow->drawable.pScreen; - Bool ret; - damageScrPriv(pScreen); - - while ((pDamage = damageGetWinPriv(pWindow))) - { - DamageUnregister (&pWindow->drawable, pDamage); - DamageDestroy (pDamage); - } - unwrap (pScrPriv, pScreen, DestroyWindow); - ret = (*pScreen->DestroyWindow) (pWindow); - wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow); - return ret; -} - -static Bool -damageCloseScreen (int i, ScreenPtr pScreen) -{ - damageScrPriv(pScreen); - - unwrap (pScrPriv, pScreen, DestroyPixmap); - unwrap (pScrPriv, pScreen, CreateGC); - unwrap (pScrPriv, pScreen, PaintWindowBackground); - unwrap (pScrPriv, pScreen, PaintWindowBorder); - unwrap (pScrPriv, pScreen, CopyWindow); - unwrap (pScrPriv, pScreen, CloseScreen); - unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); - xfree (pScrPriv); - return (*pScreen->CloseScreen) (i, pScreen); -} - -int damageScrPrivateIndex; -int damagePixPrivateIndex; -int damageGCPrivateIndex; -int damageWinPrivateIndex; -int damageGeneration; - -Bool -DamageSetup (ScreenPtr pScreen) -{ - DamageScrPrivPtr pScrPriv; -#ifdef RENDER - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); -#endif - - if (damageGeneration != serverGeneration) - { - damageScrPrivateIndex = AllocateScreenPrivateIndex (); - if (damageScrPrivateIndex == -1) - return FALSE; - damageGCPrivateIndex = AllocateGCPrivateIndex (); - if (damageGCPrivateIndex == -1) - return FALSE; - damagePixPrivateIndex = AllocatePixmapPrivateIndex (); - if (damagePixPrivateIndex == -1) - return FALSE; - damageWinPrivateIndex = AllocateWindowPrivateIndex (); - if (damageWinPrivateIndex == -1) - return FALSE; - damageGeneration = serverGeneration; - } - if (pScreen->devPrivates[damageScrPrivateIndex].ptr) - return TRUE; - - if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec))) - return FALSE; - if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0)) - return FALSE; - if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0)) - return FALSE; - - pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec)); - if (!pScrPriv) - return FALSE; - -#ifdef COMPOSITE - /* This is a kludge to ensure wrapping order with the composite wrapper. - * If it's done from compinit.c, then DamageSetup may be called before the - * extension init phase, so that cw will be higher in the wrapping chain and - * rewrite drawables before damage gets to it, causing confusion. - */ - if (!noCompositeExtension) - miInitializeCompositeWrapper (pScreen); -#endif - - pScrPriv->internalLevel = 0; - pScrPriv->pScreenDamage = 0; - - wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); - wrap (pScrPriv, pScreen, CreateGC, damageCreateGC); - wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow); - wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow); - wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow); - wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); - wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow); - wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen); - wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, - damageRestoreAreas); -#ifdef RENDER - if (ps) { - wrap (pScrPriv, ps, Glyphs, damageGlyphs); - wrap (pScrPriv, ps, Composite, damageComposite); - } -#endif - - pScreen->devPrivates[damageScrPrivateIndex].ptr = (void *) pScrPriv; - return TRUE; -} - -DamagePtr -DamageCreate (DamageReportFunc damageReport, - DamageDestroyFunc damageDestroy, - DamageReportLevel damageLevel, - Bool isInternal, - ScreenPtr pScreen, - void *closure) -{ - DamagePtr pDamage; - - pDamage = xalloc (sizeof (DamageRec)); - if (!pDamage) - return 0; - pDamage->pNext = 0; - pDamage->pNextWin = 0; - RegionNull(&pDamage->damage); - - pDamage->damageLevel = damageLevel; - pDamage->isInternal = isInternal; - pDamage->closure = closure; - pDamage->isWindow = FALSE; - pDamage->pDrawable = 0; - - pDamage->damageReport = damageReport; - pDamage->damageDestroy = damageDestroy; - return pDamage; -} - -void -DamageRegister (DrawablePtr pDrawable, - DamagePtr pDamage) -{ - if (pDrawable->type == DRAWABLE_WINDOW) - { - WindowPtr pWindow = (WindowPtr) pDrawable; - winDamageRef(pWindow); - -#if DAMAGE_VALIDATE_ENABLE - DamagePtr pOld; - - for (pOld = *pPrev; pOld; pOld = pOld->pNextWin) - if (pOld == pDamage) { - ErrorF ("Damage already on window list\n"); - abort (); - } -#endif - pDamage->pNextWin = *pPrev; - *pPrev = pDamage; - pDamage->isWindow = TRUE; - } - else - pDamage->isWindow = FALSE; - pDamage->pDrawable = pDrawable; - damageInsertDamage (getDrawableDamageRef (pDrawable), pDamage); -} - -void -DamageDrawInternal (ScreenPtr pScreen, Bool enable) -{ - damageScrPriv (pScreen); - - pScrPriv->internalLevel += enable ? 1 : -1; -} - -void -DamageUnregister (DrawablePtr pDrawable, - DamagePtr pDamage) -{ - if (pDrawable->type == DRAWABLE_WINDOW) - { - WindowPtr pWindow = (WindowPtr) pDrawable; - winDamageRef (pWindow); -#if DAMAGE_VALIDATE_ENABLE - int found = 0; -#endif - - while (*pPrev) - { - if (*pPrev == pDamage) - { - *pPrev = pDamage->pNextWin; -#if DAMAGE_VALIDATE_ENABLE - found = 1; -#endif - break; - } - pPrev = &(*pPrev)->pNextWin; - } -#if DAMAGE_VALIDATE_ENABLE - if (!found) { - ErrorF ("Damage not on window list\n"); - abort (); - } -#endif - } - pDamage->pDrawable = 0; - damageRemoveDamage (getDrawableDamageRef (pDrawable), pDamage); -} - -void -DamageDestroy (DamagePtr pDamage) -{ - if (pDamage->damageDestroy) - (*pDamage->damageDestroy) (pDamage, pDamage->closure); - RegionUninit(&pDamage->damage); - xfree (pDamage); -} - -Bool -DamageSubtract (DamagePtr pDamage, - const RegionPtr pRegion) -{ - RegionPtr pClip; - RegionRec pixmapClip; - DrawablePtr pDrawable = pDamage->pDrawable; - - RegionSubtract(&pDamage->damage, &pDamage->damage, pRegion); - if (pDrawable) - { - if (pDrawable->type == DRAWABLE_WINDOW) - pClip = &((WindowPtr) pDrawable)->borderClip; - else - { - BoxRec box; - - box.x1 = pDrawable->x; - box.y1 = pDrawable->y; - box.x2 = pDrawable->x + pDrawable->width; - box.y2 = pDrawable->y + pDrawable->height; - RegionInit(&pixmapClip, &box, 1); - pClip = &pixmapClip; - } - RegionTranslate(&pDamage->damage, pDrawable->x, pDrawable->y); - RegionIntersect(&pDamage->damage, &pDamage->damage, pClip); - RegionTranslate(&pDamage->damage, -pDrawable->x, -pDrawable->y); - if (pDrawable->type != DRAWABLE_WINDOW) - RegionUninit(&pixmapClip); - } - return RegionNotEmpty(&pDamage->damage); -} - -void -DamageEmpty (DamagePtr pDamage) -{ - RegionEmpty(&pDamage->damage); -} - -RegionPtr -DamageRegion (DamagePtr pDamage) -{ - return &pDamage->damage; -} - -void -DamageDamageRegion (DrawablePtr pDrawable, - RegionPtr pRegion) -{ - damageDamageRegion (pDrawable, pRegion, FALSE, -1); -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 5e89e67bd..b68f01b8d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -95,15 +95,6 @@ Equipment Corporation. /* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.32 2003/11/10 18:21:45 tsi Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifdef PANORAMIX_DEBUG -#include <stdio.h> -int ProcInitialConnection(); -#endif - #ifdef __sun #define False 0 #define True 1 @@ -115,37 +106,9 @@ int ProcInitialConnection(); #include <nx-X11/Xlib.h> #undef GC +#include "../../dix/dispatch.c" + #include "windowstr.h" -#include "dixfontstr.h" -#include "gcstruct.h" -#include "selection.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "scrnintstr.h" -#include "opaque.h" -#include "input.h" -#include "servermd.h" -#include "extnsionst.h" -#include "dixfont.h" -#include "../../dix/dispatch.h" -#include "swaprep.h" -#include "swapreq.h" -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif -#ifdef XCSECURITY -#define _SECURITY_SERVER -#include <nx-X11/extensions/security.h> -#endif -#ifdef XAPPGROUP -#include <nx-X11/extensions/Xagsrv.h> -#endif -#ifdef XKB -#define XKB_IN_SERVER -#include "inputstr.h" -#include <nx-X11/extensions/XKBsrv.h> -#endif #include "Atoms.h" #include "Splash.h" @@ -182,10 +145,6 @@ Bool nxagentWMPassed = 0; int nxagentAutoDisconnectTimeout = 0; -#ifdef LBX -#include "../../lbx/lbxserve.h" -#endif - #include "Xatom.h" /* @@ -211,21 +170,6 @@ int nxagentAutoDisconnectTimeout = 0; #include "Literals.h" #endif -#define mskcnt ((MAXCLIENTS + 31) / 32) -#define BITMASK(i) (1U << ((i) & 31)) -#define MASKIDX(i) ((i) >> 5) -#define MASKWORD(buf, i) buf[MASKIDX(i)] -#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i) -#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; - #ifdef VIEWPORT_FRAME extern WindowPtr nxagentViewportFrameLeft; @@ -248,82 +192,6 @@ extern int nxagentMaxAllowedResets; extern int nxagentFindClientResource(int, RESTYPE, void *); -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 int nextFreeClientID; /* always MIN free client ID */ - -static int nClients; /* number of authorized clients */ - -CallbackListPtr ClientStateCallback; - -/* dispatchException & isItTimeToYield must be declared volatile since they - * are modified by signal handlers - otherwise optimizer may assume it doesn't - * need to actually check value in memory when used and may miss changes from - * signal handlers. - */ -volatile char dispatchException = 0; -volatile 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(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) - currentTime = systime; -} - -/* Like UpdateCurrentTime, but can't call ProcessInputEvents */ -void -UpdateCurrentTimeIf() -{ - 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() @@ -358,137 +226,6 @@ InitSelections() } -void -FlushClientCaches(XID id) -{ - int i; - register ClientPtr client; - - client = clients[CLIENT_ID(id)]; - if (client == NullClient) - return ; - for (i=0; i<currentMaxClients; i++) - { - client = clients[i]; - if (client != NullClient) - { - if (client->lastDrawableID == id) - { - client->lastDrawableID = screenInfo.screens[0]->root->drawable.id; - client->lastDrawable = (DrawablePtr)screenInfo.screens[0]->root; - } - else if (client->lastGCID == id) - { - client->lastGCID = INVALID; - client->lastGC = (GCPtr)NULL; - } - } - } -} -#ifdef SMART_SCHEDULE - -#undef SMART_DEBUG - -#define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */ -#define SMART_SCHEDULE_MAX_SLICE 200 /* ms */ - -Bool SmartScheduleDisable = FALSE; -long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; -long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; -long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; -long SmartScheduleTime; -ClientPtr SmartLastClient; -int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1]; -int SmartScheduleClient(int *clientReady, int nready); - -#ifdef SMART_DEBUG -long SmartLastPrint; -#endif - -void Dispatch(void); -void InitProcVectors(void); - -int -SmartScheduleClient (int *clientReady, int nready) -{ - ClientPtr pClient; - int i; - int client; - int bestPrio, best = 0; - int bestRobin, robin; - long now = SmartScheduleTime; - long idle; - - bestPrio = -0x7fffffff; - bestRobin = 0; - idle = 2 * SmartScheduleSlice; - for (i = 0; i < nready; i++) - { - client = clientReady[i]; - pClient = clients[client]; - /* Praise clients which are idle */ - if ((now - pClient->smart_check_tick) >= idle) - { - if (pClient->smart_priority < 0) - pClient->smart_priority++; - } - pClient->smart_check_tick = now; - - /* check priority to select best client */ - robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff; - if (pClient->smart_priority > bestPrio || - (pClient->smart_priority == bestPrio && robin > bestRobin)) - { - bestPrio = pClient->smart_priority; - bestRobin = robin; - best = client; - } -#ifdef SMART_DEBUG - if ((now - SmartLastPrint) >= 5000) - fprintf (stderr, " %2d: %3d", client, pClient->smart_priority); -#endif - } -#ifdef SMART_DEBUG - if ((now - SmartLastPrint) >= 5000) - { - fprintf (stderr, " use %2d\n", best); - SmartLastPrint = now; - } -#endif - pClient = clients[best]; - SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index; - /* - * Set current client pointer - */ - if (SmartLastClient != pClient) - { - pClient->smart_start_tick = now; - SmartLastClient = pClient; - } - /* - * Adjust slice - */ - if (nready == 1) - { - /* - * If it's been a long time since another client - * has run, bump the slice up to get maximal - * performance from a single client - */ - if ((now - pClient->smart_start_tick) > 1000 && - SmartScheduleSlice < SmartScheduleMaxSlice) - { - SmartScheduleSlice += SmartScheduleInterval; - } - } - else - { - SmartScheduleSlice = SmartScheduleInterval; - } - return best; -} -#endif - #define MAJOROP ((xReq *)client->requestBuffer)->reqType void @@ -846,159 +583,6 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #undef MAJOROP int -ProcBadRequest(ClientPtr client) -{ - return (BadRequest); -} - -int -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; - } - pWin = CreateWindow(stuff->wid, pParent, stuff->x, - stuff->y, stuff->width, stuff->height, - 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, (void *)pWin)) - return BadAlloc; - pWin->eventMask = mask; - } - if (client->noClientException != Success) - return(client->noClientException); - else - return(result); -} - -int -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(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); - memset(&wa, 0, sizeof(xGetWindowAttributesReply)); - GetWindowAttributes(pWin, client, &wa); - WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa); - return(client->noClientException); -} - -int -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(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(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(register ClientPtr client) { register WindowPtr pWin, pParent; @@ -1039,171 +623,6 @@ ProcReparentWindow(register ClientPtr client) return (BadMatch); } -int -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(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(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(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(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(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(register ClientPtr client, xGetGeometryReply *rep) -{ - register DrawablePtr pDraw; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->id, client, SecurityReadAccess); - memset(rep, 0, sizeof(xGetGeometryReply)); - rep->type = X_Reply; - rep->length = 0; - rep->sequenceNumber = client->sequence; - rep->root = pDraw->pScreen->root->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(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(register ClientPtr client) @@ -1265,67 +684,6 @@ ProcQueryTree(register ClientPtr client) return(client->noClientException); } -int -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; - memset(&reply, 0, sizeof(xInternAtomReply)); - 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(register ClientPtr client) -{ - char *str; - xGetAtomNameReply reply; - int len; - REQUEST(xResourceReq); - - REQUEST_SIZE_MATCH(xResourceReq); - if ( (str = NameForAtom(stuff->id)) ) - { - len = strlen(str); - memset(&reply, 0, sizeof(xGetAtomNameReply)); - 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(register ClientPtr client) @@ -1433,37 +791,6 @@ ProcSetSelectionOwner(register ClientPtr client) } } -int -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++; - memset(&reply, 0, sizeof(xGetSelectionOwnerReply)); - 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(register ClientPtr client) @@ -1553,146 +880,6 @@ ProcConvertSelection(register ClientPtr client) } } -int -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, (void *)&grabinfo); - } - - return(client->noClientException); -} - -static void -UngrabServer(ClientPtr client) -{ - int i; - - grabState = GrabNone; - ListenToAllClients(); - for (i = mskcnt; --i >= 0 && !grabWaiters[i]; ) - ; - 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, (void *)&grabinfo); - } -} - -int -ProcUngrabServer(register ClientPtr client) -{ - REQUEST_SIZE_MATCH(xReq); - UngrabServer(client); - return(client->noClientException); -} - -int -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); - memset(&rep, 0, sizeof(xTranslateCoordsReply)); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) - { - rep.sameScreen = xFalse; - rep.child = None; - rep.dstX = rep.dstY = 0; - } - else - { - INT16 x, y; - rep.sameScreen = xTrue; - rep.child = None; - /* computing absolute coordinates -- adjust to destination later */ - x = pWin->drawable.x + stuff->srcX; - y = pWin->drawable.y + stuff->srcY; - pWin = pDst->firstChild; - while (pWin) - { -#ifdef SHAPE - BoxRec box; -#endif - if ((pWin->mapped) && - (x >= pWin->drawable.x - wBorderWidth (pWin)) && - (x < pWin->drawable.x + (int)pWin->drawable.width + - wBorderWidth (pWin)) && - (y >= pWin->drawable.y - wBorderWidth (pWin)) && - (y < pWin->drawable.y + (int)pWin->drawable.height + - wBorderWidth (pWin)) -#ifdef SHAPE - /* When a window is shaped, a further check - * is made to see if the point is inside - * borderSize - */ - && (!wBoundingShape(pWin) || - RegionContainsPoint( - &pWin->borderSize, x, y, &box)) - - && (!wInputShape(pWin) || - RegionContainsPoint( - wInputShape(pWin), - x - pWin->drawable.x, - y - pWin->drawable.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(register ClientPtr client) @@ -1784,145 +971,6 @@ ProcCloseFont(register ClientPtr client) } } -int -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 = NULL; - 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 */ - } - pFont = pGC->font; - } - -/* test -{ - Atom name_atom, value_atom; - int nprops; - FontPropPtr props; - int i; - char *name; - - name_atom = MakeAtom("FONT", 4, True); - value_atom = 0L; - - nprops = pFont->info.nprops; - props = pFont->info.props; - - for (i = 0; i < nprops; i++) - if (props[i].name == name_atom) { - value_atom = props[i].value; - break; - } - - if (!value_atom) return (BadFont); - - name = (char *)NameForAtom(value_atom); - fprintf(stderr, "QueryFont: font name [%s]\n",name); -} - end test */ - - { - xCharInfo *pmax = FONTINKMAX(pFont); - xCharInfo *pmin = FONTINKMIN(pFont); - int nprotoxcistructs; - int rlength; - - nprotoxcistructs = ( - pmax->rightSideBearing == pmin->rightSideBearing && - pmax->leftSideBearing == pmin->leftSideBearing && - pmax->descent == pmin->descent && - pmax->ascent == pmin->ascent && - pmax->characterWidth == pmin->characterWidth) ? - 0 : N2dChars(pFont); - - rlength = sizeof(xQueryFontReply) + - FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + - nprotoxcistructs * sizeof(xCharInfo); - reply = NULL; - reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength); - if(!reply) - { - return(BadAlloc); - } - memset(reply, 0, rlength); - - 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(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); - } - pFont = pGC->font; - } - length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2); - length = length << 1; - if (stuff->oddLength) - { - if (length == 0) - return(BadLength); - 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(register ClientPtr client) @@ -1962,75 +1010,6 @@ ProcListFontsWithInfo(register ClientPtr client) (unsigned char *) &stuff[1], stuff->maxNames); } -/** - * - * \param value must conform to DeleteType - */ -int -dixDestroyPixmap(void * value, XID pid) -{ - PixmapPtr pPixmap = (PixmapPtr)value; - return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap); -} - -int -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->width > 32767 || stuff->height > 32767) - { - /* It is allowed to try and allocate a pixmap which is larger than - * 32767 in either dimension. However, all of the framebuffer code - * is buggy and does not reliably draw to such big pixmaps, basically - * because the Region data structure operates with signed shorts - * for the rectangles in it. - * - * Furthermore, several places in the X server computes the - * size in bytes of the pixmap and tries to store it in an - * integer. This integer can overflow and cause the allocated size - * to be much smaller. - * - * So, such big pixmaps are rejected here with a BadAlloc - */ - return BadAlloc; - } - if (stuff->depth != 1) - { - pDepth = pDraw->pScreen->allowedDepths; - for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++) - 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, (void *)pMap)) - return(client->noClientException); - } - return (BadAlloc); -} int ProcFreePixmap(register ClientPtr client) @@ -2088,1700 +1067,6 @@ ProcFreePixmap(register ClientPtr client) } } -int -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, (void *)pGC)) - return (BadAlloc); - return(client->noClientException); -} - -int -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(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(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(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(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(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(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) - RegionDestroy(pRgn); - } - - return(client->noClientException); -} - -int -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 - psrcDraw = pdstDraw; - - SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable); - - /* Check to see if stuff->bitPlane has exactly ONE good bit set */ - if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || - (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) - RegionDestroy(pRgn); - } - return(client->noClientException); -} - -int -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(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(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 (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(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(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(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(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 -ServerOrder (void) -{ - int whichbyte = 1; - - if (*((char *) &whichbyte)) - return LSBFirst; - return MSBFirst; -} - -#define ClientOrder(client) ((client)->swapped ? !ServerOrder() : ServerOrder()) - -void -ReformatImage (char *base, int nbytes, int bpp, int order) -{ - switch (bpp) { - case 1: /* yuck */ - if (BITMAP_BIT_ORDER != order) - BitOrderInvert ((unsigned char *) base, nbytes); -#if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8 - ReformatImage (base, nbytes, BITMAP_SCANLINE_UNIT, order); -#endif - break; - case 4: - break; /* yuck */ - case 8: - break; - case 16: - if (IMAGE_BYTE_ORDER != order) - TwoByteSwap ((unsigned char *) base, nbytes); - break; - case 32: - if (IMAGE_BYTE_ORDER != order) - 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(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) || - (stuff->leftPad >= (unsigned int)screenInfo.bitmapScanlinePad)) - return BadMatch; - length = BitmapBytePad(stuff->width + stuff->leftPad); - length *= stuff->depth; - } - else if (stuff->format == ZPixmap) - { - if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0)) - return BadMatch; - length = PixmapBytePad(stuff->width, stuff->depth); - } - else - { - client->errorValue = stuff->format; - return BadValue; - } - - tmpImage = (char *)&stuff[1]; - lengthProto = length; - if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) - return BadLength; - - 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(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); - memset(&xgi, 0, sizeof(xGetImageReply)); - if(pDraw->type == DRAWABLE_WINDOW) - { - if( /* check for being viewable */ - !((WindowPtr) pDraw)->realized || - /* check for being on screen */ - pDraw->x + x < 0 || - pDraw->x + x + width > pDraw->pScreen->width || - pDraw->y + y < 0 || - pDraw->y + y + height > pDraw->pScreen->height || - /* check for being inside of border */ - x < - wBorderWidth((WindowPtr)pDraw) || - x + width > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || - y < -wBorderWidth((WindowPtr)pDraw) || - y + height > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height - ) - return(BadMatch); - xgi.visual = wVisual (((WindowPtr) pDraw)); - } - else - { - if(x < 0 || - x+width > (int)pDraw->width || - y < 0 || - y+height > (int)pDraw->height - ) - return(BadMatch); - xgi.visual = None; - } - - SET_DBE_SRCBUF(pDraw, drawable); - - xgi.type = X_Reply; - xgi.sequenceNumber = client->sequence; - xgi.depth = pDraw->depth; - if(format == ZPixmap) - { - widthBytesLine = PixmapBytePad(width, pDraw->depth); - length = widthBytesLine * height; - - } - else - { - widthBytesLine = BitmapBytePad(width); - plane = ((Mask)1) << (pDraw->depth - 1); - /* only planes asked for */ - length = widthBytesLine * height * - Ones(planemask & (plane | (plane - 1))); - - } - - xgi.length = length; - - if (im_return) { - pBuf = (char *)xcalloc(1, sz_xGetImageReply + length); - if (!pBuf) - return (BadAlloc); - - if (widthBytesLine == 0) - linesPerBuf = 0; - else - linesPerBuf = height; - *im_return = (xGetImageReply *)pBuf; - *(xGetImageReply *)pBuf = xgi; - pBuf += sz_xGetImageReply; - } else { - xgi.length = (xgi.length + 3) >> 2; - if (widthBytesLine == 0 || height == 0) - linesPerBuf = 0; - else if (widthBytesLine >= IMAGE_BUFSIZE) - linesPerBuf = 1; - else - { - linesPerBuf = IMAGE_BUFSIZE / widthBytesLine; - if (linesPerBuf > height) - linesPerBuf = height; - } - length = linesPerBuf * widthBytesLine; - if (linesPerBuf < height) - { - /* we have to make sure intermediate buffers don't need padding */ - while ((linesPerBuf > 1) && - (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1))) - { - linesPerBuf--; - length -= widthBytesLine; - } - while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1)) - { - linesPerBuf++; - length += widthBytesLine; - } - } - if(!(pBuf = (char *) ALLOCATE_LOCAL(length))) - return (BadAlloc); - memset(pBuf, 0, length); - WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); - } - -#ifdef XCSECURITY - if (client->trustLevel != XSecurityClientTrusted && - pDraw->type == DRAWABLE_WINDOW) - { - pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw); - if (pVisibleRegion) - { - RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y); - } - } -#endif - - if (linesPerBuf == 0) - { - /* nothing to do */ - } - else if (format == ZPixmap) - { - linesDone = 0; - while (height - linesDone > 0) - { - nlines = min(linesPerBuf, height - linesDone); - (*pDraw->pScreen->GetImage) (pDraw, - x, - y + linesDone, - width, - nlines, - format, - planemask, - (void *) pBuf); -#ifdef XCSECURITY - if (pVisibleRegion) - SecurityCensorImage(client, pVisibleRegion, widthBytesLine, - pDraw, x, y + linesDone, width, - nlines, format, pBuf); -#endif - - /* Note that this is NOT a call to WriteSwappedDataToClient, - as we do NOT byte swap */ - if (!im_return) - { - ReformatImage (pBuf, (int)(nlines * widthBytesLine), - BitsPerPixel (pDraw->depth), - ClientOrder(client)); - -/* Don't split me, gcc pukes when you do */ - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), - pBuf); - } - linesDone += nlines; - } - } - else /* XYPixmap */ - { - for (; plane; plane >>= 1) - { - if (planemask & plane) - { - linesDone = 0; - while (height - linesDone > 0) - { - nlines = min(linesPerBuf, height - linesDone); - (*pDraw->pScreen->GetImage) (pDraw, - x, - y + linesDone, - width, - nlines, - format, - plane, - (void *)pBuf); -#ifdef XCSECURITY - if (pVisibleRegion) - SecurityCensorImage(client, pVisibleRegion, - widthBytesLine, - pDraw, x, y + linesDone, width, - nlines, format, pBuf); -#endif - - /* Note: NOT a call to WriteSwappedDataToClient, - as we do NOT byte swap */ - if (im_return) { - pBuf += nlines * widthBytesLine; - } else { - ReformatImage (pBuf, - (int)(nlines * widthBytesLine), - 1, - ClientOrder (client)); - -/* Don't split me, gcc pukes when you do */ - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), - pBuf); - } - linesDone += nlines; - } - } - } - } -#ifdef XCSECURITY - if (pVisibleRegion) - RegionDestroy(pVisibleRegion); -#endif - if (!im_return) - DEALLOCATE_LOCAL(pBuf); - return (client->noClientException); -} - -int -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(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(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(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(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); - if (!pWin) - return(BadWindow); - - 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(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(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(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(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(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 (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 - acr.type = X_Reply; - acr.length = 0; - acr.sequenceNumber = client->sequence; - acr.red = stuff->red; - acr.green = stuff->green; - acr.blue = stuff->blue; - acr.pixel = 0; - if( (retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue, - &acr.pixel, client->index)) ) - { - 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 (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)) - return Success; -#endif - ancr.type = X_Reply; - ancr.length = 0; - ancr.sequenceNumber = client->sequence; - - if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes, - &ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) - { - ancr.screenRed = ancr.exactRed; - ancr.screenGreen = ancr.exactGreen; - ancr.screenBlue = ancr.exactBlue; - ancr.pixel = 0; - if( (retval = AllocColor(pcmp, - &ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue, - &ancr.pixel, client->index)) ) - { - if (client->noClientException != Success) - return(client->noClientException); - else - 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 (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. - */ - if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff)) - return Success; -#endif - npixels = stuff->colors; - if (!npixels) - { - client->errorValue = npixels; - return (BadValue); - } - if (stuff->contiguous != xTrue && stuff->contiguous != xFalse) - { - client->errorValue = stuff->contiguous; - return (BadValue); - } - nmasks = stuff->planes; - length = ((long)npixels + (long)nmasks) * sizeof(Pixel); - ppixels = (Pixel *)ALLOCATE_LOCAL(length); - if(!ppixels) - return(BadAlloc); - pmasks = ppixels + npixels; - - if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks, - (Bool)stuff->contiguous, ppixels, pmasks)) ) - { - DEALLOCATE_LOCAL(ppixels); - if (client->noClientException != Success) - return(client->noClientException); - else - return(retval); - } -#ifdef PANORAMIX - if (noPanoramiXExtension || !pcmp->pScreen->myNum) -#endif - { - 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(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. - */ - if (LbxCheckColorRequest (client, pcmp, (xReq *) stuff)) - return Success; -#endif - npixels = stuff->colors; - if (!npixels) - { - client->errorValue = npixels; - return (BadValue); - } - if (stuff->contiguous != xTrue && stuff->contiguous != xFalse) - { - client->errorValue = stuff->contiguous; - return (BadValue); - } - acpr.type = X_Reply; - acpr.sequenceNumber = client->sequence; - acpr.nPixels = npixels; - length = (long)npixels * sizeof(Pixel); - ppixels = (Pixel *)ALLOCATE_LOCAL(length); - if(!ppixels) - return(BadAlloc); - if( (retval = AllocColorPlanes(client->index, pcmp, npixels, - (int)stuff->red, (int)stuff->green, (int)stuff->blue, - (Bool)stuff->contiguous, ppixels, - &acpr.redMask, &acpr.greenMask, &acpr.blueMask)) ) - { - DEALLOCATE_LOCAL(ppixels); - if (client->noClientException != Success) - return(client->noClientException); - else - return(retval); - } - 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(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 (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 (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(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); - memset(prgbs, 0, count * sizeof(xrgb)); - if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) ) - { - if (prgbs) DEALLOCATE_LOCAL(prgbs); - if (client->noClientException != Success) - return(client->noClientException); - else - { - client->errorValue = clientErrorValue; - return (retval); - } - } - memset(&qcr, 0, sizeof(xQueryColorsReply)); - qcr.type = X_Reply; - qcr.length = (count * sizeof(xrgb)) >> 2; - 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(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 (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, - RT_PIXMAP, SecurityReadAccess); - if ( src == (PixmapPtr)NULL) - { - client->errorValue = stuff->source; - return (BadPixmap); - } - if ( msk == (PixmapPtr)NULL) - { - if (stuff->mask != None) - { - client->errorValue = stuff->mask; - return (BadPixmap); - } - } - else if ( src->drawable.width != msk->drawable.width - || src->drawable.height != msk->drawable.height - || src->drawable.depth != 1 - || msk->drawable.depth != 1) - return (BadMatch); - - width = src->drawable.width; - height = src->drawable.height; - - if ( stuff->x > width - || stuff->y > height ) - return (BadMatch); - - n = BitmapBytePad(width)*height; - srcbits = (unsigned char *)xalloc(n); - if (!srcbits) - return (BadAlloc); - mskbits = (unsigned char *)xalloc(n); - if (!mskbits) - { - xfree(srcbits); - return (BadAlloc); - } - - /* zeroing the (pad) bits helps some ddx cursor handling */ - bzero((char *)srcbits, n); - (* src->drawable.pScreen->GetImage)( (DrawablePtr)src, 0, 0, width, height, - XYPixmap, 1, (void *)srcbits); - if ( msk == (PixmapPtr)NULL) - { - register unsigned char *bits = mskbits; - while (--n >= 0) - *bits++ = ~0; - } - else - { - /* 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, (void *)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, (void *)pCursor)) - { - #ifdef TEST - fprintf(stderr, "ProcCreateCursor: Created cursor at [%p].\n", (void *) pCursor); - #endif - - return (client->noClientException); - } - - return BadAlloc; -} - -int -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, (void *)pCursor)) - return client->noClientException; - return BadAlloc; -} - - -int -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 (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); - memset(&reply, 0, sizeof(xQueryBestSizeReply)); - 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 (register ClientPtr client) @@ -3882,217 +1167,14 @@ ProcSetScreenSaver (register ClientPtr client) return (client->noClientException); } -int -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(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, (void *)&stuff[1]); - else if (stuff->mode == HostDelete) - result = RemoveHost(client, (int)stuff->hostFamily, - stuff->hostLength, (void *)&stuff[1]); - else - { - client->errorValue = stuff->mode; - return BadValue; - } - if (!result) - result = client->noClientException; - return (result); -} - -int -ProcListHosts(register ClientPtr client) -{ - xListHostsReply reply; - int len, nHosts, result; - void * 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(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(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(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(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(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(register ClientPtr client) -{ +{ REQUEST(xForceScreenSaverReq); REQUEST_SIZE_MATCH(xForceScreenSaverReq); - - if ((stuff->mode != ScreenSaverReset) && + + if ((stuff->mode != ScreenSaverReset) && (stuff->mode != ScreenSaverActive)) { client->errorValue = stuff->mode; @@ -4125,38 +1207,6 @@ int ProcForceScreenSaver(register ClientPtr client) return client->noClientException; } -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]) - { - k5_Vector[i] = k5_bad; - } -#endif - } - for(i = LASTEvent; i < 128; i++) - { - EventSwapVector[i] = NotImplemented; - } - -} /********************** * CloseDownClient @@ -4230,9 +1280,6 @@ CloseDownClient(register ClientPtr client) if (ClientIsAsleep(client)) ClientSignal (client); ProcessWorkQueueZombies(); -#ifdef LBX - ProcessQTagZombies(); -#endif CloseDownConnection(client); /* If the client made it to the Running stage, nClients has @@ -4276,104 +1323,6 @@ CloseDownClient(register ClientPtr client) } } -static void -KillAllClients() -{ - int i; - for (i=1; i<currentMaxClients; i++) - if (clients[i]) { - /* Make sure Retained clients are released. */ - clients[i]->closeDownMode = DestroyAll; - CloseDownClient(clients[i]); - } -} - -/********************* - * CloseDownRetainedResources - * - * 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; i<currentMaxClients; i++) - { - client = clients[i]; - if (client && (client->closeDownMode == RetainTemporary) - && (client->clientGone)) - CloseDownClient(client); - } -} - -void InitClient(ClientPtr client, int i, void * ospriv) -{ - client->index = i; - client->sequence = 0; - client->clientAsMask = ((Mask)i) << CLIENTOFFSET; - client->clientGone = FALSE; - if (i) - { - client->closeDownMode = DestroyAll; - client->lastDrawable = (DrawablePtr)screenInfo.screens[0]->root; - client->lastDrawableID = screenInfo.screens[0]->root->drawable.id; - } - else - { - client->closeDownMode = RetainPermanent; - client->lastDrawable = (DrawablePtr)NULL; - client->lastDrawableID = INVALID; - } - client->lastGC = (GCPtr) NULL; - client->lastGCID = INVALID; - client->numSaved = 0; - client->saveSet = (SaveSetElt *)NULL; - client->noClientException = Success; -#ifdef LOG_DEBUG - client->requestLogIndex = 0; -#endif - client->requestVector = InitialVector; - client->osPrivate = ospriv; - client->swapped = FALSE; - client->big_requests = FALSE; - client->priority = 0; - client->clientState = ClientStateInitial; -#ifdef XKB - if (!noXkbExtension) { - client->xkbClientFlags = 0; - client->mapNotifyMask = 0; - QueryMinMaxKeyCodes(&client->minKC,&client->maxKC); - } -#endif - client->replyBytesRemaining = 0; -#ifdef LBX - client->readRequest = StandardReadRequestFromClient; -#endif -#ifdef XCSECURITY - client->trustLevel = XSecurityClientTrusted; - 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(ClientPtr client) { @@ -4415,289 +1364,3 @@ InitClientPrivates(ClientPtr client) 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(void * 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; - if (!InsertFakeRequest(client, (char *)&data, sz_xReq)) - { - FreeClientResources(client); - 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), (void *)&clientinfo); - } - return(client); -} - -int -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(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); - (void)WriteToClient(client, (int)csp.lengthReason, reason); - return (client->noClientException = -1); - } - - numScreens = screenInfo.numScreens; - lConnectionInfo = ConnectionInfo; - lconnSetupPrefix = &connSetupPrefix; - - /* We're about to start speaking X protocol back to the client by - * sending the connection setup info. This means the authorization - * step is complete, and we can count the client as an - * authorized one. - */ - nClients++; - - client->requestVector = client->swapped ? SwappedProcVector : ProcVector; - client->sequence = 0; -#ifdef XAPPGROUP - XagConnectionInfo (client, &lconnSetupPrefix, &lConnectionInfo, &numScreens); -#endif - ((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask; - ((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK; -#ifdef MATCH_CLIENT_ENDIAN - ((xConnSetup *)lConnectionInfo)->imageByteOrder = ClientOrder (client); - ((xConnSetup *)lConnectionInfo)->bitmapBitOrder = ClientOrder (client); -#endif - /* fill in the "currentInputMask" */ - root = (xWindowRoot *)(lConnectionInfo + connBlockScreenStart); -#ifdef PANORAMIX - if (noPanoramiXExtension) - numScreens = screenInfo.numScreens; - else - numScreens = ((xConnSetup *)ConnectionInfo)->numRoots; -#endif - - for (i=0; i<numScreens; i++) - { - register unsigned int j; - register xDepth *pDepth; - - root->currentInputMask = screenInfo.screens[i]->root->eventMask | - wOtherEventMasks (screenInfo.screens[i]->root); - pDepth = (xDepth *)(root + 1); - for (j = 0; j < root->nDepths; j++) - { - pDepth = (xDepth *)(((char *)(pDepth + 1)) + - pDepth->nVisuals * sizeof(xVisualType)); - } - root = (xWindowRoot *)pDepth; - } - - if (client->swapped) - { - WriteSConnSetupPrefix(client, lconnSetupPrefix); - WriteSConnectionInfo(client, - (unsigned long)(lconnSetupPrefix->length << 2), - lConnectionInfo); - } - else - { - (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), (void *)&clientinfo); - } - return (client->noClientException); -} - -int -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(ClientPtr client, unsigned majorCode, unsigned minorCode, - XID resId, int errorCode) -{ - xError rep; - - memset(&rep, 0, sizeof(xError)); - 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(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(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(ClientPtr client) -{ - client->noClientException = -1; -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index 33b0ea93d..77f21e495 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -68,31 +68,18 @@ Equipment Corporation. ******************************************************************/ /* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */ -#define NEED_REPLIES -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#include <nx-X11/Xmd.h> -#include <nx-X11/Xproto.h> -#include "scrnintstr.h" -#include "resource.h" #include "dixstruct.h" -#include "cursorstr.h" -#include "misc.h" -#include "opaque.h" #include "dixfontstr.h" -#include "closestr.h" + +static Bool doOpenFont(ClientPtr client, OFclosurePtr c); +static Bool doListFontsAndAliases(ClientPtr client, LFclosurePtr c); + +#include "../../dix/dixfonts.c" /* #define NXAGENT_DEBUG */ -#ifdef DEBUG -#include <stdio.h> -#endif - #include "Agent.h" #include "Font.h" @@ -160,170 +147,6 @@ _NXGetFontPathError: #endif -#ifdef PANORAMIX -#include "../../Xext/panoramiX.h" -#include "../../Xext/panoramiXsrv.h" -#endif - -#ifdef LBX -#include "lbxserve.h" -#endif - -#ifdef XF86BIGFONT -#define _XF86BIGFONT_SERVER_ -#include <nx-X11/extensions/xf86bigfont.h> -#endif - -#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics - -extern void register_fpe_functions(void); - -extern void * fosNaturalParams; -extern FontPtr defaultFont; - -static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; -static int num_fpes = 0; -FPEFunctions *fpe_functions = (FPEFunctions *) 0; -static int num_fpe_types = 0; - -static unsigned char *font_path_string; - -static int num_slept_fpes = 0; -static int size_slept_fpes = 0; -static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; -static FontPatternCachePtr patternCache; - -int -FontToXError(err) - int err; -{ - switch (err) { - 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(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(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(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; - } - } -} - -void -FontWakeup(void * data, int count, void * 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++; -} - -static void -FreeFPE (FontPathElementPtr fpe) -{ - fpe->refcount--; - if (fpe->refcount == 0) { - (*fpe_functions[fpe->type].free_fpe) (fpe); - xfree(fpe->name); - xfree(fpe); - } -} - static Bool doOpenFont(ClientPtr client, OFclosurePtr c) { @@ -509,206 +332,6 @@ bail: return TRUE; } -int -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 - ** is cachable, immediately satisfy the request with it. If we find - ** a cached version of this font that is non-cachable, we do not - ** satisfy the request with it. Instead, we pass the FontPtr to the - ** FPE's open_font code (the fontfile FPE in turn passes the - ** information to the rasterizer; the fserve FPE ignores it). - ** - ** Presumably, the font is marked non-cachable because the FPE has - ** put some licensing restrictions on it. If the FPE, using - ** whatever logic it relies on, determines that it is willing to - ** share this existing font with the client, then it has the option - ** to return the FontPtr we passed it as the newly-opened font. - ** This allows the FPE to exercise its licensing logic without - ** having to create another instance of a font that already exists. - */ - - cached = FindCachedFontPattern(patternCache, pfontname, lenfname); - if (cached && cached->info.cachable) - { - if (!AddResource(fid, RT_FONT, (void *) cached)) - return BadAlloc; - cached->refcnt++; - return Success; - } - } - c = (OFclosurePtr) xalloc(sizeof(OFclosureRec)); - if (!c) - return BadAlloc; - c->fontname = (char *) xalloc(lenfname); - c->origFontName = pfontname; - c->origFontNameLen = lenfname; - if (!c->fontname) { - xfree(c); - return BadAlloc; - } - /* - * copy the current FPE list, so that if it gets changed by another client - * while we're blocking, the request still appears atomic - */ - c->fpe_list = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * num_fpes); - if (!c->fpe_list) { - xfree(c->fontname); - xfree(c); - 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 - */ -int -CloseFont(void * 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 - { - extern void XF86BigfontFreeFontShm(FontPtr); - 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. - * - * \param pReply caller must allocate this storage - */ -void -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; - pReply->maxByte1 = pFont->info.lastRow; - pReply->fontAscent = pFont->info.fontAscent; - pReply->fontDescent = pFont->info.fontDescent; - - pReply->minBounds = pFont->info.ink_minbounds; - pReply->maxBounds = pFont->info.ink_maxbounds; - - pReply->nFontProps = pFont->info.nprops; - pReply->nCharInfos = nProtoCCIStructs; - - for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]); - i < pFont->info.nprops; - i++, pFP++, prFP++) { - prFP->name = pFP->name; - prFP->value = pFP->value; - } - - ninfos = 0; - ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1); - prCI = (xCharInfo *) (prFP); - for (r = pFont->info.firstRow; - ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow; - r++) { - i = 0; - for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) { - chars[i++] = r; - chars[i++] = c; - } - (*pFont->get_metrics) (pFont, ncols, chars, - TwoD16Bit, &count, charInfos); - i = 0; - for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) { - *prCI = *charInfos[i]; - prCI++; - ninfos++; - } - } - return; -} static Bool doListFontsAndAliases(ClientPtr client, LFclosurePtr c) @@ -1294,728 +917,6 @@ bail: return TRUE; } -int -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); - goto badAlloc; - } - 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->reply = 0; - c->length = 0; - 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->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(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) ((void *) 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. */ - c->pDraw = (DrawablePtr)0; - } - else - { - 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 and avoid further - rendering while we clean up after ourself. */ - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); - c->pDraw = (DrawablePtr)0; - } - - client_state = c->slept ? SLEEPING : NEVER_SLEPT; - - while (c->endReq - c->pElt > TextEltHeader) - { - if (*c->pElt == FontChange) - { - if (c->endReq - c->pElt < FontShiftSize) - { - err = BadLength; - goto bail; - } - - oldpFont = pFont; - oldfid = fid; - - fid = ((Font)*(c->pElt+4)) /* big-endian */ - | ((Font)*(c->pElt+3)) << 8 - | ((Font)*(c->pElt+2)) << 16 - | ((Font)*(c->pElt+1)) << 24; - pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT, - SecurityReadAccess); - if (!pFont) - { - client->errorValue = fid; - err = BadFont; - /* restore pFont and fid for step 4 (described below) */ - pFont = oldpFont; - fid = oldfid; - - /* If we're in START_SLEEP mode, the following step - shortens the request... in the unlikely event that - the fid somehow becomes valid before we come through - again to actually execute the polytext, which would - then mess up our refcounting scheme badly. */ - c->err = err; - c->endReq = c->pElt; - - goto bail; - } - - /* Step 3 (described below) on our new font */ - if (client_state == START_SLEEP) - pFont->refcnt++; - else - { - if (pFont != c->pGC->font && c->pDraw) - { - ChangeGC( c->pGC, GCFont, &fid); - ValidateGC(c->pDraw, c->pGC); - if (c->reqType == X_PolyText8) - c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8; - else - c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16; - } - - /* Undo the refcnt++ we performed when going to sleep */ - if (client_state == SLEEPING) - (void)CloseFont(c->pGC->font, (Font)0); - } - c->pElt += FontShiftSize; - } - else /* print a string */ - { - unsigned char *pNextElt; - pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize; - if ( pNextElt > c->endReq) - { - err = BadLength; - goto bail; - } - if (client_state == START_SLEEP) - { - c->pElt = pNextElt; - continue; - } - if (c->pDraw) - { - lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize, - c->pElt + TextEltHeader); - } - else lgerr = Successful; - - if (lgerr == Suspended) - { - if (!c->slept) { - int len; - GC *pGC; - PTclosurePtr new_closure; - - /* We're putting the client to sleep. We need to do a few things - to ensure successful and atomic-appearing execution of the - remainder of the request. First, copy the remainder of the - request into a safe malloc'd area. Second, create a scratch GC - to use for the remainder of the request. Third, mark all fonts - referenced in the remainder of the request to prevent their - deallocation. Fourth, make the original GC look like the - request has completed... set its font to the final font value - from this request. These GC manipulations are for the unlikely - (but possible) event that some other client is using the GC. - Steps 3 and 4 are performed by running this procedure through - the remainder of the request in a special no-render mode - indicated by client_state = START_SLEEP. */ - - /* Step 1 */ - /* Allocate a malloc'd closure structure to replace - the local one we were passed */ - new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec)); - if (!new_closure) - { - err = BadAlloc; - goto bail; - } - *new_closure = *c; - c = new_closure; - - len = c->endReq - c->pElt; - c->data = (unsigned char *)xalloc(len); - if (!c->data) - { - xfree(c); - err = BadAlloc; - goto bail; - } - memmove(c->data, c->pElt, len); - c->pElt = c->data; - c->endReq = c->pElt + len; - - /* Step 2 */ - - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); - if (!pGC) - { - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - - pGC->tileIsPixel = TRUE; - pGC->tile.pixel = 0; - pGC->stipple = NullPixmap; - - if ((err = CopyGC(c->pGC, pGC, GCFunction | - GCPlaneMask | GCForeground | - GCBackground | GCFillStyle | - GCTile | GCStipple | - GCTileStipXOrigin | - GCTileStipYOrigin | GCFont | - GCSubwindowMode | GCClipXOrigin | - GCClipYOrigin | GCClipMask)) != - Success) - { - FreeScratchGC(pGC); - xfree(c->data); - xfree(c); - err = BadAlloc; - goto bail; - } - origGC = c->pGC; - c->pGC = pGC; - ValidateGC(c->pDraw, c->pGC); - - c->slept = TRUE; - ClientSleep(client, - (ClientSleepProcPtr)doPolyText, - (void *) c); -#ifdef NXAGENT_DEBUG - fprintf(stderr, " NXdixfonts: doPolyText (1): client [%lx] sleeping.\n", client); -#endif - - /* Set up to perform steps 3 and 4 */ - client_state = START_SLEEP; - continue; /* on to steps 3 and 4 */ - } - return TRUE; - } - else if (lgerr != Successful) - { - err = FontToXError(lgerr); - goto bail; - } - if (c->pDraw) - { - c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */ - c->xorg = (* c->polyText)(c->pDraw, c->pGC, c->xorg, c->yorg, - *c->pElt, c->pElt + TextEltHeader); - } - c->pElt = pNextElt; - } - } - -bail: - - if (client_state == START_SLEEP) - { - /* Step 4 */ - if (pFont != origGC->font) - { - ChangeGC(origGC, GCFont, &fid); - ValidateGC(c->pDraw, origGC); - } - - /* restore pElt pointer for execution of remainder of the request */ - c->pElt = c->data; - return TRUE; - } - - if (c->err != Success) err = c->err; - if (err != Success && c->client != serverClient) { -#ifdef PANORAMIX - if (noPanoramiXExtension || !c->pGC->pScreen->myNum) -#endif - SendErrorToClient(c->client, c->reqType, 0, 0, err); - } - if (c->slept) - { - ClientWakeup(c->client); -#ifdef NXAGENT_DEBUG - fprintf(stderr, " NXdixfonts: doPolytext: client [%lx] wakeup.\n", client); -#endif - 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(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(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) ((void *) 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. */ - fpe = c->pGC->font->fpe; - (*fpe_functions[fpe->type].client_died) ((void *) client, fpe); - err = Success; - goto bail; - } - - lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data); - if (lgerr == Suspended) - { - if (!c->slept) { - GC *pGC; - unsigned char *data; - ITclosurePtr new_closure; - ITclosurePtr old_closure; - - /* We're putting the client to sleep. We need to - save some state. Similar problem to that handled - in doPolyText, but much simpler because the - request structure is much simpler. */ - - new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec)); - if (!new_closure) - { - err = BadAlloc; - goto bail; - } - old_closure = c; - *new_closure = *c; - c = new_closure; - - data = (unsigned char *)xalloc(c->nChars * c->itemSize); - if (!data) - { - xfree(c); - c = old_closure; - err = BadAlloc; - goto bail; - } - memmove(data, c->data, c->nChars * c->itemSize); - c->data = data; - - pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); - if (!pGC) - { - xfree(c->data); - xfree(c); - c = old_closure; - err = BadAlloc; - goto bail; - } - - pGC->tileIsPixel = TRUE; - pGC->tile.pixel = 0; - pGC->stipple = NullPixmap; - - if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask | - GCForeground | GCBackground | GCFillStyle | - GCTile | GCStipple | GCTileStipXOrigin | - GCTileStipYOrigin | GCFont | - GCSubwindowMode | GCClipXOrigin | - GCClipYOrigin | GCClipMask)) != Success) - { - FreeScratchGC(pGC); - xfree(c->data); - xfree(c); - c = old_closure; - err = BadAlloc; - goto bail; - } - c->pGC = pGC; - ValidateGC(c->pDraw, c->pGC); - - c->slept = TRUE; - ClientSleep(client, (ClientSleepProcPtr)doImageText, (void *) c); -#ifdef NXAGENT_DEBUG - fprintf(stderr, " NXdixfonts: doImageText (1): client [%lx] sleeping.\n", client); -#endif - - } - return TRUE; - } - else if (lgerr != Successful) - { - err = FontToXError(lgerr); - goto bail; - } - if (c->pDraw) - { - (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg, - c->nChars, c->data); - } - -bail: - - if (err != Success && c->client != serverClient) { - SendErrorToClient(c->client, c->reqType, 0, 0, err); - } - if (c->slept) - { - ClientWakeup(c->client); -#ifdef NXAGENT_DEBUG - fprintf(stderr, " NXdixfonts: doImageText: client [%lx] wakeup.\n", client); -#endif - 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(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; - } - local_closure.did = did; - local_closure.slept = FALSE; - - (void) doImageText(client, &local_closure); - return Success; -} - - -/* does the necessary magic to figure out the fpe type */ -static int -DetermineFPEType(char *pathname) -{ - int i; - - for (i = 0; i < num_fpe_types; i++) { - if ((*fpe_functions[i].name_check) (pathname)) - return i; - } - return -1; -} - - -static void -FreeFontPath(FontPathElementPtr *list, int n, Bool force) -{ - int i; - - for (i = 0; i < n; i++) { - if (force) { - /* Sanity check that all refcounts will be 0 by the time - we get to the end of the list. */ - int found = 1; /* the first reference is us */ - int j; - for (j = i+1; j < n; j++) { - if (list[j] == list[i]) - found++; - } - if (list[i]->refcount != found) { - ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n", - list[i]->name_length, list[i]->name, - list[i]->refcount, found); - list[i]->refcount = found; /* ensure it will get freed */ - } - } - FreeFPE(list[i]); - } - xfree((char *) list); -} - -static FontPathElementPtr -find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len) -{ - FontPathElementPtr fpe; - int i; - - for (i = 0; i < num; i++) { - fpe = list[i]; - if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0) - return fpe; - } - return (FontPathElementPtr) 0; -} - - -static int -SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) -{ - int i, err = 0; - int valid_paths = 0; - unsigned int len; - unsigned char *cp = paths; - FontPathElementPtr fpe = NULL, *fplist; - - fplist = (FontPathElementPtr *) - xalloc(sizeof(FontPathElementPtr) * npaths); - if (!fplist) { - *bad = 0; - return BadAlloc; - } - for (i = 0; i < num_fpe_types; i++) { - if (fpe_functions[i].set_path_hook) - (*fpe_functions[i].set_path_hook) (); - } - for (i = 0; i < npaths; i++) - { - len = (unsigned int) (*cp++); - - if (len == 0) - { - if (persist) - ErrorF ("Removing empty element from the valid list of fontpaths\n"); - err = BadValue; - } - else - { - /* if it's already in our active list, just reset it */ - /* - * note that this can miss FPE's in limbo -- may be worth catching - * them, though it'd muck up refcounting - */ - fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); - if (fpe) - { - err = (*fpe_functions[fpe->type].reset_fpe) (fpe); - if (err == Successful) - { - UseFPE(fpe);/* since it'll be decref'd later when freed - * from the old list */ - } - else - fpe = 0; - } - /* if error or can't do it, act like it's a new one */ - if (!fpe) - { - fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec)); - if (!fpe) - { - err = BadAlloc; - goto bail; - } - fpe->name = (char *) xalloc(len + 1); - if (!fpe->name) - { - xfree(fpe); - err = BadAlloc; - goto bail; - } - fpe->refcount = 1; - - strncpy(fpe->name, (char *) cp, (int) len); - fpe->name[len] = '\0'; - fpe->name_length = len; - fpe->type = DetermineFPEType(fpe->name); - if (fpe->type == -1) - err = BadValue; - else - err = (*fpe_functions[fpe->type].init_fpe) (fpe); - if (err != Successful) - { - #ifndef NXAGENT_SERVER - if (persist) - { - ErrorF("Could not init font path element %s, removing from list!\n", - fpe->name); - } - #endif - xfree (fpe->name); - xfree (fpe); - } - } - } - if (err != Successful) - { - if (!persist) - goto bail; - } - else - { - fplist[valid_paths++] = fpe; - } - 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(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(char *path) @@ -2066,296 +967,6 @@ SetDefaultFontPath(char *path) return err; } -unsigned char * -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(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(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) ((void *) client, fpe); - } -} - -void -InitFonts () -{ - patternCache = MakeFontPatternCache(); - - register_fpe_functions(); -} - -int -GetDefaultPointSize () -{ - return 120; -} - - -FontResolutionPtr -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; - res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight; - if (res.y_resolution < 88) - res.y_resolution = 75; - else - res.y_resolution = 100; - res.point_size = 120; - *num = 1; - return &res; - } -} - -/* - * returns the type index of the new fpe - * - * should be called (only once!) by each type of fpe when initialized - */ - -int -RegisterFPEFunctions(NameCheckFunc name_func, - InitFpeFunc init_func, - FreeFpeFunc free_func, - ResetFpeFunc reset_func, - OpenFontFunc open_func, - CloseFontFunc close_func, - ListFontsFunc list_func, - StartLfwiFunc start_lfwi_func, - NextLfwiFunc next_lfwi_func, - WakeupFpeFunc wakeup_func, - ClientDiedFunc client_died, - LoadGlyphsFunc load_glyphs, - StartLaFunc start_list_alias_func, - NextLaFunc next_list_alias_func, - SetPathFunc set_path_func) -{ - FPEFunctions *new; - - /* grow the list */ - new = (FPEFunctions *) xrealloc(fpe_functions, - (num_fpe_types + 1) * sizeof(FPEFunctions)); - if (!new) - return -1; - fpe_functions = new; - - fpe_functions[num_fpe_types].name_check = name_func; - fpe_functions[num_fpe_types].open_font = open_func; - fpe_functions[num_fpe_types].close_font = close_func; - fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func; - fpe_functions[num_fpe_types].list_fonts = list_func; - fpe_functions[num_fpe_types].start_list_fonts_with_info = - start_lfwi_func; - fpe_functions[num_fpe_types].list_next_font_with_info = - next_lfwi_func; - fpe_functions[num_fpe_types].init_fpe = init_func; - fpe_functions[num_fpe_types].free_fpe = free_func; - fpe_functions[num_fpe_types].reset_fpe = reset_func; - fpe_functions[num_fpe_types].client_died = client_died; - fpe_functions[num_fpe_types].load_glyphs = load_glyphs; - fpe_functions[num_fpe_types].start_list_fonts_and_aliases = - start_list_alias_func; - fpe_functions[num_fpe_types].list_next_font_or_alias = - next_list_alias_func; - fpe_functions[num_fpe_types].set_path_hook = set_path_func; - - return num_fpe_types++; -} - -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(XID id) -{ - return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE, - SecurityUnknownAccess); -} - -Font -GetNewFontClientID() -{ - return FakeClientID(0); -} - -int -StoreFontClientFont(FontPtr pfont, Font id) -{ - return AddResource(id, RT_NONE, (void *) pfont); -} - -void -DeleteFontClientID(Font id) -{ - FreeResource(id, RT_NONE); -} - -int -client_auth_generation(ClientPtr client) -{ - return 0; -} - -static int fs_handlers_installed = 0; -static unsigned int last_server_gen; - -int -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, (void *) 0)) - return AllocError; - fs_handlers_installed++; - } - QueueFontWakeup(fpe); - return Successful; -} - -void -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, - (void *) 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)) -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++) { - void * row = (void *) cip->bits + r * bpr; - - byte = 0; - for (l = 0; l <= (cip->metrics.rightSideBearing - - cip->metrics.leftSideBearing); l++) { - if (maskTab[l & 7] & (((int *)row)[l >> 3])) - putchar('X'); - else - putchar('.'); - } - putchar('\n'); - } -} - -#endif - typedef struct { @@ -2796,4 +1407,3 @@ nxOpenFont(client, fid, flags, lenfname, pfontname) nxdoListFontsAndAliases(client, fss); return Success; } - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c index 3142233ac..be42ea110 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c @@ -128,59 +128,9 @@ of the copyright holder. /* $Xorg: events.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#include "Xlib.h" -#include "misc.h" -#include "resource.h" -#define NEED_EVENTS -#define NEED_REPLIES -#include <nx-X11/Xproto.h> -#include "windowstr.h" -#include "inputstr.h" -#include "scrnintstr.h" -#include "cursorstr.h" - -#include "dixstruct.h" -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif -#include "globals.h" - -#ifdef XKB -#include <nx-X11/extensions/XKBsrv.h> -extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); -#endif - -#ifdef XCSECURITY -#define _SECURITY_SERVER -#include <nx-X11/extensions/security.h> -#endif - -#ifdef XEVIE -extern int xevieFlag; -extern int xevieClientIndex; -extern DeviceIntPtr xeviemouse; -extern DeviceIntPtr xeviekb; -extern Mask xevieMask; -extern Mask xevieFilters[128]; -extern int xevieEventSent; -extern int xevieKBEventSent; -int xeviegrabState = 0; -xEvent *xeviexE; -#endif - -#include <nx-X11/extensions/XIproto.h> -#include "exevents.h" -#include "extnsionst.h" +#include <nx-X11/Xlib.h> -#include "dixevents.h" -#include "dixgrabs.h" -#include "../../dix/dispatch.h" +#include "../../dix/events.c" #include <nx/NXlib.h> @@ -188,1147 +138,10 @@ xEvent *xeviexE; #include "Windows.h" #include "Args.h" -#ifdef NX_DEBUG_INPUT -extern int nxagentDebugInput; -extern int nxagentDebugInputDevices; -#endif - extern Display *nxagentDisplay; extern WindowPtr nxagentLastEnteredWindow; -#define EXTENSION_EVENT_BASE 64 - -#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */ -#define StructureAndSubMask ( StructureNotifyMask | SubstructureNotifyMask ) -#define AllButtonsMask ( \ - Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) -#define MotionMask ( \ - PointerMotionMask | Button1MotionMask | \ - Button2MotionMask | Button3MotionMask | Button4MotionMask | \ - Button5MotionMask | ButtonMotionMask ) -#define PropagateMask ( \ - KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | \ - MotionMask ) -#define PointerGrabMask ( \ - ButtonPressMask | ButtonReleaseMask | \ - EnterWindowMask | LeaveWindowMask | \ - PointerMotionHintMask | KeymapStateMask | \ - MotionMask ) -#define AllModifiersMask ( \ - ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \ - Mod3Mask | Mod4Mask | Mod5Mask ) -#define AllEventMasks (lastEventMask|(lastEventMask-1)) -/* - * The following relies on the fact that the Button<n>MotionMasks are equal - * to the corresponding Button<n>Masks from the current modifier/button state. - */ -#define Motion_Filter(class) (PointerMotionMask | \ - (class)->state | (class)->motionMask) - - -#define WID(w) ((w) ? ((w)->drawable.id) : 0) - -#define XE_KBPTR (xE->u.keyButtonPointer) - - -#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) - -CallbackListPtr EventCallback; -CallbackListPtr DeviceEventCallback; - -#define DNPMCOUNT 8 - -Mask DontPropagateMasks[DNPMCOUNT]; -static int DontPropagateRefCnts[DNPMCOUNT]; - -#ifdef DEBUG -static debug_events = 0; -#endif -InputInfo inputInfo; - -static struct { - QdEventPtr pending, *pendtail; - DeviceIntPtr replayDev; /* kludgy rock to put flag for */ - WindowPtr replayWin; /* ComputeFreezes */ - Bool playingEvents; - TimeStamp time; -} syncEvents; - -/* - * The window trace information is used to avoid having to compute all the - * windows between the root and the current pointer window each time a button - * or key goes down. The grabs on each of those windows must be checked. - */ -static WindowPtr *spriteTrace = (WindowPtr *)NULL; -#define ROOT spriteTrace[0] -static int spriteTraceSize = 0; -static int spriteTraceGood; - -static struct { - CursorPtr current; - BoxRec hotLimits; /* logical constraints of hot spot */ - Bool confined; /* confined to screen */ -#if defined(SHAPE) || defined(PANORAMIX) - RegionPtr hotShape; /* additional logical shape constraint */ -#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 -); - -static WindowPtr XYToWindow( - 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) */ - EnterWindowMask, /* EnterNotify */ - LeaveWindowMask, /* LeaveNotify */ - FocusChangeMask, /* FocusIn */ - FocusChangeMask, /* FocusOut */ - KeymapStateMask, /* KeymapNotify */ - ExposureMask, /* Expose */ - CantBeFiltered, /* GraphicsExpose */ - CantBeFiltered, /* NoExpose */ - VisibilityChangeMask, /* VisibilityNotify */ - SubstructureNotifyMask, /* CreateNotify */ - StructureAndSubMask, /* DestroyNotify */ - StructureAndSubMask, /* UnmapNotify */ - StructureAndSubMask, /* MapNotify */ - SubstructureRedirectMask, /* MapRequest */ - StructureAndSubMask, /* ReparentNotify */ - StructureAndSubMask, /* ConfigureNotify */ - SubstructureRedirectMask, /* ConfigureRequest */ - StructureAndSubMask, /* GravityNotify */ - ResizeRedirectMask, /* ResizeRequest */ - StructureAndSubMask, /* CirculateNotify */ - SubstructureRedirectMask, /* CirculateRequest */ - PropertyChangeMask, /* PropertyNotify */ - CantBeFiltered, /* SelectionClear */ - CantBeFiltered, /* SelectionRequest */ - CantBeFiltered, /* SelectionNotify */ - ColormapChangeMask, /* ColormapNotify */ - CantBeFiltered, /* ClientMessage */ - CantBeFiltered /* MappingNotify */ -}; - -static CARD8 criticalEvents[32] = -{ - 0x7c /* key and button events */ -}; - -#ifdef PANORAMIX - -static void ConfineToShape(RegionPtr shape, int *px, int *py); -static void SyntheticMotion(int x, int y); -static void PostNewCursor(void); - -static Bool -XineramaSetCursorPosition( - int x, - int y, - Bool generateEvent -){ - ScreenPtr pScreen; - BoxRec box; - int i; - - /* x,y are in Screen 0 coordinates. We need to decide what Screen - to send the message too and what the coordinates relative to - that screen are. */ - - pScreen = sprite.screen; - x += panoramiXdataPtr[0].x; - y += panoramiXdataPtr[0].y; - - if(!RegionContainsPoint(&XineramaScreenRegions[pScreen->myNum], - x, y, &box)) - { - FOR_NSCREENS(i) - { - if(i == pScreen->myNum) - continue; - if(RegionContainsPoint(&XineramaScreenRegions[i], x, y, &box)) - { - pScreen = screenInfo.screens[i]; - break; - } - } - } - - sprite.screen = pScreen; - sprite.hotPhys.x = x - panoramiXdataPtr[0].x; - sprite.hotPhys.y = y - panoramiXdataPtr[0].y; - x -= panoramiXdataPtr[pScreen->myNum].x; - y -= panoramiXdataPtr[pScreen->myNum].y; - - return (*pScreen->SetCursorPosition)(pScreen, x, y, generateEvent); -} - - -static void -XineramaConstrainCursor(void) -{ - ScreenPtr pScreen = sprite.screen; - BoxRec newBox = sprite.physLimits; - - /* Translate the constraining box to the screen - the sprite is actually on */ - newBox.x1 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x; - newBox.x2 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x; - newBox.y1 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y; - newBox.y2 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y; - - (* pScreen->ConstrainCursor)(pScreen, &newBox); -} - -static void -XineramaCheckPhysLimits( - CursorPtr cursor, - Bool generateEvents -){ - HotSpot new; - - if (!cursor) - return; - - new = sprite.hotPhys; - - /* I don't care what the DDX has to say about it */ - sprite.physLimits = sprite.hotLimits; - - /* constrain the pointer to those limits */ - if (new.x < sprite.physLimits.x1) - new.x = sprite.physLimits.x1; - else - if (new.x >= sprite.physLimits.x2) - new.x = sprite.physLimits.x2 - 1; - if (new.y < sprite.physLimits.y1) - new.y = sprite.physLimits.y1; - else - if (new.y >= sprite.physLimits.y2) - new.y = sprite.physLimits.y2 - 1; - - if (sprite.hotShape) /* more work if the shape is a mess */ - ConfineToShape(sprite.hotShape, &new.x, &new.y); - - if((new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y)) - { - XineramaSetCursorPosition (new.x, new.y, generateEvents); - if (!generateEvents) - SyntheticMotion(new.x, new.y); - } - - /* Tell DDX what the limits are */ - XineramaConstrainCursor(); -} - - -static Bool -XineramaSetWindowPntrs(WindowPtr pWin) -{ - if(pWin == screenInfo.screens[0]->root) { - int i; - for (i = 0; i < PanoramiXNumScreens; i++) - sprite.windows[i] = screenInfo.screens[i]->root; - } else { - PanoramiXRes *win; - int i; - - win = (PanoramiXRes*)LookupIDByType(pWin->drawable.id, XRT_WINDOW); - - if(!win) - return FALSE; - - for(i = 0; i < PanoramiXNumScreens; i++) { - sprite.windows[i] = LookupIDByType(win->info[i].id, RT_WINDOW); - if(!sprite.windows[i]) /* window is being unmapped */ - return FALSE; - } - } - return TRUE; -} - -static void -XineramaCheckVirtualMotion( - QdEventPtr qe, - WindowPtr pWin -){ - - if (qe) - { - sprite.hot.pScreen = qe->pScreen; /* should always be Screen 0 */ -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = qe->event->u.keyButtonPointer.rootX; -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = qe->event->u.keyButtonPointer.rootY; - pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo : - NullWindow; - } - if (pWin) - { - int x, y, off_x, off_y, i; - BoxRec lims; - - if(!XineramaSetWindowPntrs(pWin)) - return; - - i = PanoramiXNumScreens - 1; - - RegionCopy(&sprite.Reg2, - &sprite.windows[i]->borderSize); - off_x = panoramiXdataPtr[i].x; - off_y = panoramiXdataPtr[i].y; - - while(i--) { - x = off_x - panoramiXdataPtr[i].x; - y = off_y - panoramiXdataPtr[i].y; - - if(x || y) - RegionTranslate(&sprite.Reg2, x, y); - - RegionUnion(&sprite.Reg2, &sprite.Reg2, - &sprite.windows[i]->borderSize); - - off_x = panoramiXdataPtr[i].x; - off_y = panoramiXdataPtr[i].y; - } - - lims = *RegionExtents(&sprite.Reg2); - - if (sprite.hot.x < lims.x1) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = lims.x1; - else if (sprite.hot.x >= lims.x2) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = lims.x2 - 1; - if (sprite.hot.y < lims.y1) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = lims.y1; - else if (sprite.hot.y >= lims.y2) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = lims.y2 - 1; - - if (RegionNumRects(&sprite.Reg2) > 1) - ConfineToShape(&sprite.Reg2, &sprite.hot.x, &sprite.hot.y); - - if (qe) - { - qe->pScreen = sprite.hot.pScreen; - qe->event->u.keyButtonPointer.rootX = sprite.hot.x; - qe->event->u.keyButtonPointer.rootY = sprite.hot.y; - } - } -} - - -static Bool -XineramaCheckMotion(xEvent *xE) -{ - WindowPtr prevSpriteWin = sprite.win; - - if (xE && !syncEvents.playingEvents) - { - /* Motion events entering DIX get translated to Screen 0 - coordinates. Replayed events have already been - translated since they've entered DIX before */ - XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x - - panoramiXdataPtr[0].x; - XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y - - panoramiXdataPtr[0].y; -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = XE_KBPTR.rootX; -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = XE_KBPTR.rootY; - if (sprite.hot.x < sprite.physLimits.x1) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = sprite.physLimits.x1; - else if (sprite.hot.x >= sprite.physLimits.x2) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = sprite.physLimits.x2 - 1; - if (sprite.hot.y < sprite.physLimits.y1) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = sprite.physLimits.y1; - else if (sprite.hot.y >= sprite.physLimits.y2) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = sprite.physLimits.y2 - 1; - - if (sprite.hotShape) - ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y); - - sprite.hotPhys = sprite.hot; - if ((sprite.hotPhys.x != XE_KBPTR.rootX) || - (sprite.hotPhys.y != XE_KBPTR.rootY)) - { - XineramaSetCursorPosition( - sprite.hotPhys.x, sprite.hotPhys.y, FALSE); - } - XE_KBPTR.rootX = sprite.hot.x; - XE_KBPTR.rootY = sprite.hot.y; - } - -#ifdef XEVIE - xeviewin = -#endif - sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y); - - if (sprite.win != prevSpriteWin) - { - if (prevSpriteWin != NullWindow) { - if (!xE) - UpdateCurrentTimeIf(); - DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal); - } - PostNewCursor(); - return FALSE; - } - return TRUE; -} - - -static void -XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents) -{ - - if (syncEvents.playingEvents) - { - XineramaCheckVirtualMotion((QdEventPtr)NULL, pWin); - SyntheticMotion(sprite.hot.x, sprite.hot.y); - } - else - { - int x, y, off_x, off_y, i; - - if(!XineramaSetWindowPntrs(pWin)) - return; - - i = PanoramiXNumScreens - 1; - - RegionCopy(&sprite.Reg1, - &sprite.windows[i]->borderSize); - off_x = panoramiXdataPtr[i].x; - off_y = panoramiXdataPtr[i].y; - - while(i--) { - x = off_x - panoramiXdataPtr[i].x; - y = off_y - panoramiXdataPtr[i].y; - - if(x || y) - RegionTranslate(&sprite.Reg1, x, y); - - RegionUnion(&sprite.Reg1, &sprite.Reg1, - &sprite.windows[i]->borderSize); - - off_x = panoramiXdataPtr[i].x; - off_y = panoramiXdataPtr[i].y; - } - - sprite.hotLimits = *RegionExtents(&sprite.Reg1); - - if(RegionNumRects(&sprite.Reg1) > 1) - sprite.hotShape = &sprite.Reg1; - else - sprite.hotShape = NullRegion; - - sprite.confined = FALSE; - sprite.confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin; - - XineramaCheckPhysLimits(sprite.current, generateEvents); - } -} - - -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); - FreeCursor(sprite.current, (Cursor)0); - sprite.current = cursor; - sprite.current->refcnt++; - } -} - - -#endif /* PANORAMIX */ - -void -SetMaskForEvent(Mask mask, int event) -{ - if ((event < LASTEvent) || (event >= 128)) - FatalError("SetMaskForEvent: bogus event number"); - filters[event] = mask; -} - -void -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 - xE.u.keyButtonPointer.rootX = x; - xE.u.keyButtonPointer.rootY = y; - if (syncEvents.playingEvents) - xE.u.keyButtonPointer.time = syncEvents.time.milliseconds; - else - xE.u.keyButtonPointer.time = currentTime.milliseconds; - xE.u.u.type = MotionNotify; - (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1); -} - -#ifdef SHAPE -static void -ConfineToShape(RegionPtr shape, int *px, int *py) -{ - BoxRec box; - int x = *px, y = *py; - int incx = 1, incy = 1; - - if (RegionContainsPoint(shape, x, y, &box)) - return; - box = *RegionExtents(shape); - /* this is rather crude */ - do { - x += incx; - if (x >= box.x2) - { - incx = -1; - x = *px - 1; - } - else if (x < box.x1) - { - incx = 1; - x = *px; - y += incy; - if (y >= box.y2) - { - incy = -1; - y = *py - 1; - } - else if (y < box.y1) - return; /* should never get here! */ - } - } while (!RegionContainsPoint(shape, x, y, &box)); - *px = x; - *py = y; -} -#endif - -static void -CheckPhysLimits( - CursorPtr cursor, - Bool generateEvents, - Bool confineToScreen, - ScreenPtr pScreen) -{ - HotSpot new; - - if (!cursor) - return; - new = sprite.hotPhys; - if (pScreen) - new.pScreen = pScreen; - else - pScreen = new.pScreen; - (*pScreen->CursorLimits) (pScreen, cursor, &sprite.hotLimits, - &sprite.physLimits); - sprite.confined = confineToScreen; - (* pScreen->ConstrainCursor)(pScreen, &sprite.physLimits); - if (new.x < sprite.physLimits.x1) - new.x = sprite.physLimits.x1; - else - if (new.x >= sprite.physLimits.x2) - new.x = sprite.physLimits.x2 - 1; - if (new.y < sprite.physLimits.y1) - new.y = sprite.physLimits.y1; - else - if (new.y >= sprite.physLimits.y2) - new.y = sprite.physLimits.y2 - 1; -#ifdef SHAPE - if (sprite.hotShape) - ConfineToShape(sprite.hotShape, &new.x, &new.y); -#endif - if ((pScreen != sprite.hotPhys.pScreen) || - (new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y)) - { - if (pScreen != sprite.hotPhys.pScreen) - sprite.hotPhys = new; - (*pScreen->SetCursorPosition) (pScreen, new.x, new.y, generateEvents); - if (!generateEvents) - SyntheticMotion(new.x, new.y); - } -} - -static void -CheckVirtualMotion( - register QdEventPtr qe, - register WindowPtr pWin) -{ -#ifdef PANORAMIX - if(!noPanoramiXExtension) { - XineramaCheckVirtualMotion(qe, pWin); - return; - } -#endif - if (qe) - { - sprite.hot.pScreen = qe->pScreen; -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = qe->event->u.keyButtonPointer.rootX; -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = qe->event->u.keyButtonPointer.rootY; - pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo : - NullWindow; - } - if (pWin) - { - BoxRec lims; - - if (sprite.hot.pScreen != pWin->drawable.pScreen) - { - sprite.hot.pScreen = pWin->drawable.pScreen; -#ifdef XEVIE - xeviehot.x = xeviehot.y = 0; -#endif - sprite.hot.x = sprite.hot.y = 0; - } - lims = *RegionExtents(&pWin->borderSize); - if (sprite.hot.x < lims.x1) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = lims.x1; - else if (sprite.hot.x >= lims.x2) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = lims.x2 - 1; - if (sprite.hot.y < lims.y1) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = lims.y1; - else if (sprite.hot.y >= lims.y2) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = lims.y2 - 1; -#ifdef SHAPE - if (wBoundingShape(pWin)) - ConfineToShape(&pWin->borderSize, &sprite.hot.x, &sprite.hot.y); -#endif - if (qe) - { - qe->pScreen = sprite.hot.pScreen; - qe->event->u.keyButtonPointer.rootX = sprite.hot.x; - qe->event->u.keyButtonPointer.rootY = sprite.hot.y; - } - } - ROOT = sprite.hot.pScreen->root; -} - -static void -ConfineCursorToWindow(WindowPtr pWin, Bool generateEvents, Bool confineToScreen) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - -#ifdef PANORAMIX - if(!noPanoramiXExtension) { - XineramaConfineCursorToWindow(pWin, generateEvents); - return; - } -#endif - - if (syncEvents.playingEvents) - { - CheckVirtualMotion((QdEventPtr)NULL, pWin); - SyntheticMotion(sprite.hot.x, sprite.hot.y); - } - else - { - sprite.hotLimits = *RegionExtents(&pWin->borderSize); -#ifdef SHAPE - sprite.hotShape = wBoundingShape(pWin) ? &pWin->borderSize - : NullRegion; -#endif - CheckPhysLimits(sprite.current, generateEvents, confineToScreen, - pScreen); - } -} - -Bool -PointerConfinedToScreen() -{ - return sprite.confined; -} - -static void -ChangeToCursor(CursorPtr cursor) -{ -#ifdef PANORAMIX - 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); - FreeCursor(sprite.current, (Cursor)0); - sprite.current = cursor; - sprite.current->refcnt++; - } -} - -/* returns true if b is a descendent of a */ -Bool -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; - } - if (IsParent(grab->window, sprite.win)) - win = sprite.win; - else - win = grab->window; - } - else - win = sprite.win; - for (; win; win = win->parent) - if (win->optional && win->optional->cursor != NullCursor) - { - ChangeToCursor(win->optional->cursor); - return; - } -} - -WindowPtr -GetCurrentRootWindow() -{ - return ROOT; -} - -WindowPtr -GetSpriteWindow() -{ - return sprite.win; -} - -CursorPtr -GetSpriteCursor() -{ - return sprite.current; -} - -void -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(register xEvent *xE) -{ - if (!syncEvents.playingEvents) - NoticeTime(xE); -} - -/************************************************************************** - * The following procedures deal with synchronous events * - **************************************************************************/ - -void -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 - * the current root window; the apparently reasonable alternative - * GetCurrentRootWindow()->drawable.id doesn't give you the right - * answer on the first motion event after a screen change because - * the data that GetCurrentRootWindow relies on hasn't been - * updated yet. - */ - if (xE->u.u.type == MotionNotify) - XE_KBPTR.root = - sprite.hotPhys.pScreen->root->drawable.id; - eventinfo.events = xE; - eventinfo.count = count; - CallCallbacks(&DeviceEventCallback, (void *)&eventinfo); - } - if (xE->u.u.type == MotionNotify) - { -#ifdef PANORAMIX - if(!noPanoramiXExtension) { - XE_KBPTR.rootX += panoramiXdataPtr[sprite.screen->myNum].x - - panoramiXdataPtr[0].x; - XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y - - panoramiXdataPtr[0].y; - } -#endif - sprite.hotPhys.x = XE_KBPTR.rootX; - sprite.hotPhys.y = XE_KBPTR.rootY; - /* do motion compression */ - if (tail && - (tail->event->u.u.type == MotionNotify) && - (tail->pScreen == sprite.hotPhys.pScreen)) - { - tail->event->u.keyButtonPointer.rootX = sprite.hotPhys.x; - tail->event->u.keyButtonPointer.rootY = sprite.hotPhys.y; - tail->event->u.keyButtonPointer.time = XE_KBPTR.time; - tail->months = currentTime.months; - return; - } - } - qe = (QdEventPtr)xalloc(sizeof(QdEventRec) + (count * sizeof(xEvent))); - if (!qe) - return; - qe->next = (QdEventPtr)NULL; - qe->device = device; - qe->pScreen = sprite.hotPhys.pScreen; - qe->months = currentTime.months; - qe->event = (xEvent *)(qe + 1); - qe->evcount = count; - for (qxE = qe->event; --count >= 0; qxE++, xE++) - *qxE = *xE; - if (tail) - syncEvents.pendtail = &tail->next; - *syncEvents.pendtail = qe; -} - -static void -PlayReleasedEvents(void) -{ - register QdEventPtr *prev, qe; - register DeviceIntPtr dev; - - prev = &syncEvents.pending; - while ( (qe = *prev) ) - { - if (!qe->device->sync.frozen) - { - *prev = qe->next; - if (*syncEvents.pendtail == *prev) - syncEvents.pendtail = prev; - if (qe->event->u.u.type == MotionNotify) - CheckVirtualMotion(qe, NullWindow); - syncEvents.time.months = qe->months; - syncEvents.time.milliseconds = qe->event->u.keyButtonPointer.time; -#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) { - qe->event->u.keyButtonPointer.rootX += - panoramiXdataPtr[0].x - - panoramiXdataPtr[sprite.screen->myNum].x; - qe->event->u.keyButtonPointer.rootY += - panoramiXdataPtr[0].y - - panoramiXdataPtr[sprite.screen->myNum].y; - } -#endif - (*qe->device->public.processInputProc)(qe->event, qe->device, - qe->evcount); - xfree(qe); - for (dev = inputInfo.devices; dev && dev->sync.frozen; dev = dev->next) - ; - if (!dev) - break; - /* Playing the event may have unfrozen another device. */ - /* So to play it safe, restart at the head of the queue */ - prev = &syncEvents.pending; - } - else - prev = &qe->next; - } -} - -static void -FreezeThaw(register DeviceIntPtr dev, Bool frozen) -{ - dev->sync.frozen = frozen; - if (frozen) - dev->public.processInputProc = dev->public.enqueueInputProc; - else - dev->public.processInputProc = dev->public.realInputProc; -} - -void -ComputeFreezes() -{ - register DeviceIntPtr replayDev = syncEvents.replayDev; - register int i; - WindowPtr w; - register xEvent *xE; - int count; - GrabPtr grab; - register DeviceIntPtr dev; - - for (dev = inputInfo.devices; dev; dev = dev->next) - FreezeThaw(dev, dev->sync.other || (dev->sync.state >= FROZEN)); - if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending)) - return; - syncEvents.playingEvents = TRUE; - if (replayDev) - { - xE = replayDev->sync.event; - count = replayDev->sync.evcount; - syncEvents.replayDev = (DeviceIntPtr)NULL; - - w = XYToWindow( XE_KBPTR.rootX, XE_KBPTR.rootY); - for (i = 0; i < spriteTraceGood; i++) - { - if (syncEvents.replayWin == spriteTrace[i]) - { - if (!CheckDeviceGrabs(replayDev, xE, i+1, count)) { - if (replayDev->focus) - DeliverFocusedEvent(replayDev, xE, w, count); - else - DeliverDeviceEvents(w, xE, NullGrab, NullWindow, - replayDev, count); - } - goto playmore; - } - } - /* must not still be in the same stack */ - if (replayDev->focus) - DeliverFocusedEvent(replayDev, xE, w, count); - else - DeliverDeviceEvents(w, xE, NullGrab, NullWindow, replayDev, count); - } -playmore: - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (!dev->sync.frozen) - { - PlayReleasedEvents(); - break; - } - } - syncEvents.playingEvents = FALSE; - /* the following may have been skipped during replay, so do it now */ - 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(sprite.hotPhys.pScreen->root, - TRUE, FALSE); - PostNewCursor(); -} - -#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(sprite.hotPhys.pScreen->root, - TRUE, FALSE); -} -#endif - -void -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(register DeviceIntPtr mouse, register GrabPtr grab, TimeStamp time, Bool autoGrab) @@ -1442,700 +255,59 @@ DeactivatePointerGrab(register DeviceIntPtr mouse) #endif } -void -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(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(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; - if (thisDev->sync.other == dev->grab) - thisSynced = TRUE; - if (dev->sync.state < FROZEN) - othersFrozen = FALSE; - } - else if (!dev->sync.other || !SameClient(dev->sync.other, client)) - othersFrozen = FALSE; - } - if (!((thisGrabbed && thisDev->sync.state >= FROZEN) || thisSynced)) - return; - if ((CompareTimeStamps(time, currentTime) == LATER) || - (CompareTimeStamps(time, grabTime) == EARLIER)) - return; - switch (newState) - { - case THAWED: /* Async */ - if (thisGrabbed) - thisDev->sync.state = THAWED; - if (thisSynced) - thisDev->sync.other = NullGrab; - ComputeFreezes(); - break; - case FREEZE_NEXT_EVENT: /* Sync */ - if (thisGrabbed) - { - thisDev->sync.state = FREEZE_NEXT_EVENT; - if (thisSynced) - thisDev->sync.other = NullGrab; - ComputeFreezes(); - } - break; - case THAWED_BOTH: /* AsyncBoth */ - if (othersFrozen) - { - for (dev = inputInfo.devices; dev; dev = dev->next) - { - 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; - case FREEZE_BOTH_NEXT_EVENT: /* SyncBoth */ - if (othersFrozen) - { - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (dev->grab && SameClient(dev->grab, client)) - dev->sync.state = FREEZE_BOTH_NEXT_EVENT; - if (dev->sync.other && SameClient(dev->sync.other, client)) - dev->sync.other = NullGrab; - } - ComputeFreezes(); - } - break; - case NOT_GRABBED: /* Replay */ - if (thisGrabbed && thisDev->sync.state == FROZEN_WITH_EVENT) - { - if (thisSynced) - thisDev->sync.other = NullGrab; - syncEvents.replayDev = thisDev; - syncEvents.replayWin = thisDev->grab->window; - (*thisDev->DeactivateGrab)(thisDev); - syncEvents.replayDev = (DeviceIntPtr)NULL; - } - 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(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: - AllowSome(client, time, keybd, NOT_GRABBED); - break; - 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; - } - - /* - * This is not necessary if we export grab to X as asynchronous. - * - * if (nxagentOption(Rootless) && stuff -> mode != ReplayKeyboard && - * stuff -> mode != SyncKeyboard && stuff -> mode != AsyncKeyboard) - * { - * XAllowEvents(nxagentDisplay, stuff -> mode, CurrentTime); - * } - */ - - return Success; -} - -void -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 (ClientPtr client, xEvent *pEvents, int count, Mask mask, - Mask filter, GrabPtr grab) -{ - int i; - int type; - -#ifdef NX_DEBUG_INPUT - if (grab && nxagentDebugInput && grab->window) - { - fprintf(stderr, "TryClientEvents: Grab window is [0x%x].\n", - (unsigned int)grab->window->drawable.id); - if (!SameClient(grab, client)) - fprintf(stderr, "TryClientEvents: Events are going to be " - "discarded.\n"); - } -#endif -#if defined(DEBUG) || defined(NX_DEBUG_INPUT) -#ifdef NX_DEBUG_INPUT - if (nxagentDebugInput == 1) - fprintf(stderr, "Event([%d, %d], mask=0x%x), client=%d", - pEvents->u.u.type, pEvents->u.u.detail, (unsigned int)mask, - client->index); -#else - if (debug_events) ErrorF( - "Event([%d, %d], mask=0x%x), client=%d", - pEvents->u.u.type, pEvents->u.u.detail, mask, client->index); -#endif -#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) == - pEvents->u.keyButtonPointer.event) - { -#if defined(DEBUG) || defined(NX_DEBUG_INPUT) -#ifdef NX_DEBUG_INPUT - if (nxagentDebugInput == 1) - { - fprintf(stderr,"\nmotionHintWindow == keyButtonPointer.event\n"); - } -#else - if (debug_events) ErrorF("\n"); - fprintf(stderr,"motionHintWindow == keyButtonPointer.event\n"); -#endif -#endif - return 1; /* don't send, but pretend we did */ - } - pEvents->u.u.detail = NotifyHint; - } - else - { - pEvents->u.u.detail = NotifyNormal; - } - } -#ifdef XINPUT - else - { - if ((type == DeviceMotionNotify) && - MaybeSendDeviceMotionNotifyHint - ((deviceKeyButtonPointer*)pEvents, mask) != 0) - return 1; - } -#endif - type &= 0177; - if (type != KeymapNotify) - { - /* all extension events must have a sequence number */ - for (i = 0; i < count; i++) - pEvents[i].u.u.sequenceNumber = client->sequence; - } - - if (BitIsOn(criticalEvents, type)) - { -#ifdef SMART_SCHEDULE - if (client->smart_priority < SMART_MAX_PRIORITY) - client->smart_priority++; -#endif - SetCriticalOutputPending(); - } - - WriteEventsToClient(client, count, pEvents); -#if defined(DEBUG) || defined(NX_DEBUG_INPUT) -#ifdef NX_DEBUG_INPUT - if (nxagentDebugInput == 1) - fprintf(stderr, " delivered\n"); -#else - if (debug_events) ErrorF( " delivered\n"); -#endif -#endif - return 1; - } - else - { -#if defined(DEBUG) || defined(NX_DEBUG_INPUT) -#ifdef NX_DEBUG_INPUT - if (nxagentDebugInput == 1) - fprintf(stderr, "\n"); -#else - if (debug_events) ErrorF("\n"); -#endif -#endif - return 0; - } -} - -int -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) - { - deliveries++; - client = wClient(pWin); - deliveryMask = pWin->eventMask; - } else - nondeliveries--; - } - } - if (filter != CantBeFiltered) - { - if (type & EXTENSION_EVENT_BASE) - { - OtherInputMasks *inputMasks; - - inputMasks = wOtherInputMasks(pWin); - if (!inputMasks || - !(inputMasks->inputEvents[mskidx] & filter)) - return 0; - other = inputMasks->inputClients; - } - else - other = (InputClients *)wOtherClients(pWin); - for (; other; other = other->next) - { - if ( (attempt = TryClientEvents(rClient(other), pEvents, count, - other->mask[mskidx], filter, grab)) ) - { - if (attempt > 0) - { - deliveries++; - client = rClient(other); - deliveryMask = other->mask[mskidx]; - } else - nondeliveries--; - } - } - } - if ((type == ButtonPress) && deliveries && (!grab)) - { - GrabRec tempGrab; - - tempGrab.device = inputInfo.pointer; - tempGrab.resource = client->clientAsMask; - tempGrab.window = pWin; - tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE; - tempGrab.eventMask = deliveryMask; - tempGrab.keyboardMode = GrabModeAsync; - tempGrab.pointerMode = GrabModeAsync; - tempGrab.confineTo = NullWindow; - tempGrab.cursor = NullCursor; - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "DeliverEventsToWindow: Activating passive grab on pointer.\n"); - } - #endif - (*inputInfo.pointer->ActivateGrab)(inputInfo.pointer, &tempGrab, - currentTime, TRUE); - } - else if ((type == MotionNotify) && deliveries) - inputInfo.pointer->valuator->motionHintWindow = pWin; -#ifdef XINPUT - else - { - if (((type == DeviceMotionNotify) -#ifdef XKB - || (type == DeviceButtonPress) -#endif - ) && deliveries) - CheckDeviceGrabAndHintWindow (pWin, type, - (deviceKeyButtonPointer*) pEvents, - grab, client, deliveryMask); - } -#endif - if (deliveries) - return deliveries; - return nondeliveries; -} - -/* If the event goes to dontClient, don't send it and return 0. if - send works, return 1 or if send didn't work, return 2. - Only works for core events. -*/ - -#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(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) - { - if (SameClient(other, dontClient)) - return 0; -#ifdef PANORAMIX - if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) - return XineramaTryClientEventsResult( - rClient(other), NullGrab, other->mask, filter); -#endif - return TryClientEvents(rClient(other), pEvents, count, - other->mask, filter, NullGrab); - } - } - return 2; -} - -static void -FixUpEventFromWindow( - xEvent *xE, - WindowPtr pWin, - Window child, - Bool calcChild) -{ - if (calcChild) - { - WindowPtr w=spriteTrace[spriteTraceGood-1]; - /* If the search ends up past the root should the child field be - set to none or should the value in the argument be passed - through. It probably doesn't matter since everyone calls - this function with child == None anyway. */ - - while (w) - { - /* If the source window is same as event window, child should be - none. Don't bother going all all the way back to the root. */ - - if (w == pWin) - { - child = None; - break; - } - - if (w->parent == pWin) - { - child = w->drawable.id; - break; - } - w = w->parent; - } - } - XE_KBPTR.root = ROOT->drawable.id; - 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(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, - grab, mskidx); - if (deliveries > 0) - return deliveries; - } - if ((deliveries < 0) || - (pWin == stopAt) || - (inputMasks && - (filter & inputMasks->dontPropagateMask[mskidx]))) - return 0; - child = pWin->drawable.id; - pWin = pWin->parent; - if (pWin) - inputMasks = wOtherInputMasks(pWin); - } - } - else - { - if (!(filter & pWin->deliverableEvents)) - return 0; - while (pWin) - { - if ((wOtherEventMasks(pWin)|pWin->eventMask) & filter) - { - 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(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) - { - xE->u.destroyNotify.event = pWin->parent->drawable.id; - deliveries += DeliverEventsToWindow(pWin->parent, xE, count, - SubstructureNotifyMask, NullGrab, - 0); - if (xE->u.u.type == ReparentNotify) - { - xE->u.destroyNotify.event = otherParent->drawable.id; - deliveries += DeliverEventsToWindow(otherParent, xE, count, - SubstructureNotifyMask, - NullGrab, 0); - } - } - return deliveries; -} - - -static Bool -PointInBorderSize(WindowPtr pWin, int x, int y) -{ - BoxRec box; - - if(RegionContainsPoint(&pWin->borderSize, x, y, &box)) - return TRUE; - -#ifdef PANORAMIX - if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) { - int i; - - for(i = 1; i < PanoramiXNumScreens; i++) { - if(RegionContainsPoint( - &sprite.windows[i]->borderSize, - x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x, - y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y, - &box)) - return TRUE; - } - } -#endif - return FALSE; -} +// int +// 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: +// AllowSome(client, time, keybd, NOT_GRABBED); +// break; +// 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; +// } +// +// /* +// * This is not necessary if we export grab to X as asynchronous. +// * +// * if (nxagentOption(Rootless) && stuff -> mode != ReplayKeyboard && +// * stuff -> mode != SyncKeyboard && stuff -> mode != AsyncKeyboard) +// * { +// * XAllowEvents(nxagentDisplay, stuff -> mode, CurrentTime); +// * } +// */ +// +// return Success; +// } static WindowPtr XYToWindow(int x, int y) @@ -2204,145 +376,79 @@ XYToWindow(int x, int y) return spriteTrace[spriteTraceGood-1]; } -static Bool -CheckMotion(xEvent *xE) -{ - WindowPtr prevSpriteWin = sprite.win; - +// static Bool +// CheckMotion(xEvent *xE) +// { +// WindowPtr prevSpriteWin = sprite.win; +// #ifdef PANORAMIX - if(!noPanoramiXExtension) - return XineramaCheckMotion(xE); -#endif - - if (xE && !syncEvents.playingEvents) - { - if (sprite.hot.pScreen != sprite.hotPhys.pScreen) - { - sprite.hot.pScreen = sprite.hotPhys.pScreen; - ROOT = sprite.hot.pScreen->root; - } -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = XE_KBPTR.rootX; -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = XE_KBPTR.rootY; - if (sprite.hot.x < sprite.physLimits.x1) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = sprite.physLimits.x1; - else if (sprite.hot.x >= sprite.physLimits.x2) -#ifdef XEVIE - xeviehot.x = -#endif - sprite.hot.x = sprite.physLimits.x2 - 1; - if (sprite.hot.y < sprite.physLimits.y1) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = sprite.physLimits.y1; - else if (sprite.hot.y >= sprite.physLimits.y2) -#ifdef XEVIE - xeviehot.y = -#endif - sprite.hot.y = sprite.physLimits.y2 - 1; +// if(!noPanoramiXExtension) +// return XineramaCheckMotion(xE); +#endif + +// if (xE && !syncEvents.playingEvents) +// { +// if (sprite.hot.pScreen != sprite.hotPhys.pScreen) +// { +// sprite.hot.pScreen = sprite.hotPhys.pScreen; +// ROOT = sprite.hot.pScreen->root; +// } +// sprite.hot.x = XE_KBPTR.rootX; +// sprite.hot.y = XE_KBPTR.rootY; +// if (sprite.hot.x < sprite.physLimits.x1) +// sprite.hot.x = sprite.physLimits.x1; +// else if (sprite.hot.x >= sprite.physLimits.x2) +// sprite.hot.x = sprite.physLimits.x2 - 1; +// if (sprite.hot.y < sprite.physLimits.y1) +// sprite.hot.y = sprite.physLimits.y1; +// else if (sprite.hot.y >= sprite.physLimits.y2) +// sprite.hot.y = sprite.physLimits.y2 - 1; #ifdef SHAPE - if (sprite.hotShape) - ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y); -#endif - sprite.hotPhys = sprite.hot; - - /* - * This code force cursor position to be inside the - * root window of the agent. We can't view a reason - * to do this and it interacts in an undesirable way - * with toggling fullscreen. - * - * if ((sprite.hotPhys.x != XE_KBPTR.rootX) || - * (sprite.hotPhys.y != XE_KBPTR.rootY)) - * { - * (*sprite.hotPhys.pScreen->SetCursorPosition)( - * sprite.hotPhys.pScreen, - * sprite.hotPhys.x, sprite.hotPhys.y, FALSE); - * } - */ - - XE_KBPTR.rootX = sprite.hot.x; - XE_KBPTR.rootY = sprite.hot.y; - } - -#ifdef XEVIE - xeviewin = -#endif - sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y); +// if (sprite.hotShape) +// ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y); +#endif +// sprite.hotPhys = sprite.hot; +// +// /* +// * This code force cursor position to be inside the +// * root window of the agent. We can't view a reason +// * to do this and it interacts in an undesirable way +// * with toggling fullscreen. +// * +// * if ((sprite.hotPhys.x != XE_KBPTR.rootX) || +// * (sprite.hotPhys.y != XE_KBPTR.rootY)) +// * { +// * (*sprite.hotPhys.pScreen->SetCursorPosition)( +// * sprite.hotPhys.pScreen, +// * sprite.hotPhys.x, sprite.hotPhys.y, FALSE); +// * } +// */ +// +// XE_KBPTR.rootX = sprite.hot.x; +// XE_KBPTR.rootY = sprite.hot.y; +// } +// +// sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y); #ifdef notyet - if (!(sprite.win->deliverableEvents & - Motion_Filter(inputInfo.pointer->button)) - !syncEvents.playingEvents) - { - /* XXX Do PointerNonInterestBox here */ - } -#endif - if (sprite.win != prevSpriteWin) - { - if (prevSpriteWin != NullWindow) { - if (!xE) - UpdateCurrentTimeIf(); - DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal); - } - PostNewCursor(); - return FALSE; - } - return TRUE; -} - -void -WindowsRestructured() -{ - (void) CheckMotion((xEvent *)NULL); -} - -#ifdef PANORAMIX -/* This was added to support reconfiguration under Xdmx. The problem is - * that if the 0th screen (i.e., screenInfo.screens[0]->root) is moved to - * an origin other than 0,0, the information in the private sprite structure - * must be updated accordingly, or XYToWindow (and other routines) will not - * compute correctly. */ -void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) -{ - GrabPtr grab; - - if (noPanoramiXExtension) return; - - sprite.hot.x -= xoff; - sprite.hot.y -= yoff; - - sprite.hotPhys.x -= xoff; - sprite.hotPhys.y -= yoff; - - sprite.hotLimits.x1 -= xoff; - sprite.hotLimits.y1 -= yoff; - sprite.hotLimits.x2 -= xoff; - sprite.hotLimits.y2 -= yoff; - - if (RegionNotEmpty(&sprite.Reg1)) - RegionTranslate(&sprite.Reg1, xoff, yoff); - if (RegionNotEmpty(&sprite.Reg2)) - RegionTranslate(&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(sprite.hotPhys.pScreen->root, - TRUE, FALSE); -} -#endif +// if (!(sprite.win->deliverableEvents & +// Motion_Filter(inputInfo.pointer->button)) +// !syncEvents.playingEvents) +// { +// /* XXX Do PointerNonInterestBox here */ +// } +#endif +// if (sprite.win != prevSpriteWin) +// { +// if (prevSpriteWin != NullWindow) { +// if (!xE) +// UpdateCurrentTimeIf(); +// DoEnterLeaveEvents(prevSpriteWin, sprite.win, NotifyNormal); +// } +// PostNewCursor(); +// return FALSE; +// } +// return TRUE; +// } void DefineInitialRootWindow(register WindowPtr win) @@ -2359,9 +465,6 @@ DefineInitialRootWindow(register WindowPtr win) sprite.hot = sprite.hotPhys; sprite.hotLimits.x2 = pScreen->width; sprite.hotLimits.y2 = pScreen->height; -#ifdef XEVIE - xeviewin = -#endif sprite.win = win; sprite.current = wCursor (win); sprite.current->refcnt++; @@ -2405,2107 +508,6 @@ DefineInitialRootWindow(register WindowPtr win) } } -/* - * 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. - */ -void -WindowHasNewCursor(WindowPtr pWin) -{ - PostNewCursor(); -} - -void -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(screenInfo.screens[0]->root, 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, - sprite.hotPhys.x + panoramiXdataPtr[0].x - - panoramiXdataPtr[sprite.screen->myNum].x, - sprite.hotPhys.y + panoramiXdataPtr[0].y - - panoramiXdataPtr[sprite.screen->myNum].y, FALSE); - } - } else -#endif - if (newScreen != sprite.hotPhys.pScreen) - ConfineCursorToWindow(newScreen->root, TRUE, FALSE); -} - -#ifdef PANORAMIX - -static Bool -XineramaPointInWindowIsVisible( - WindowPtr pWin, - int x, - int y -) -{ - BoxRec box; - int i, xoff, yoff; - - if (!pWin->realized) return FALSE; - - if (RegionContainsPoint(&pWin->borderClip, x, y, &box)) - return TRUE; - - if(!XineramaSetWindowPntrs(pWin)) return FALSE; - - xoff = x + panoramiXdataPtr[0].x; - yoff = y + panoramiXdataPtr[0].y; - - for(i = 1; i < PanoramiXNumScreens; i++) { - pWin = sprite.windows[i]; - x = xoff - panoramiXdataPtr[i].x; - y = yoff - panoramiXdataPtr[i].y; - - if(RegionContainsPoint(&pWin->borderClip, x, y, &box) - && (!wInputShape(pWin) || - RegionContainsPoint( - wInputShape(pWin), - x - pWin->drawable.x, - y - pWin->drawable.y, &box))) - return TRUE; - - } - - return FALSE; -} - -static int -XineramaWarpPointer(ClientPtr client) -{ - WindowPtr dest = NULL; - int x, y; - - REQUEST(xWarpPointerReq); - - - if (stuff->dstWid != None) - { - dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); - if (!dest) - return BadWindow; - } - x = sprite.hotPhys.x; - y = sprite.hotPhys.y; - - if (stuff->srcWid != None) - { - int winX, winY; - XID winID = stuff->srcWid; - WindowPtr source; - - source = SecurityLookupWindow(winID, client, SecurityReadAccess); - if (!source) return BadWindow; - - winX = source->drawable.x; - winY = source->drawable.y; - if(source == screenInfo.screens[0]->root) { - winX -= panoramiXdataPtr[0].x; - winY -= panoramiXdataPtr[0].y; - } - if (x < winX + stuff->srcX || - y < winY + stuff->srcY || - (stuff->srcWidth != 0 && - winX + stuff->srcX + (int)stuff->srcWidth < x) || - (stuff->srcHeight != 0 && - winY + stuff->srcY + (int)stuff->srcHeight < y) || - !XineramaPointInWindowIsVisible(source, x, y)) - return Success; - } - if (dest) { - x = dest->drawable.x; - y = dest->drawable.y; - if(dest == screenInfo.screens[0]->root) { - x -= panoramiXdataPtr[0].x; - y -= panoramiXdataPtr[0].y; - } - } - - x += stuff->dstX; - y += stuff->dstY; - - 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(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; - } - x = sprite.hotPhys.x; - y = sprite.hotPhys.y; - - if (stuff->srcWid != None) - { - int winX, winY; - XID winID = stuff->srcWid; - WindowPtr source; - - source = SecurityLookupWindow(winID, client, SecurityReadAccess); - if (!source) return BadWindow; - - winX = source->drawable.x; - winY = source->drawable.y; - if (source->drawable.pScreen != sprite.hotPhys.pScreen || - x < winX + stuff->srcX || - y < winY + stuff->srcY || - (stuff->srcWidth != 0 && - winX + stuff->srcX + (int)stuff->srcWidth < x) || - (stuff->srcHeight != 0 && - winY + stuff->srcY + (int)stuff->srcHeight < y) || - !PointInWindowIsVisible(source, x, y)) - return Success; - } - if (dest) - { - x = dest->drawable.x; - y = dest->drawable.y; - newScreen = dest->drawable.pScreen; - } else - newScreen = sprite.hotPhys.pScreen; - - x += stuff->dstX; - y += stuff->dstY; - - if (x < 0) - x = 0; - else if (x >= newScreen->width) - x = newScreen->width - 1; - if (y < 0) - y = 0; - else if (y >= newScreen->height) - y = newScreen->height - 1; - - if (newScreen == sprite.hotPhys.pScreen) - { - 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 defined(SHAPE) - if (sprite.hotShape) - ConfineToShape(sprite.hotShape, &x, &y); -#endif - (*newScreen->SetCursorPosition)(newScreen, x, y, TRUE); - } - else if (!PointerConfinedToScreen()) - { - NewCurrentScreen(newScreen, x, y); - } - return Success; -} - -static Bool -BorderSizeNotEmpty(WindowPtr pWin) -{ - if(RegionNotEmpty(&pWin->borderSize)) - return TRUE; - -#ifdef PANORAMIX - if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) { - int i; - - for(i = 1; i < PanoramiXNumScreens; i++) { - if(RegionNotEmpty(&sprite.windows[i]->borderSize)) - return TRUE; - } - } -#endif - return FALSE; -} - -/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a - passive grab set on the window to be activated. */ - -static Bool -CheckPassiveGrabsOnWindow( - WindowPtr pWin, - register DeviceIntPtr device, - register xEvent *xE, - int count) -{ - register GrabPtr grab = wPassiveGrabs(pWin); - GrabRec tempGrab; - register xEvent *dxE; - - if (!grab) - return FALSE; - tempGrab.window = pWin; - tempGrab.device = device; - tempGrab.type = xE->u.u.type; - tempGrab.detail.exact = xE->u.u.detail; - tempGrab.detail.pMask = NULL; - tempGrab.modifiersDetail.pMask = NULL; - for (; grab; grab = grab->next) - { -#ifdef XKB - DeviceIntPtr gdev; - XkbSrvInfoPtr xkbi; - - gdev= grab->modifierDevice; - xkbi= gdev->key->xkbInfo; -#endif - tempGrab.modifierDevice = grab->modifierDevice; - if ((device == grab->modifierDevice) && - ((xE->u.u.type == KeyPress) -#if defined(XINPUT) && defined(XKB) - || (xE->u.u.type == DeviceKeyPress) -#endif - )) - tempGrab.modifiersDetail.exact = -#ifdef XKB - (noXkbExtension?gdev->key->prev_state:xkbi->state.grab_mods); -#else - grab->modifierDevice->key->prev_state; -#endif - else - tempGrab.modifiersDetail.exact = -#ifdef XKB - (noXkbExtension ? gdev->key->state : xkbi->state.grab_mods); -#else - grab->modifierDevice->key->state; -#endif - if (GrabMatchesSecond(&tempGrab, grab) && - (!grab->confineTo || - (grab->confineTo->realized && - BorderSizeNotEmpty(grab->confineTo)))) - { -#ifdef XCSECURITY - if (!SecurityCheckDeviceAccess(wClient(pWin), device, FALSE)) - return FALSE; -#endif -#ifdef XKB - if (!noXkbExtension) { - XE_KBPTR.state &= 0x1f00; - XE_KBPTR.state |= - tempGrab.modifiersDetail.exact&(~0x1f00); - } -#endif - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "CheckPassiveGrabsOnWindow: Activating passive grab on %s.\n", - device == inputInfo.keyboard ? "keyboard" : "pointer"); - } - #endif - (*device->ActivateGrab)(device, grab, currentTime, TRUE); - - FixUpEventFromWindow(xE, grab->window, None, TRUE); - - (void) TryClientEvents(rClient(grab), xE, count, - filters[xE->u.u.type], - filters[xE->u.u.type], grab); - - if (device->sync.state == FROZEN_NO_EVENT) - { - 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 -its descendants contain the 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(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 && - CheckPassiveGrabsOnWindow(pWin, device, xE, count)) - return TRUE; - } - - 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(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(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, - thisDev, count); - else if (focus && (focus == sprite.win || IsParent(focus, sprite.win))) - deliveries = DeliverDeviceEvents(sprite.win, xE, grab, focus, - thisDev, count); - else if (focus) - deliveries = DeliverDeviceEvents(focus, xE, grab, focus, - thisDev, count); - } - if (!deliveries) - { - FixUpEventFromWindow(xE, grab->window, None, TRUE); - deliveries = TryClientEvents(rClient(grab), xE, count, - (Mask)grab->eventMask, - filters[xE->u.u.type], grab); - if (deliveries && (xE->u.u.type == MotionNotify -#ifdef XINPUT - || xE->u.u.type == DeviceMotionNotify -#endif - )) - thisDev->valuator->motionHintWindow = grab->window; - } - if (deliveries && !deactivateGrab && (xE->u.u.type != MotionNotify -#ifdef XINPUT - && xE->u.u.type != DeviceMotionNotify -#endif - )) - switch (thisDev->sync.state) - { - case FREEZE_BOTH_NEXT_EVENT: - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (dev == thisDev) - continue; - FreezeThaw(dev, TRUE); - if ((dev->sync.state == FREEZE_BOTH_NEXT_EVENT) && - (CLIENT_BITS(dev->grab->resource) == - CLIENT_BITS(thisDev->grab->resource))) - dev->sync.state = FROZEN_NO_EVENT; - else - dev->sync.other = thisDev->grab; - } - /* 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 (register xEvent *xE, register DeviceIntPtr keybd, int count) -#else -ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int count) -#endif -{ - 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 { -#ifdef XKB - if(!noXkbExtension) - xevieKBEventSent = 1; -#endif - if(!xevieKBEventSent) - { - xeviekb = keybd; - if(!rootWin) { - rootWin = GetCurrentRootWindow()->drawable.id; - } - xE->u.keyButtonPointer.event = xeviewin->drawable.id; - xE->u.keyButtonPointer.root = rootWin; - xE->u.keyButtonPointer.child = (xeviewin->firstChild) ? xeviewin->firstChild-> -drawable.id:0; - xE->u.keyButtonPointer.rootX = xeviehot.x; - xE->u.keyButtonPointer.rootY = xeviehot.y; - xE->u.keyButtonPointer.state = keyc->state; - WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE); -#ifdef XKB - if(noXkbExtension) -#endif - return; - } else { - xevieKBEventSent = 0; - } - } - } -#endif - - if (!syncEvents.playingEvents) - { - NoticeTime(xE); - if (DeviceEventCallback) - { - DeviceEventInfoRec eventinfo; - eventinfo.events = xE; - eventinfo.count = count; - CallCallbacks(&DeviceEventCallback, (void *)&eventinfo); - } - } -#ifdef XEVIE - /* fix for bug5094030: don't change the state bit if the event is from XEvIE client */ - if(!(!xeviegrabState && xevieFlag && clients[xevieClientIndex] && - (xevieMask & xevieFilters[xE->u.u.type] -#ifdef XKB - && !noXkbExtension -#endif - ))) -#endif - XE_KBPTR.state = (keyc->state | inputInfo.pointer->button->state); - XE_KBPTR.rootX = sprite.hot.x; - XE_KBPTR.rootY = sprite.hot.y; - key = xE->u.u.detail; - kptr = &keyc->down[key >> 3]; - bit = 1 << (key & 7); - modifiers = keyc->modifierMap[key]; -#if defined(XKB) && defined(XEVIE) - if(!noXkbExtension && !xeviegrabState && - xevieFlag && clients[xevieClientIndex] && - (xevieMask & xevieFilters[xE->u.u.type])) { - switch(xE->u.u.type) { - case KeyPress: *kptr &= ~bit; break; - case KeyRelease: *kptr |= bit; break; - } - } -#endif - -#ifdef DEBUG - if ((xkbDebugFlags&0x4)&& - ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) { - ErrorF("CoreProcessKbdEvent: Key %d %s\n",key, - (xE->u.u.type==KeyPress?"down":"up")); - } -#endif - switch (xE->u.u.type) - { - case KeyPress: - if (*kptr & bit) /* allow ddx to generate multiple downs */ - { - if (!modifiers) - { - xE->u.u.type = KeyRelease; - (*keybd->public.processInputProc)(xE, keybd, count); - xE->u.u.type = KeyPress; - /* release can have side effects, don't fall through */ - (*keybd->public.processInputProc)(xE, keybd, count); - } - return; - } - inputInfo.pointer->valuator->motionHintWindow = NullWindow; - *kptr |= bit; - keyc->prev_state = keyc->state; - for (i = 0, mask = 1; modifiers; i++, mask <<= 1) - { - if (mask & modifiers) - { - /* This key affects modifier "i" */ - keyc->modifierKeyCount[i]++; - keyc->state |= mask; - modifiers &= ~mask; - } - } - if (!grab && CheckDeviceGrabs(keybd, xE, 0, count)) - { - keybd->activatingKey = key; - return; - } - break; - case KeyRelease: - if (!(*kptr & bit)) /* guard against duplicates */ - return; - inputInfo.pointer->valuator->motionHintWindow = NullWindow; - *kptr &= ~bit; - keyc->prev_state = keyc->state; - for (i = 0, mask = 1; modifiers; i++, mask <<= 1) - { - if (mask & modifiers) { - /* This key affects modifier "i" */ - if (--keyc->modifierKeyCount[i] <= 0) { - keyc->state &= ~mask; - keyc->modifierKeyCount[i] = 0; - } - modifiers &= ~mask; - } - } - 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) - #ifdef NX_DEBUG_INPUT - { - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcessKeyboardEvent: Deactivating grab on keyboard.\n"); - } - #endif - (*keybd->DeactivateGrab)(keybd); - #ifdef NX_DEBUG_INPUT - } - #endif -} - -#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 (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 (register xEvent *xE, register DeviceIntPtr mouse, int count) -#else -ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count) -#endif -{ - register GrabPtr grab = mouse->grab; - Bool deactivateGrab = FALSE; - register ButtonClassPtr butc = mouse->button; -#ifdef XKB - XkbSrvInfoPtr xkbi; - - 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; - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInput == 1) - { - fprintf(stderr, "ProcessPointerEvent: Going to send XEVIE event.\n"); - } - #endif - WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE); - return; - } - } -#endif - - if (!syncEvents.playingEvents) - NoticeTime(xE) - XE_KBPTR.state = (butc->state | ( -#ifdef XKB - (noXkbExtension ? - inputInfo.keyboard->key->state : - xkbi->state.grab_mods) -#else - inputInfo.keyboard->key->state -#endif - )); - { - NoticeTime(xE); - if (DeviceEventCallback) - { - DeviceEventInfoRec eventinfo; - /* see comment in EnqueueEvents regarding the next three lines */ - if (xE->u.u.type == MotionNotify) - XE_KBPTR.root = - sprite.hotPhys.pScreen->root->drawable.id; - eventinfo.events = xE; - eventinfo.count = count; - CallCallbacks(&DeviceEventCallback, (void *)&eventinfo); - } - } - if (xE->u.u.type != MotionNotify) - { - register int key; - register BYTE *kptr; - int bit; - - XE_KBPTR.rootX = sprite.hot.x; - XE_KBPTR.rootY = sprite.hot.y; - - key = xE->u.u.detail; - kptr = &butc->down[key >> 3]; - bit = 1 << (key & 7); - switch (xE->u.u.type) - { - case ButtonPress: - mouse->valuator->motionHintWindow = NullWindow; - if (!(*kptr & bit)) - butc->buttonsDown++; - butc->motionMask = ButtonMotionMask; - *kptr |= bit; -#if !defined(XFree86Server) || !defined(XINPUT) - xE->u.u.detail = butc->map[key]; -#endif - #ifdef NX_DEBUG_INPUT - if (xE->u.u.detail == 0) - { - if (nxagentDebugInput == 1) - { - fprintf(stderr, "ProcessPointerEvent: WARNING! detail == 0" - " for ButtonPress.\n"); - } - return; - } - #else - if (xE->u.u.detail == 0) - return; - #endif - if (xE->u.u.detail <= 5) - butc->state |= (Button1Mask >> 1) << xE->u.u.detail; - filters[MotionNotify] = Motion_Filter(butc); - if (!grab) - #ifdef NX_DEBUG_INPUT - if (CheckDeviceGrabs(mouse, xE, 0, count)) - { - if (nxagentDebugInput == 1) - { - fprintf(stderr, "ProcessPointerEvent: CheckDeviceGrabs" - " returned True for ButtonPress.\n"); - } - return; - } - #else - if (CheckDeviceGrabs(mouse, xE, 0, count)) - return; - #endif - break; - case ButtonRelease: - mouse->valuator->motionHintWindow = NullWindow; - if (*kptr & bit) - --butc->buttonsDown; - if (!butc->buttonsDown) - butc->motionMask = 0; - *kptr &= ~bit; -#if !defined(XFree86Server) || !defined(XINPUT) - xE->u.u.detail = butc->map[key]; -#endif - #ifdef NX_DEBUG_INPUT - if (xE->u.u.detail == 0) - { - if (nxagentDebugInput == 1) - { - fprintf(stderr, "ProcessPointerEvent: WARNING! detail == 0" - " for ButtonRelease.\n"); - } - return; - } - #else - if (xE->u.u.detail == 0) - return; - #endif - if (xE->u.u.detail <= 5) - butc->state &= ~((Button1Mask >> 1) << xE->u.u.detail); - filters[MotionNotify] = Motion_Filter(butc); - if (!butc->state && mouse->fromPassiveGrab) - deactivateGrab = TRUE; - break; - default: - FatalError("bogus pointer event from ddx"); - } - } - #ifdef NX_DEBUG_INPUT - else if (!CheckMotion(xE)) - { - if (nxagentDebugInput == 1) - { - fprintf(stderr, "ProcessPointerEvent: CheckMotion returned False" - " for MotionNotify.\n"); - } - return; - } - if (grab) - { - if (nxagentDebugInput == 1) - { - fprintf(stderr, "ProcessPointerEvent: Going to deliver grabbed " - "events (count = %d).\n", count); - } - DeliverGrabbedEvent(xE, mouse, deactivateGrab, count); - } - else - { - if (nxagentDebugInput == 1) - { - fprintf(stderr, "ProcessPointerEvent: Going to deliver device " - "events (count = %d).\n", count); - } - DeliverDeviceEvents(sprite.win, xE, NullGrab, NullWindow, - mouse, count); - } - #else - else if (!CheckMotion(xE)) - return; - if (grab) - DeliverGrabbedEvent(xE, mouse, deactivateGrab, count); - else - DeliverDeviceEvents(sprite.win, xE, NullGrab, NullWindow, - mouse, count); - #endif - if (deactivateGrab) - #ifdef NX_DEBUG_INPUT - { - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcessPointerEvent: Deactivating grab on pointer.\n"); - } - #endif - (*mouse->DeactivateGrab)(mouse); - #ifdef NX_DEBUG_INPUT - } - #endif -} - -#define AtMostOneClient \ - (SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask) - -void -RecalculateDeliverableEvents(pWin) - register WindowPtr pWin; -{ - register OtherClients *others; - register WindowPtr pChild; - - pChild = pWin; - while (1) - { - if (pChild->optional) - { - pChild->optional->otherEventMasks = 0; - for (others = wOtherClients(pChild); others; others = others->next) - { - pChild->optional->otherEventMasks |= others->mask; - } - } - 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(void * 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(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) - { - if (!SameClient(others, client) && (check & others->mask)) - return BadAccess; - } - } - if (wClient (pWin) == client) - { - check = pWin->eventMask; -#ifdef SGIMISC - pWin->eventMask = - (mask & ~SGIMiscSpecialDestroyMask) | (pWin->eventMask & SGIMiscSpecialDestroyMask); -#else - pWin->eventMask = mask; -#endif - } - else - { - for (others = wOtherClients (pWin); others; others = others->next) - { - if (SameClient(others, client)) - { - check = others->mask; -#ifdef SGIMISC - mask = (mask & ~SGIMiscSpecialDestroyMask) | (others->mask & SGIMiscSpecialDestroyMask); -#endif - if (mask == 0) - { - FreeResource(others->resource, RT_NONE); - return Success; - } - else - others->mask = mask; - goto maskSet; - } - } - check = 0; - if (!pWin->optional && !MakeWindowOptional (pWin)) - return BadAlloc; - 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, (void *)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; -} - -int -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; - } - if (!i && free) - { - i = free; - DontPropagateMasks[i] = mask; - } - } - if (i || !mask) - { - pWin->dontPropagate = i; - if (i) - DontPropagateRefCnts[i]++; - if (pWin->optional) - { - pWin->optional->dontPropagateMask = mask; - *checkOptional = TRUE; - } - } - else - { - if (!pWin->optional && !MakeWindowOptional (pWin)) - { - if (pWin->dontPropagate) - DontPropagateRefCnts[pWin->dontPropagate]++; - return BadAlloc; - } - pWin->dontPropagate = 0; - pWin->optional->dontPropagateMask = mask; - } - RecalculateDeliverableEvents(pWin); - return Success; -} - -static WindowPtr -CommonAncestor( - register WindowPtr a, - register WindowPtr b) -{ - for (b = b->parent; b; b = b->parent) - if (IsParent(b, a)) return b; - return NullWindow; -} - -static void -EnterLeaveEvent( - int type, - int mode, - int detail, - register WindowPtr pWin, - Window child) -{ - xEvent event; - register DeviceIntPtr keybd = inputInfo.keyboard; - WindowPtr focus; - register DeviceIntPtr mouse = inputInfo.pointer; - register GrabPtr grab = mouse->grab; - Mask mask; - - if ((pWin == mouse->valuator->motionHintWindow) && - (detail != NotifyInferior)) - mouse->valuator->motionHintWindow = NullWindow; - if (grab) - { - mask = (pWin == grab->window) ? grab->eventMask : 0; - if (grab->ownerEvents) - mask |= EventMaskForClient(pWin, rClient(grab)); - } - else - { - mask = pWin->eventMask | wOtherEventMasks(pWin); - } - if (mask & filters[type]) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = type; - event.u.u.detail = detail; - event.u.enterLeave.time = currentTime.milliseconds; - event.u.enterLeave.rootX = sprite.hot.x; - event.u.enterLeave.rootY = sprite.hot.y; - /* Counts on the same initial structure of crossing & button events! */ - FixUpEventFromWindow(&event, pWin, None, FALSE); - /* Enter/Leave events always set child */ - event.u.enterLeave.child = child; - event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ? - ELFlagSameScreen : 0; -#ifdef XKB - if (!noXkbExtension) { - event.u.enterLeave.state = mouse->button->state & 0x1f00; - event.u.enterLeave.state |= - XkbGrabStateFromRec(&keybd->key->xkbInfo->state); - } else -#endif - event.u.enterLeave.state = keybd->key->state | mouse->button->state; - event.u.enterLeave.mode = mode; - focus = keybd->focus->win; - if ((focus != NoneWin) && - ((pWin == focus) || (focus == PointerRootWin) || - IsParent(focus, pWin))) - event.u.enterLeave.flags |= ELFlagFocus; - if (grab) - (void)TryClientEvents(rClient(grab), &event, 1, mask, - filters[type], grab); - else - (void)DeliverEventsToWindow(pWin, &event, 1, filters[type], - NullGrab, 0); - } - if ((type == EnterNotify) && (mask & KeymapStateMask)) - { - xKeymapEvent ke; - -#ifdef XCSECURITY - ClientPtr client = grab ? rClient(grab) - : clients[CLIENT_ID(pWin->drawable.id)]; - if (!SecurityCheckDeviceAccess(client, keybd, FALSE)) - { - bzero((char *)&ke.map[0], 31); - } - else -#endif - memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31); - ke.type = KeymapNotify; - if (grab) - (void)TryClientEvents(rClient(grab), (xEvent *)&ke, 1, mask, - KeymapStateMask, grab); - else - (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1, - KeymapStateMask, NullGrab, 0); - } -} - -static void -EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail) -{ - WindowPtr parent = child->parent; - - if (ancestor == parent) - return; - EnterNotifies(ancestor, parent, mode, detail); - EnterLeaveEvent(EnterNotify, mode, detail, parent, child->drawable.id); -} - -static void -LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail) -{ - register WindowPtr pWin; - - if (ancestor == child) - return; - for (pWin = child->parent; pWin != ancestor; pWin = pWin->parent) - { - EnterLeaveEvent(LeaveNotify, mode, detail, pWin, child->drawable.id); - child = pWin; - } -} - -static void -DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode) -{ - if (fromWin == toWin) - return; - if (IsParent(fromWin, toWin)) - { - EnterLeaveEvent(LeaveNotify, mode, NotifyInferior, fromWin, None); - EnterNotifies(fromWin, toWin, mode, NotifyVirtual); - EnterLeaveEvent(EnterNotify, mode, NotifyAncestor, toWin, None); - } - else if (IsParent(toWin, fromWin)) - { - EnterLeaveEvent(LeaveNotify, mode, NotifyAncestor, fromWin, None); - LeaveNotifies(fromWin, toWin, mode, NotifyVirtual); - EnterLeaveEvent(EnterNotify, mode, NotifyInferior, toWin, None); - } - else - { /* neither fromWin nor toWin is descendent of the other */ - WindowPtr common = CommonAncestor(toWin, fromWin); - /* common == NullWindow ==> different screens */ - EnterLeaveEvent(LeaveNotify, mode, NotifyNonlinear, fromWin, None); - LeaveNotifies(fromWin, common, mode, NotifyNonlinearVirtual); - EnterNotifies(common, toWin, mode, NotifyNonlinearVirtual); - EnterLeaveEvent(EnterNotify, mode, NotifyNonlinear, toWin, None); - } -} - -static void -FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, register WindowPtr pWin) -{ - xEvent event; - -#ifdef XINPUT - if (dev != inputInfo.keyboard) - { - DeviceFocusEvent(dev, type, mode, detail, pWin); - return; - } -#endif - event.u.focus.mode = mode; - event.u.u.type = type; - event.u.u.detail = detail; - event.u.focus.window = pWin->drawable.id; - (void)DeliverEventsToWindow(pWin, &event, 1, filters[type], NullGrab, - 0); - if ((type == FocusIn) && - ((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask)) - { - xKeymapEvent ke; -#ifdef XCSECURITY - ClientPtr client = clients[CLIENT_ID(pWin->drawable.id)]; - if (!SecurityCheckDeviceAccess(client, dev, FALSE)) - { - bzero((char *)&ke.map[0], 31); - } - else -#endif - memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31); - ke.type = KeymapNotify; - (void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1, - KeymapStateMask, NullGrab, 0); - } -} - - /* - * recursive because it is easier - * no-op if child not descended from ancestor - */ -static Bool -FocusInEvents( - DeviceIntPtr dev, - WindowPtr ancestor, WindowPtr child, WindowPtr skipChild, - int mode, int detail, - Bool doAncestor) -{ - if (child == NullWindow) - return ancestor == NullWindow; - if (ancestor == child) - { - if (doAncestor) - FocusEvent(dev, FocusIn, mode, detail, child); - return TRUE; - } - if (FocusInEvents(dev, ancestor, child->parent, skipChild, mode, detail, - doAncestor)) - { - if (child != skipChild) - FocusEvent(dev, FocusIn, mode, detail, child); - return TRUE; - } - 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(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 - if ( !noPanoramiXExtension ) - FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[0]->root); - else -#endif - for (i=0; i<screenInfo.numScreens; i++) - FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[i]->root); - } - else - { - if (IsParent(fromWin, sprite.win)) - FocusOutEvents(dev, sprite.win, fromWin, mode, NotifyPointer, - FALSE); - FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin); - /* next call catches the root too, if the screen changed */ - FocusOutEvents(dev, fromWin->parent, NullWindow, mode, - NotifyNonlinearVirtual, FALSE); - } - /* Notify all the roots */ -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - FocusEvent(dev, FocusIn, mode, in, screenInfo.screens[0]->root); - else -#endif - for (i=0; i<screenInfo.numScreens; i++) - FocusEvent(dev, FocusIn, mode, in, screenInfo.screens[i]->root); - if (toWin == PointerRootWin) - (void)FocusInEvents(dev, ROOT, sprite.win, NullWindow, mode, - NotifyPointer, TRUE); - } - else - { - if ((fromWin == NullWindow) || (fromWin == PointerRootWin)) - { - if (fromWin == PointerRootWin) - FocusOutEvents(dev, sprite.win, ROOT, mode, NotifyPointer, - TRUE); -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[0]->root); - else -#endif - for (i=0; i<screenInfo.numScreens; i++) - FocusEvent(dev, FocusOut, mode, out, screenInfo.screens[i]->root); - if (toWin->parent != NullWindow) - (void)FocusInEvents(dev, ROOT, toWin, toWin, mode, - NotifyNonlinearVirtual, TRUE); - FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin); - if (IsParent(toWin, sprite.win)) - (void)FocusInEvents(dev, toWin, sprite.win, NullWindow, mode, - NotifyPointer, FALSE); - } - else - { - if (IsParent(toWin, fromWin)) - { - FocusEvent(dev, FocusOut, mode, NotifyAncestor, fromWin); - FocusOutEvents(dev, fromWin->parent, toWin, mode, - NotifyVirtual, FALSE); - FocusEvent(dev, FocusIn, mode, NotifyInferior, toWin); - if ((IsParent(toWin, sprite.win)) && - (sprite.win != fromWin) && - (!IsParent(fromWin, sprite.win)) && - (!IsParent(sprite.win, fromWin))) - (void)FocusInEvents(dev, toWin, sprite.win, NullWindow, - mode, NotifyPointer, FALSE); - } - else - if (IsParent(fromWin, toWin)) - { - if ((IsParent(fromWin, sprite.win)) && - (sprite.win != fromWin) && - (!IsParent(toWin, sprite.win)) && - (!IsParent(sprite.win, toWin))) - FocusOutEvents(dev, sprite.win, fromWin, mode, - NotifyPointer, FALSE); - FocusEvent(dev, FocusOut, mode, NotifyInferior, fromWin); - (void)FocusInEvents(dev, fromWin, toWin, toWin, mode, - NotifyVirtual, FALSE); - FocusEvent(dev, FocusIn, mode, NotifyAncestor, toWin); - } - else - { - /* neither fromWin or toWin is child of other */ - WindowPtr common = CommonAncestor(toWin, fromWin); - /* common == NullWindow ==> different screens */ - if (IsParent(fromWin, sprite.win)) - FocusOutEvents(dev, sprite.win, fromWin, mode, - NotifyPointer, FALSE); - FocusEvent(dev, FocusOut, mode, NotifyNonlinear, fromWin); - if (fromWin->parent != NullWindow) - FocusOutEvents(dev, fromWin->parent, common, mode, - NotifyNonlinearVirtual, FALSE); - if (toWin->parent != NullWindow) - (void)FocusInEvents(dev, common, toWin, toWin, mode, - NotifyNonlinearVirtual, FALSE); - FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin); - if (IsParent(toWin, sprite.win)) - (void)FocusInEvents(dev, toWin, sprite.win, NullWindow, - mode, NotifyPointer, FALSE); - } - } - } -} - -int -SetInputFocus( - ClientPtr client, - DeviceIntPtr dev, - Window focusID, - CARD8 revertTo, - Time ctime, - Bool followOK) -{ - register FocusClassPtr focus; - register WindowPtr focusWin; - int mode; - TimeStamp time; - - UpdateCurrentTime(); - if ((revertTo != RevertToParent) && - (revertTo != RevertToPointerRoot) && - (revertTo != RevertToNone) && - ((revertTo != RevertToFollowKeyboard) || !followOK)) - { - client->errorValue = revertTo; - return BadValue; - } - time = ClientTimeToServerTime(ctime); - if ((focusID == None) || (focusID == PointerRoot)) - focusWin = (WindowPtr)(long)focusID; - else if ((focusID == FollowKeyboard) && followOK) - focusWin = inputInfo.keyboard->focus->win; - else if (!(focusWin = SecurityLookupWindow(focusID, client, - SecurityReadAccess))) - return BadWindow; - else - { - /* It is a match error to try to set the input focus to an - unviewable window. */ - - if(!focusWin->realized) - return(BadMatch); - } - focus = dev->focus; - if ((CompareTimeStamps(time, currentTime) == LATER) || - (CompareTimeStamps(time, focus->time) == EARLIER)) - return Success; - mode = (dev->grab) ? NotifyWhileGrabbed : NotifyNormal; - if (focus->win == FollowKeyboardWin) - DoFocusEvents(dev, inputInfo.keyboard->focus->win, focusWin, mode); - else - DoFocusEvents(dev, focus->win, focusWin, mode); - focus->time = time; - focus->revert = revertTo; - if (focusID == FollowKeyboard) - focus->win = FollowKeyboardWin; - else - focus->win = focusWin; - if ((focusWin == NoneWin) || (focusWin == PointerRootWin)) - focus->traceGood = 0; - else - { - int depth = 0; - register WindowPtr pWin; - - for (pWin = focusWin; pWin; pWin = pWin->parent) depth++; - if (depth > focus->traceSize) - { - focus->traceSize = depth+1; - Must_have_memory = TRUE; /* XXX */ - focus->trace = (WindowPtr *)xrealloc(focus->trace, - focus->traceSize * - sizeof(WindowPtr)); - Must_have_memory = FALSE; /* XXX */ - } - focus->traceGood = depth; - for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--) - focus->trace[depth] = pWin; - } - 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(ClientPtr client) -{ - xGetInputFocusReply rep; - /* REQUEST(xReq); */ - FocusClassPtr focus = inputInfo.keyboard->focus; - - REQUEST_SIZE_MATCH(xReq); - memset(&rep, 0, sizeof(xGetInputFocusReply)); - 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(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)) - { - client->errorValue = stuff->keyboardMode; - return BadValue; - } - if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue)) - { - client->errorValue = stuff->ownerEvents; - return BadValue; - } - if ((stuff->eventMask & ~PointerGrabMask) && !permitOldBugs) - { - client->errorValue = stuff->eventMask; - return BadValue; - } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); - if (!pWin) - return BadWindow; - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcGrabPointer: pWin [%p] client [%d].\n", pWin, client -> index); - } - #endif - if (stuff->confineTo == None) - confineTo = NullWindow; - else - { - confineTo = SecurityLookupWindow(stuff->confineTo, client, - SecurityReadAccess); - if (!confineTo) - return BadWindow; - } - if (stuff->cursor == None) - cursor = NullCursor; - else - { - cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); - if (!cursor) - { - client->errorValue = stuff->cursor; - return BadCursor; - } - } - /* at this point, some sort of reply is guaranteed. */ - time = ClientTimeToServerTime(stuff->time); - memset(&rep, 0, sizeof(xGrabPointerReply)); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - grab = device->grab; - if ((grab) && !SameClient(grab, client)) - rep.status = AlreadyGrabbed; - else if ((!pWin->realized) || - (confineTo && - !(confineTo->realized && BorderSizeNotEmpty(confineTo)))) - rep.status = GrabNotViewable; - else if (device->sync.frozen && - device->sync.other && !SameClient(device->sync.other, client)) - rep.status = GrabFrozen; - else if ((CompareTimeStamps(time, currentTime) == LATER) || - (CompareTimeStamps(time, device->grabTime) == EARLIER)) - rep.status = GrabInvalidTime; - else - { - GrabRec tempGrab; - - oldCursor = NullCursor; - if (grab) - { - if (grab->confineTo && !confineTo) - ConfineCursorToWindow(ROOT, FALSE, FALSE); - oldCursor = grab->cursor; - } - 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; - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcGrabPointer: Activating active grab on pointer.\n"); - } - #endif - (*device->ActivateGrab)(device, &tempGrab, time, FALSE); - if (oldCursor) - FreeCursor (oldCursor, (Cursor)0); - rep.status = GrabSuccess; - } - WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep); - return Success; -} - -int -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) - { - client->errorValue = stuff->cursor; - return BadCursor; - } - } - 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(ClientPtr client) -{ - DeviceIntPtr device = inputInfo.pointer; - GrabPtr grab; - TimeStamp time; - REQUEST(xResourceReq); - - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcUngrabPointer: client [%d].\n", client -> index); - } - #endif - 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)) - #ifdef NX_DEBUG_INPUT - { - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcUngrabPointer: Deactivating grab on pointer.\n"); - } - #endif - (*device->DeactivateGrab)(device); - #ifdef NX_DEBUG_INPUT - } - else - { - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcUngrabPointer: current time [%lu] request time [%lu] grab time [%lu].\n", - currentTime.milliseconds, time.milliseconds, device->grabTime.milliseconds); - } - } - #endif - return Success; -} - -int -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; - } - pWin = SecurityLookupWindow(grabWindow, client, SecurityReadAccess); - if (!pWin) - return BadWindow; - time = ClientTimeToServerTime(ctime); - grab = dev->grab; - if (grab && !SameClient(grab, client)) - *status = AlreadyGrabbed; - else if (!pWin->realized) - *status = GrabNotViewable; - else if ((CompareTimeStamps(time, currentTime) == LATER) || - (CompareTimeStamps(time, dev->grabTime) == EARLIER)) - *status = GrabInvalidTime; - else if (dev->sync.frozen && - 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; - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "GrabDevice: Activating active grab on keyboard.\n"); - } - #endif - (*dev->ActivateGrab)(dev, &tempGrab, time, FALSE); - *status = GrabSuccess; - } - return Success; -} - -int -ProcGrabKeyboard(ClientPtr client) -{ - xGrabKeyboardReply rep; - REQUEST(xGrabKeyboardReq); - int result; - - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcGrabKeyboard: client [%d].\n", client -> index); - } - #endif - REQUEST_SIZE_MATCH(xGrabKeyboardReq); - memset(&rep, 0, sizeof(xGrabKeyboardReply)); - -#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(ClientPtr client) -{ - DeviceIntPtr device = inputInfo.keyboard; - GrabPtr grab; - TimeStamp time; - REQUEST(xResourceReq); - - #ifdef NX_DEBUG_INPUT - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcUngrabKeyboard: client [%d].\n", client -> index); - } - #endif - 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)) - #ifdef NX_DEBUG_INPUT - { - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcUngrabKeyboard: Deactivating grab on keyboard.\n"); - } - #endif - (*device->DeactivateGrab)(device); - #ifdef NX_DEBUG_INPUT - } - else - { - if (nxagentDebugInputDevices == 1) - { - fprintf(stderr, "ProcUngrabKeyboard: current time [%lu] request time [%lu] grab time [%lu].\n", - currentTime.milliseconds, time.milliseconds, device->grabTime.milliseconds); - } - } - #endif - return Success; -} - -int -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); - memset(&rep, 0, sizeof(xQueryPointerReply)); - 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; - if (sprite.hot.pScreen == pWin->drawable.pScreen) - { - rep.sameScreen = xTrue; - rep.winX = sprite.hot.x - pWin->drawable.x; - rep.winY = sprite.hot.y - pWin->drawable.y; - for (t = sprite.win; t; t = t->parent) - if (t->parent == pWin) - { - rep.child = t->drawable.id; - break; - } - } - else - { - rep.sameScreen = xFalse; - rep.winX = 0; - rep.winY = 0; - } - -#ifdef PANORAMIX - if(!noPanoramiXExtension) { - rep.rootX += panoramiXdataPtr[0].x; - rep.rootY += panoramiXdataPtr[0].y; - if(stuff->id == rep.root) { - rep.winX += panoramiXdataPtr[0].x; - rep.winY += panoramiXdataPtr[0].y; - } - } -#endif - - WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep); - - return(Success); -} - -void -InitEvents() -{ - int i; - - sprite.hot.pScreen = sprite.hotPhys.pScreen = (ScreenPtr)NULL; - inputInfo.numDevices = 0; - inputInfo.devices = (DeviceIntPtr)NULL; - inputInfo.off_devices = (DeviceIntPtr)NULL; - inputInfo.keyboard = (DeviceIntPtr)NULL; - inputInfo.pointer = (DeviceIntPtr)NULL; - if (spriteTraceSize == 0) - { - spriteTraceSize = 32; - spriteTrace = (WindowPtr *)xalloc(32*sizeof(WindowPtr)); - if (!spriteTrace) - FatalError("failed to allocate spriteTrace"); - } - spriteTraceGood = 0; - lastEventMask = OwnerGrabButtonMask; - filters[MotionNotify] = PointerMotionMask; -#ifdef XEVIE - xeviewin = -#endif - sprite.win = NullWindow; - sprite.current = NullCursor; - sprite.hotLimits.x1 = 0; - sprite.hotLimits.y1 = 0; - sprite.hotLimits.x2 = 0; - sprite.hotLimits.y2 = 0; - sprite.confined = FALSE; - syncEvents.replayDev = (DeviceIntPtr)NULL; - syncEvents.replayWin = NullWindow; - while (syncEvents.pending) - { - QdEventPtr next = syncEvents.pending->next; - xfree(syncEvents.pending); - syncEvents.pending = next; - } - syncEvents.pendtail = &syncEvents.pending; - syncEvents.playingEvents = FALSE; - syncEvents.time.months = 0; - 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(ClientPtr client) { @@ -4604,444 +606,3 @@ ProcSendEvent(ClientPtr client) NullGrab, 0); return Success; } - -int -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(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)) - { - client->errorValue = stuff->keyboardMode; - return BadValue; - } - 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; - } - 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(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) && - (stuff->modifiers & ~AllModifiersMask)) - { - client->errorValue = stuff->modifiers; - return BadValue; - } - if ((stuff->ownerEvents != xFalse) && (stuff->ownerEvents != xTrue)) - { - client->errorValue = stuff->ownerEvents; - return BadValue; - } - if (stuff->eventMask & ~PointerGrabMask) - { - client->errorValue = stuff->eventMask; - return BadValue; - } - pWin = SecurityLookupWindow(stuff->grabWindow, client, SecurityReadAccess); - if (!pWin) - return BadWindow; - if (stuff->confineTo == None) - confineTo = NullWindow; - else { - confineTo = SecurityLookupWindow(stuff->confineTo, client, - SecurityReadAccess); - if (!confineTo) - return BadWindow; - } - if (stuff->cursor == None) - cursor = NullCursor; - else - { - cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor, - RT_CURSOR, SecurityReadAccess); - if (!cursor) - { - 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(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(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); - - /* If the focus window is a root window (ie. has no parent) then don't - delete the focus from it. */ - - if ((pWin == focus->win) && (pWin->parent != NullWindow)) - { - int focusEventMode = NotifyNormal; - - /* If a grab is in progress, then alter the mode of focus events. */ - - if (keybd->grab) - focusEventMode = NotifyWhileGrabbed; - - switch (focus->revert) - { - case RevertToNone: - DoFocusEvents(keybd, pWin, NoneWin, focusEventMode); - focus->win = NoneWin; - focus->traceGood = 0; - break; - case RevertToParent: - parent = pWin; - do - { - parent = parent->parent; - focus->traceGood--; - } while (!parent->realized -/* This would be a good protocol change -- windows being reparented - during SaveSet processing would cause the focus to revert to the - nearest enclosing window which will survive the death of the exiting - client, instead of ending up reverting to a dying window and thence - to None - */ -#ifdef NOTDEF - || clients[CLIENT_ID(parent->drawable.id)]->clientGone -#endif - ); - DoFocusEvents(keybd, pWin, parent, focusEventMode); - focus->win = parent; - focus->revert = RevertToNone; - break; - case RevertToPointerRoot: - DoFocusEvents(keybd, pWin, PointerRootWin, focusEventMode); - focus->win = PointerRootWin; - focus->traceGood = 0; - break; - } - } - - 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 - */ -void -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(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(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(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: - case KeyPress: - case KeyRelease: - case EnterNotify: - case LeaveNotify: - /* - When multiple clients want the same event DeliverEventsToWindow - passes the same event structure multiple times so we can't - modify the one passed to us - */ - count = 1; /* should always be 1 */ - memcpy(&eventCopy, events, sizeof(xEvent)); - eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x; - eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y; - if(eventCopy.u.keyButtonPointer.event == - eventCopy.u.keyButtonPointer.root) - { - eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x; - eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y; - } - events = &eventCopy; - break; - default: break; - } - } -#endif - - if (EventCallback) - { - EventInfoRec eventinfo; - eventinfo.client = pClient; - eventinfo.events = events; - eventinfo.count = count; - CallCallbacks(&EventCallback, (void *)&eventinfo); - } - if(pClient->swapped) - { - for(i = 0; i < count; i++) - { - eventFrom = &events[i]; - /* Remember to strip off the leading bit of type in case - this event was sent with "SendEvent." */ - (*EventSwapVector[eventFrom->u.u.type & 0177]) - (eventFrom, &eventTo); - (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo); - } - } - else - { - (void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events); - } -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c index 0c0145477..71478fcc4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c @@ -64,265 +64,9 @@ SOFTWARE. ******************************************************************/ /* $Xorg: extension.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES -#include <nx-X11/Xproto.h> -#include "misc.h" -#include "dixstruct.h" -#include "extnsionst.h" -#include "gcstruct.h" -#include "scrnintstr.h" -#include "../../dix/dispatch.h" -#ifdef XCSECURITY -#define _SECURITY_SERVER -#include <nx-X11/extensions/security.h> -#endif -#ifdef LBX -#include "lbxserve.h" -#endif - #include "Trap.h" -#define EXTENSION_BASE 128 -#define EXTENSION_EVENT_BASE 64 -#define LAST_EVENT 128 -#define LAST_ERROR 255 - -ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS]; - -static ExtensionEntry **extensions = (ExtensionEntry **)NULL; - -int lastEvent = EXTENSION_EVENT_BASE; -static int lastError = FirstExtensionError; -static unsigned int NumExtensions = 0; - -ExtensionEntry * -AddExtension(char *name, int NumEvents, int NumErrors, - int (*MainProc)(ClientPtr c1), - int (*SwappedMainProc)(ClientPtr c2), - void (*CloseDownProc)(ExtensionEntry *e), - unsigned short (*MinorOpcodeProc)(ClientPtr c3)) -{ - int i; - register ExtensionEntry *ext, **newexts; - - if (!MainProc || !SwappedMainProc || !MinorOpcodeProc) - return((ExtensionEntry *) NULL); - if ((lastEvent + NumEvents > LAST_EVENT) || - (unsigned)(lastError + NumErrors > LAST_ERROR)) - return((ExtensionEntry *) NULL); - - ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry)); - if (!ext) - return((ExtensionEntry *) NULL); - ext->name = (char *)xalloc(strlen(name) + 1); - ext->num_aliases = 0; - ext->aliases = (char **)NULL; - if (!ext->name) - { - xfree(ext); - return((ExtensionEntry *) NULL); - } - strcpy(ext->name, name); - i = NumExtensions; - newexts = (ExtensionEntry **) xrealloc(extensions, - (i + 1) * sizeof(ExtensionEntry *)); - if (!newexts) - { - xfree(ext->name); - xfree(ext); - return((ExtensionEntry *) NULL); - } - NumExtensions++; - extensions = newexts; - extensions[i] = ext; - ext->index = i; - ext->base = i + EXTENSION_BASE; - ext->CloseDown = CloseDownProc; - ext->MinorOpcode = MinorOpcodeProc; - ProcVector[i + EXTENSION_BASE] = MainProc; - SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc; - if (NumEvents) - { - ext->eventBase = lastEvent; - ext->eventLast = lastEvent + NumEvents; - lastEvent += NumEvents; - } - else - { - ext->eventBase = 0; - ext->eventLast = 0; - } - if (NumErrors) - { - 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(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 -} - -static int -FindExtension(char *extname, int len) -{ - int i, j; - - for (i=0; i<NumExtensions; i++) - { - if ((strlen(extensions[i]->name) == len) && - !strncmp(extname, extensions[i]->name, len)) - break; - for (j = extensions[i]->num_aliases; --j >= 0;) - { - if ((strlen(extensions[i]->aliases[j]) == len) && - !strncmp(extname, extensions[i]->aliases[j], len)) - break; - } - if (j >= 0) break; - } - 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(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(ClientPtr client) -{ - return ((xReq *)client->requestBuffer)->data; -} - -unsigned short -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 - - for (i = NumExtensions - 1; i >= 0; i--) - { - if (extensions[i]->CloseDown) - (* extensions[i]->CloseDown)(extensions[i]); - NumExtensions = i; - xfree(extensions[i]->name); - for (j = extensions[i]->num_aliases; --j >= 0;) - xfree(extensions[i]->aliases[j]); - xfree(extensions[i]->aliases); - xfree(extensions[i]); - } - xfree(extensions); - extensions = (ExtensionEntry **)NULL; - lastEvent = EXTENSION_EVENT_BASE; - lastError = FirstExtensionError; - for (i=0; i<MAXSCREENS; i++) - { - register ScreenProcEntry *spentry = &AuxillaryScreenProcs[i]; - - while (spentry->num) - { - spentry->num--; - xfree(spentry->procList[spentry->num].name); - } - xfree(spentry->procList); - spentry->procList = (ProcEntryPtr)NULL; - } -} - +#include "../../dix/extension.c" int ProcQueryExtension(ClientPtr client) @@ -443,69 +187,3 @@ ProcListExtensions(ClientPtr client) } return(client->noClientException); } - - -ExtensionLookupProc -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(char *name, GC *pGC, ExtensionLookupProc proc) -{ - return RegisterScreenProc(name, pGC->pScreen, proc); -} - -Bool -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 - { - newname = (char *)xalloc(strlen(name)+1); - if (!newname) - return FALSE; - procEntry = (ProcEntryPtr) - xrealloc(spentry->procList, - sizeof(ProcEntryRec) * (spentry->num+1)); - if (!procEntry) - { - xfree(newname); - return FALSE; - } - spentry->procList = procEntry; - procEntry += spentry->num; - procEntry->name = newname; - strcpy(newname, name); - procEntry->proc = proc; - spentry->num++; - } - return TRUE; -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c b/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c index 4b9ac9a67..2c3383dd5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglxext.c @@ -35,20 +35,7 @@ ** */ -#define NEED_REPLIES -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "glxserver.h" -#include <windowstr.h> -#include <propertyst.h> -#include <os.h> -#include "g_disptab.h" -#include "unpack.h" -#include "glxutil.h" -#include "glxext.h" -#include "micmap.h" +#include "../../GL/glx/glxext.c" #include "Trap.h" @@ -57,362 +44,6 @@ #undef TEST #undef DEBUG -void GlxWrapInitVisuals(miInitVisualsProcPtr *); -void GlxSetVisualConfigs(int nconfigs, - __GLXvisualConfig *configs, void **privates); - -static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */; - -/* -** Forward declarations. -*/ -static int __glXSwapDispatch(ClientPtr); -static int __glXDispatch(ClientPtr); - -/* -** Called when the extension is reset. -*/ -static void ResetExtension(ExtensionEntry* extEntry) -{ - __glXFlushContextCache(); - (*__glXExt->resetExtension)(); - __glXScreenReset(); -} - -/* -** Initialize the per-client context storage. -*/ -static void ResetClientState(int clientIndex) -{ - __GLXclientState *cl = __glXClients[clientIndex]; - - if (cl->returnBuf) __glXFree(cl->returnBuf); - if (cl->largeCmdBuf) __glXFree(cl->largeCmdBuf); - if (cl->currentContexts) __glXFree(cl->currentContexts); - __glXMemset(cl, 0, sizeof(__GLXclientState)); - /* - ** By default, assume that the client supports - ** GLX major version 1 minor version 0 protocol. - */ - cl->GLClientmajorVersion = 1; - cl->GLClientminorVersion = 0; - if (cl->GLClientextensions) __glXFree(cl->GLClientextensions); - -} - -/* -** Reset state used to keep track of large (multi-request) commands. -*/ -void __glXResetLargeCommandStatus(__GLXclientState *cl) -{ - cl->largeCmdBytesSoFar = 0; - cl->largeCmdBytesTotal = 0; - cl->largeCmdRequestsSoFar = 0; - cl->largeCmdRequestsTotal = 0; -} - -/* -** This procedure is called when the client who created the context goes -** away OR when glXDestroyContext is called. In either case, all we do is -** flag that the ID is no longer valid, and (maybe) free the context. -** use. -*/ -static int ContextGone(__GLXcontext* cx, XID id) -{ - cx->idExists = GL_FALSE; - if (!cx->isCurrent) { - __glXFreeContext(cx); - } - - return True; -} - -/* -** Free a client's state. -*/ -static int ClientGone(int clientIndex, XID id) -{ - __GLXcontext *cx; - __GLXclientState *cl = __glXClients[clientIndex]; - int i; - - if (cl) { - /* - ** Free all the contexts that are current for this client. - */ - for (i=0; i < cl->numCurrentContexts; i++) { - cx = cl->currentContexts[i]; - if (cx) { - __glXDeassociateContext(cx); - cx->isCurrent = GL_FALSE; - if (!cx->idExists) { - __glXFreeContext(cx); - } - } - } - /* - ** Re-initialize the client state structure. Don't free it because - ** we'll probably get another client with this index and use the struct - ** again. There is a maximum of MAXCLIENTS of these structures. - */ - ResetClientState(clientIndex); - } - - return True; -} - -/* -** Free a GLX Pixmap. -*/ -static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id) -{ - PixmapPtr pPixmap = (PixmapPtr) pGlxPixmap->pDraw; - - pGlxPixmap->idExists = False; - if (!pGlxPixmap->refcnt) { - /* - ** The DestroyPixmap routine should decrement the refcount and free - ** only if it's zero. - */ - (*pGlxPixmap->pScreen->DestroyPixmap)(pPixmap); - __glXFree(pGlxPixmap); - } - - return True; -} - -/* -** Free a context. -*/ -GLboolean __glXFreeContext(__GLXcontext *cx) -{ - if (cx->idExists || cx->isCurrent) return GL_FALSE; - - if (!cx->isDirect) { - if ((*cx->gc->exports.destroyContext)((__GLcontext *)cx->gc) == GL_FALSE) { - return GL_FALSE; - } - } - if (cx->feedbackBuf) __glXFree(cx->feedbackBuf); - if (cx->selectBuf) __glXFree(cx->selectBuf); - __glXFree(cx); - if (cx == __glXLastContext) { - __glXFlushContextCache(); - } - - return GL_TRUE; -} - -extern RESTYPE __glXSwapBarrierRes; - -static int SwapBarrierGone(int screen, XID drawable) -{ - if (__glXSwapBarrierFuncs && - __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc != NULL) { - __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc(screen, drawable, 0); - } - FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE); - return True; -} - -/************************************************************************/ - -/* -** These routines can be used to check whether a particular GL command -** has caused an error. Specifically, we use them to check whether a -** given query has caused an error, in which case a zero-length data -** reply is sent to the client. -*/ - -static GLboolean errorOccured = GL_FALSE; - -/* -** The GL was will call this routine if an error occurs. -*/ -void __glXErrorCallBack(__GLinterface *gc, GLenum code) -{ - errorOccured = GL_TRUE; -} - -/* -** Clear the error flag before calling the GL command. -*/ -void __glXClearErrorOccured(void) -{ - errorOccured = GL_FALSE; -} - -/* -** Check if the GL command caused an error. -*/ -GLboolean __glXErrorOccured(void) -{ - return errorOccured; -} - -/************************************************************************/ - -/* -** Initialize the GLX extension. -*/ -void GlxExtensionInit(void) -{ - ExtensionEntry *extEntry; - int i; - - __glXContextRes = CreateNewResourceType((DeleteType)ContextGone); - __glXClientRes = CreateNewResourceType((DeleteType)ClientGone); - __glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone); - - /* - ** Add extension to server extensions. - */ - extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS, - __GLX_NUMBER_ERRORS, __glXDispatch, - __glXSwapDispatch, ResetExtension, - StandardMinorOpcode); - if (!extEntry) { - FatalError("__glXExtensionInit: AddExtensions failed\n"); - return; - } - if (!AddExtensionAlias(GLX_EXTENSION_ALIAS, extEntry)) { - ErrorF("__glXExtensionInit: AddExtensionAlias failed\n"); - return; - } - - __glXBadContext = extEntry->errorBase + GLXBadContext; - __glXBadContextState = extEntry->errorBase + GLXBadContextState; - __glXBadDrawable = extEntry->errorBase + GLXBadDrawable; - __glXBadPixmap = extEntry->errorBase + GLXBadPixmap; - __glXBadContextTag = extEntry->errorBase + GLXBadContextTag; - __glXBadCurrentWindow = extEntry->errorBase + GLXBadCurrentWindow; - __glXBadRenderRequest = extEntry->errorBase + GLXBadRenderRequest; - __glXBadLargeRequest = extEntry->errorBase + GLXBadLargeRequest; - __glXUnsupportedPrivateRequest = extEntry->errorBase + - GLXUnsupportedPrivateRequest; - - __glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone); - - /* - ** Initialize table of client state. There is never a client 0. - */ - for (i=1; i <= MAXCLIENTS; i++) { - __glXClients[i] = 0; - } - - /* - ** Initialize screen specific data. - */ - __glXScreenInit(screenInfo.numScreens); -} - -/************************************************************************/ - -Bool __glXCoreType(void) -{ - return __glXExt->type; -} - -/************************************************************************/ - -void GlxSetVisualConfigs(int nconfigs, - __GLXvisualConfig *configs, void **privates) -{ - (*__glXExt->setVisualConfigs)(nconfigs, configs, privates); -} - -static miInitVisualsProcPtr saveInitVisualsProc; - -Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, - int *rootDepthp, VisualID *defaultVisp, - unsigned long sizes, int bitsPerRGB, - int preferredVis) -{ - Bool ret; - - if (saveInitVisualsProc) { - ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp, - rootDepthp, defaultVisp, sizes, bitsPerRGB, - preferredVis); - if (!ret) - return False; - } - (*__glXExt->initVisuals)(visualp, depthp, nvisualp, ndepthp, rootDepthp, - defaultVisp, sizes, bitsPerRGB); - return True; -} - -void -GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc) -{ - saveInitVisualsProc = *initVisProc; - *initVisProc = GlxInitVisuals; - /* HACK: this shouldn't be done here but it's the earliest time */ - __glXExt = __glXglDDXExtensionInfo(); /* from GLcore */ -} - -/************************************************************************/ - -void __glXFlushContextCache(void) -{ - __glXLastContext = 0; -} - -/* -** Make a context the current one for the GL (in this implementation, there -** is only one instance of the GL, and we use it to serve all GL clients by -** switching it between different contexts). While we are at it, look up -** a context by its tag and return its (__GLXcontext *). -*/ -__GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag, - int *error) -{ - __GLXcontext *cx; - - /* - ** See if the context tag is legal; it is managed by the extension, - ** so if it's invalid, we have an implementation error. - */ - cx = (__GLXcontext *) __glXLookupContextByTag(cl, tag); - if (!cx) { - cl->client->errorValue = tag; - *error = __glXBadContextTag; - return 0; - } - - if (!cx->isDirect) { - if (cx->drawPriv == NULL) { - /* - ** The drawable has vanished. It must be a window, because only - ** windows can be destroyed from under us; GLX pixmaps are - ** refcounted and don't go away until no one is using them. - */ - *error = __glXBadCurrentWindow; - return 0; - } - } - - if (cx == __glXLastContext) { - /* No need to re-bind */ - return cx; - } - - /* Make this context the current one for the GL. */ - if (!cx->isDirect) { - if (!(*cx->gc->exports.forceCurrent)((__GLcontext *)cx->gc)) { - /* Bind failed, and set the error code. Bummer */ - cl->client->errorValue = cx->id; - *error = __glXBadContextState; - return 0; - } - } - __glXLastContext = cx; - return cx; -} - -/************************************************************************/ - /* ** Top level dispatcher; all commands are executed from here down. */ @@ -563,13 +194,3 @@ static int __glXSwapDispatch(ClientPtr client) return result; } - -int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc) -{ - return BadRequest; -} - -void __glXNoSuchRenderOpcode(GLbyte *pc) -{ - return; -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 757ffff21..4359a552b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -40,28 +40,10 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "misc.h" -#include "scrnintstr.h" -#include "os.h" -#include "regionstr.h" -#include "validate.h" -#include "windowstr.h" -#include "input.h" -#include "resource.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" +#include "../../render/glyph.c" #ifdef NXAGENT_SERVER -#include "NXpicturestr.h" -#include "NXglyphstr.h" #include "Render.h" #define PANIC @@ -69,239 +51,9 @@ #undef DEBUG #undef TEST -#else - -#include "picturestr.h" -#include "glyphstr.h" - -#endif - -#include <stdint.h> - -/* - * From Knuth -- a good choice for hash/rehash values is p, p-2 where - * p and p-2 are both prime. These tables are sized to have an extra 10% - * free to avoid exponential performance degradation as the hash table fills - */ -static GlyphHashSetRec glyphHashSets[] = { - { 32, 43, 41 }, - { 64, 73, 71 }, - { 128, 151, 149 }, - { 256, 283, 281 }, - { 512, 571, 569 }, - { 1024, 1153, 1151 }, - { 2048, 2269, 2267 }, - { 4096, 4519, 4517 }, - { 8192, 9013, 9011 }, - { 16384, 18043, 18041 }, - { 32768, 36109, 36107 }, - { 65536, 72091, 72089 }, - { 131072, 144409, 144407 }, - { 262144, 288361, 288359 }, - { 524288, 576883, 576881 }, - { 1048576, 1153459, 1153457 }, - { 2097152, 2307163, 2307161 }, - { 4194304, 4613893, 4613891 }, - { 8388608, 9227641, 9227639 }, - { 16777216, 18455029, 18455027 }, - { 33554432, 36911011, 36911009 }, - { 67108864, 73819861, 73819859 }, - { 134217728, 147639589, 147639587 }, - { 268435456, 295279081, 295279079 }, - { 536870912, 590559793, 590559791 } -}; - -#define NGLYPHHASHSETS (sizeof(glyphHashSets)/sizeof(glyphHashSets[0])) - -const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 }; - -GlyphHashRec globalGlyphs[GlyphFormatNum]; - -GlyphHashSetPtr -FindGlyphHashSet (CARD32 filled) -{ - int i; - - for (i = 0; i < NGLYPHHASHSETS; i++) - if (glyphHashSets[i].entries >= filled) - return &glyphHashSets[i]; - return 0; -} - -static int _GlyphSetPrivateAllocateIndex = 0; - -int -AllocateGlyphSetPrivateIndex (void) -{ - return _GlyphSetPrivateAllocateIndex++; -} - -void -ResetGlyphSetPrivateIndex (void) -{ - _GlyphSetPrivateAllocateIndex = 0; -} - -Bool -_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr) -{ - void **new; - - if (n > glyphSet->maxPrivate) { - if (glyphSet->devPrivates && - glyphSet->devPrivates != (void *)(&glyphSet[1])) { - new = (void **) xrealloc (glyphSet->devPrivates, - (n + 1) * sizeof (void *)); - if (!new) - return FALSE; - } else { - new = (void **) xalloc ((n + 1) * sizeof (void *)); - if (!new) - return FALSE; - if (glyphSet->devPrivates) - memcpy (new, - glyphSet->devPrivates, - (glyphSet->maxPrivate + 1) * sizeof (void *)); - } - glyphSet->devPrivates = new; - /* Zero out new, uninitialize privates */ - while (++glyphSet->maxPrivate < n) - glyphSet->devPrivates[glyphSet->maxPrivate] = (void *)0; - } - glyphSet->devPrivates[n] = ptr; - return TRUE; -} - -Bool -GlyphInit (ScreenPtr pScreen) -{ - return TRUE; -} - -GlyphRefPtr -FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) -{ - CARD32 elt, step, s; - GlyphPtr glyph; - GlyphRefPtr table, gr, del; - CARD32 tableSize = hash->hashSet->size; - - table = hash->table; - elt = signature % tableSize; - step = 0; - del = 0; - for (;;) - { - gr = &table[elt]; - s = gr->signature; - glyph = gr->glyph; - if (!glyph) - { - if (del) - gr = del; - break; - } - if (glyph == DeletedGlyph) - { - if (!del) - del = gr; - else if (gr == del) - break; - } - else if (s == signature && - (!match || - memcmp (&compare->info, &glyph->info, compare->size) == 0)) - { - break; - } - if (!step) - { - step = signature % hash->hashSet->rehash; - if (!step) - step = 1; - } - elt += step; - if (elt >= tableSize) - elt -= tableSize; - } - return gr; -} - -CARD32 -HashGlyph (GlyphPtr glyph) -{ - CARD32 *bits = (CARD32 *) &(glyph->info); - CARD32 hash; - int n = glyph->size / sizeof (CARD32); - - hash = 0; - while (n--) - hash ^= *bits++; - return hash; -} - -#ifdef CHECK_DUPLICATES -void -DuplicateRef (GlyphPtr glyph, char *where) -{ - ErrorF ("Duplicate Glyph 0x%x from %s\n", glyph, where); -} - -void -CheckDuplicates (GlyphHashPtr hash, char *where) -{ - GlyphPtr g; - int i, j; - - for (i = 0; i < hash->hashSet->size; i++) - { - g = hash->table[i].glyph; - if (!g || g == DeletedGlyph) - continue; - for (j = i + 1; j < hash->hashSet->size; j++) - if (hash->table[j].glyph == g) - DuplicateRef (g, where); - } -} -#else -#define CheckDuplicates(a,b) -#define DuplicateRef(a,b) #endif void -FreeGlyph (GlyphPtr glyph, int format) -{ - CheckDuplicates (&globalGlyphs[format], "FreeGlyph"); - if (--glyph->refcnt == 0) - { - GlyphRefPtr gr; - int i; - int first; - - first = -1; - for (i = 0; i < globalGlyphs[format].hashSet->size; i++) - if (globalGlyphs[format].table[i].glyph == glyph) - { - if (first != -1) - DuplicateRef (glyph, "FreeGlyph check"); - first = i; - } - - gr = FindGlyphRef (&globalGlyphs[format], - HashGlyph (glyph), TRUE, glyph); - if (gr - globalGlyphs[format].table != first) - DuplicateRef (glyph, "Found wrong one"); - if (gr->glyph && gr->glyph != DeletedGlyph) - { - gr->glyph = DeletedGlyph; - gr->signature = 0; - globalGlyphs[format].tableEntries--; - } - xfree (glyph); - } -} - -void AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) { GlyphRefPtr gr; @@ -342,26 +94,6 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom"); } -Bool -DeleteGlyph (GlyphSetPtr glyphSet, Glyph id) -{ - GlyphRefPtr gr; - GlyphPtr glyph; - - gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0); - glyph = gr->glyph; - if (glyph && glyph != DeletedGlyph) - { - gr->glyph = DeletedGlyph; - glyphSet->hash.tableEntries--; - FreeGlyph (glyph, glyphSet->fdepth); - return TRUE; - } - return FALSE; -} - -#ifdef NXAGENT_SERVER - GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id) { GlyphRefPtr gr; @@ -388,53 +120,6 @@ GlyphPtr FindGlyph (GlyphSetPtr glyphSet, Glyph id) return glyph; } -#else - -GlyphPtr -FindGlyph (GlyphSetPtr glyphSet, Glyph id) -{ - GlyphPtr glyph; - - glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph; - if (glyph == DeletedGlyph) - glyph = 0; - return glyph; -} - -#endif - -GlyphPtr -AllocateGlyph (xGlyphInfo *gi, int fdepth) -{ - int size; - GlyphPtr glyph; - size_t padded_width; - - padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]); - if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height) - return 0; - size = gi->height * padded_width; - glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec)); - if (!glyph) - return 0; - glyph->refcnt = 0; - glyph->size = size + sizeof (xGlyphInfo); - glyph->info = *gi; - return glyph; -} - -Bool -AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet) -{ - hash->table = (GlyphRefPtr) xalloc (hashSet->size * sizeof (GlyphRefRec)); - if (!hash->table) - return FALSE; - memset (hash->table, 0, hashSet->size * sizeof (GlyphRefRec)); - hash->hashSet = hashSet; - hash->tableEntries = 0; - return TRUE; -} - Bool ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) { @@ -497,81 +182,3 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) CheckDuplicates (hash, "ResizeGlyphHash bottom"); return TRUE; } - -Bool -ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change) -{ - return (ResizeGlyphHash (&glyphSet->hash, change, FALSE) && - ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], change, TRUE)); -} - -GlyphSetPtr -AllocateGlyphSet (int fdepth, PictFormatPtr format) -{ - GlyphSetPtr glyphSet; - int size; - - if (!globalGlyphs[fdepth].hashSet) - { - if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0])) - return FALSE; - } - - size = (sizeof (GlyphSetRec) + - (sizeof (void *) * _GlyphSetPrivateAllocateIndex)); - glyphSet = xalloc (size); - if (!glyphSet) - return FALSE; - bzero((char *)glyphSet, size); - glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1; - if (_GlyphSetPrivateAllocateIndex) - glyphSet->devPrivates = (void *)(&glyphSet[1]); - - if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0])) - { - xfree (glyphSet); - return FALSE; - } - glyphSet->refcnt = 1; - glyphSet->fdepth = fdepth; - glyphSet->format = format; - return glyphSet; -} - -int -FreeGlyphSet (void * value, - XID gid) -{ - GlyphSetPtr glyphSet = (GlyphSetPtr) value; - - if (--glyphSet->refcnt == 0) - { - CARD32 i, tableSize = glyphSet->hash.hashSet->size; - GlyphRefPtr table = glyphSet->hash.table; - GlyphPtr glyph; - - for (i = 0; i < tableSize; i++) - { - glyph = table[i].glyph; - if (glyph && glyph != DeletedGlyph) - FreeGlyph (glyph, glyphSet->fdepth); - } - if (!globalGlyphs[glyphSet->fdepth].tableEntries) - { - xfree (globalGlyphs[glyphSet->fdepth].table); - globalGlyphs[glyphSet->fdepth].table = 0; - globalGlyphs[glyphSet->fdepth].hashSet = 0; - } - else - ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE); - xfree (table); - - if (glyphSet->devPrivates && - glyphSet->devPrivates != (void *)(&glyphSet[1])) - xfree(glyphSet->devPrivates); - - xfree (glyphSet); - } - return Success; -} - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c index 1696ae51f..33492a6d6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyphcurs.c @@ -64,20 +64,7 @@ SOFTWARE. /* $Xorg: glyphcurs.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "misc.h" -#include <X11/fonts/fontstruct.h> -#include "dixfontstr.h" -#include "scrnintstr.h" -#include "gcstruct.h" -#include "resource.h" -#include "dix.h" -#include "cursorstr.h" -#include "opaque.h" -#include "servermd.h" +#include "../../dix/glyphcurs.c" #include "../../fb/fb.h" #include "Pixmaps.h" @@ -183,57 +170,3 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, register CursorMetricPtr cm, uns return Success; } - - -Bool -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; - } - (*pfont->get_glyphs) (pfont, 1, chs, encoding, &nglyphs, &pci); - if (nglyphs == 0) - return FALSE; - cm->width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; - cm->height = pci->metrics.descent + pci->metrics.ascent; - if (pci->metrics.leftSideBearing > 0) - { - cm->width += pci->metrics.leftSideBearing; - cm->xhot = 0; - } - else - { - cm->xhot = -pci->metrics.leftSideBearing; - if (pci->metrics.rightSideBearing < 0) - cm->width -= pci->metrics.rightSideBearing; - } - if (pci->metrics.ascent < 0) - { - cm->height -= pci->metrics.ascent; - cm->yhot = 0; - } - else - { - cm->yhot = pci->metrics.ascent; - if (pci->metrics.descent < 0) - cm->height -= pci->metrics.descent; - } - return TRUE; -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphRef.h b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphRef.h new file mode 100644 index 000000000..6239b113e --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphRef.h @@ -0,0 +1,54 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NXAGENT, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of Medialogic S.p.A. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* + * $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $ + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +/* this header file gets included into Xserver/render/glyphstr.h */ + +#ifndef NX_GLYPHSTR_GLYPHREF_H +#define NX_GLYPHSTR_GLYPHREF_H 1 + +typedef struct _GlyphRef { + CARD32 signature; + GlyphPtr glyph; + CARD16 corruptedGlyph; +} GlyphRefRec, *GlyphRefPtr; + +#endif /* NX_GLYPHSTR_GLYPHREF_H */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr.h b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h index 5d7fcf640..9f6ab45e6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr.h +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h @@ -40,53 +40,10 @@ * Author: Keith Packard, SuSE, Inc. */ -/* - * This must keep the same symbol as the original glyphstr.h - * or symbols will be redefined. The code here adds a field - * to _GlyphSet. This should be done by defining a new type - * and casting when appropriate. - */ - -#ifndef _GLYPHSTR_H_ -#define _GLYPHSTR_H_ - -#include <nx-X11/extensions/renderproto.h> -#include "../../render/picture.h" -#include "screenint.h" - -#define GlyphFormat1 0 -#define GlyphFormat4 1 -#define GlyphFormat8 2 -#define GlyphFormat16 3 -#define GlyphFormat32 4 -#define GlyphFormatNum 5 - -typedef struct _Glyph { - CARD32 refcnt; - CARD32 size; /* info + bitmap */ - xGlyphInfo info; - /* bits follow */ -} GlyphRec, *GlyphPtr; - -typedef struct _GlyphRef { - CARD32 signature; - GlyphPtr glyph; - CARD16 corruptedGlyph; -} GlyphRefRec, *GlyphRefPtr; - -#define DeletedGlyph ((GlyphPtr) 1) - -typedef struct _GlyphHashSet { - CARD32 entries; - CARD32 size; - CARD32 rehash; -} GlyphHashSetRec, *GlyphHashSetPtr; +/* this header file gets included into Xserver/render/glyphstr.h */ -typedef struct _GlyphHash { - GlyphRefPtr table; - GlyphHashSetPtr hashSet; - CARD32 tableEntries; -} GlyphHashRec, *GlyphHashPtr; +#ifndef NX_GLYPHSTR_GLYPHSET_H +#define NX_GLYPHSTR_GLYPHSET_H 1 typedef struct _GlyphSet { CARD32 refcnt; @@ -98,77 +55,4 @@ typedef struct _GlyphSet { CARD32 remoteID; } GlyphSetRec, *GlyphSetPtr; -#define GlyphSetGetPrivate(pGlyphSet,n) \ - ((n) > (pGlyphSet)->maxPrivate ? \ - (void *) 0 : \ - (pGlyphSet)->devPrivates[n]) - -#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \ - ((n) > (pGlyphSet)->maxPrivate ? \ - _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \ - ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE)) - -typedef struct _GlyphList { - INT16 xOff; - INT16 yOff; - CARD8 len; - PictFormatPtr format; -} GlyphListRec, *GlyphListPtr; - -extern GlyphHashRec globalGlyphs[GlyphFormatNum]; - -GlyphHashSetPtr -FindGlyphHashSet (CARD32 filled); - -int -AllocateGlyphSetPrivateIndex (void); - -void -ResetGlyphSetPrivateIndex (void); - -Bool -_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr); - -Bool -GlyphInit (ScreenPtr pScreen); - -GlyphRefPtr -FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare); - -CARD32 -HashGlyph (GlyphPtr glyph); - -void -FreeGlyph (GlyphPtr glyph, int format); - -void -AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id); - -Bool -DeleteGlyph (GlyphSetPtr glyphSet, Glyph id); - -GlyphPtr -FindGlyph (GlyphSetPtr glyphSet, Glyph id); - -GlyphPtr -AllocateGlyph (xGlyphInfo *gi, int format); - -Bool -AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet); - -Bool -ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global); - -Bool -ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change); - -GlyphSetPtr -AllocateGlyphSet (int fdepth, PictFormatPtr format); - -int -FreeGlyphSet (void *value, - XID gid); - - - -#endif /* _GLYPHSTR_H_ */ +#endif /* NX_GLYPHSTR_GLYPHSET_H */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c index a52a5200a..0ef38630f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c @@ -93,48 +93,9 @@ Equipment Corporation. /* $Xorg: miexpose.c,v 1.4 2001/02/09 02:05:20 xorgcvs Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#define NEED_EVENTS -#include <nx-X11/Xproto.h> -#include <nx-X11/Xprotostr.h> - -#include "misc.h" -#include "regionstr.h" -#include "scrnintstr.h" -#include "gcstruct.h" -#include "windowstr.h" -#include "pixmap.h" -#include "input.h" - -#include "dixstruct.h" -#include "mi.h" -#include <nx-X11/Xmd.h> - -#include "globals.h" - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif - -/* - machine-independent graphics exposure code. any device that uses -the region package can call this. -*/ - -#ifdef NXAGENT_SERVER - #include "Windows.h" -#endif - -#ifndef RECTLIMIT -#define RECTLIMIT 25 /* pick a number, any number > 8 */ -#endif +#include "../../mi/miexpose.c" /* miHandleExposures generate a region for exposures for areas that were copied from obscured or @@ -181,8 +142,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable, BoxRec expBox; Bool extents; -#ifdef NXAGENT_SERVER - /* * Set the elements reported by the compiler * as uninitialized. @@ -193,8 +152,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable, expBox.x2 = 0; expBox.y2 = 0; -#endif - /* This prevents warning about pscr not being used. */ pGC->pScreen = pscr = pGC->pScreen; @@ -414,133 +371,14 @@ miHandleExposures(pSrcDrawable, pDstDrawable, } } -/* send GraphicsExpose events, or a NoExpose event, based on the region */ - -void -miSendGraphicsExpose (client, pRgn, drawable, major, minor) - ClientPtr client; - RegionPtr pRgn; - XID drawable; - int major; - int minor; -{ - if (pRgn && !RegionNil(pRgn)) - { - xEvent *pEvent; - register xEvent *pe; - register BoxPtr pBox; - register int i; - int numRects; - - numRects = RegionNumRects(pRgn); - pBox = RegionRects(pRgn); - if(!(pEvent = (xEvent *)ALLOCATE_LOCAL(numRects * sizeof(xEvent)))) - return; - pe = pEvent; - - for (i=1; i<=numRects; i++, pe++, pBox++) - { - pe->u.u.type = GraphicsExpose; - pe->u.graphicsExposure.drawable = drawable; - pe->u.graphicsExposure.x = pBox->x1; - pe->u.graphicsExposure.y = pBox->y1; - pe->u.graphicsExposure.width = pBox->x2 - pBox->x1; - pe->u.graphicsExposure.height = pBox->y2 - pBox->y1; - pe->u.graphicsExposure.count = numRects - i; - pe->u.graphicsExposure.majorEvent = major; - pe->u.graphicsExposure.minorEvent = minor; - } - TryClientEvents(client, pEvent, numRects, - (Mask)0, NoEventMask, NullGrab); - DEALLOCATE_LOCAL(pEvent); - } - else - { - xEvent event; - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = NoExpose; - event.u.noExposure.drawable = drawable; - event.u.noExposure.majorEvent = major; - event.u.noExposure.minorEvent = minor; - TryClientEvents(client, &event, 1, - (Mask)0, NoEventMask, NullGrab); - } -} - - -void -miSendExposures(pWin, pRgn, dx, dy) - WindowPtr pWin; - RegionPtr pRgn; - register int dx, dy; -{ - register BoxPtr pBox; - int numRects; - register xEvent *pEvent, *pe; - register int i; - - pBox = RegionRects(pRgn); - numRects = RegionNumRects(pRgn); - if(!(pEvent = (xEvent *) ALLOCATE_LOCAL(numRects * sizeof(xEvent)))) - return; - memset(pEvent, 0, numRects * sizeof(xEvent)); - for (i=numRects, pe = pEvent; --i >= 0; pe++, pBox++) - { - pe->u.u.type = Expose; - pe->u.expose.window = pWin->drawable.id; - pe->u.expose.x = pBox->x1 - dx; - pe->u.expose.y = pBox->y1 - dy; - pe->u.expose.width = pBox->x2 - pBox->x1; - pe->u.expose.height = pBox->y2 - pBox->y1; - pe->u.expose.count = i; - } - -#ifdef PANORAMIX - if(!noPanoramiXExtension) { - int scrnum = pWin->drawable.pScreen->myNum; - int x = 0, y = 0; - XID realWin = 0; - - if(!pWin->parent) { - x = panoramiXdataPtr[scrnum].x; - y = panoramiXdataPtr[scrnum].y; - pWin = screenInfo.screens[0]->root; - realWin = pWin->drawable.id; - } else if (scrnum) { - PanoramiXRes *win; - win = PanoramiXFindIDByScrnum(XRT_WINDOW, - pWin->drawable.id, scrnum); - if(!win) { - DEALLOCATE_LOCAL(pEvent); - return; - } - realWin = win->info[0].id; - pWin = LookupIDByType(realWin, RT_WINDOW); - } - if(x || y || scrnum) - for (i = 0; i < numRects; i++) { - pEvent[i].u.expose.window = realWin; - pEvent[i].u.expose.x += x; - pEvent[i].u.expose.y += y; - } - } -#endif - - DeliverEvents(pWin, pEvent, numRects, NullWindow); - - DEALLOCATE_LOCAL(pEvent); -} - void miWindowExposures(pWin, prgn, other_exposed) WindowPtr pWin; register RegionPtr prgn, other_exposed; { -#ifdef NXAGENT_SERVER int total; -#endif RegionPtr exposures = prgn; if (pWin->backStorage && prgn) /* @@ -576,7 +414,6 @@ miWindowExposures(pWin, prgn, other_exposed) } exposures = other_exposed; } -#ifdef NXAGENT_SERVER /* * If the number of rectangles is greater @@ -587,9 +424,6 @@ miWindowExposures(pWin, prgn, other_exposed) if (clientInterested && exposures && (total > RECTLIMIT || (total > 4 && nxagentExtentsPredicate(total) == 1))) -#else - if (clientInterested && exposures && (RegionNumRects(exposures) > RECTLIMIT)) -#endif { /* * If we have LOTS of rectangles, we decide to take the extents @@ -638,54 +472,6 @@ miWindowExposures(pWin, prgn, other_exposed) RegionDestroy(exposures); } - -/* - this code is highly unlikely. it is not haile selassie. - - there is some hair here. we can't just use the window's -clip region as it is, because if we are painting the border, -the border is not in the client area and so we will be excluded -when we validate the GC, and if we are painting a parent-relative -background, the area we want to paint is in some other window. -since we trust the code calling us to tell us to paint only areas -that are really ours, we will temporarily give the window a -clipList the size of the whole screen and an origin at (0,0). -this more or less assumes that ddX code will do translation -based on the window's absolute position, and that ValidateGC will -look at clipList, and that no other fields from the -window will be used. it's not possible to just draw -in the root because it may be a different depth. - -to get the tile to align correctly we set the GC's tile origin to -be the (x,y) of the window's upper left corner, after which we -get the right bits when drawing into the root. - -because the clip_mask is being set to None, we may call DoChangeGC with -fPointer set true, thus we no longer need to install the background or -border tile in the resource table. -*/ - -static RESTYPE ResType = 0; -static int numGCs = 0; -static GCPtr screenContext[MAXSCREENS]; - -/*ARGSUSED*/ -static int -tossGC ( - void * value, - XID id) -{ - GCPtr pGC = (GCPtr)value; - screenContext[pGC->pScreen->myNum] = (GCPtr)NULL; - FreeGC (pGC, id); - numGCs--; - if (!numGCs) - ResType = 0; - - return 0; -} - - void miPaintWindow(pWin, prgn, what) register WindowPtr pWin; @@ -722,8 +508,6 @@ int what; register xRectangle *prect; int numRects; -#ifdef NXAGENT_SERVER - /* * Set the elements reported by the compiler * as uninitialized. @@ -739,8 +523,6 @@ int what; oldCorner.x = 0; oldCorner.y = 0; -#endif - gcmask = 0; if (what == PW_BACKGROUND) @@ -954,27 +736,3 @@ int what; FreeScratchGC(pGC); } } - - -/* MICLEARDRAWABLE -- sets the entire drawable to the background color of - * the GC. Useful when we have a scratch drawable and need to initialize - * it. */ -void -miClearDrawable(pDraw, pGC) - DrawablePtr pDraw; - GCPtr pGC; -{ - XID fg = pGC->fgPixel; - XID bg = pGC->bgPixel; - xRectangle rect; - - rect.x = 0; - rect.y = 0; - rect.width = pDraw->width; - rect.height = pDraw->height; - DoChangeGC(pGC, GCForeground, &bg, 0); - ValidateGC(pDraw, pGC); - (*pGC->ops->PolyFillRect)(pDraw, pGC, 1, &rect); - DoChangeGC(pGC, GCForeground, &fg, 0); - ValidateGC(pDraw, pGC); -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c index f86c81de6..bdc0bc316 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmiglyph.c @@ -40,77 +40,9 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "scrnintstr.h" -#include "gcstruct.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "mi.h" -#include "picturestr.h" -#include "mipict.h" - -#ifdef NXAGENT_SERVER - #include "Render.h" -#endif - -void -miGlyphExtents (int nlist, - GlyphListPtr list, - GlyphPtr *glyphs, - BoxPtr extents) -{ - int x1, x2, y1, y2; - int n; - GlyphPtr glyph; - int x, y; - - x = 0; - y = 0; - extents->x1 = MAXSHORT; - extents->x2 = MINSHORT; - extents->y1 = MAXSHORT; - extents->y2 = MINSHORT; - while (nlist--) - { - x += list->xOff; - y += list->yOff; - n = list->len; - list++; - while (n--) - { - glyph = *glyphs++; - x1 = x - glyph->info.x; - if (x1 < MINSHORT) - x1 = MINSHORT; - y1 = y - glyph->info.y; - if (y1 < MINSHORT) - y1 = MINSHORT; - x2 = x1 + glyph->info.width; - if (x2 > MAXSHORT) - x2 = MAXSHORT; - y2 = y1 + glyph->info.height; - if (y2 > MAXSHORT) - y2 = MAXSHORT; - if (x1 < extents->x1) - extents->x1 = x1; - if (x2 > extents->x2) - extents->x2 = x2; - if (y1 < extents->y1) - extents->y1 = y1; - if (y2 > extents->y2) - extents->y2 = y2; - x += glyph->info.xOff; - y += glyph->info.yOff; - } - } -} - -#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0) +#include "../../render/miglyph.c" void miGlyphs (CARD8 op, @@ -137,8 +69,6 @@ miGlyphs (CARD8 op, BoxRec extents; CARD32 component_alpha; - #ifdef NXAGENT_SERVER - /* * Get rid of the warning. */ @@ -146,15 +76,11 @@ miGlyphs (CARD8 op, extents.x1 = 0; extents.y1 = 0; - #endif - if (maskFormat) { GCPtr pGC; xRectangle rect; - #ifdef NXAGENT_SERVER - if (nxagentGlyphsExtents != NullBox) { memcpy(&extents, nxagentGlyphsExtents, sizeof(BoxRec)); @@ -168,12 +94,6 @@ miGlyphs (CARD8 op, memcpy(nxagentGlyphsExtents, &extents, sizeof(BoxRec)); } - #else - - miGlyphExtents (nlist, list, glyphs, &extents); - - #endif - if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) return; width = extents.x2 - extents.x1; @@ -242,8 +162,6 @@ miGlyphs (CARD8 op, glyph->info.width, glyph->info.height, 0, 0, -1, (void *) (glyph + 1)); - #ifdef NXAGENT_SERVER - /* * The following line fixes a problem with glyphs that appeared * as clipped. It was a side effect due the validate function @@ -254,8 +172,6 @@ miGlyphs (CARD8 op, pPicture->pDrawable->serialNumber = NEXT_SERIAL_NUMBER; - #endif - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (maskFormat) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c index f418654b4..1ef445af5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c @@ -39,117 +39,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "scrnintstr.h" -#include "gcstruct.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "servermd.h" -#include "mi.h" -#include "picturestr.h" -#include "mipict.h" - -#ifdef NXAGENT_SERVER - #include "Render.h" -#endif - -PicturePtr -miCreateAlphaPicture (ScreenPtr pScreen, - PicturePtr pDst, - PictFormatPtr pPictFormat, - CARD16 width, - CARD16 height) -{ - PixmapPtr pPixmap; - PicturePtr pPicture; - GCPtr pGC; - int error; - xRectangle rect; - - if (width > 32767 || height > 32767) - return 0; - - if (!pPictFormat) - { - if (pDst->polyEdge == PolyEdgeSharp) - pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1); - else - pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8); - if (!pPictFormat) - return 0; - } - - pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, - pPictFormat->depth); - if (!pPixmap) - return 0; - pGC = GetScratchGC (pPixmap->drawable.depth, pScreen); - if (!pGC) - { - (*pScreen->DestroyPixmap) (pPixmap); - return 0; - } - ValidateGC (&pPixmap->drawable, pGC); - rect.x = 0; - rect.y = 0; - rect.width = width; - rect.height = height; - (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect); - FreeScratchGC (pGC); - pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat, - 0, 0, serverClient, &error); - (*pScreen->DestroyPixmap) (pPixmap); - return pPicture; -} - -static xFixed -miLineFixedX (xLineFixed *l, xFixed y, Bool ceil) -{ - xFixed dx = l->p2.x - l->p1.x; - xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx; - xFixed dy = l->p2.y - l->p1.y; - if (ceil) - ex += (dy - 1); - return l->p1.x + (xFixed) (ex / dy); -} - -void -miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box) -{ - box->y1 = MAXSHORT; - box->y2 = MINSHORT; - box->x1 = MAXSHORT; - box->x2 = MINSHORT; - for (; ntrap; ntrap--, traps++) - { - INT16 x1, y1, x2, y2; - - if (!xTrapezoidValid(traps)) - continue; - y1 = xFixedToInt (traps->top); - if (y1 < box->y1) - box->y1 = y1; - - y2 = xFixedToInt (xFixedCeil (traps->bottom)); - if (y2 > box->y2) - box->y2 = y2; - - x1 = xFixedToInt (min (miLineFixedX (&traps->left, traps->top, FALSE), - miLineFixedX (&traps->left, traps->bottom, FALSE))); - if (x1 < box->x1) - box->x1 = x1; - - x2 = xFixedToInt (xFixedCeil (max (miLineFixedX (&traps->right, traps->top, TRUE), - miLineFixedX (&traps->right, traps->bottom, TRUE)))); - if (x2 > box->x2) - box->x2 = x2; - } -} +#include "../../render/mitrap.c" void miTrapezoids (CARD8 op, @@ -182,8 +74,6 @@ miTrapezoids (CARD8 op, xDst = traps[0].left.p1.x >> 16; yDst = traps[0].left.p1.y >> 16; - #ifdef NXAGENT_SERVER - if (nxagentTrapezoidExtents != NullBox) { memcpy(&bounds, nxagentTrapezoidExtents, sizeof(BoxRec)); @@ -197,12 +87,6 @@ miTrapezoids (CARD8 op, memcpy(nxagentTrapezoidExtents, &bounds, sizeof(BoxRec)); } - #else - - miTrapezoidBounds (ntrap, traps, &bounds); - - #endif - if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) return; pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiwindow.c deleted file mode 100644 index 56237605e..000000000 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmiwindow.c +++ /dev/null @@ -1,1209 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NXAGENT, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/programs/Xserver/mi/miwindow.c,v 1.9tsi Exp $ */ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $Xorg: miwindow.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#include "regionstr.h" -#include "region.h" -#include "mi.h" -#include "windowstr.h" -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "mivalidate.h" - -void -miClearToBackground(pWin, x, y, w, h, generateExposures) - WindowPtr pWin; - int x,y; - int w,h; - Bool generateExposures; -{ - BoxRec box; - RegionRec reg; - RegionPtr pBSReg = NullRegion; - ScreenPtr pScreen; - BoxPtr extents; - int x1, y1, x2, y2; - - /* compute everything using ints to avoid overflow */ - - x1 = pWin->drawable.x + x; - y1 = pWin->drawable.y + y; - if (w) - x2 = x1 + (int) w; - else - x2 = x1 + (int) pWin->drawable.width - (int) x; - if (h) - y2 = y1 + h; - else - y2 = y1 + (int) pWin->drawable.height - (int) y; - - extents = &pWin->clipList.extents; - - /* clip the resulting rectangle to the window clipList extents. This - * makes sure that the result will fit in a box, given that the - * screen is < 32768 on a side. - */ - - if (x1 < extents->x1) - x1 = extents->x1; - if (x2 > extents->x2) - x2 = extents->x2; - if (y1 < extents->y1) - y1 = extents->y1; - if (y2 > extents->y2) - y2 = extents->y2; - - if (x2 <= x1 || y2 <= y1) - { - x2 = x1 = 0; - y2 = y1 = 0; - } - - box.x1 = x1; - box.x2 = x2; - box.y1 = y1; - box.y2 = y2; - - pScreen = pWin->drawable.pScreen; - RegionInit(®, &box, 1); - if (pWin->backStorage) - { - /* - * If the window has backing-store on, call through the - * ClearToBackground vector to handle the special semantics - * (i.e. things backing store is to be cleared out and - * an Expose event is to be generated for those areas in backing - * store if generateExposures is TRUE). - */ - pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h, - generateExposures); - } - - RegionIntersect(®, ®, &pWin->clipList); - if (generateExposures) - (*pScreen->WindowExposures)(pWin, ®, pBSReg); - else if (pWin->backgroundState != None) - (*pScreen->PaintWindowBackground)(pWin, ®, PW_BACKGROUND); - RegionUninit(®); - if (pBSReg) - RegionDestroy(pBSReg); -} - -/* - * For SaveUnders using backing-store. The idea is that when a window is mapped - * with saveUnder set TRUE, any windows it obscures will have its backing - * store turned on setting the DIXsaveUnder bit, - * The backing-store code must be written to allow for this - */ - -/*- - *----------------------------------------------------------------------- - * miCheckSubSaveUnder -- - * Check all the inferiors of a window for coverage by saveUnder - * windows. Called from ChangeSaveUnder and CheckSaveUnder. - * This code is very inefficient. - * - * Results: - * TRUE if any windows need to have backing-store removed. - * - * Side Effects: - * Windows may have backing-store turned on or off. - * - *----------------------------------------------------------------------- - */ -static Bool -miCheckSubSaveUnder( - register WindowPtr pParent, /* Parent to check */ - WindowPtr pFirst, /* first reconfigured window */ - RegionPtr pRegion) /* Initial area obscured by saveUnder */ -{ - register WindowPtr pChild; /* Current child */ - register ScreenPtr pScreen; /* Screen to use */ - RegionRec SubRegion; /* Area of children obscured */ - Bool res = FALSE; /* result */ - Bool subInited=FALSE;/* SubRegion initialized */ - - pScreen = pParent->drawable.pScreen; - if ( (pChild = pParent->firstChild) ) - { - /* - * build region above first changed window - */ - - for (; pChild != pFirst; pChild = pChild->nextSib) - if (pChild->viewable && pChild->saveUnder) - RegionUnion(pRegion, pRegion, &pChild->borderSize); - - /* - * check region below and including first changed window - */ - - for (; pChild; pChild = pChild->nextSib) - { - if (pChild->viewable) - { - /* - * don't save under nephew/niece windows; - * use a separate region - */ - - if (pChild->firstChild) - { - if (!subInited) - { - RegionNull(&SubRegion); - subInited = TRUE; - } - RegionCopy(&SubRegion, pRegion); - res |= miCheckSubSaveUnder(pChild, pChild->firstChild, - &SubRegion); - } - else - { - res |= miCheckSubSaveUnder(pChild, pChild->firstChild, - pRegion); - } - - if (pChild->saveUnder) - RegionUnion(pRegion, pRegion, &pChild->borderSize); - } - } - - if (subInited) - RegionUninit(&SubRegion); - } - - /* - * Check the state of this window. DIX save unders are - * enabled for viewable windows with some client expressing - * exposure interest and which intersect the save under region - */ - - if (pParent->viewable && - ((pParent->eventMask | wOtherEventMasks(pParent)) & ExposureMask) && - RegionNotEmpty(&pParent->borderSize) && - RegionContainsRect(pRegion, RegionExtents( - &pParent->borderSize)) != rgnOUT) - { - if (!pParent->DIXsaveUnder) - { - pParent->DIXsaveUnder = TRUE; - (*pScreen->ChangeWindowAttributes) (pParent, CWBackingStore); - } - } - else - { - if (pParent->DIXsaveUnder) - { - res = TRUE; - pParent->DIXsaveUnder = FALSE; - } - } - return res; -} - - -/*- - *----------------------------------------------------------------------- - * miChangeSaveUnder -- - * Change the save-under state of a tree of windows. Called when - * a window with saveUnder TRUE is mapped/unmapped/reconfigured. - * - * Results: - * TRUE if any windows need to have backing-store removed (which - * means that PostChangeSaveUnder needs to be called later to - * finish the job). - * - * Side Effects: - * Windows may have backing-store turned on or off. - * - *----------------------------------------------------------------------- - */ -Bool -miChangeSaveUnder(pWin, first) - register WindowPtr pWin; - WindowPtr first; /* First window to check. - * Used when pWin was restacked */ -{ - RegionRec rgn; /* Area obscured by saveUnder windows */ - Bool res; - - if (!deltaSaveUndersViewable && !numSaveUndersViewable) - return FALSE; - numSaveUndersViewable += deltaSaveUndersViewable; - deltaSaveUndersViewable = 0; - RegionNull(&rgn); - res = miCheckSubSaveUnder (pWin->parent, - pWin->saveUnder ? first : pWin->nextSib, - &rgn); - RegionUninit(&rgn); - return res; -} - -/*- - *----------------------------------------------------------------------- - * miPostChangeSaveUnder -- - * Actually turn backing-store off for those windows that no longer - * need to have it on. - * - * Results: - * None. - * - * Side Effects: - * Backing-store and SAVE_UNDER_CHANGE_BIT are turned off for those - * windows affected. - * - *----------------------------------------------------------------------- - */ -void -miPostChangeSaveUnder(pWin, pFirst) - WindowPtr pWin; - WindowPtr pFirst; -{ - register WindowPtr pParent, pChild; - ChangeWindowAttributesProcPtr ChangeWindowAttributes; - - if (!(pParent = pWin->parent)) - return; - ChangeWindowAttributes = pParent->drawable.pScreen->ChangeWindowAttributes; - if (!pParent->DIXsaveUnder && - (pParent->backingStore == NotUseful) && pParent->backStorage) - (*ChangeWindowAttributes)(pParent, CWBackingStore); - if (!(pChild = pFirst)) - return; - while (1) - { - if (!pChild->DIXsaveUnder && - (pChild->backingStore == NotUseful) && pChild->backStorage) - (*ChangeWindowAttributes)(pChild, CWBackingStore); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - while (!pChild->nextSib) - { - pChild = pChild->parent; - if (pChild == pParent) - return; - } - pChild = pChild->nextSib; - } -} - -void -miMarkWindow(pWin) - register WindowPtr pWin; -{ - register ValidatePtr val; - - if (pWin->valdata) - return; - val = (ValidatePtr)xnfalloc(sizeof(ValidateRec)); - val->before.oldAbsCorner.x = pWin->drawable.x; - val->before.oldAbsCorner.y = pWin->drawable.y; - val->before.borderVisible = NullRegion; - val->before.resized = FALSE; - pWin->valdata = val; -} - -Bool -miMarkOverlappedWindows(pWin, pFirst, ppLayerWin) - WindowPtr pWin; - WindowPtr pFirst; - WindowPtr *ppLayerWin; -{ - register BoxPtr box; - register WindowPtr pChild, pLast; - Bool anyMarked = FALSE; - MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow; - - /* single layered systems are easy */ - if (ppLayerWin) *ppLayerWin = pWin; - - if (pWin == pFirst) - { - /* Blindly mark pWin and all of its inferiors. This is a slight - * overkill if there are mapped windows that outside pWin's border, - * but it's better than wasting time on RectIn checks. - */ - pChild = pWin; - while (1) - { - if (pChild->viewable) - { - if (RegionBroken(&pChild->winSize)) - SetWinSize (pChild); - if (RegionBroken(&pChild->borderSize)) - SetBorderSize (pChild); - (* MarkWindow)(pChild); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pWin)) - pChild = pChild->parent; - if (pChild == pWin) - break; - pChild = pChild->nextSib; - } - anyMarked = TRUE; - pFirst = pFirst->nextSib; - } - if ( (pChild = pFirst) ) - { - box = RegionExtents(&pWin->borderSize); - pLast = pChild->parent->lastChild; - while (1) - { - if (pChild->viewable) - { - if (RegionBroken(&pChild->winSize)) - SetWinSize (pChild); - if (RegionBroken(&pChild->borderSize)) - SetBorderSize (pChild); - if (RegionContainsRect(&pChild->borderSize, box)) - { - (* MarkWindow)(pChild); - anyMarked = TRUE; - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - } - while (!pChild->nextSib && (pChild != pLast)) - pChild = pChild->parent; - if (pChild == pLast) - break; - pChild = pChild->nextSib; - } - } - if (anyMarked) - (* MarkWindow)(pWin->parent); - return anyMarked; -} - -/***** - * miHandleValidateExposures(pWin) - * starting at pWin, draw background in any windows that have exposure - * regions, translate the regions, restore any backing store, - * and then send any regions still exposed to the client - *****/ -void -miHandleValidateExposures(pWin) - WindowPtr pWin; -{ - register WindowPtr pChild; - register ValidatePtr val; - WindowExposuresProcPtr WindowExposures; - - pChild = pWin; - WindowExposures = pChild->drawable.pScreen->WindowExposures; - while (1) - { - if ( (val = pChild->valdata) ) - { - if (RegionNotEmpty(&val->after.borderExposed)) - (*pChild->drawable.pScreen->PaintWindowBorder)(pChild, - &val->after.borderExposed, - PW_BORDER); - RegionUninit(&val->after.borderExposed); - (*WindowExposures)(pChild, &val->after.exposed, NullRegion); - RegionUninit(&val->after.exposed); - xfree(val); - pChild->valdata = (ValidatePtr)NULL; - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - } - while (!pChild->nextSib && (pChild != pWin)) - pChild = pChild->parent; - if (pChild == pWin) - break; - pChild = pChild->nextSib; - } -} - -void -miMoveWindow(pWin, x, y, pNextSib, kind) - register WindowPtr pWin; - int x,y; - WindowPtr pNextSib; - VTKind kind; -{ - WindowPtr pParent; - Bool WasViewable = (Bool)(pWin->viewable); - short bw; - RegionPtr oldRegion = NULL; - DDXPointRec oldpt; - Bool anyMarked = FALSE; - register ScreenPtr pScreen; - WindowPtr windowToValidate; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif - WindowPtr pLayerWin; - - /* if this is a root window, can't be moved */ - if (!(pParent = pWin->parent)) - return ; - pScreen = pWin->drawable.pScreen; - bw = wBorderWidth (pWin); - - oldpt.x = pWin->drawable.x; - oldpt.y = pWin->drawable.y; - if (WasViewable) - { - oldRegion = RegionCreate(NullBox, 1); - RegionCopy(oldRegion, &pWin->borderClip); - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); - } - pWin->origin.x = x + (int)bw; - pWin->origin.y = y + (int)bw; - x = pWin->drawable.x = pParent->drawable.x + x + (int)bw; - y = pWin->drawable.y = pParent->drawable.y + y + (int)bw; - - SetWinSize (pWin); - SetBorderSize (pWin); - - (*pScreen->PositionWindow)(pWin, x, y); - - windowToValidate = MoveWindowInStack(pWin, pNextSib); - - ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0); - - if (WasViewable) - { - if (pLayerWin == pWin) - anyMarked |= (*pScreen->MarkOverlappedWindows) - (pWin, windowToValidate, (WindowPtr *)NULL); - else - anyMarked |= (*pScreen->MarkOverlappedWindows) - (pWin, pLayerWin, (WindowPtr *)NULL); - -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, windowToValidate); - } -#endif /* DO_SAVE_UNDERS */ - - if (anyMarked) - { - (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind); - (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, oldRegion); - RegionDestroy(oldRegion); - /* XXX need to retile border if ParentRelative origin */ - (*pScreen->HandleExposures)(pLayerWin->parent); - } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, windowToValidate); -#endif /* DO_SAVE_UNDERS */ - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, kind); - } - if (pWin->realized) - WindowsRestructured (); -} - - -/* - * pValid is a region of the screen which has been - * successfully copied -- recomputed exposed regions for affected windows - */ - -static int -miRecomputeExposures ( - register WindowPtr pWin, - void * value) /* must conform to VisitWindowProcPtr */ -{ - RegionPtr pValid = (RegionPtr)value; - - if (pWin->valdata) - { - /* - * compute exposed regions of this window - */ - RegionSubtract(&pWin->valdata->after.exposed, - &pWin->clipList, pValid); - /* - * compute exposed regions of the border - */ - RegionSubtract(&pWin->valdata->after.borderExposed, - &pWin->borderClip, &pWin->winSize); - RegionSubtract(&pWin->valdata->after.borderExposed, - &pWin->valdata->after.borderExposed, pValid); - return WT_WALKCHILDREN; - } - return WT_NOMATCH; -} - -void -miSlideAndSizeWindow(pWin, x, y, w, h, pSib) - register WindowPtr pWin; - int x,y; - unsigned int w, h; - WindowPtr pSib; -{ - WindowPtr pParent; - Bool WasViewable = (Bool)(pWin->viewable); - unsigned short width = pWin->drawable.width, - height = pWin->drawable.height; - short oldx = pWin->drawable.x, - oldy = pWin->drawable.y; - int bw = wBorderWidth (pWin); - short dw, dh; - DDXPointRec oldpt; - RegionPtr oldRegion = NULL; - Bool anyMarked = FALSE; - register ScreenPtr pScreen; - WindowPtr pFirstChange; - register WindowPtr pChild; - RegionPtr gravitate[StaticGravity + 1]; - register unsigned g; - int nx, ny; /* destination x,y */ - int newx, newy; /* new inner window position */ - RegionPtr pRegion = NULL; - RegionPtr destClip; /* portions of destination already written */ - RegionPtr oldWinClip = NULL; /* old clip list for window */ - RegionPtr borderVisible = NullRegion; /* visible area of the border */ - RegionPtr bsExposed = NullRegion; /* backing store exposures */ - Bool shrunk = FALSE; /* shrunk in an inner dimension */ - Bool moved = FALSE; /* window position changed */ -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif - WindowPtr pLayerWin; - - /* if this is a root window, can't be resized */ - if (!(pParent = pWin->parent)) - return ; - - pScreen = pWin->drawable.pScreen; - newx = pParent->drawable.x + x + bw; - newy = pParent->drawable.y + y + bw; - if (WasViewable) - { - anyMarked = FALSE; - /* - * save the visible region of the window - */ - oldRegion = RegionCreate(NullBox, 1); - RegionCopy(oldRegion, &pWin->winSize); - - /* - * categorize child windows into regions to be moved - */ - for (g = 0; g <= StaticGravity; g++) - gravitate[g] = (RegionPtr) NULL; - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) - { - g = pChild->winGravity; - if (g != UnmapGravity) - { - if (!gravitate[g]) - gravitate[g] = RegionCreate(NullBox, 1); - RegionUnion(gravitate[g], - gravitate[g], &pChild->borderClip); - } - else - { - UnmapWindow(pChild, TRUE); - anyMarked = TRUE; - } - } - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, - &pLayerWin); - - oldWinClip = NULL; - if (pWin->bitGravity != ForgetGravity) - { - oldWinClip = RegionCreate(NullBox, 1); - RegionCopy(oldWinClip, &pWin->clipList); - } - /* - * if the window is changing size, borderExposed - * can't be computed correctly without some help. - */ - if (pWin->drawable.height > h || pWin->drawable.width > w) - shrunk = TRUE; - - if (newx != oldx || newy != oldy) - moved = TRUE; - - if ((pWin->drawable.height != h || pWin->drawable.width != w) && - HasBorder (pWin)) - { - borderVisible = RegionCreate(NullBox, 1); - /* for tiled borders, we punt and draw the whole thing */ - if (pWin->borderIsPixel || !moved) - { - if (shrunk || moved) - RegionSubtract(borderVisible, - &pWin->borderClip, - &pWin->winSize); - else - RegionCopy(borderVisible, - &pWin->borderClip); - } - } - } - pWin->origin.x = x + bw; - pWin->origin.y = y + bw; - pWin->drawable.height = h; - pWin->drawable.width = w; - - x = pWin->drawable.x = newx; - y = pWin->drawable.y = newy; - - SetWinSize (pWin); - SetBorderSize (pWin); - - dw = (int)w - (int)width; - dh = (int)h - (int)height; - ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh); - - /* let the hardware adjust background and border pixmaps, if any */ - (*pScreen->PositionWindow)(pWin, x, y); - - pFirstChange = MoveWindowInStack(pWin, pSib); - - if (WasViewable) - { - pRegion = RegionCreate(NullBox, 1); - if (pWin->backStorage) - RegionCopy(pRegion, &pWin->clipList); - - if (pLayerWin == pWin) - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, - (WindowPtr *)NULL); - else - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin, - (WindowPtr *)NULL); - - if (pWin->valdata) - { - pWin->valdata->before.resized = TRUE; - pWin->valdata->before.borderVisible = borderVisible; - } - -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange); - } -#endif /* DO_SAVE_UNDERS */ - - if (anyMarked) - (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther); - /* - * the entire window is trashed unless bitGravity - * recovers portions of it - */ - RegionCopy(&pWin->valdata->after.exposed, &pWin->clipList); - } - - GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny); - - if (pWin->backStorage && - ((pWin->backingStore == Always) || WasViewable)) - { - if (!WasViewable) - pRegion = &pWin->clipList; /* a convenient empty region */ - if (pWin->bitGravity == ForgetGravity) - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, 0, 0, NullRegion, oldx, oldy); - else - { - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, nx - x, ny - y, pRegion, oldx, oldy); - } - } - - if (WasViewable) - { - /* avoid the border */ - if (HasBorder (pWin)) - { - int offx, offy, dx, dy; - - /* kruft to avoid double translates for each gravity */ - offx = 0; - offy = 0; - for (g = 0; g <= StaticGravity; g++) - { - if (!gravitate[g]) - continue; - - /* align winSize to gravitate[g]. - * winSize is in new coordinates, - * gravitate[g] is still in old coordinates */ - GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny); - - dx = (oldx - nx) - offx; - dy = (oldy - ny) - offy; - if (dx || dy) - { - RegionTranslate(&pWin->winSize, dx, dy); - offx += dx; - offy += dy; - } - RegionIntersect(gravitate[g], gravitate[g], - &pWin->winSize); - } - /* get winSize back where it belongs */ - if (offx || offy) - RegionTranslate(&pWin->winSize, -offx, -offy); - } - /* - * add screen bits to the appropriate bucket - */ - - if (oldWinClip) - { - /* - * clip to new clipList - */ - RegionCopy(pRegion, oldWinClip); - RegionTranslate(pRegion, nx - oldx, ny - oldy); - RegionIntersect(oldWinClip, pRegion, &pWin->clipList); - /* - * don't step on any gravity bits which will be copied after this - * region. Note -- this assumes that the regions will be copied - * in gravity order. - */ - for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) - { - if (gravitate[g]) - RegionSubtract(oldWinClip, oldWinClip, - gravitate[g]); - } - RegionTranslate(oldWinClip, oldx - nx, oldy - ny); - g = pWin->bitGravity; - if (!gravitate[g]) - gravitate[g] = oldWinClip; - else - { - RegionUnion(gravitate[g], gravitate[g], oldWinClip); - RegionDestroy(oldWinClip); - } - } - - /* - * move the bits on the screen - */ - - destClip = NULL; - - for (g = 0; g <= StaticGravity; g++) - { - if (!gravitate[g]) - continue; - - GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny); - - oldpt.x = oldx + (x - nx); - oldpt.y = oldy + (y - ny); - - /* Note that gravitate[g] is *translated* by CopyWindow */ - - /* only copy the remaining useful bits */ - - RegionIntersect(gravitate[g], gravitate[g], oldRegion); - - /* clip to not overwrite already copied areas */ - - if (destClip) { - RegionTranslate(destClip, oldpt.x - x, oldpt.y - y); - RegionSubtract(gravitate[g], gravitate[g], destClip); - RegionTranslate(destClip, x - oldpt.x, y - oldpt.y); - } - - /* and move those bits */ - - if (oldpt.x != x || oldpt.y != y -#ifdef COMPOSITE - || pWin->redirectDraw -#endif - ) - { - (*pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, gravitate[g]); - } - - /* remove any overwritten bits from the remaining useful bits */ - - RegionSubtract(oldRegion, oldRegion, gravitate[g]); - - /* - * recompute exposed regions of child windows - */ - - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) - { - if (pChild->winGravity != g) - continue; - RegionIntersect(pRegion, - &pChild->borderClip, gravitate[g]); - TraverseTree (pChild, miRecomputeExposures, (void *)pRegion); - } - - /* - * remove the successfully copied regions of the - * window from its exposed region - */ - - if (g == pWin->bitGravity) - RegionSubtract(&pWin->valdata->after.exposed, - &pWin->valdata->after.exposed, gravitate[g]); - if (!destClip) - destClip = gravitate[g]; - else - { - RegionUnion(destClip, destClip, gravitate[g]); - RegionDestroy(gravitate[g]); - } - } - - RegionDestroy(oldRegion); - RegionDestroy(pRegion); - if (destClip) - RegionDestroy(destClip); - if (bsExposed) - { - RegionPtr valExposed = NullRegion; - - if (pWin->valdata) - valExposed = &pWin->valdata->after.exposed; - (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); - if (valExposed) - RegionEmpty(valExposed); - RegionDestroy(bsExposed); - } - if (anyMarked) - (*pScreen->HandleExposures)(pLayerWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - { - (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange); - } -#endif /* DO_SAVE_UNDERS */ - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, - VTOther); - } - else if (bsExposed) - { - (*pScreen->WindowExposures) (pWin, NullRegion, bsExposed); - RegionDestroy(bsExposed); - } - if (pWin->realized) - WindowsRestructured (); -} - -WindowPtr -miGetLayerWindow(pWin) - WindowPtr pWin; -{ - return pWin->firstChild; -} - -#ifdef SHAPE -/****** - * - * miSetShape - * The border/window shape has changed. Recompute winSize/borderSize - * and send appropriate exposure events - */ - -void -miSetShape(pWin) - register WindowPtr pWin; -{ - Bool WasViewable = (Bool)(pWin->viewable); - register ScreenPtr pScreen = pWin->drawable.pScreen; - Bool anyMarked = FALSE; - RegionPtr pOldClip = NULL, bsExposed; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif - WindowPtr pLayerWin; - - if (WasViewable) - { - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, - &pLayerWin); - if (pWin->valdata) - { - if (HasBorder (pWin)) - { - RegionPtr borderVisible; - - borderVisible = RegionCreate(NullBox, 1); - RegionSubtract(borderVisible, - &pWin->borderClip, &pWin->winSize); - pWin->valdata->before.borderVisible = borderVisible; - } - pWin->valdata->before.resized = TRUE; - } - } - - SetWinSize (pWin); - SetBorderSize (pWin); - - ResizeChildrenWinSize(pWin, 0, 0, 0, 0); - - if (WasViewable) - { - if (pWin->backStorage) - { - pOldClip = RegionCreate(NullBox, 1); - RegionCopy(pOldClip, &pWin->clipList); - } - - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, - (WindowPtr *)NULL); - -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); - } -#endif /* DO_SAVE_UNDERS */ - - if (anyMarked) - (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther); - } - - if (pWin->backStorage && - ((pWin->backingStore == Always) || WasViewable)) - { - if (!WasViewable) - pOldClip = &pWin->clipList; /* a convenient empty region */ - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, 0, 0, pOldClip, - pWin->drawable.x, pWin->drawable.y); -#ifdef NXAGENT_SERVER - - /* - * We got a few, rare, segfaults here after having - * started using the backing store. It may be a - * different bug but miChangeSaveUnder() calls mi- - * CheckSubSaveUnder() that, in turn, can change - * the backing store attribute of the window. This - * means that we may try to destroy the region - * even if it was not created at the beginning of - * this function as, at the time, the backing store - * was off. miCheckSubSaveUnder() appear to get a - * pointer to the parent, so maybe doesn't change - * the attribute of the window itself. This is to - * be better investigated. - */ - - if (WasViewable && pOldClip) - RegionDestroy(pOldClip); -#else - if (WasViewable) - RegionDestroy(pOldClip); -#endif - if (bsExposed) - { - RegionPtr valExposed = NullRegion; - - if (pWin->valdata) - valExposed = &pWin->valdata->after.exposed; - (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); - if (valExposed) - RegionEmpty(valExposed); - RegionDestroy(bsExposed); - } - } - if (WasViewable) - { - if (anyMarked) - (*pScreen->HandleExposures)(pLayerWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); -#endif /* DO_SAVE_UNDERS */ - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther); - } - if (pWin->realized) - WindowsRestructured (); - CheckCursorConfinement(pWin); -} -#endif - -/* Keeps the same inside(!) origin */ - -void -miChangeBorderWidth(pWin, width) - register WindowPtr pWin; - unsigned int width; -{ - int oldwidth; - Bool anyMarked = FALSE; - register ScreenPtr pScreen; - Bool WasViewable = (Bool)(pWin->viewable); - Bool HadBorder; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif - WindowPtr pLayerWin; - - oldwidth = wBorderWidth (pWin); - if (oldwidth == width) - return; - HadBorder = HasBorder(pWin); - pScreen = pWin->drawable.pScreen; - if (WasViewable && width < oldwidth) - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); - - pWin->borderWidth = width; - SetBorderSize (pWin); - - if (WasViewable) - { - if (width > oldwidth) - { - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, - &pLayerWin); - /* - * save the old border visible region to correctly compute - * borderExposed. - */ - if (pWin->valdata && HadBorder) - { - RegionPtr borderVisible; - borderVisible = RegionCreate(NULL, 1); - RegionSubtract(borderVisible, - &pWin->borderClip, &pWin->winSize); - pWin->valdata->before.borderVisible = borderVisible; - } - } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib); - } -#endif /* DO_SAVE_UNDERS */ - - if (anyMarked) - { - (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther); - (*pScreen->HandleExposures)(pLayerWin->parent); - } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); -#endif /* DO_SAVE_UNDERS */ - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, - VTOther); - } - if (pWin->realized) - WindowsRestructured (); -} - -void -miMarkUnrealizedWindow(pChild, pWin, fromConfigure) - WindowPtr pChild; - WindowPtr pWin; - Bool fromConfigure; -{ - if ((pChild != pWin) || fromConfigure) - { - RegionEmpty(&pChild->clipList); - if (pChild->drawable.pScreen->ClipNotify) - (* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0); - RegionEmpty(&pChild->borderClip); - } -} - -void -miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth) -{ - WindowPtr pChild; - - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) - { - if (pChild->drawable.depth == depth) - RegionUnion(pReg, pReg, &pChild->borderClip); - - if (pChild->firstChild) - miSegregateChildren(pChild, pReg, depth); - } -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 10111adec..a47e158df 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -40,30 +40,30 @@ * Author: Keith Packard, SuSE, Inc. */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "misc.h" -#include "scrnintstr.h" -#include "os.h" -#include "regionstr.h" -#include "validate.h" -#include "windowstr.h" -#include "input.h" -#include "resource.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" -#include "NXpicturestr.h" +#include "picturestr.h" #include "Screen.h" #include "Pixmaps.h" #include "Drawable.h" #include "Render.h" +/* prototypes */ + +PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp); +PicturePtr AllocatePicture (ScreenPtr pScreen); +PicturePtr CreatePicture (Picture pid, + DrawablePtr pDrawable, + PictFormatPtr pFormat, + Mask vmask, + XID *vlist, + ClientPtr client, + int *error); +static PicturePtr createSourcePicture(void); +int FreePicture (void *value, XID pid); + +#include "../../render/picture.c" + + #define PANIC #define WARNING #undef TEST @@ -73,183 +73,8 @@ void *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual); void *nxagentMatchingFormats(PictFormatPtr pForm); -int PictureScreenPrivateIndex = -1; -int PictureWindowPrivateIndex; -int PictureGeneration; -RESTYPE PictureType; -RESTYPE PictFormatType; -RESTYPE GlyphSetType; -int PictureCmapPolicy = PictureCmapPolicyDefault; - -typedef struct _formatInit { - CARD32 format; - CARD8 depth; -} FormatInitRec, *FormatInitPtr; - void nxagentPictureCreateDefaultFormats(ScreenPtr pScreen, FormatInitRec *formats, int *nformats); -/* Picture Private machinery */ - -static int picturePrivateCount; - -void -ResetPicturePrivateIndex (void) -{ - picturePrivateCount = 0; -} - -int -AllocatePicturePrivateIndex (void) -{ - return picturePrivateCount++; -} - -Bool -AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount) -{ - PictureScreenPtr ps = GetPictureScreen(pScreen); - unsigned int oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= ps->PicturePrivateLen) - { - unsigned int *nsizes; - - nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes, - (index2 + 1) * sizeof(unsigned int)); - if (!nsizes) - return FALSE; - while (ps->PicturePrivateLen <= index2) - { - nsizes[ps->PicturePrivateLen++] = 0; - ps->totalPictureSize += sizeof(DevUnion); - } - ps->PicturePrivateSizes = nsizes; - } - oldamount = ps->PicturePrivateSizes[index2]; - if (amount > oldamount) - { - ps->PicturePrivateSizes[index2] = amount; - ps->totalPictureSize += (amount - oldamount); - } - - return TRUE; -} - - -Bool -PictureDestroyWindow (WindowPtr pWindow) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - PicturePtr pPicture; - PictureScreenPtr ps = GetPictureScreen(pScreen); - Bool ret; - - while ((pPicture = GetPictureWindow(pWindow))) - { - SetPictureWindow(pWindow, pPicture->pNext); - if (pPicture->id) - FreeResource (pPicture->id, PictureType); - FreePicture ((void *) pPicture, pPicture->id); - } - pScreen->DestroyWindow = ps->DestroyWindow; - ret = (*pScreen->DestroyWindow) (pWindow); - ps->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = PictureDestroyWindow; - return ret; -} - -Bool -PictureCloseScreen (int index, ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreen(pScreen); - Bool ret; - int n; - - pScreen->CloseScreen = ps->CloseScreen; - ret = (*pScreen->CloseScreen) (index, pScreen); - PictureResetFilters (pScreen); - for (n = 0; n < ps->nformats; n++) - if (ps->formats[n].type == PictTypeIndexed) - (*ps->CloseIndexed) (pScreen, &ps->formats[n]); - SetPictureScreen(pScreen, 0); - if (ps->PicturePrivateSizes) - xfree (ps->PicturePrivateSizes); - xfree (ps->formats); - xfree (ps); - return ret; -} - -void -PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef) -{ - ScreenPtr pScreen = pColormap->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - - pScreen->StoreColors = ps->StoreColors; - (*pScreen->StoreColors) (pColormap, ndef, pdef); - ps->StoreColors = pScreen->StoreColors; - pScreen->StoreColors = PictureStoreColors; - - if (pColormap->class == PseudoColor || pColormap->class == GrayScale) - { - PictFormatPtr format = ps->formats; - int nformats = ps->nformats; - - while (nformats--) - { - if (format->type == PictTypeIndexed && - format->index.pColormap == pColormap) - { - (*ps->UpdateIndexed) (pScreen, format, ndef, pdef); - break; - } - format++; - } - } -} - -static int -visualDepth (ScreenPtr pScreen, VisualPtr pVisual) -{ - int d, v; - DepthPtr pDepth; - - for (d = 0; d < pScreen->numDepths; d++) - { - pDepth = &pScreen->allowedDepths[d]; - for (v = 0; v < pDepth->numVids; v++) - if (pDepth->vids[v] == pVisual->vid) - return pDepth->depth; - } - return 0; -} - -static int -addFormat (FormatInitRec formats[256], - int nformat, - CARD32 format, - CARD8 depth) -{ - int n; - - for (n = 0; n < nformat; n++) - if (formats[n].format == format && formats[n].depth == depth) - return nformat; - formats[nformat].format = format; - formats[nformat].depth = depth; - - #ifdef DEBUG - fprintf(stderr, "addFormat: Added format [%lu] depth [%d].\n", format, depth); - #endif - - return ++nformat; -} - -#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1)) - PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) { @@ -258,164 +83,10 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) FormatInitRec formats[1024]; CARD32 format; -#ifndef NXAGENT_SERVER - - CARD8 depth; - VisualPtr pVisual; - int v; - int bpp; - int type; - int r, g, b; - int d; - DepthPtr pDepth; - -#endif - nformats = 0; -#ifdef NXAGENT_SERVER - nxagentPictureCreateDefaultFormats(pScreen, formats, &nformats); -#else - - /* formats required by protocol */ - formats[nformats].format = PICT_a1; - formats[nformats].depth = 1; - nformats++; - formats[nformats].format = PICT_a8; - formats[nformats].depth = 8; - nformats++; - formats[nformats].format = PICT_a4; - formats[nformats].depth = 4; - nformats++; - formats[nformats].format = PICT_a8r8g8b8; - formats[nformats].depth = 32; - nformats++; - formats[nformats].format = PICT_x8r8g8b8; - formats[nformats].depth = 32; - nformats++; - - /* now look through the depths and visuals adding other formats */ - for (v = 0; v < pScreen->numVisuals; v++) - { - pVisual = &pScreen->visuals[v]; - depth = visualDepth (pScreen, pVisual); - if (!depth) - continue; - bpp = BitsPerPixel (depth); - - switch (pVisual->class) { - case DirectColor: - case TrueColor: - r = Ones (pVisual->redMask); - g = Ones (pVisual->greenMask); - b = Ones (pVisual->blueMask); - type = PICT_TYPE_OTHER; - /* - * Current rendering code supports only two direct formats, - * fields must be packed together at the bottom of the pixel - * and must be either RGB or BGR - */ - if (pVisual->offsetBlue == 0 && - pVisual->offsetGreen == b && - pVisual->offsetRed == b + g) - { - type = PICT_TYPE_ARGB; - } - else if (pVisual->offsetRed == 0 && - pVisual->offsetGreen == r && - pVisual->offsetBlue == r + g) - { - type = PICT_TYPE_ABGR; - } - if (type != PICT_TYPE_OTHER) - { - format = PICT_FORMAT(bpp, type, 0, r, g, b); - nformats = addFormat (formats, nformats, format, depth); - } - break; - case StaticColor: - case PseudoColor: - format = PICT_VISFORMAT (bpp, PICT_TYPE_COLOR, v); - nformats = addFormat (formats, nformats, format, depth); - break; - case StaticGray: - case GrayScale: - format = PICT_VISFORMAT (bpp, PICT_TYPE_GRAY, v); - nformats = addFormat (formats, nformats, format, depth); - break; - } - } - - /* - * Walk supported depths and add useful Direct formats - */ - for (d = 0; d < pScreen->numDepths; d++) - { - pDepth = &pScreen->allowedDepths[d]; - bpp = BitsPerPixel (pDepth->depth); - format = 0; - - switch (bpp) { - case 16: - /* depth 12 formats */ - if (pDepth->depth >= 12) - { - nformats = addFormat (formats, nformats, - PICT_x4r4g4b4, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_x4b4g4r4, pDepth->depth); - } - - /* depth 15 formats */ - if (pDepth->depth >= 15) - { - nformats = addFormat (formats, nformats, - PICT_x1r5g5b5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_x1b5g5r5, pDepth->depth); - } - /* depth 16 formats */ - if (pDepth->depth >= 16) - { - nformats = addFormat (formats, nformats, - PICT_a1r5g5b5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_a1b5g5r5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_r5g6b5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_b5g6r5, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_a4r4g4b4, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_a4b4g4r4, pDepth->depth); - } - break; - case 24: - if (pDepth->depth >= 24) - { - nformats = addFormat (formats, nformats, - PICT_r8g8b8, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_b8g8r8, pDepth->depth); - } - break; - case 32: - if (pDepth->depth >= 24) - { - nformats = addFormat (formats, nformats, - PICT_x8r8g8b8, pDepth->depth); - nformats = addFormat (formats, nformats, - PICT_x8b8g8r8, pDepth->depth); - } - break; - } - } - -#endif - pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec)); if (!pFormats) return 0; @@ -483,7 +154,6 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) break; } -#ifdef NXAGENT_SERVER if (nxagentMatchingFormats(&pFormats[f]) != NULL) { #ifdef DEBUG @@ -504,347 +174,11 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) pFormats[f].direct.blueMask, pFormats[f].direct.alpha, pFormats[f].direct.alphaMask); #endif } -#endif } *nformatp = nformats; return pFormats; } -static VisualPtr -PictureFindVisual (ScreenPtr pScreen, VisualID visual) -{ - int i; - VisualPtr pVisual; - for (i = 0, pVisual = pScreen->visuals; - i < pScreen->numVisuals; - i++, pVisual++) - { - if (pVisual->vid == visual) - return pVisual; - } - return 0; -} - -Bool -PictureInitIndexedFormats (ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - PictFormatPtr format; - int nformat; - - if (!ps) - return FALSE; - format = ps->formats; - nformat = ps->nformats; - while (nformat--) - { - if (format->type == PictTypeIndexed && !format->index.pColormap) - { - if (format->index.vid == pScreen->rootVisual) - format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap, - RT_COLORMAP); - else - { - VisualPtr pVisual; - - pVisual = PictureFindVisual (pScreen, format->index.vid); - if (CreateColormap (FakeClientID (0), pScreen, - pVisual, - &format->index.pColormap, AllocNone, - 0) != Success) - { - return FALSE; - } - } - if (!(*ps->InitIndexed) (pScreen, format)) - return FALSE; - } - format++; - } - return TRUE; -} - -Bool -PictureFinishInit (void) -{ - int s; - - for (s = 0; s < screenInfo.numScreens; s++) - { - if (!PictureInitIndexedFormats (screenInfo.screens[s])) - return FALSE; - (void) AnimCurInit (screenInfo.screens[s]); - } - - return TRUE; -} - -Bool -PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - - if (!ps) - return FALSE; - ps->subpixel = subpixel; - return TRUE; - -} - -int -PictureGetSubpixelOrder (ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - - if (!ps) - return SubPixelUnknown; - return ps->subpixel; -} - -PictFormatPtr -PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - PictFormatPtr format; - int nformat; - int type; - - if (!ps) - return 0; - format = ps->formats; - nformat = ps->nformats; - switch (pVisual->class) { - case StaticGray: - case GrayScale: - case StaticColor: - case PseudoColor: - type = PictTypeIndexed; - break; - case TrueColor: - case DirectColor: - type = PictTypeDirect; - break; - default: - return 0; - } - while (nformat--) - { - if (format->depth == depth && format->type == type) - { - if (type == PictTypeIndexed) - { - if (format->index.vid == pVisual->vid) - return format; - } - else - { - if (format->direct.redMask << format->direct.red == - pVisual->redMask && - format->direct.greenMask << format->direct.green == - pVisual->greenMask && - format->direct.blueMask << format->direct.blue == - pVisual->blueMask) - { - return format; - } - } - } - format++; - } - return 0; -} - -PictFormatPtr -PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 f) -{ - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - PictFormatPtr format; - int nformat; - - if (!ps) - return 0; - format = ps->formats; - nformat = ps->nformats; - while (nformat--) - { - if (format->depth == depth && format->format == (f & 0xffffff)) - return format; - format++; - } - return 0; -} - -int -PictureParseCmapPolicy (const char *name) -{ - if ( strcmp (name, "default" ) == 0) - return PictureCmapPolicyDefault; - else if ( strcmp (name, "mono" ) == 0) - return PictureCmapPolicyMono; - else if ( strcmp (name, "gray" ) == 0) - return PictureCmapPolicyGray; - else if ( strcmp (name, "color" ) == 0) - return PictureCmapPolicyColor; - else if ( strcmp (name, "all" ) == 0) - return PictureCmapPolicyAll; - else - return PictureCmapPolicyInvalid; -} - -Bool -PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) -{ - PictureScreenPtr ps; - int n; - CARD32 type, a, r, g, b; - - if (PictureGeneration != serverGeneration) - { - PictureType = CreateNewResourceType (FreePicture); - if (!PictureType) - return FALSE; - PictFormatType = CreateNewResourceType (FreePictFormat); - if (!PictFormatType) - return FALSE; - GlyphSetType = CreateNewResourceType (FreeGlyphSet); - if (!GlyphSetType) - return FALSE; - PictureScreenPrivateIndex = AllocateScreenPrivateIndex(); - if (PictureScreenPrivateIndex < 0) - return FALSE; - PictureWindowPrivateIndex = AllocateWindowPrivateIndex(); - PictureGeneration = serverGeneration; -#ifdef XResExtension - RegisterResourceName (PictureType, "PICTURE"); - RegisterResourceName (PictFormatType, "PICTFORMAT"); - RegisterResourceName (GlyphSetType, "GLYPHSET"); -#endif - } - if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0)) - return FALSE; - - if (!formats) - { - formats = PictureCreateDefaultFormats (pScreen, &nformats); - if (!formats) - return FALSE; - } - for (n = 0; n < nformats; n++) - { - if (!AddResource (formats[n].id, PictFormatType, (void *) (formats+n))) - { - xfree (formats); - return FALSE; - } - if (formats[n].type == PictTypeIndexed) - { - VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid); - if ((pVisual->class | DynamicClass) == PseudoColor) - type = PICT_TYPE_COLOR; - else - type = PICT_TYPE_GRAY; - a = r = g = b = 0; - } - else - { - if ((formats[n].direct.redMask| - formats[n].direct.blueMask| - formats[n].direct.greenMask) == 0) - type = PICT_TYPE_A; - else if (formats[n].direct.red > formats[n].direct.blue) - type = PICT_TYPE_ARGB; - else - type = PICT_TYPE_ABGR; - a = Ones (formats[n].direct.alphaMask); - r = Ones (formats[n].direct.redMask); - g = Ones (formats[n].direct.greenMask); - b = Ones (formats[n].direct.blueMask); - } - formats[n].format = PICT_FORMAT(0,type,a,r,g,b); - } - ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec)); - if (!ps) - { - xfree (formats); - return FALSE; - } - SetPictureScreen(pScreen, ps); - if (!GlyphInit (pScreen)) - { - SetPictureScreen(pScreen, 0); - xfree (formats); - xfree (ps); - return FALSE; - } - - ps->totalPictureSize = sizeof (PictureRec); - ps->PicturePrivateSizes = 0; - ps->PicturePrivateLen = 0; - - ps->formats = formats; - ps->fallback = formats; - ps->nformats = nformats; - - ps->filters = 0; - ps->nfilters = 0; - ps->filterAliases = 0; - ps->nfilterAliases = 0; - - ps->subpixel = SubPixelUnknown; - - ps->CloseScreen = pScreen->CloseScreen; - ps->DestroyWindow = pScreen->DestroyWindow; - ps->StoreColors = pScreen->StoreColors; - pScreen->DestroyWindow = PictureDestroyWindow; - pScreen->CloseScreen = PictureCloseScreen; - pScreen->StoreColors = PictureStoreColors; - - if (!PictureSetDefaultFilters (pScreen)) - { - PictureResetFilters (pScreen); - SetPictureScreen(pScreen, 0); - xfree (formats); - xfree (ps); - return FALSE; - } - - return TRUE; -} - -void -SetPictureToDefaults (PicturePtr pPicture) -{ - pPicture->refcnt = 1; - pPicture->repeat = 0; - pPicture->graphicsExposures = FALSE; - pPicture->subWindowMode = ClipByChildren; - pPicture->polyEdge = PolyEdgeSharp; - pPicture->polyMode = PolyModePrecise; - pPicture->freeCompClip = FALSE; - pPicture->clientClipType = CT_NONE; - pPicture->componentAlpha = FALSE; - pPicture->repeatType = RepeatNone; - - pPicture->alphaMap = 0; - pPicture->alphaOrigin.x = 0; - pPicture->alphaOrigin.y = 0; - - pPicture->clipOrigin.x = 0; - pPicture->clipOrigin.y = 0; - pPicture->clientClip = 0; - - pPicture->transform = 0; - - pPicture->dither = None; - pPicture->filter = PictureGetFilterId (FilterNearest, -1, TRUE); - pPicture->filter_params = 0; - pPicture->filter_nparams = 0; - - pPicture->serialNumber = GC_CHANGE_SERIAL_BIT; - pPicture->stateChanges = (1 << (CPLastBit+1)) - 1; - pPicture->pSourcePict = 0; -} - PicturePtr AllocatePicture (ScreenPtr pScreen) { @@ -879,14 +213,6 @@ AllocatePicture (ScreenPtr pScreen) return pPicture; } -/* - * Let picture always point to the virtual pixmap. - * For sure this is not the best way to deal with - * the virtual frame-buffer. - */ - -#define NXAGENT_PICTURE_ALWAYS_POINTS_TO_VIRTUAL - PicturePtr CreatePicture (Picture pid, DrawablePtr pDrawable, @@ -912,12 +238,13 @@ CreatePicture (Picture pid, pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24); if (pDrawable->type == DRAWABLE_PIXMAP) { - #ifdef NXAGENT_PICTURE_ALWAYS_POINTS_TO_VIRTUAL - + /* + * Let picture always point to the virtual pixmap. + * For sure this is not the best way to deal with + * the virtual frame-buffer. + */ pPicture->pDrawable = nxagentVirtualDrawable(pDrawable); - #endif - ++((PixmapPtr)pDrawable)->refcnt; pPicture->pNext = 0; } @@ -943,125 +270,30 @@ CreatePicture (Picture pid, return pPicture; } -static CARD32 xRenderColorToCard32(xRenderColor c) -{ - return - (c.alpha >> 8 << 24) | - (c.red >> 8 << 16) | - (c.green & 0xff00) | - (c.blue >> 8); -} - -static unsigned int premultiply(unsigned int x) -{ - unsigned int a = x >> 24; - unsigned int t = (x & 0xff00ff) * a; - t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; - t &= 0xff00ff; - - x = ((x >> 8) & 0xff) * a; - x = (x + ((x >> 8) & 0xff) + 0x80); - x &= 0xff00; - x |= t | (a << 24); - return x; -} - -static unsigned int INTERPOLATE_PIXEL_256(unsigned int x, unsigned int a, - unsigned int y, unsigned int b) -{ - CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; - t >>= 8; - t &= 0xff00ff; - - x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; - x &= 0xff00ff00; - x |= t; - return x; -} - -static void initGradientColorTable(SourcePictPtr pGradient, int *error) -{ - int begin_pos, end_pos; - xFixed incr, dpos; - int pos, current_stop; - PictGradientStopPtr stops = pGradient->linear.stops; - int nstops = pGradient->linear.nstops; - - /* The position where the gradient begins and ends */ - begin_pos = (stops[0].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; - end_pos = (stops[nstops - 1].x * PICT_GRADIENT_STOPTABLE_SIZE) >> 16; - - pos = 0; /* The position in the color table. */ - - /* Up to first point */ - while (pos <= begin_pos) { - pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[0].color); - ++pos; - } - - incr = (1<<16)/ PICT_GRADIENT_STOPTABLE_SIZE; /* the double increment. */ - dpos = incr * pos; /* The position in terms of 0-1. */ - - current_stop = 0; /* We always interpolate between current and current + 1. */ - - /* Gradient area */ - while (pos < end_pos) { - unsigned int current_color = xRenderColorToCard32(stops[current_stop].color); - unsigned int next_color = xRenderColorToCard32(stops[current_stop + 1].color); - - int dist = (int)(256*(dpos - stops[current_stop].x) - / (stops[current_stop+1].x - stops[current_stop].x)); - int idist = 256 - dist; - - pGradient->linear.colorTable[pos] = premultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist)); - - ++pos; - dpos += incr; - - if (dpos > stops[current_stop + 1].x) - ++current_stop; - } - - /* After last point */ - while (pos < PICT_GRADIENT_STOPTABLE_SIZE) { - pGradient->linear.colorTable[pos] = xRenderColorToCard32(stops[nstops - 1].color); - ++pos; - } -} - -static void initGradient(SourcePictPtr pGradient, int stopCount, - xFixed *stopPoints, xRenderColor *stopColors, int *error) +PicturePtr +CreateSolidPicture (Picture pid, xRenderColor *color, int *error) { - int i; - xFixed dpos; - - if (stopCount <= 0) { - *error = BadValue; - return; - } - - dpos = -1; - for (i = 0; i < stopCount; ++i) { - if (stopPoints[i] <= dpos || stopPoints[i] > (1<<16)) { - *error = BadValue; - return; - } - dpos = stopPoints[i]; - } - - pGradient->linear.stops = xalloc(stopCount*sizeof(PictGradientStop)); - if (!pGradient->linear.stops) { + PicturePtr pPicture; + pPicture = createSourcePicture(); + if (!pPicture) { *error = BadAlloc; - return; + return 0; } - pGradient->linear.nstops = stopCount; - - for (i = 0; i < stopCount; ++i) { - pGradient->linear.stops[i].x = stopPoints[i]; - pGradient->linear.stops[i].color = stopColors[i]; + pPicture->id = pid; + pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill)); + if (!pPicture->pSourcePict) { + *error = BadAlloc; + xfree(pPicture); + return 0; } - initGradientColorTable(pGradient, error); + pPicture->pSourcePict->type = SourcePictTypeSolidFill; + pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color); + pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha; + pPicture->pSourcePict->solidFill.fullColor.red=color->red; + pPicture->pSourcePict->solidFill.fullColor.green=color->green; + pPicture->pSourcePict->solidFill.fullColor.blue=color->blue; + return pPicture; } static PicturePtr createSourcePicture(void) @@ -1118,627 +350,6 @@ static PicturePtr createSourcePicture(void) return pPicture; } -PicturePtr -CreateSolidPicture (Picture pid, xRenderColor *color, int *error) -{ - PicturePtr pPicture; - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictSolidFill)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - pPicture->pSourcePict->type = SourcePictTypeSolidFill; - pPicture->pSourcePict->solidFill.color = xRenderColorToCard32(*color); - pPicture->pSourcePict->solidFill.fullColor.alpha=color->alpha; - pPicture->pSourcePict->solidFill.fullColor.red=color->red; - pPicture->pSourcePict->solidFill.fullColor.green=color->green; - pPicture->pSourcePict->solidFill.fullColor.blue=color->blue; - return pPicture; -} - -PicturePtr -CreateLinearGradientPicture (Picture pid, xPointFixed *p1, xPointFixed *p2, - int nStops, xFixed *stops, xRenderColor *colors, int *error) -{ - PicturePtr pPicture; - - if (nStops < 2) { - *error = BadValue; - return 0; - } - - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - if (p1->x == p2->x && p1->y == p2->y) { - *error = BadValue; - return 0; - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictLinearGradient)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - - pPicture->pSourcePict->linear.type = SourcePictTypeLinear; - pPicture->pSourcePict->linear.p1 = *p1; - pPicture->pSourcePict->linear.p2 = *p2; - - initGradient(pPicture->pSourcePict, nStops, stops, colors, error); - if (*error) { - xfree(pPicture); - return 0; - } - return pPicture; -} - -#define FixedToDouble(x) ((x)/65536.) - -PicturePtr -CreateRadialGradientPicture (Picture pid, xPointFixed *inner, xPointFixed *outer, - xFixed innerRadius, xFixed outerRadius, - int nStops, xFixed *stops, xRenderColor *colors, int *error) -{ - PicturePtr pPicture; - PictRadialGradient *radial; - - if (nStops < 2) { - *error = BadValue; - return 0; - } - - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - { - double dx = (double)(inner->x - outer->x); - double dy = (double)(inner->y - outer->y); - if (sqrt(dx*dx + dy*dy) + (double)(innerRadius) > (double)(outerRadius)) { - *error = BadValue; - return 0; - } - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictRadialGradient)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - radial = &pPicture->pSourcePict->radial; - - radial->type = SourcePictTypeRadial; - { - double x = (double)innerRadius / (double)outerRadius; - radial->dx = (outer->x - inner->x); - radial->dy = (outer->y - inner->y); - radial->fx = (inner->x) - x*radial->dx; - radial->fy = (inner->y) - x*radial->dy; - radial->m = 1./(1+x); - radial->b = -x*radial->m; - radial->dx /= 65536.; - radial->dy /= 65536.; - radial->fx /= 65536.; - radial->fy /= 65536.; - x = outerRadius/65536.; - radial->a = x*x - radial->dx*radial->dx - radial->dy*radial->dy; - } - - initGradient(pPicture->pSourcePict, nStops, stops, colors, error); - if (*error) { - xfree(pPicture); - return 0; - } - return pPicture; -} - -PicturePtr -CreateConicalGradientPicture (Picture pid, xPointFixed *center, xFixed angle, - int nStops, xFixed *stops, xRenderColor *colors, int *error) -{ - PicturePtr pPicture; - - if (nStops < 2) { - *error = BadValue; - return 0; - } - - pPicture = createSourcePicture(); - if (!pPicture) { - *error = BadAlloc; - return 0; - } - - pPicture->id = pid; - pPicture->pSourcePict = (SourcePictPtr) xalloc(sizeof(PictConicalGradient)); - if (!pPicture->pSourcePict) { - *error = BadAlloc; - xfree(pPicture); - return 0; - } - - pPicture->pSourcePict->conical.type = SourcePictTypeConical; - pPicture->pSourcePict->conical.center = *center; - pPicture->pSourcePict->conical.angle = angle; - - initGradient(pPicture->pSourcePict, nStops, stops, colors, error); - if (*error) { - xfree(pPicture); - return 0; - } - return pPicture; -} - -#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val) - -#define NEXT_PTR(_type) ((_type) ulist++->ptr) - -int -ChangePicture (PicturePtr pPicture, - Mask vmask, - XID *vlist, - DevUnion *ulist, - ClientPtr client) -{ - ScreenPtr pScreen = pPicture->pDrawable ? pPicture->pDrawable->pScreen : 0; - PictureScreenPtr ps = pScreen ? GetPictureScreen(pScreen) : 0; - BITS32 index2; - int error = 0; - BITS32 maskQ; - - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - maskQ = vmask; - while (vmask && !error) - { - index2 = (BITS32) lowbit (vmask); - vmask &= ~index2; - pPicture->stateChanges |= index2; - switch (index2) - { - case CPRepeat: - { - unsigned int newr; - newr = NEXT_VAL(unsigned int); - if (newr <= RepeatReflect) - { - pPicture->repeat = (newr != RepeatNone); - pPicture->repeatType = newr; - } - else - { - client->errorValue = newr; - error = BadValue; - } - } - break; - case CPAlphaMap: - { - PicturePtr pAlpha; - - if (vlist) - { - Picture pid = NEXT_VAL(Picture); - - if (pid == None) - pAlpha = 0; - else - { - pAlpha = (PicturePtr) SecurityLookupIDByType(client, - pid, - PictureType, - SecurityWriteAccess|SecurityReadAccess); - if (!pAlpha) - { - client->errorValue = pid; - error = BadPixmap; - break; - } - if (pAlpha->pDrawable->type != DRAWABLE_PIXMAP) - { - client->errorValue = pid; - error = BadMatch; - break; - } - } - } - else - pAlpha = NEXT_PTR(PicturePtr); - if (!error) - { - if (pAlpha && pAlpha->pDrawable->type == DRAWABLE_PIXMAP) - pAlpha->refcnt++; - if (pPicture->alphaMap) - FreePicture ((void *) pPicture->alphaMap, (XID) 0); - pPicture->alphaMap = pAlpha; - } - } - break; - case CPAlphaXOrigin: - pPicture->alphaOrigin.x = NEXT_VAL(INT16); - break; - case CPAlphaYOrigin: - pPicture->alphaOrigin.y = NEXT_VAL(INT16); - break; - case CPClipXOrigin: - pPicture->clipOrigin.x = NEXT_VAL(INT16); - break; - case CPClipYOrigin: - pPicture->clipOrigin.y = NEXT_VAL(INT16); - break; - case CPClipMask: - { - Pixmap pid; - PixmapPtr pPixmap; - int clipType; - if (!pScreen) - return BadDrawable; - - if (vlist) - { - pid = NEXT_VAL(Pixmap); - if (pid == None) - { - clipType = CT_NONE; - pPixmap = NullPixmap; - } - else - { - clipType = CT_PIXMAP; - pPixmap = (PixmapPtr)SecurityLookupIDByType(client, - pid, - RT_PIXMAP, - SecurityReadAccess); - if (!pPixmap) - { - client->errorValue = pid; - error = BadPixmap; - break; - } - } - } - else - { - pPixmap = NEXT_PTR(PixmapPtr); - if (pPixmap) - clipType = CT_PIXMAP; - else - clipType = CT_NONE; - } - - if (pPixmap) - { - if ((pPixmap->drawable.depth != 1) || - (pPixmap->drawable.pScreen != pScreen)) - { - error = BadMatch; - break; - } - else - { - clipType = CT_PIXMAP; - pPixmap->refcnt++; - } - } - - #ifdef DEBUG - fprintf(stderr, "ChangePicture: Going to call ChangePictureClip with clipType [%d] pPixmap [%p].\n", - clipType, (void *) pPixmap); - #endif - - error = (*ps->ChangePictureClip)(pPicture, clipType, - (void *)pPixmap, 0); - break; - } - case CPGraphicsExposure: - { - unsigned int newe; - newe = NEXT_VAL(unsigned int); - if (newe <= xTrue) - pPicture->graphicsExposures = newe; - else - { - client->errorValue = newe; - error = BadValue; - } - } - break; - case CPSubwindowMode: - { - unsigned int news; - news = NEXT_VAL(unsigned int); - if (news == ClipByChildren || news == IncludeInferiors) - pPicture->subWindowMode = news; - else - { - client->errorValue = news; - error = BadValue; - } - } - break; - case CPPolyEdge: - { - unsigned int newe; - newe = NEXT_VAL(unsigned int); - if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth) - pPicture->polyEdge = newe; - else - { - client->errorValue = newe; - error = BadValue; - } - } - break; - case CPPolyMode: - { - unsigned int newm; - newm = NEXT_VAL(unsigned int); - if (newm == PolyModePrecise || newm == PolyModeImprecise) - pPicture->polyMode = newm; - else - { - client->errorValue = newm; - error = BadValue; - } - } - break; - case CPDither: - pPicture->dither = NEXT_VAL(Atom); - break; - case CPComponentAlpha: - { - unsigned int newca; - - newca = NEXT_VAL (unsigned int); - if (newca <= xTrue) - pPicture->componentAlpha = newca; - else - { - client->errorValue = newca; - error = BadValue; - } - } - break; - default: - client->errorValue = maskQ; - error = BadValue; - break; - } - } - if (ps) - (*ps->ChangePicture) (pPicture, maskQ); - return error; -} - -int -SetPictureClipRects (PicturePtr pPicture, - int xOrigin, - int yOrigin, - int nRect, - xRectangle *rects) -{ - ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - RegionPtr clientClip; - int result; - - clientClip = RegionFromRects( - nRect, rects, CT_UNSORTED); - if (!clientClip) - return BadAlloc; - result =(*ps->ChangePictureClip) (pPicture, CT_REGION, - (void *) clientClip, 0); - if (result == Success) - { - pPicture->clipOrigin.x = xOrigin; - pPicture->clipOrigin.y = yOrigin; - pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask; - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - } - return result; -} - -int -SetPictureClipRegion (PicturePtr pPicture, - int xOrigin, - int yOrigin, - RegionPtr pRegion) -{ - ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - RegionPtr clientClip; - int result; - int type; - - if (pRegion) - { - type = CT_REGION; - clientClip = RegionCreate( - RegionExtents(pRegion), - RegionNumRects(pRegion)); - if (!clientClip) - return BadAlloc; - if (!RegionCopy(clientClip, pRegion)) - { - RegionDestroy(clientClip); - return BadAlloc; - } - } - else - { - type = CT_NONE; - clientClip = 0; - } - - result =(*ps->ChangePictureClip) (pPicture, type, - (void *) clientClip, 0); - if (result == Success) - { - pPicture->clipOrigin.x = xOrigin; - pPicture->clipOrigin.y = yOrigin; - pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask; - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - } - return result; -} - - -int -SetPictureTransform (PicturePtr pPicture, - PictTransform *transform) -{ - static const PictTransform identity = { { - { xFixed1, 0x00000, 0x00000 }, - { 0x00000, xFixed1, 0x00000 }, - { 0x00000, 0x00000, xFixed1 }, - } }; - - if (transform && memcmp (transform, &identity, sizeof (PictTransform)) == 0) - transform = 0; - - if (transform) - { - if (!pPicture->transform) - { - pPicture->transform = (PictTransform *) xalloc (sizeof (PictTransform)); - if (!pPicture->transform) - return BadAlloc; - } - *pPicture->transform = *transform; - } - else - { - if (pPicture->transform) - { - xfree (pPicture->transform); - pPicture->transform = 0; - } - } - pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; - - return Success; -} - -void -CopyPicture (PicturePtr pSrc, - Mask mask, - PicturePtr pDst) -{ - PictureScreenPtr ps = GetPictureScreen(pSrc->pDrawable->pScreen); - Mask origMask = mask; - - pDst->serialNumber |= GC_CHANGE_SERIAL_BIT; - pDst->stateChanges |= mask; - - while (mask) { - Mask bit = lowbit(mask); - - switch (bit) - { - case CPRepeat: - pDst->repeat = pSrc->repeat; - pDst->repeatType = pSrc->repeatType; - break; - case CPAlphaMap: - if (pSrc->alphaMap && pSrc->alphaMap->pDrawable->type == DRAWABLE_PIXMAP) - pSrc->alphaMap->refcnt++; - if (pDst->alphaMap) - FreePicture ((void *) pDst->alphaMap, (XID) 0); - pDst->alphaMap = pSrc->alphaMap; - break; - case CPAlphaXOrigin: - pDst->alphaOrigin.x = pSrc->alphaOrigin.x; - break; - case CPAlphaYOrigin: - pDst->alphaOrigin.y = pSrc->alphaOrigin.y; - break; - case CPClipXOrigin: - pDst->clipOrigin.x = pSrc->clipOrigin.x; - break; - case CPClipYOrigin: - pDst->clipOrigin.y = pSrc->clipOrigin.y; - break; - case CPClipMask: - switch (pSrc->clientClipType) { - case CT_NONE: - (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0); - break; - case CT_REGION: - if (!pSrc->clientClip) { - (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0); - } else { - RegionPtr clientClip; - RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip; - - clientClip = RegionCreate( - RegionExtents(srcClientClip), - RegionNumRects(srcClientClip)); - (*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0); - } - break; - default: - /* XXX: CT_PIXMAP unimplemented */ - break; - } - break; - case CPGraphicsExposure: - pDst->graphicsExposures = pSrc->graphicsExposures; - break; - case CPPolyEdge: - pDst->polyEdge = pSrc->polyEdge; - break; - case CPPolyMode: - pDst->polyMode = pSrc->polyMode; - break; - case CPDither: - pDst->dither = pSrc->dither; - break; - case CPComponentAlpha: - pDst->componentAlpha = pSrc->componentAlpha; - break; - } - mask &= ~bit; - } - - (*ps->ChangePicture)(pDst, origMask); -} - -static void -ValidateOnePicture (PicturePtr pPicture) -{ - if (pPicture->pDrawable && pPicture->serialNumber != pPicture->pDrawable->serialNumber) - { - PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen); - - (*ps->ValidatePicture) (pPicture, pPicture->stateChanges); - pPicture->stateChanges = 0; - pPicture->serialNumber = pPicture->pDrawable->serialNumber; - } -} - -void -ValidatePicture(PicturePtr pPicture) -{ - ValidateOnePicture (pPicture); - if (pPicture->alphaMap) - ValidateOnePicture (pPicture->alphaMap); -} - int FreePicture (void * value, XID pid) @@ -1747,9 +358,7 @@ FreePicture (void * value, if (--pPicture->refcnt == 0) { -#ifdef NXAGENT_SERVER nxagentDestroyPicture(pPicture); -#endif if (pPicture->transform) xfree (pPicture->transform); @@ -1793,264 +402,6 @@ FreePicture (void * value, return Success; } -int -FreePictFormat (void * pPictFormat, - XID pid) -{ - return Success; -} - -/** - * ReduceCompositeOp is used to choose simpler ops for cases where alpha - * channels are always one and so math on the alpha channel per pixel becomes - * unnecessary. It may also avoid destination reads sometimes if apps aren't - * being careful to avoid these cases. - */ -static CARD8 -ReduceCompositeOp (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst) -{ - Bool no_src_alpha, no_dst_alpha; - - no_src_alpha = PICT_FORMAT_COLOR(pSrc->format) && - PICT_FORMAT_A(pSrc->format) == 0 && - pSrc->alphaMap == NULL && - pMask == NULL; - no_dst_alpha = PICT_FORMAT_COLOR(pDst->format) && - PICT_FORMAT_A(pDst->format) == 0 && - pDst->alphaMap == NULL; - - /* TODO, maybe: Conjoint and Disjoint op reductions? */ - - /* Deal with simplifications where the source alpha is always 1. */ - if (no_src_alpha) - { - switch (op) { - case PictOpOver: - op = PictOpSrc; - break; - case PictOpInReverse: - op = PictOpDst; - break; - case PictOpOutReverse: - op = PictOpClear; - break; - case PictOpAtop: - op = PictOpIn; - break; - case PictOpAtopReverse: - op = PictOpOverReverse; - break; - case PictOpXor: - op = PictOpOut; - break; - default: - break; - } - } - - /* Deal with simplifications when the destination alpha is always 1 */ - if (no_dst_alpha) - { - switch (op) { - case PictOpOverReverse: - op = PictOpDst; - break; - case PictOpIn: - op = PictOpSrc; - break; - case PictOpOut: - op = PictOpClear; - break; - case PictOpAtop: - op = PictOpOver; - break; - case PictOpXor: - op = PictOpOutReverse; - break; - default: - break; - } - } - - /* Reduce some con/disjoint ops to the basic names. */ - switch (op) { - case PictOpDisjointClear: - case PictOpConjointClear: - op = PictOpClear; - break; - case PictOpDisjointSrc: - case PictOpConjointSrc: - op = PictOpSrc; - break; - case PictOpDisjointDst: - case PictOpConjointDst: - op = PictOpDst; - break; - default: - break; - } - - return op; -} - -void -CompositePicture (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - if (pMask) - ValidatePicture (pMask); - ValidatePicture (pDst); - - op = ReduceCompositeOp (op, pSrc, pMask, pDst); - if (op == PictOpDst) - return; - - (*ps->Composite) (op, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height); -} - -void -CompositeGlyphs (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr lists, - GlyphPtr *glyphs) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - - #ifdef TEST - fprintf(stderr, "CompositeGlyphs: Going to composite glyphs with " - "source at [%p] and destination at [%p].\n", - (void *) pSrc, (void *) pDst); - #endif - - (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs); -} - -void -CompositeRects (CARD8 op, - PicturePtr pDst, - xRenderColor *color, - int nRect, - xRectangle *rects) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pDst); - (*ps->CompositeRects) (op, pDst, color, nRect, rects); -} - -void -CompositeTrapezoids (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntrap, - xTrapezoid *traps) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->Trapezoids) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, traps); -} - -void -CompositeTriangles (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntriangles, - xTriangle *triangles) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntriangles, triangles); -} - -void -CompositeTriStrip (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->TriStrip) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); -} - -void -CompositeTriFan (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points) -{ - PictureScreenPtr ps = GetPictureScreen(pDst->pDrawable->pScreen); - - ValidatePicture (pSrc); - ValidatePicture (pDst); - (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); -} - -void -AddTraps (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntrap, - xTrap *traps) -{ - PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen); - - ValidatePicture (pPicture); - (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps); -} - #ifndef True # define True 1 #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h b/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h deleted file mode 100644 index 30e1005c2..000000000 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr.h +++ /dev/null @@ -1,707 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NXAGENT, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* - * $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $ - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Keith Packard, SuSE, Inc. - */ - -/* - * This must keep the same symbol as the original - * picturestr.h or symbols will be redefined. We - * should define a new types and cast when appro- - * priate. - */ - -#ifndef _PICTURESTR_H_ -#define _PICTURESTR_H_ - -#include "NXglyphstr.h" -#include "scrnintstr.h" -#include "resource.h" - -typedef struct _DirectFormat { - CARD16 red, redMask; - CARD16 green, greenMask; - CARD16 blue, blueMask; - CARD16 alpha, alphaMask; -} DirectFormatRec; - -typedef struct _IndexFormat { - VisualID vid; - ColormapPtr pColormap; - int nvalues; - xIndexValue *pValues; - void *devPrivate; -} IndexFormatRec; - -typedef struct _PictFormat { - CARD32 id; - CARD32 format; /* except bpp */ - unsigned char type; - unsigned char depth; - DirectFormatRec direct; - IndexFormatRec index; -} PictFormatRec; - -typedef struct pixman_vector PictVector, *PictVectorPtr; -typedef struct pixman_transform PictTransform, *PictTransformPtr; - -#define pict_f_transform pixman_f_transform - -#define PICT_GRADIENT_STOPTABLE_SIZE 1024 -#define SourcePictTypeSolidFill 0 -#define SourcePictTypeLinear 1 -#define SourcePictTypeRadial 2 -#define SourcePictTypeConical 3 - -typedef struct _PictSolidFill { - unsigned int type; - CARD32 color; - xRenderColor fullColor; -} PictSolidFill, *PictSolidFillPtr; - -typedef struct _PictGradientStop { - xFixed x; - xRenderColor color; -} PictGradientStop, *PictGradientStopPtr; - -typedef struct _PictGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; -} PictGradient, *PictGradientPtr; - -typedef struct _PictLinearGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; - xPointFixed p1; - xPointFixed p2; -} PictLinearGradient, *PictLinearGradientPtr; - -typedef struct _PictRadialGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; - double fx; - double fy; - double dx; - double dy; - double a; - double m; - double b; -} PictRadialGradient, *PictRadialGradientPtr; - -typedef struct _PictConicalGradient { - unsigned int type; - int nstops; - PictGradientStopPtr stops; - CARD32 colorTable[PICT_GRADIENT_STOPTABLE_SIZE]; - xPointFixed center; - xFixed angle; -} PictConicalGradient, *PictConicalGradientPtr; - -typedef union _SourcePict { - unsigned int type; - PictSolidFill solidFill; - PictGradient gradient; - PictLinearGradient linear; - PictRadialGradient radial; - PictConicalGradient conical; -} SourcePict, *SourcePictPtr; - -typedef struct _Picture { - DrawablePtr pDrawable; - PictFormatPtr pFormat; - CARD32 format; /* PICT_FORMAT */ - int refcnt; - CARD32 id; - PicturePtr pNext; /* chain on same drawable */ - - unsigned int repeat : 1; - unsigned int graphicsExposures : 1; - unsigned int subWindowMode : 1; - unsigned int polyEdge : 1; - unsigned int polyMode : 1; - unsigned int freeCompClip : 1; - unsigned int clientClipType : 2; - unsigned int componentAlpha : 1; - unsigned int repeatType : 2; - unsigned int unused : 21; - - PicturePtr alphaMap; - DDXPointRec alphaOrigin; - - DDXPointRec clipOrigin; - void * clientClip; - - Atom dither; - - unsigned long stateChanges; - unsigned long serialNumber; - - RegionPtr pCompositeClip; - - DevUnion *devPrivates; - - PictTransform *transform; - - int filter; - xFixed *filter_params; - int filter_nparams; - SourcePictPtr pSourcePict; -} PictureRec; - -typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id, - xFixed *params, int nparams, - int *width, int *height); -typedef struct { - char *name; - int id; - PictFilterValidateParamsProcPtr ValidateParams; - int width, height; -} PictFilterRec, *PictFilterPtr; - -#define PictFilterNearest 0 -#define PictFilterBilinear 1 - -#define PictFilterFast 2 -#define PictFilterGood 3 -#define PictFilterBest 4 - -#define PictFilterConvolution 5 - -typedef struct { - char *alias; - int alias_id; - int filter_id; -} PictFilterAliasRec, *PictFilterAliasPtr; - -typedef int (*CreatePictureProcPtr) (PicturePtr pPicture); -typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture); -typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture, - int clipType, - void *value, - int n); -typedef void (*DestroyPictureClipProcPtr)(PicturePtr pPicture); - -typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture, - PictTransform *transform); - -typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture, - int filter, - xFixed *params, - int nparams); - -typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture); - -typedef void (*ChangePictureProcPtr) (PicturePtr pPicture, - Mask mask); -typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture, - Mask mask); -typedef void (*CompositeProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -typedef void (*GlyphsProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlists, - GlyphListPtr lists, - GlyphPtr *glyphs); - -typedef void (*CompositeRectsProcPtr) (CARD8 op, - PicturePtr pDst, - xRenderColor *color, - int nRect, - xRectangle *rects); - -typedef void (*RasterizeTrapezoidProcPtr)(PicturePtr pMask, - xTrapezoid *trap, - int x_off, - int y_off); - -typedef void (*TrapezoidsProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntrap, - xTrapezoid *traps); - -typedef void (*TrianglesProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntri, - xTriangle *tris); - -typedef void (*TriStripProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoint, - xPointFixed *points); - -typedef void (*TriFanProcPtr) (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoint, - xPointFixed *points); - -typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen, - PictFormatPtr pFormat); - -typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen, - PictFormatPtr pFormat); - -typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen, - PictFormatPtr pFormat, - int ndef, - xColorItem *pdef); - -typedef void (*AddTrapsProcPtr) (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntrap, - xTrap *traps); - -typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntri, - xTriangle *tris); - -typedef struct _PictureScreen { - int totalPictureSize; - unsigned int *PicturePrivateSizes; - int PicturePrivateLen; - - PictFormatPtr formats; - PictFormatPtr fallback; - int nformats; - - CreatePictureProcPtr CreatePicture; - DestroyPictureProcPtr DestroyPicture; - ChangePictureClipProcPtr ChangePictureClip; - DestroyPictureClipProcPtr DestroyPictureClip; - - ChangePictureProcPtr ChangePicture; - ValidatePictureProcPtr ValidatePicture; - - CompositeProcPtr Composite; - GlyphsProcPtr Glyphs; - CompositeRectsProcPtr CompositeRects; - - DestroyWindowProcPtr DestroyWindow; - CloseScreenProcPtr CloseScreen; - - StoreColorsProcPtr StoreColors; - - InitIndexedProcPtr InitIndexed; - CloseIndexedProcPtr CloseIndexed; - UpdateIndexedProcPtr UpdateIndexed; - - int subpixel; - - PictFilterPtr filters; - int nfilters; - PictFilterAliasPtr filterAliases; - int nfilterAliases; - - ChangePictureTransformProcPtr ChangePictureTransform; - - /** - * Called immediately after a picture's transform is changed through the - * SetPictureFilter request. Not called for source-only pictures. - */ - ChangePictureFilterProcPtr ChangePictureFilter; - - DestroyPictureFilterProcPtr DestroyPictureFilter; - - TrapezoidsProcPtr Trapezoids; - TrianglesProcPtr Triangles; - TriStripProcPtr TriStrip; - TriFanProcPtr TriFan; - - RasterizeTrapezoidProcPtr RasterizeTrapezoid; - - AddTrianglesProcPtr AddTriangles; - - AddTrapsProcPtr AddTraps; - -} PictureScreenRec, *PictureScreenPtr; - -extern int PictureScreenPrivateIndex; -extern int PictureWindowPrivateIndex; -extern RESTYPE PictureType; -extern RESTYPE PictFormatType; -extern RESTYPE GlyphSetType; - -#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr)) -#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL) -#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (void *) (p)) -#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr)) -#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (void *) (p)) - -#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\ - pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\ - if (!pPicture) { \ - client->errorValue = pid; \ - return err; \ - } \ -} - -#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\ - if (pid == None) \ - pPicture = 0; \ - else { \ - VERIFY_PICTURE(pPicture, pid, client, mode, err); \ - } \ -} \ - -void -ResetPicturePrivateIndex (void); - -int -AllocatePicturePrivateIndex (void); - -Bool -AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount); - -Bool -PictureDestroyWindow (WindowPtr pWindow); - -Bool -PictureCloseScreen (int Index, ScreenPtr pScreen); - -void -PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef); - -Bool -PictureInitIndexedFormats (ScreenPtr pScreen); - -Bool -PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel); - -int -PictureGetSubpixelOrder (ScreenPtr pScreen); - -PictFormatPtr -PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp); - -PictFormatPtr -PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual); - -PictFormatPtr -PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format); - -Bool -PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); - -int -PictureGetFilterId (char *filter, int len, Bool makeit); - -char * -PictureGetFilterName (int id); - -int -PictureAddFilter (ScreenPtr pScreen, - char *filter, - PictFilterValidateParamsProcPtr ValidateParams); - -Bool -PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias); - -Bool -PictureSetDefaultFilters (ScreenPtr pScreen); - -void -PictureResetFilters (ScreenPtr pScreen); - -PictFilterPtr -PictureFindFilter (ScreenPtr pScreen, char *name, int len); - -int -SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter, - xFixed *params, int nparams); - -int -SetPictureFilter (PicturePtr pPicture, char *name, int len, - xFixed *params, int nparams); - -Bool -PictureFinishInit (void); - -void -SetPictureToDefaults (PicturePtr pPicture); - -PicturePtr -AllocatePicture (ScreenPtr pScreen); - -#if 0 -Bool -miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats); -#endif - - -PicturePtr -CreatePicture (Picture pid, - DrawablePtr pDrawable, - PictFormatPtr pFormat, - Mask mask, - XID *list, - ClientPtr client, - int *error); - -int -ChangePicture (PicturePtr pPicture, - Mask vmask, - XID *vlist, - DevUnion *ulist, - ClientPtr client); - -int -SetPictureClipRects (PicturePtr pPicture, - int xOrigin, - int yOrigin, - int nRect, - xRectangle *rects); - -int -SetPictureClipRegion (PicturePtr pPicture, - int xOrigin, - int yOrigin, - RegionPtr pRegion); - -int -SetPictureTransform (PicturePtr pPicture, - PictTransform *transform); - -void -CopyPicture (PicturePtr pSrc, - Mask mask, - PicturePtr pDst); - -void -ValidatePicture(PicturePtr pPicture); - -int -FreePicture (void * pPicture, - XID pid); - -int -FreePictFormat (void * pPictFormat, - XID pid); - -void -CompositePicture (CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -void -CompositeGlyphs (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr lists, - GlyphPtr *glyphs); - -void -CompositeRects (CARD8 op, - PicturePtr pDst, - xRenderColor *color, - int nRect, - xRectangle *rects); - -void -CompositeTrapezoids (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntrap, - xTrapezoid *traps); - -void -CompositeTriangles (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int ntriangles, - xTriangle *triangles); - -void -CompositeTriStrip (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points); - -void -CompositeTriFan (CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int npoints, - xPointFixed *points); - -Bool -PictureTransformPoint (PictTransformPtr transform, - PictVectorPtr vector); - -Bool -PictureTransformPoint3d (PictTransformPtr transform, - PictVectorPtr vector); - -void RenderExtensionInit (void); - -Bool -AnimCurInit (ScreenPtr pScreen); - -int -AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor); - -void -AddTraps (PicturePtr pPicture, - INT16 xOff, - INT16 yOff, - int ntraps, - xTrap *traps); - -PicturePtr -CreateSolidPicture (Picture pid, - xRenderColor *color, - int *error); - -PicturePtr -CreateLinearGradientPicture (Picture pid, - xPointFixed *p1, - xPointFixed *p2, - int nStops, - xFixed *stops, - xRenderColor *colors, - int *error); - -PicturePtr -CreateRadialGradientPicture (Picture pid, - xPointFixed *inner, - xPointFixed *outer, - xFixed innerRadius, - xFixed outerRadius, - int nStops, - xFixed *stops, - xRenderColor *colors, - int *error); - -PicturePtr -CreateConicalGradientPicture (Picture pid, - xPointFixed *center, - xFixed angle, - int nStops, - xFixed *stops, - xRenderColor *colors, - int *error); - -#ifdef PANORAMIX -void PanoramiXRenderInit (void); -void PanoramiXRenderReset (void); -#endif - -/* - * matrix.c - */ - -extern _X_EXPORT void -PictTransform_from_xRenderTransform(PictTransformPtr pict, - xRenderTransform * render); - -extern _X_EXPORT void -xRenderTransform_from_PictTransform(xRenderTransform * render, - PictTransformPtr pict); - -extern _X_EXPORT Bool - PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector); - -extern _X_EXPORT Bool - PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector); - -#endif /* _PICTURESTR_H_ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr_PictSolidFill.h b/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr_PictSolidFill.h new file mode 100644 index 000000000..e54bfafc2 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicturestr_PictSolidFill.h @@ -0,0 +1,55 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NXAGENT, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of Medialogic S.p.A. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* + * $Id: picturestr.h,v 1.15 2005/12/09 18:35:21 ajax Exp $ + * + * Copyright © 2000 SuSE, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, SuSE, Inc. + */ + +/* this header file gets included into Xserver/render/picturestr.h */ + +#ifndef NX_PICTURESTR_PICTSOLIDFILL_H +#define NX_PICTURESTR_PICTSOLIDFILL_H 1 + + +typedef struct _PictSolidFill { + unsigned int type; + CARD32 color; + xRenderColor fullColor; +} PictSolidFill, *PictSolidFillPtr; + +#endif /* NX_PICTURESTR_PICTSOLIDFILL_H */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c index d6c5aa4dd..2458c12d0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c @@ -64,42 +64,13 @@ SOFTWARE. ******************************************************************/ /* $Xorg: property.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#define NEED_REPLIES -#define NEED_EVENTS -#include <nx-X11/Xproto.h> -#include "windowstr.h" -#include "propertyst.h" -#include "dixstruct.h" -#include "../../dix/dispatch.h" -#include "swaprep.h" -#ifdef XCSECURITY -#define _SECURITY_SERVER -#include <nx-X11/extensions/security.h> -#endif -#ifdef LBX -#include "lbxserve.h" -#include "lbxtags.h" -#endif +#include "../../dix/property.c" #include "Options.h" #include "Rootless.h" #include "Client.h" #include "Windows.h" -#if defined(LBX) || defined(LBX_COMPAT) -#if 0 /* no header in X11 environment, not used in X11 environment */ -int fWriteToClient(ClientPtr client, int len, char *buf) -{ - return WriteToClient(client, len, buf); -} -#endif -#endif - extern Atom clientCutProperty; #ifdef NXAGENT_SERVER @@ -111,129 +82,6 @@ typedef struct nxagentWMStateRec; #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(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(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) - return(BadAlloc); - for (i = 0; i < stuff->nAtoms; i++) - { -#ifdef XCSECURITY - char action = SecurityCheckPropertyAccess(client, pWin, atoms[i], - SecurityReadAccess|SecurityWriteAccess); -#endif - if (!ValidAtom(atoms[i]) -#ifdef XCSECURITY - || (SecurityErrorOperation == action) -#endif - ) - { - DEALLOCATE_LOCAL(props); - client->errorValue = atoms[i]; - return BadAtom; - } -#ifdef XCSECURITY - if (SecurityIgnoreOperation == action) - { - DEALLOCATE_LOCAL(props); - return Success; - } -#endif - for (j = i + 1; j < stuff->nAtoms; j++) - if (atoms[j] == atoms[i]) - { - DEALLOCATE_LOCAL(props); - return BadMatch; - } - pProp = wUserProps (pWin); - while (pProp) - { - if (pProp->propertyName == atoms[i]) - goto found; - pProp = pProp->next; - } - DEALLOCATE_LOCAL(props); - return BadMatch; -found: - props[i] = pProp; - } - delta = stuff->nPositions; - - /* If the rotation is a complete 360 degrees, then moving the properties - around and generating PropertyNotify events should be skipped. */ - - if ( (stuff->nAtoms != 0) && (abs(delta) % stuff->nAtoms) != 0 ) - { - while (delta < 0) /* faster if abs value is small */ - delta += stuff->nAtoms; - 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(ClientPtr client) { @@ -315,13 +163,8 @@ ProcChangeProperty(ClientPtr client) } #endif -#ifdef LBX - err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type, - (int)format, (int)mode, len, TRUE, (void *)&stuff[1], TRUE, NULL); -#else err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format, (int)mode, len, (void *)&stuff[1], TRUE); -#endif if (err != Success) return err; else @@ -349,11 +192,6 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, int mode, unsigned long len, void * 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; @@ -473,92 +311,6 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); } return(Success); -#endif -} - -int -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); - } - else - { - 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(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); - pProp = pNextProp; - } -} - -static int -NullPropertyReply( - ClientPtr client, - ATOM propertyType, - int format, - xGetPropertyReply *reply) -{ - reply->nItems = 0; - reply->length = 0; - reply->bytesAfter = 0; - reply->propertyType = propertyType; - reply->format = format; - WriteReplyToClient(client, sizeof(xGenericReply), reply); - return(client->noClientException); } /***************** @@ -712,13 +464,6 @@ ProcGetProperty(ClientPtr client) WriteReplyToClient(client, sizeof(xGenericReply), &reply); return(Success); } -#ifdef LBX - /* make sure we have the current value */ - if (pProp->tag_id && pProp->owner_pid) { - LbxStallPropRequest(client, pProp); - return client->noClientException; - } -#endif /* * Return type, format, value to client @@ -769,10 +514,6 @@ ProcGetProperty(ClientPtr client) 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)) @@ -888,10 +629,6 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, if (delete && (*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)) @@ -905,89 +642,3 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, return(Success); } #endif - -int -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++; - } - if (numProps) - if(!(pAtoms = (Atom *)ALLOCATE_LOCAL(numProps * sizeof(Atom)))) - return(BadAlloc); - - xlpr.type = X_Reply; - xlpr.nProperties = numProps; - 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(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)) - { - case SecurityErrorOperation: - client->errorValue = stuff->property; - return BadAtom;; - case SecurityIgnoreOperation: - return Success; - } -#endif - - result = DeleteProperty(pWin, stuff->property); - if (client->noClientException != Success) - return(client->noClientException); - else - return(result); -} - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 238e5a39c..93760f482 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -41,38 +41,7 @@ /* */ /**************************************************************************/ -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#include <nx-X11/Xproto.h> -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "resource.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "colormapst.h" -#include "extnsionst.h" -#include "servermd.h" -#include <nx-X11/extensions/render.h> -#include <nx-X11/extensions/renderproto.h> -#include <nx-X11/Xfuncproto.h> -#include "cursorstr.h" -#ifdef EXTMODULE -#include "xf86_ansic.h" -#endif - -#if !defined(UINT32_MAX) -#define UINT32_MAX 0xffffffffU -#endif - -#include "NXpicturestr.h" -#include "NXglyphstr.h" +#include "../render/render.c" #include "Trap.h" @@ -99,6 +68,7 @@ * From NXmiglyph.c. */ +extern void miGlyphExtents(int nlist, GlyphListPtr list, GlyphPtr *glyphs, BoxPtr extents); @@ -106,52 +76,48 @@ void miGlyphExtents(int nlist, GlyphListPtr list, * From NXmitrap.c. */ +extern void miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box); /* * Functions from Render.c. */ -int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr); -void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int); -int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); -int nxagentCreatePicture(PicturePtr, Mask); -void nxagentChangePicture(PicturePtr, Mask); -int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int); -void nxagentComposite(CARD8, PicturePtr, PicturePtr, PicturePtr, INT16, INT16, - INT16, INT16, INT16, INT16, CARD16, CARD16); -void nxagentCompositeRects(CARD8, PicturePtr, xRenderColor *, int, xRectangle *); -void nxagentCreateGlyphSet(GlyphSetPtr glyphSet); -void nxagentReferenceGlyphSet(GlyphSetPtr glyphSet); -void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph); -void nxagentFreeGlyphSet(GlyphSetPtr glyphSet); -void nxagentSetPictureTransform(PicturePtr pPicture, void * transform); -void nxagentSetPictureFilter(PicturePtr pPicture, char *filter, int name_size, - void * params, int nparams); -void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, - INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps); - -void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color); - -void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, - xPointFixed *p2, int nStops, - xFixed *stops, - xRenderColor *colors); - -void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, - xPointFixed *outer, - xFixed innerRadius, - xFixed outerRadius, - int nStops, - xFixed *stops, - xRenderColor *colors); - -void nxagentRenderCreateConicalGradient(PicturePtr pPicture, - xPointFixed *center, - xFixed angle, int nStops, - xFixed *stops, - xRenderColor *colors); - +extern int nxagentCursorSaveRenderInfo(ScreenPtr, CursorPtr); +extern void nxagentCursorPostSaveRenderInfo(CursorPtr, ScreenPtr, PicturePtr, int, int); +extern int nxagentRenderRealizeCursor(ScreenPtr, CursorPtr); +extern int nxagentCreatePicture(PicturePtr, Mask); +extern void nxagentChangePicture(PicturePtr, Mask); +extern int nxagentChangePictureClip(PicturePtr, int, int, xRectangle *, int, int); +extern void nxagentComposite(CARD8, PicturePtr, PicturePtr, PicturePtr, INT16, INT16, + INT16, INT16, INT16, INT16, CARD16, CARD16); +extern void nxagentCompositeRects(CARD8, PicturePtr, xRenderColor *, int, xRectangle *); +extern void nxagentCreateGlyphSet(GlyphSetPtr glyphSet); +extern void nxagentReferenceGlyphSet(GlyphSetPtr glyphSet); +extern void nxagentFreeGlyphs(GlyphSetPtr glyphSet, CARD32 *gids, int nglyph); +extern void nxagentFreeGlyphSet(GlyphSetPtr glyphSet); +extern void nxagentSetPictureTransform(PicturePtr pPicture, void * transform); +extern void nxagentSetPictureFilter(PicturePtr pPicture, char *filter, int name_size, + void * params, int nparams); +extern void nxagentTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst, PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid *traps); +extern void nxagentRenderCreateSolidFill(PicturePtr pPicture, xRenderColor *color); +extern void nxagentRenderCreateLinearGradient(PicturePtr pPicture, xPointFixed *p1, + xPointFixed *p2, int nStops, + xFixed *stops, + xRenderColor *colors); +extern void nxagentRenderCreateRadialGradient(PicturePtr pPicture, xPointFixed *inner, + xPointFixed *outer, + xFixed innerRadius, + xFixed outerRadius, + int nStops, + xFixed *stops, + xRenderColor *colors); +extern void nxagentRenderCreateConicalGradient(PicturePtr pPicture, + xPointFixed *center, + xFixed angle, int nStops, + xFixed *stops, + xRenderColor *colors); /* * The void pointer is actually a XGlyphElt8. @@ -160,225 +126,6 @@ void nxagentRenderCreateConicalGradient(PicturePtr pPicture, void nxagentGlyphs(CARD8, PicturePtr, PicturePtr, PictFormatPtr, INT16, INT16, int, void *, int, GlyphPtr *); -static int ProcRenderQueryVersion (ClientPtr pClient); -static int ProcRenderQueryPictFormats (ClientPtr pClient); -static int ProcRenderQueryPictIndexValues (ClientPtr pClient); -static int ProcRenderQueryDithers (ClientPtr pClient); -static int ProcRenderCreatePicture (ClientPtr pClient); -static int ProcRenderChangePicture (ClientPtr pClient); -static int ProcRenderSetPictureClipRectangles (ClientPtr pClient); -static int ProcRenderFreePicture (ClientPtr pClient); -static int ProcRenderComposite (ClientPtr pClient); -static int ProcRenderScale (ClientPtr pClient); -static int ProcRenderTrapezoids (ClientPtr pClient); -static int ProcRenderTriangles (ClientPtr pClient); -static int ProcRenderTriStrip (ClientPtr pClient); -static int ProcRenderTriFan (ClientPtr pClient); -static int ProcRenderColorTrapezoids (ClientPtr pClient); -static int ProcRenderColorTriangles (ClientPtr pClient); -static int ProcRenderTransform (ClientPtr pClient); -static int ProcRenderCreateGlyphSet (ClientPtr pClient); -static int ProcRenderReferenceGlyphSet (ClientPtr pClient); -static int ProcRenderFreeGlyphSet (ClientPtr pClient); -static int ProcRenderAddGlyphs (ClientPtr pClient); -static int ProcRenderAddGlyphsFromPicture (ClientPtr pClient); -static int ProcRenderFreeGlyphs (ClientPtr pClient); -static int ProcRenderCompositeGlyphs (ClientPtr pClient); -static int ProcRenderFillRectangles (ClientPtr pClient); -static int ProcRenderCreateCursor (ClientPtr pClient); -static int ProcRenderSetPictureTransform (ClientPtr pClient); -static int ProcRenderQueryFilters (ClientPtr pClient); -static int ProcRenderSetPictureFilter (ClientPtr pClient); -static int ProcRenderCreateAnimCursor (ClientPtr pClient); -static int ProcRenderAddTraps (ClientPtr pClient); -static int ProcRenderCreateSolidFill (ClientPtr pClient); -static int ProcRenderCreateLinearGradient (ClientPtr pClient); -static int ProcRenderCreateRadialGradient (ClientPtr pClient); -static int ProcRenderCreateConicalGradient (ClientPtr pClient); - -static int ProcRenderDispatch (ClientPtr pClient); - -static int SProcRenderQueryVersion (ClientPtr pClient); -static int SProcRenderQueryPictFormats (ClientPtr pClient); -static int SProcRenderQueryPictIndexValues (ClientPtr pClient); -static int SProcRenderQueryDithers (ClientPtr pClient); -static int SProcRenderCreatePicture (ClientPtr pClient); -static int SProcRenderChangePicture (ClientPtr pClient); -static int SProcRenderSetPictureClipRectangles (ClientPtr pClient); -static int SProcRenderFreePicture (ClientPtr pClient); -static int SProcRenderComposite (ClientPtr pClient); -static int SProcRenderScale (ClientPtr pClient); -static int SProcRenderTrapezoids (ClientPtr pClient); -static int SProcRenderTriangles (ClientPtr pClient); -static int SProcRenderTriStrip (ClientPtr pClient); -static int SProcRenderTriFan (ClientPtr pClient); -static int SProcRenderColorTrapezoids (ClientPtr pClient); -static int SProcRenderColorTriangles (ClientPtr pClient); -static int SProcRenderTransform (ClientPtr pClient); -static int SProcRenderCreateGlyphSet (ClientPtr pClient); -static int SProcRenderReferenceGlyphSet (ClientPtr pClient); -static int SProcRenderFreeGlyphSet (ClientPtr pClient); -static int SProcRenderAddGlyphs (ClientPtr pClient); -static int SProcRenderAddGlyphsFromPicture (ClientPtr pClient); -static int SProcRenderFreeGlyphs (ClientPtr pClient); -static int SProcRenderCompositeGlyphs (ClientPtr pClient); -static int SProcRenderFillRectangles (ClientPtr pClient); -static int SProcRenderCreateCursor (ClientPtr pClient); -static int SProcRenderSetPictureTransform (ClientPtr pClient); -static int SProcRenderQueryFilters (ClientPtr pClient); -static int SProcRenderSetPictureFilter (ClientPtr pClient); -static int SProcRenderCreateAnimCursor (ClientPtr pClient); -static int SProcRenderAddTraps (ClientPtr pClient); -static int SProcRenderCreateSolidFill (ClientPtr pClient); -static int SProcRenderCreateLinearGradient (ClientPtr pClient); -static int SProcRenderCreateRadialGradient (ClientPtr pClient); -static int SProcRenderCreateConicalGradient (ClientPtr pClient); - -static int SProcRenderDispatch (ClientPtr pClient); - -int (*ProcRenderVector[RenderNumberRequests])(ClientPtr) = { - ProcRenderQueryVersion, - ProcRenderQueryPictFormats, - ProcRenderQueryPictIndexValues, - ProcRenderQueryDithers, - ProcRenderCreatePicture, - ProcRenderChangePicture, - ProcRenderSetPictureClipRectangles, - ProcRenderFreePicture, - ProcRenderComposite, - ProcRenderScale, - ProcRenderTrapezoids, - ProcRenderTriangles, - ProcRenderTriStrip, - ProcRenderTriFan, - ProcRenderColorTrapezoids, - ProcRenderColorTriangles, - ProcRenderTransform, - ProcRenderCreateGlyphSet, - ProcRenderReferenceGlyphSet, - ProcRenderFreeGlyphSet, - ProcRenderAddGlyphs, - ProcRenderAddGlyphsFromPicture, - ProcRenderFreeGlyphs, - ProcRenderCompositeGlyphs, - ProcRenderCompositeGlyphs, - ProcRenderCompositeGlyphs, - ProcRenderFillRectangles, - ProcRenderCreateCursor, - ProcRenderSetPictureTransform, - ProcRenderQueryFilters, - ProcRenderSetPictureFilter, - ProcRenderCreateAnimCursor, - ProcRenderAddTraps, - ProcRenderCreateSolidFill, - ProcRenderCreateLinearGradient, - ProcRenderCreateRadialGradient, - ProcRenderCreateConicalGradient -}; - -int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { - SProcRenderQueryVersion, - SProcRenderQueryPictFormats, - SProcRenderQueryPictIndexValues, - SProcRenderQueryDithers, - SProcRenderCreatePicture, - SProcRenderChangePicture, - SProcRenderSetPictureClipRectangles, - SProcRenderFreePicture, - SProcRenderComposite, - SProcRenderScale, - SProcRenderTrapezoids, - SProcRenderTriangles, - SProcRenderTriStrip, - SProcRenderTriFan, - SProcRenderColorTrapezoids, - SProcRenderColorTriangles, - SProcRenderTransform, - SProcRenderCreateGlyphSet, - SProcRenderReferenceGlyphSet, - SProcRenderFreeGlyphSet, - SProcRenderAddGlyphs, - SProcRenderAddGlyphsFromPicture, - SProcRenderFreeGlyphs, - SProcRenderCompositeGlyphs, - SProcRenderCompositeGlyphs, - SProcRenderCompositeGlyphs, - SProcRenderFillRectangles, - SProcRenderCreateCursor, - SProcRenderSetPictureTransform, - SProcRenderQueryFilters, - SProcRenderSetPictureFilter, - SProcRenderCreateAnimCursor, - SProcRenderAddTraps, - SProcRenderCreateSolidFill, - SProcRenderCreateLinearGradient, - SProcRenderCreateRadialGradient, - SProcRenderCreateConicalGradient -}; - -static void -RenderResetProc (ExtensionEntry *extEntry); - -#if 0 -static CARD8 RenderReqCode; -#endif -int RenderErrBase; -int RenderClientPrivateIndex; - -typedef struct _RenderClient { - int major_version; - int minor_version; -} RenderClientRec, *RenderClientPtr; - -#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr) - -static void -RenderClientCallback (CallbackListPtr *list, - void * closure, - void * data) -{ - NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; - ClientPtr pClient = clientinfo->client; - RenderClientPtr pRenderClient = GetRenderClient (pClient); - - pRenderClient->major_version = 0; - pRenderClient->minor_version = 0; -} - -void -RenderExtensionInit (void) -{ - ExtensionEntry *extEntry; - - if (!PictureType) - return; - if (!PictureFinishInit ()) - return; - RenderClientPrivateIndex = AllocateClientPrivateIndex (); - if (!AllocateClientPrivate (RenderClientPrivateIndex, - sizeof (RenderClientRec))) - return; - if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0)) - return; - - extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors, - ProcRenderDispatch, SProcRenderDispatch, - RenderResetProc, StandardMinorOpcode); - if (!extEntry) - return; -#if 0 - RenderReqCode = (CARD8) extEntry->base; -#endif - RenderErrBase = extEntry->errorBase; -} - -static void -RenderResetProc (ExtensionEntry *extEntry) -{ - ResetPicturePrivateIndex(); - ResetGlyphSetPrivateIndex(); -} - static int ProcRenderQueryVersion (ClientPtr client) { @@ -408,43 +155,6 @@ ProcRenderQueryVersion (ClientPtr client) return (client->noClientException); } -#if 0 -static int -VisualDepth (ScreenPtr pScreen, VisualPtr pVisual) -{ - DepthPtr pDepth; - int d, v; - - for (d = 0; d < pScreen->numDepths; d++) - { - pDepth = pScreen->allowedDepths + d; - for (v = 0; v < pDepth->numVids; v++) - { - if (pDepth->vids[v] == pVisual->vid) - return pDepth->depth; - } - } - return 0; -} -#endif - -static VisualPtr -findVisual (ScreenPtr pScreen, VisualID vid) -{ - VisualPtr pVisual; - int v; - - for (v = 0; v < pScreen->numVisuals; v++) - { - pVisual = pScreen->visuals + v; - if (pVisual->vid == vid) - return pVisual; - } - return 0; -} - -extern char *ConnectionInfo; - static int ProcRenderQueryPictFormats (ClientPtr client) { @@ -657,76 +367,6 @@ ProcRenderQueryPictFormats (ClientPtr client) } static int -ProcRenderQueryPictIndexValues (ClientPtr client) -{ - PictFormatPtr pFormat; - int num; - int rlength; - int i, n; - REQUEST(xRenderQueryPictIndexValuesReq); - xRenderQueryPictIndexValuesReply *reply; - xIndexValue *values; - - REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); - - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->format, - PictFormatType, - SecurityReadAccess); - - if (!pFormat) - { - client->errorValue = stuff->format; - return RenderErrBase + BadPictFormat; - } - if (pFormat->type != PictTypeIndexed) - { - client->errorValue = stuff->format; - return BadMatch; - } - num = pFormat->index.nvalues; - rlength = (sizeof (xRenderQueryPictIndexValuesReply) + - num * sizeof(xIndexValue)); - reply = (xRenderQueryPictIndexValuesReply *) xalloc (rlength); - if (!reply) - return BadAlloc; - - reply->type = X_Reply; - reply->sequenceNumber = client->sequence; - reply->length = (rlength - sizeof(xGenericReply)) >> 2; - reply->numIndexValues = num; - - values = (xIndexValue *) (reply + 1); - - memcpy (reply + 1, pFormat->index.pValues, num * sizeof (xIndexValue)); - - if (client->swapped) - { - for (i = 0; i < num; i++) - { - swapl (&values[i].pixel, n); - swaps (&values[i].red, n); - swaps (&values[i].green, n); - swaps (&values[i].blue, n); - swaps (&values[i].alpha, n); - } - swaps (&reply->sequenceNumber, n); - swapl (&reply->length, n); - swapl (&reply->numIndexValues, n); - } - - WriteToClient(client, rlength, (char *) reply); - xfree(reply); - return (client->noClientException); -} - -static int -ProcRenderQueryDithers (ClientPtr client) -{ - return BadImplementation; -} - -static int ProcRenderCreatePicture (ClientPtr client) { PicturePtr pPicture; @@ -836,33 +476,6 @@ ProcRenderSetPictureClipRectangles (ClientPtr client) return(result); } -static int -ProcRenderFreePicture (ClientPtr client) -{ - PicturePtr pPicture; - REQUEST(xRenderFreePictureReq); - - REQUEST_SIZE_MATCH(xRenderFreePictureReq); - - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityDestroyAccess, - RenderErrBase + BadPicture); - - FreeResource (stuff->picture, RT_NONE); - return(client->noClientException); -} - -static Bool -PictOpValid (CARD8 op) -{ - if (/*PictOpMinimum <= op && */ op <= PictOpMaximum) - return TRUE; - if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum) - return TRUE; - if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum) - return TRUE; - return FALSE; -} - /* * Check if both pictures have drawables which are * virtual pixmaps. See the corresponding define @@ -948,14 +561,8 @@ ProcRenderComposite (ClientPtr client) RenderErrBase + BadPicture); VERIFY_ALPHA (pMask, stuff->mask, client, SecurityReadAccess, RenderErrBase + BadPicture); -/* -FIXME: Imported change from newest version of Xorg. Changed pSrc to pDst. if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) || - (pMask && pMask->pDrawable && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen)) - return BadMatch; -*/ - if ((pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) || (pMask && pMask->pDrawable && pDst->pDrawable->pScreen != pMask->pDrawable->pScreen)) return BadMatch; @@ -1062,12 +669,6 @@ FIXME: Imported change from newest version of Xorg. Changed pSrc to pDst. } static int -ProcRenderScale (ClientPtr client) -{ - return BadImplementation; -} - -static int ProcRenderTrapezoids (ClientPtr client) { int ntraps; @@ -1139,165 +740,6 @@ ProcRenderTrapezoids (ClientPtr client) } static int -ProcRenderTriangles (ClientPtr client) -{ - int ntris; - PicturePtr pSrc, pDst; - PictFormatPtr pFormat; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - if (!PictOpValid (stuff->op)) - { - client->errorValue = stuff->op; - return BadValue; - } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pDst->pDrawable) - return BadDrawable; - if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) - return BadMatch; - if (stuff->maskFormat) - { - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->maskFormat, - PictFormatType, - SecurityReadAccess); - if (!pFormat) - { - client->errorValue = stuff->maskFormat; - return RenderErrBase + BadPictFormat; - } - } - else - pFormat = 0; - ntris = (client->req_len << 2) - sizeof (xRenderTrianglesReq); - if (ntris % sizeof (xTriangle)) - return BadLength; - ntris /= sizeof (xTriangle); - if (ntris) - CompositeTriangles (stuff->op, pSrc, pDst, pFormat, - stuff->xSrc, stuff->ySrc, - ntris, (xTriangle *) &stuff[1]); - return client->noClientException; -} - -static int -ProcRenderTriStrip (ClientPtr client) -{ - int npoints; - PicturePtr pSrc, pDst; - PictFormatPtr pFormat; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - if (!PictOpValid (stuff->op)) - { - client->errorValue = stuff->op; - return BadValue; - } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pDst->pDrawable) - return BadDrawable; - if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) - return BadMatch; - if (stuff->maskFormat) - { - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->maskFormat, - PictFormatType, - SecurityReadAccess); - if (!pFormat) - { - client->errorValue = stuff->maskFormat; - return RenderErrBase + BadPictFormat; - } - } - else - pFormat = 0; - npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); - if (npoints & 4) - return(BadLength); - npoints >>= 3; - if (npoints >= 3) - CompositeTriStrip (stuff->op, pSrc, pDst, pFormat, - stuff->xSrc, stuff->ySrc, - npoints, (xPointFixed *) &stuff[1]); - return client->noClientException; -} - -static int -ProcRenderTriFan (ClientPtr client) -{ - int npoints; - PicturePtr pSrc, pDst; - PictFormatPtr pFormat; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - if (!PictOpValid (stuff->op)) - { - client->errorValue = stuff->op; - return BadValue; - } - VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pDst->pDrawable) - return BadDrawable; - if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) - return BadMatch; - if (stuff->maskFormat) - { - pFormat = (PictFormatPtr) SecurityLookupIDByType (client, - stuff->maskFormat, - PictFormatType, - SecurityReadAccess); - if (!pFormat) - { - client->errorValue = stuff->maskFormat; - return RenderErrBase + BadPictFormat; - } - } - else - pFormat = 0; - npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); - if (npoints & 4) - return(BadLength); - npoints >>= 3; - if (npoints >= 3) - CompositeTriFan (stuff->op, pSrc, pDst, pFormat, - stuff->xSrc, stuff->ySrc, - npoints, (xPointFixed *) &stuff[1]); - return client->noClientException; -} - -static int -ProcRenderColorTrapezoids (ClientPtr client) -{ - return BadImplementation; -} - -static int -ProcRenderColorTriangles (ClientPtr client) -{ - return BadImplementation; -} - -static int -ProcRenderTransform (ClientPtr client) -{ - return BadImplementation; -} - -static int ProcRenderCreateGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; @@ -1377,9 +819,6 @@ ProcRenderReferenceGlyphSet (ClientPtr client) return client->noClientException; } -#define NLOCALDELTA 64 -#define NLOCALGLYPH 256 - static int ProcRenderFreeGlyphSet (ClientPtr client) { @@ -1403,127 +842,6 @@ ProcRenderFreeGlyphSet (ClientPtr client) return client->noClientException; } -typedef struct _GlyphNew { - Glyph id; - GlyphPtr glyph; -} GlyphNewRec, *GlyphNewPtr; - -static int -ProcRenderAddGlyphs (ClientPtr client) -{ - GlyphSetPtr glyphSet; - REQUEST(xRenderAddGlyphsReq); - GlyphNewRec glyphsLocal[NLOCALGLYPH]; - GlyphNewPtr glyphsBase, glyphs; - GlyphPtr glyph = NULL; - int remain, nglyphs; - CARD32 *gids; - xGlyphInfo *gi; - CARD8 *bits; - int size; - int err = BadAlloc; - - int totSizeImages; - - REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); - glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client, - stuff->glyphset, - GlyphSetType, - SecurityWriteAccess); - if (!glyphSet) - { - client->errorValue = stuff->glyphset; - return RenderErrBase + BadGlyphSet; - } - - nglyphs = stuff->nglyphs; - if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec)) - return BadAlloc; - - if (nglyphs <= NLOCALGLYPH) - glyphsBase = glyphsLocal; - else - { - glyphsBase = (GlyphNewPtr) Xalloc (nglyphs * sizeof (GlyphNewRec)); - if (!glyphsBase) - return BadAlloc; - } - - remain = (client->req_len << 2) - sizeof (xRenderAddGlyphsReq); - - glyphs = glyphsBase; - - totSizeImages = 0; - gids = (CARD32 *) (stuff + 1); - gi = (xGlyphInfo *) (gids + nglyphs); - bits = (CARD8 *) (gi + nglyphs); - remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; - - while (remain >= 0 && nglyphs) - { - glyph = AllocateGlyph (gi, glyphSet->fdepth); - if (!glyph) - { - err = BadAlloc; - goto bail; - } - - glyphs->glyph = glyph; - glyphs->id = *gids; - - size = glyph->size - sizeof (xGlyphInfo); - if (remain < size) - break; - memcpy ((CARD8 *) (glyph + 1), bits, size); - - if (size & 3) - size += 4 - (size & 3); - bits += size; - totSizeImages += size; - remain -= size; - gi++; - gids++; - glyphs++; - nglyphs--; - } - - if (nglyphs || remain) - { - err = BadLength; - goto bail; - } - nglyphs = stuff->nglyphs; - if (!ResizeGlyphSet (glyphSet, nglyphs)) - { - err = BadAlloc; - goto bail; - } - glyphs = glyphsBase; - while (nglyphs--) { - AddGlyph (glyphSet, glyphs->glyph, glyphs->id); - glyphs++; - } - - if (glyphsBase != glyphsLocal) - Xfree (glyphsBase); - return client->noClientException; -bail: - while (glyphs != glyphsBase) - { - --glyphs; - xfree (glyphs->glyph); - } - if (glyphsBase != glyphsLocal) - Xfree (glyphsBase); - return err; -} - -static int -ProcRenderAddGlyphsFromPicture (ClientPtr client) -{ - return BadImplementation; -} - static int ProcRenderFreeGlyphs (ClientPtr client) { @@ -1866,32 +1184,6 @@ ProcRenderFillRectangles (ClientPtr client) return client->noClientException; } -static void -SetBit (unsigned char *line, int x, int bit) -{ - unsigned char mask; - - if (screenInfo.bitmapBitOrder == LSBFirst) - mask = (1 << (x & 7)); - else - mask = (0x80 >> (x & 7)); - /* XXX assumes byte order is host byte order */ - line += (x >> 3); - if (bit) - *line |= mask; - else - *line &= ~mask; -} - -#define DITHER_DIM 2 - -static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = { - { 1, 3, }, - { 4, 2, }, -}; - -#define DITHER_SIZE ((sizeof orderedDither / sizeof orderedDither[0][0]) + 1) - static int ProcRenderCreateCursor (ClientPtr client) { @@ -2146,115 +1438,6 @@ ProcRenderSetPictureTransform (ClientPtr client) } static int -ProcRenderQueryFilters (ClientPtr client) -{ - REQUEST (xRenderQueryFiltersReq); - DrawablePtr pDrawable; - xRenderQueryFiltersReply *reply; - int nbytesName; - int nnames; - ScreenPtr pScreen; - PictureScreenPtr ps; - int i, j; - int len; - int total_bytes; - INT16 *aliases; - char *names; - - REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); - SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client, SecurityReadAccess); - - pScreen = pDrawable->pScreen; - nbytesName = 0; - nnames = 0; - ps = GetPictureScreenIfSet(pScreen); - if (ps) - { - for (i = 0; i < ps->nfilters; i++) - nbytesName += 1 + strlen (ps->filters[i].name); - for (i = 0; i < ps->nfilterAliases; i++) - nbytesName += 1 + strlen (ps->filterAliases[i].alias); - nnames = ps->nfilters + ps->nfilterAliases; - } - len = ((nnames + 1) >> 1) + ((nbytesName + 3) >> 2); - total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2); - reply = (xRenderQueryFiltersReply *) xalloc (total_bytes); - if (!reply) - return BadAlloc; - aliases = (INT16 *) (reply + 1); - names = (char *) (aliases + ((nnames + 1) & ~1)); - - reply->type = X_Reply; - reply->sequenceNumber = client->sequence; - reply->length = len; - reply->numAliases = nnames; - reply->numFilters = nnames; - if (ps) - { - - /* fill in alias values */ - for (i = 0; i < ps->nfilters; i++) - aliases[i] = FilterAliasNone; - for (i = 0; i < ps->nfilterAliases; i++) - { - for (j = 0; j < ps->nfilters; j++) - if (ps->filterAliases[i].filter_id == ps->filters[j].id) - break; - if (j == ps->nfilters) - { - for (j = 0; j < ps->nfilterAliases; j++) - if (ps->filterAliases[i].filter_id == - ps->filterAliases[j].alias_id) - { - break; - } - if (j == ps->nfilterAliases) - j = FilterAliasNone; - else - j = j + ps->nfilters; - } - aliases[i + ps->nfilters] = j; - } - - /* fill in filter names */ - for (i = 0; i < ps->nfilters; i++) - { - j = strlen (ps->filters[i].name); - *names++ = j; - strncpy (names, ps->filters[i].name, j); - names += j; - } - - /* fill in filter alias names */ - for (i = 0; i < ps->nfilterAliases; i++) - { - j = strlen (ps->filterAliases[i].alias); - *names++ = j; - strncpy (names, ps->filterAliases[i].alias, j); - names += j; - } - } - - if (client->swapped) - { - register int n; - - for (i = 0; i < (int)reply->numAliases; i++) - { - swaps (&aliases[i], n); - } - swaps(&reply->sequenceNumber, n); - swapl(&reply->length, n); - swapl(&reply->numAliases, n); - swapl(&reply->numFilters, n); - } - WriteToClient(client, total_bytes, (char *) reply); - xfree (reply); - - return(client->noClientException); -} - -static int ProcRenderSetPictureFilter (ClientPtr client) { REQUEST (xRenderSetPictureFilterReq); @@ -2329,29 +1512,6 @@ ProcRenderCreateAnimCursor (ClientPtr client) return BadAlloc; } -static int -ProcRenderAddTraps (ClientPtr client) -{ - int ntraps; - PicturePtr pPicture; - REQUEST(xRenderAddTrapsReq); - - REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); - VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - if (!pPicture->pDrawable) - return BadDrawable; - ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); - if (ntraps % sizeof (xTrap)) - return BadLength; - ntraps /= sizeof (xTrap); - if (ntraps) - AddTraps (pPicture, - stuff->xOff, stuff->yOff, - ntraps, (xTrap *) &stuff[1]); - return client->noClientException; -} - static int ProcRenderCreateSolidFill(ClientPtr client) { PicturePtr pPicture; @@ -2530,603 +1690,6 @@ ProcRenderDispatch (ClientPtr client) } static int -SProcRenderQueryVersion (ClientPtr client) -{ - register int n; - REQUEST(xRenderQueryVersionReq); - REQUEST_SIZE_MATCH(xRenderQueryVersionReq); - - swaps(&stuff->length, n); - swapl(&stuff->majorVersion, n); - swapl(&stuff->minorVersion, n); - return (*ProcRenderVector[stuff->renderReqType])(client); -} - -static int -SProcRenderQueryPictFormats (ClientPtr client) -{ - register int n; - REQUEST(xRenderQueryPictFormatsReq); - REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); - swaps(&stuff->length, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderQueryPictIndexValues (ClientPtr client) -{ - register int n; - REQUEST(xRenderQueryPictIndexValuesReq); - REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); - swaps(&stuff->length, n); - swapl(&stuff->format, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderQueryDithers (ClientPtr client) -{ - return BadImplementation; -} - -static int -SProcRenderCreatePicture (ClientPtr client) -{ - register int n; - REQUEST(xRenderCreatePictureReq); - REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->drawable, n); - swapl(&stuff->format, n); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderChangePicture (ClientPtr client) -{ - register int n; - REQUEST(xRenderChangePictureReq); - REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swapl(&stuff->mask, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderSetPictureClipRectangles (ClientPtr client) -{ - register int n; - REQUEST(xRenderSetPictureClipRectanglesReq); - REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - SwapRestS(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderFreePicture (ClientPtr client) -{ - register int n; - REQUEST(xRenderFreePictureReq); - REQUEST_SIZE_MATCH(xRenderFreePictureReq); - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderComposite (ClientPtr client) -{ - register int n; - REQUEST(xRenderCompositeReq); - REQUEST_SIZE_MATCH(xRenderCompositeReq); - swaps(&stuff->length, n); - swapl(&stuff->src, n); - swapl(&stuff->mask, n); - swapl(&stuff->dst, n); - swaps(&stuff->xSrc, n); - swaps(&stuff->ySrc, n); - swaps(&stuff->xMask, n); - swaps(&stuff->yMask, n); - swaps(&stuff->xDst, n); - swaps(&stuff->yDst, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderScale (ClientPtr client) -{ - register int n; - REQUEST(xRenderScaleReq); - REQUEST_SIZE_MATCH(xRenderScaleReq); - swaps(&stuff->length, n); - swapl(&stuff->src, n); - swapl(&stuff->dst, n); - swapl(&stuff->colorScale, n); - swapl(&stuff->alphaScale, n); - swaps(&stuff->xSrc, n); - swaps(&stuff->ySrc, n); - swaps(&stuff->xDst, n); - swaps(&stuff->yDst, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTrapezoids (ClientPtr client) -{ - register int n; - REQUEST(xRenderTrapezoidsReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTriangles (ClientPtr client) -{ - register int n; - REQUEST(xRenderTrianglesReq); - - REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTriStrip (ClientPtr client) -{ - register int n; - REQUEST(xRenderTriStripReq); - - REQUEST_AT_LEAST_SIZE(xRenderTriStripReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderTriFan (ClientPtr client) -{ - register int n; - REQUEST(xRenderTriFanReq); - - REQUEST_AT_LEAST_SIZE(xRenderTriFanReq); - swaps (&stuff->length, n); - swapl (&stuff->src, n); - swapl (&stuff->dst, n); - swapl (&stuff->maskFormat, n); - swaps (&stuff->xSrc, n); - swaps (&stuff->ySrc, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderColorTrapezoids (ClientPtr client) -{ - return BadImplementation; -} - -static int -SProcRenderColorTriangles (ClientPtr client) -{ - return BadImplementation; -} - -static int -SProcRenderTransform (ClientPtr client) -{ - return BadImplementation; -} - -static int -SProcRenderCreateGlyphSet (ClientPtr client) -{ - register int n; - REQUEST(xRenderCreateGlyphSetReq); - REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq); - swaps(&stuff->length, n); - swapl(&stuff->gsid, n); - swapl(&stuff->format, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderReferenceGlyphSet (ClientPtr client) -{ - register int n; - REQUEST(xRenderReferenceGlyphSetReq); - REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq); - swaps(&stuff->length, n); - swapl(&stuff->gsid, n); - swapl(&stuff->existing, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderFreeGlyphSet (ClientPtr client) -{ - register int n; - REQUEST(xRenderFreeGlyphSetReq); - REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); - swaps(&stuff->length, n); - swapl(&stuff->glyphset, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderAddGlyphs (ClientPtr client) -{ - register int n; - register unsigned int i; - CARD32 *gids; - void *end; - xGlyphInfo *gi; - REQUEST(xRenderAddGlyphsReq); - REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq); - swaps(&stuff->length, n); - swapl(&stuff->glyphset, n); - swapl(&stuff->nglyphs, n); - if (stuff->nglyphs & 0xe0000000) - return BadLength; - end = (CARD8 *) stuff + (client->req_len << 2); - gids = (CARD32 *) (stuff + 1); - gi = (xGlyphInfo *) (gids + stuff->nglyphs); - if ((char *) end - (char *) (gids + stuff->nglyphs) < 0) - return BadLength; - if ((char *) end - (char *) (gi + stuff->nglyphs) < 0) - return BadLength; - for (i = 0; i < stuff->nglyphs; i++) - { - swapl (&gids[i], n); - swaps (&gi[i].width, n); - swaps (&gi[i].height, n); - swaps (&gi[i].x, n); - swaps (&gi[i].y, n); - swaps (&gi[i].xOff, n); - swaps (&gi[i].yOff, n); - } - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderAddGlyphsFromPicture (ClientPtr client) -{ - return BadImplementation; -} - -static int -SProcRenderFreeGlyphs (ClientPtr client) -{ - register int n; - REQUEST(xRenderFreeGlyphsReq); - REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); - swaps(&stuff->length, n); - swapl(&stuff->glyphset, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCompositeGlyphs (ClientPtr client) -{ - register int n; - xGlyphElt *elt; - CARD8 *buffer; - CARD8 *end; - int space; - int i; - int size; - - REQUEST(xRenderCompositeGlyphsReq); - REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); - - switch (stuff->renderReqType) { - default: size = 1; break; - case X_RenderCompositeGlyphs16: size = 2; break; - case X_RenderCompositeGlyphs32: size = 4; break; - } - - swaps(&stuff->length, n); - swapl(&stuff->src, n); - swapl(&stuff->dst, n); - swapl(&stuff->maskFormat, n); - swapl(&stuff->glyphset, n); - swaps(&stuff->xSrc, n); - swaps(&stuff->ySrc, n); - buffer = (CARD8 *) (stuff + 1); - end = (CARD8 *) stuff + (client->req_len << 2); - while (buffer + sizeof (xGlyphElt) < end) - { - elt = (xGlyphElt *) buffer; - buffer += sizeof (xGlyphElt); - - swaps (&elt->deltax, n); - swaps (&elt->deltay, n); - - i = elt->len; - if (i == 0xff) - { - swapl (buffer, n); - buffer += 4; - } - else - { - space = size * i; - switch (size) { - case 1: - buffer += i; - break; - case 2: - while (i--) - { - swaps (buffer, n); - buffer += 2; - } - break; - case 4: - while (i--) - { - swapl (buffer, n); - buffer += 4; - } - break; - } - if (space & 3) - buffer += 4 - (space & 3); - } - } - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderFillRectangles (ClientPtr client) -{ - register int n; - REQUEST(xRenderFillRectanglesReq); - - REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); - swaps(&stuff->length, n); - swapl(&stuff->dst, n); - swaps(&stuff->color.red, n); - swaps(&stuff->color.green, n); - swaps(&stuff->color.blue, n); - swaps(&stuff->color.alpha, n); - SwapRestS(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateCursor (ClientPtr client) -{ - register int n; - REQUEST(xRenderCreateCursorReq); - REQUEST_SIZE_MATCH (xRenderCreateCursorReq); - - swaps(&stuff->length, n); - swapl(&stuff->cid, n); - swapl(&stuff->src, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderSetPictureTransform (ClientPtr client) -{ - register int n; - REQUEST(xRenderSetPictureTransformReq); - REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); - - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swapl(&stuff->transform.matrix11, n); - swapl(&stuff->transform.matrix12, n); - swapl(&stuff->transform.matrix13, n); - swapl(&stuff->transform.matrix21, n); - swapl(&stuff->transform.matrix22, n); - swapl(&stuff->transform.matrix23, n); - swapl(&stuff->transform.matrix31, n); - swapl(&stuff->transform.matrix32, n); - swapl(&stuff->transform.matrix33, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderQueryFilters (ClientPtr client) -{ - register int n; - REQUEST (xRenderQueryFiltersReq); - REQUEST_SIZE_MATCH (xRenderQueryFiltersReq); - - swaps(&stuff->length, n); - swapl(&stuff->drawable, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderSetPictureFilter (ClientPtr client) -{ - register int n; - REQUEST (xRenderSetPictureFilterReq); - REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq); - - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swaps(&stuff->nbytes, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateAnimCursor (ClientPtr client) -{ - register int n; - REQUEST (xRenderCreateAnimCursorReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateAnimCursorReq); - - swaps(&stuff->length, n); - swapl(&stuff->cid, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderAddTraps (ClientPtr client) -{ - register int n; - REQUEST (xRenderAddTrapsReq); - REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); - - swaps(&stuff->length, n); - swapl(&stuff->picture, n); - swaps(&stuff->xOff, n); - swaps(&stuff->yOff, n); - SwapRestL(stuff); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateSolidFill(ClientPtr client) -{ - register int n; - REQUEST (xRenderCreateSolidFillReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateSolidFillReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swaps(&stuff->color.alpha, n); - swaps(&stuff->color.red, n); - swaps(&stuff->color.green, n); - swaps(&stuff->color.blue, n); - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static void swapStops(void *stuff, int num) -{ - int i, n; - CARD32 *stops; - stops = (CARD32 *)(stuff); - for (i = 0; i < num; ++i) { - swapl(stops, n); - ++stops; - } - for (i = 0; i < 4*num; ++i) { - swaps(stops, n); - ++stops; - } -} - -static int -SProcRenderCreateLinearGradient (ClientPtr client) -{ - register int n; - int len; - REQUEST (xRenderCreateLinearGradientReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateLinearGradientReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->p1.x, n); - swapl(&stuff->p1.y, n); - swapl(&stuff->p2.x, n); - swapl(&stuff->p2.y, n); - swapl(&stuff->nStops, n); - - len = (client->req_len << 2) - sizeof(xRenderCreateLinearGradientReq); - if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - swapStops(stuff+1, stuff->nStops); - - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateRadialGradient (ClientPtr client) -{ - register int n; - int len; - REQUEST (xRenderCreateRadialGradientReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateRadialGradientReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->inner.x, n); - swapl(&stuff->inner.y, n); - swapl(&stuff->outer.x, n); - swapl(&stuff->outer.y, n); - swapl(&stuff->inner_radius, n); - swapl(&stuff->outer_radius, n); - swapl(&stuff->nStops, n); - - len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); - if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - swapStops(stuff+1, stuff->nStops); - - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int -SProcRenderCreateConicalGradient (ClientPtr client) -{ - register int n; - int len; - REQUEST (xRenderCreateConicalGradientReq); - REQUEST_AT_LEAST_SIZE (xRenderCreateConicalGradientReq); - - swaps(&stuff->length, n); - swapl(&stuff->pid, n); - swapl(&stuff->center.x, n); - swapl(&stuff->center.y, n); - swapl(&stuff->angle, n); - swapl(&stuff->nStops, n); - - len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq); - if (stuff->nStops > UINT32_MAX/(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) - return BadLength; - - swapStops(stuff+1, stuff->nStops); - - return (*ProcRenderVector[stuff->renderReqType]) (client); -} - -static int SProcRenderDispatch (ClientPtr client) { int result; @@ -3162,716 +1725,3 @@ SProcRenderDispatch (ClientPtr client) else return BadRequest; } - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" - -#define VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err) {\ - pPicture = SecurityLookupIDByType(client, pid, XRT_PICTURE, mode);\ - if (!pPicture) { \ - client->errorValue = pid; \ - return err; \ - } \ -} - -#define VERIFY_XIN_ALPHA(pPicture, pid, client, mode, err) {\ - if (pid == None) \ - pPicture = 0; \ - else { \ - VERIFY_XIN_PICTURE(pPicture, pid, client, mode, err); \ - } \ -} \ - -int (*PanoramiXSaveRenderVector[RenderNumberRequests])(ClientPtr); - -unsigned long XRT_PICTURE; - -static int -PanoramiXRenderCreatePicture (ClientPtr client) -{ - REQUEST(xRenderCreatePictureReq); - PanoramiXRes *refDraw, *newPict; - int result = Success, j; - - REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); - if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - if(!(newPict = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) - return BadAlloc; - newPict->type = XRT_PICTURE; - newPict->info[0].id = stuff->pid; - - if (refDraw->type == XRT_WINDOW && - stuff->drawable == screenInfo.screens[0]->root->drawable.id) - { - newPict->u.pict.root = TRUE; - } - else - newPict->u.pict.root = FALSE; - - for(j = 1; j < PanoramiXNumScreens; j++) - newPict->info[j].id = FakeClientID(client->index); - - FOR_NSCREENS_BACKWARD(j) { - stuff->pid = newPict->info[j].id; - stuff->drawable = refDraw->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture]) (client); - if(result != Success) break; - } - - if (result == Success) - AddResource(newPict->info[0].id, XRT_PICTURE, newPict); - else - xfree(newPict); - - return (result); -} - -static int -PanoramiXRenderChangePicture (ClientPtr client) -{ - PanoramiXRes *pict; - int result = Success, j; - REQUEST(xRenderChangePictureReq); - - REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderSetPictureClipRectangles (ClientPtr client) -{ - REQUEST(xRenderSetPictureClipRectanglesReq); - int result = Success, j; - PanoramiXRes *pict; - - REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderSetPictureTransform (ClientPtr client) -{ - REQUEST(xRenderSetPictureTransformReq); - int result = Success, j; - PanoramiXRes *pict; - - REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderSetPictureFilter (ClientPtr client) -{ - REQUEST(xRenderSetPictureFilterReq); - int result = Success, j; - PanoramiXRes *pict; - - REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq); - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client); - if(result != Success) break; - } - - return (result); -} - -static int -PanoramiXRenderFreePicture (ClientPtr client) -{ - PanoramiXRes *pict; - int result = Success, j; - REQUEST(xRenderFreePictureReq); - - REQUEST_SIZE_MATCH(xRenderFreePictureReq); - - client->errorValue = stuff->picture; - - VERIFY_XIN_PICTURE(pict, stuff->picture, client, SecurityDestroyAccess, - RenderErrBase + BadPicture); - - - FOR_NSCREENS_BACKWARD(j) { - stuff->picture = pict->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client); - if(result != Success) break; - } - - /* Since ProcRenderFreePicture is using FreeResource, it will free - our resource for us on the last pass through the loop above */ - - return (result); -} - -static int -PanoramiXRenderComposite (ClientPtr client) -{ - PanoramiXRes *src, *msk, *dst; - int result = Success, j; - xRenderCompositeReq orig; - REQUEST(xRenderCompositeReq); - - REQUEST_SIZE_MATCH(xRenderCompositeReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_ALPHA (msk, stuff->mask, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - orig = *stuff; - - FOR_NSCREENS_FORWARD(j) { - stuff->src = src->info[j].id; - if (src->u.pict.root) - { - stuff->xSrc = orig.xSrc - panoramiXdataPtr[j].x; - stuff->ySrc = orig.ySrc - panoramiXdataPtr[j].y; - } - stuff->dst = dst->info[j].id; - if (dst->u.pict.root) - { - stuff->xDst = orig.xDst - panoramiXdataPtr[j].x; - stuff->yDst = orig.yDst - panoramiXdataPtr[j].y; - } - if (msk) - { - stuff->mask = msk->info[j].id; - if (msk->u.pict.root) - { - stuff->xMask = orig.xMask - panoramiXdataPtr[j].x; - stuff->yMask = orig.yMask - panoramiXdataPtr[j].y; - } - } - result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client); - if(result != Success) break; - } - - return result; -} - -static int -PanoramiXRenderCompositeGlyphs (ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderCompositeGlyphsReq); - xGlyphElt origElt, *elt; - INT16 xSrc, ySrc; - - REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - if (client->req_len << 2 >= (sizeof (xRenderCompositeGlyphsReq) + - sizeof (xGlyphElt))) - { - elt = (xGlyphElt *) (stuff + 1); - origElt = *elt; - xSrc = stuff->xSrc; - ySrc = stuff->ySrc; - FOR_NSCREENS_FORWARD(j) { - stuff->src = src->info[j].id; - if (src->u.pict.root) - { - stuff->xSrc = xSrc - panoramiXdataPtr[j].x; - stuff->ySrc = ySrc - panoramiXdataPtr[j].y; - } - stuff->dst = dst->info[j].id; - if (dst->u.pict.root) - { - elt->deltax = origElt.deltax - panoramiXdataPtr[j].x; - elt->deltay = origElt.deltay - panoramiXdataPtr[j].y; - } - result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client); - if(result != Success) break; - } - } - - return result; -} - -static int -PanoramiXRenderFillRectangles (ClientPtr client) -{ - PanoramiXRes *dst; - int result = Success, j; - REQUEST(xRenderFillRectanglesReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq); - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) - { - memcpy (extra, stuff + 1, extra_len); - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) - { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xRectangle *rects = (xRectangle *) (stuff + 1); - int i = extra_len / sizeof (xRectangle); - - while (i--) - { - rects->x -= x_off; - rects->y -= y_off; - rects++; - } - } - } - stuff->dst = dst->info[j].id; - result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client); - if(result != Success) break; - } - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTrapezoids(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTrapezoidsReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTrapezoidsReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xTrapezoid *trap = (xTrapezoid *) (stuff + 1); - int i = extra_len / sizeof (xTrapezoid); - - while (i--) { - trap->top -= y_off; - trap->bottom -= y_off; - trap->left.p1.x -= x_off; - trap->left.p1.y -= y_off; - trap->left.p2.x -= x_off; - trap->left.p2.y -= y_off; - trap->right.p1.x -= x_off; - trap->right.p1.y -= y_off; - trap->right.p2.x -= x_off; - trap->right.p2.y -= y_off; - trap++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTriangles(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTrianglesReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTrianglesReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xTriangle *tri = (xTriangle *) (stuff + 1); - int i = extra_len / sizeof (xTriangle); - - while (i--) { - tri->p1.x -= x_off; - tri->p1.y -= y_off; - tri->p2.x -= x_off; - tri->p2.y -= y_off; - tri->p3.x -= x_off; - tri->p3.y -= y_off; - tri++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTriangles]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTriStrip(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTriStripReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTriStripReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xPointFixed *fixed = (xPointFixed *) (stuff + 1); - int i = extra_len / sizeof (xPointFixed); - - while (i--) { - fixed->x -= x_off; - fixed->y -= y_off; - fixed++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderTriFan(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderTriFanReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderTriFanReq); - - VERIFY_XIN_PICTURE (src, stuff->src, client, SecurityReadAccess, - RenderErrBase + BadPicture); - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - xPointFixed *fixed = (xPointFixed *) (stuff + 1); - int i = extra_len / sizeof (xPointFixed); - - while (i--) { - fixed->x -= x_off; - fixed->y -= y_off; - fixed++; - } - } - } - - stuff->src = src->info[j].id; - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderTriFan]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -#if 0 /* Not implemented yet */ - -static int -PanoramiXRenderColorTrapezoids(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderColorTrapezoidsReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderColorTrapezoidsReq); - - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderColorTrapezoidsReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - ....; - } - } - - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderColorTrapezoids]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -static int -PanoramiXRenderColorTriangles(ClientPtr client) -{ - PanoramiXRes *src, *dst; - int result = Success, j; - REQUEST(xRenderColorTrianglesReq); - char *extra; - int extra_len; - - REQUEST_AT_LEAST_SIZE (xRenderColorTrianglesReq); - - VERIFY_XIN_PICTURE (dst, stuff->dst, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - - extra_len = (client->req_len << 2) - sizeof (xRenderColorTrianglesReq); - - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) { - memcpy (extra, stuff + 1, extra_len); - - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - if (dst->u.pict.root) { - int x_off = panoramiXdataPtr[j].x; - int y_off = panoramiXdataPtr[j].y; - - if(x_off || y_off) { - ....; - } - } - - stuff->dst = dst->info[j].id; - result = - (*PanoramiXSaveRenderVector[X_RenderColorTriangles]) (client); - - if(result != Success) break; - } - - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -#endif - -static int -PanoramiXRenderAddTraps (ClientPtr client) -{ - PanoramiXRes *picture; - int result = Success, j; - REQUEST(xRenderAddTrapsReq); - char *extra; - int extra_len; - INT16 x_off, y_off; - - REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); - VERIFY_XIN_PICTURE (picture, stuff->picture, client, SecurityWriteAccess, - RenderErrBase + BadPicture); - extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); - if (extra_len && - (extra = (char *) ALLOCATE_LOCAL (extra_len))) - { - memcpy (extra, stuff + 1, extra_len); - x_off = stuff->xOff; - y_off = stuff->yOff; - FOR_NSCREENS_FORWARD(j) { - if (j) memcpy (stuff + 1, extra, extra_len); - stuff->picture = picture->info[j].id; - - if (picture->u.pict.root) - { - stuff->xOff = x_off + panoramiXdataPtr[j].x; - stuff->yOff = y_off + panoramiXdataPtr[j].y; - } - result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client); - if(result != Success) break; - } - DEALLOCATE_LOCAL(extra); - } - - return result; -} - -void -PanoramiXRenderInit (void) -{ - int i; - - XRT_PICTURE = CreateNewResourceType (XineramaDeleteResource); - for (i = 0; i < RenderNumberRequests; i++) - PanoramiXSaveRenderVector[i] = ProcRenderVector[i]; - /* - * Stuff in Xinerama aware request processing hooks - */ - ProcRenderVector[X_RenderCreatePicture] = PanoramiXRenderCreatePicture; - ProcRenderVector[X_RenderChangePicture] = PanoramiXRenderChangePicture; - ProcRenderVector[X_RenderSetPictureTransform] = PanoramiXRenderSetPictureTransform; - ProcRenderVector[X_RenderSetPictureFilter] = PanoramiXRenderSetPictureFilter; - ProcRenderVector[X_RenderSetPictureClipRectangles] = PanoramiXRenderSetPictureClipRectangles; - ProcRenderVector[X_RenderFreePicture] = PanoramiXRenderFreePicture; - ProcRenderVector[X_RenderComposite] = PanoramiXRenderComposite; - ProcRenderVector[X_RenderCompositeGlyphs8] = PanoramiXRenderCompositeGlyphs; - ProcRenderVector[X_RenderCompositeGlyphs16] = PanoramiXRenderCompositeGlyphs; - ProcRenderVector[X_RenderCompositeGlyphs32] = PanoramiXRenderCompositeGlyphs; - ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles; - - ProcRenderVector[X_RenderTrapezoids] = PanoramiXRenderTrapezoids; - ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles; - ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip; - ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan; - ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps; -} - -void -PanoramiXRenderReset (void) -{ - int i; - for (i = 0; i < RenderNumberRequests; i++) - ProcRenderVector[i] = PanoramiXSaveRenderVector[i]; -} - -#endif /* PANORAMIX */ - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXresource.c b/nx-X11/programs/Xserver/hw/nxagent/NXresource.c index 96bbde00c..38bc05e51 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXresource.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXresource.c @@ -118,31 +118,7 @@ Equipment Corporation. */ /* $XFree86: xc/programs/Xserver/dix/resource.c,v 3.13 2003/09/24 02:43:13 dawes Exp $ */ -#define NEED_EVENTS -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#include "misc.h" -#include "os.h" -#include "resource.h" -#include "dixstruct.h" -#include "opaque.h" -#include "windowstr.h" -#include "dixfont.h" -#include "colormap.h" -#include "inputstr.h" -#include "dixevents.h" -#include "dixgrabs.h" -#include "cursor.h" -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif -#include <assert.h> - -#ifdef NXAGENT_SERVER +#include "../../dix/resource.c" #include "Agent.h" #include "Font.h" @@ -154,311 +130,11 @@ Equipment Corporation. #undef TEST #undef DEBUG -#endif - -static void RebuildTable( - int /*client*/ -); - -#define SERVER_MINID 32 - -#define INITBUCKETS 64 -#define INITHASHSIZE 6 -#define MAXHASHSIZE 11 - -typedef struct _Resource { - struct _Resource *next; - XID id; - RESTYPE type; - void * value; -} ResourceRec, *ResourcePtr; -#define NullResource ((ResourcePtr)NULL) - -typedef struct _ClientResource { - ResourcePtr *resources; - int elements; - int buckets; - int hashsize; /* log(2)(buckets) */ - XID fakeID; - XID endFakeID; - XID expectID; -} 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 - #ifdef NXAGENT_SERVER static int nxagentResChangedFlag = 0; #endif -RESTYPE -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; - } -#endif - - lastResourceType = next; - DeleteFuncs = funcs; - DeleteFuncs[next] = deleteFunc; - return next; -} - -RESTYPE -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(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; - DeleteFuncs[RT_COLORMAP & TypeMask] = FreeColormap; - DeleteFuncs[RT_CMAPENTRY & TypeMask] = FreeClientPixels; - DeleteFuncs[RT_OTHERCLIENT & TypeMask] = OtherClientGone; - DeleteFuncs[RT_PASSIVEGRAB & TypeMask] = DeletePassiveGrab; - -#ifdef XResExtension - if(ResourceNames) - xfree(ResourceNames); - ResourceNames = xalloc((lastResourceType + 1) * sizeof(Atom)); - if(!ResourceNames) - return FALSE; -#endif - } - clientTable[i = client->index].resources = - (ResourcePtr *)xalloc(INITBUCKETS*sizeof(ResourcePtr)); - if (!clientTable[i].resources) - return FALSE; - clientTable[i].buckets = INITBUCKETS; - clientTable[i].elements = 0; - clientTable[i].hashsize = INITHASHSIZE; - /* Many IDs allocated from the server client are visible to clients, - * so we don't use the SERVER_BIT for them, but we have to start - * past the magic value constants used in the protocol. For normal - * clients, we can start from zero, with SERVER_BIT set. - */ - clientTable[i].fakeID = client->clientAsMask | - (client->index ? SERVER_BIT : SERVER_MINID); - clientTable[i].endFakeID = (clientTable[i].fakeID | RESOURCE_ID_MASK) + 1; - clientTable[i].expectID = client->clientAsMask; - for (j=0; j<INITBUCKETS; j++) - { - clientTable[i].resources[j] = NullResource; - } - return TRUE; -} - - -static int -Hash(int client, register XID id) -{ - id &= RESOURCE_ID_MASK; - switch (clientTable[client].hashsize) - { - case 6: - return ((int)(0x03F & (id ^ (id>>6) ^ (id>>12)))); - case 7: - return ((int)(0x07F & (id ^ (id>>7) ^ (id>>13)))); - case 8: - return ((int)(0x0FF & (id ^ (id>>8) ^ (id>>16)))); - case 9: - return ((int)(0x1FF & (id ^ (id>>9)))); - case 10: - return ((int)(0x3FF & (id ^ (id>>10)))); - case 11: - return ((int)(0x7FF & (id ^ (id>>11)))); - } - return -1; -} - -static XID -AvailableID( - register int client, - 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(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. - * 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(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(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; -} - #ifdef NXAGENT_SERVER - int nxagentFindClientResource(int client, RESTYPE type, void * value) { ResourcePtr pResource; @@ -548,8 +224,7 @@ int nxagentSwitchResourceType(int client, RESTYPE type, void * value) return 0; } - -#endif +#endif /* NXAGENT_SERVER */ Bool AddResource(XID id, RESTYPE type, void * value) @@ -602,55 +277,6 @@ AddResource(XID id, RESTYPE type, void * value) return TRUE; } -static void -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; - } - for (rptr = resources, tptr = tails; --j >= 0; rptr++, tptr++) - { - *rptr = NullResource; - *tptr = rptr; - } - clientTable[client].hashsize++; - for (j = clientTable[client].buckets, - 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(XID id, RESTYPE skipDeleteFuncType) { @@ -732,32 +358,6 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree) } } -/* - * Change the value associated with a resource id. Caller - * is responsible for "doing the right thing" with the old - * data - */ - -Bool -ChangeResourceValue (XID id, RESTYPE rtype, void * 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)) - { - res->value = value; - return TRUE; - } - } - return FALSE; -} - /* Note: if func adds or deletes resources, then func can get called * more than once for some resources. If func adds new resources, * func might or might not get called for them. func cannot both @@ -988,243 +588,3 @@ RestartLoop: } return NULL; } - - -void -FreeClientNeverRetainResources(ClientPtr client) -{ - ResourcePtr *resources; - ResourcePtr this; - ResourcePtr *prev; - int j; - - if (!client) - return; - - resources = clientTable[client->index].resources; - for (j=0; j < clientTable[client->index].buckets; j++) - { - prev = &resources[j]; - while ( (this = *prev) ) - { - RESTYPE rtype = this->type; - if (rtype & RC_NEVERRETAIN) - { - *prev = this->next; - (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); - xfree(this); - } - else - prev = &this->next; - } - } -} - -void -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 - case), so the resource list must be kept valid up to the point that - it is deleted, so every time we delete a resource, we must update the - head, just like in FreeResource. I hope that this doesn't slow down - mass deletion appreciably. PRH */ - - ResourcePtr *head; - - head = &resources[j]; - - for (this = *head; this; this = *head) - { - RESTYPE rtype = this->type; - *head = this->next; - (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); - xfree(this); - } - } - 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(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. - */ - -void * -SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode) -{ - int cid; - register ResourcePtr res; - void * 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; -} - - -void * -SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode) -{ - int cid; - register ResourcePtr res = NULL; - void * 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. - */ - -void * -LookupIDByType(XID id, RESTYPE rtype) -{ - return SecurityLookupIDByType(NullClient, id, rtype, - SecurityUnknownAccess); -} - -void * -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. - */ -void * -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 (void *)NULL; -} - -/* - * LookupIDByClass returns the object with the given id and any one of the - * given classes, else NULL. - */ -void * -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 (void *)NULL; -} - -#endif /* XCSECURITY */ - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c index 95905fde7..d2ff7fd8f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c @@ -46,55 +46,16 @@ in this Software without prior written authorization from The Open Group. /* $Xorg: shm.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */ -#define SHM - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <sys/types.h> -#ifndef Lynx -#include <sys/ipc.h> -#include <sys/shm.h> -#else -#include <ipc.h> -#include <shm.h> -#endif -#include <unistd.h> -#include <sys/stat.h> -#define NEED_REPLIES -#define NEED_EVENTS #include <nx-X11/X.h> -#include <nx-X11/Xproto.h> -#include "misc.h" -#include "os.h" -#include "dixstruct.h" -#include "resource.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "gcstruct.h" -#include "extnsionst.h" -#include "servermd.h" -#define _XSHM_SERVER_ -#include <nx-X11/extensions/shmstr.h> -#include <nx-X11/Xfuncproto.h> -#ifdef EXTMODULE -#include "xf86_ansic.h" -#endif - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" -#endif - -#include "modinit.h" #include "Trap.h" #include "Agent.h" + #include "Drawable.h" #include "Pixmaps.h" +#include "../../Xext/shm.c" + /* * Set here the required log level. */ @@ -115,135 +76,6 @@ extern void fbPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *pImage); -typedef struct _ShmDesc { - struct _ShmDesc *next; - int shmid; - int refcnt; - char *addr; - Bool writable; - unsigned long size; -} ShmDescRec, *ShmDescPtr; - -static void miShmPutImage(XSHM_PUT_IMAGE_ARGS); -static void fbShmPutImage(XSHM_PUT_IMAGE_ARGS); -static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS); -static int ShmDetachSegment( - void * /* value */, - XID /* shmseg */ - ); -static void ShmResetProc( - ExtensionEntry * /* extEntry */ - ); -static void SShmCompletionEvent( - xShmCompletionEvent * /* from */, - xShmCompletionEvent * /* to */ - ); - -static Bool ShmDestroyPixmap (PixmapPtr pPixmap); - -static DISPATCH_PROC(ProcShmAttach); -static DISPATCH_PROC(ProcShmCreatePixmap); -static DISPATCH_PROC(ProcShmDetach); -static DISPATCH_PROC(ProcShmDispatch); -static DISPATCH_PROC(ProcShmGetImage); -static DISPATCH_PROC(ProcShmPutImage); -static DISPATCH_PROC(ProcShmQueryVersion); -static DISPATCH_PROC(SProcShmAttach); -static DISPATCH_PROC(SProcShmCreatePixmap); -static DISPATCH_PROC(SProcShmDetach); -static DISPATCH_PROC(SProcShmDispatch); -static DISPATCH_PROC(SProcShmGetImage); -static DISPATCH_PROC(SProcShmPutImage); -static DISPATCH_PROC(SProcShmQueryVersion); - -static unsigned char ShmReqCode; -int ShmCompletionCode; -int BadShmSegCode; -RESTYPE ShmSegType; -static ShmDescPtr Shmsegs; -static Bool sharedPixmaps; -static int pixmapFormat; -static int shmPixFormat[MAXSCREENS]; -static ShmFuncsPtr shmFuncs[MAXSCREENS]; -static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS]; -#ifdef PIXPRIV -static int shmPixmapPrivate; -#endif -static ShmFuncs miFuncs = {NULL, miShmPutImage}; -static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage}; - -#define VERIFY_SHMSEG(shmseg,shmdesc,client) \ -{ \ - shmdesc = (ShmDescPtr)LookupIDByType(shmseg, ShmSegType); \ - if (!shmdesc) \ - { \ - client->errorValue = shmseg; \ - return BadShmSegCode; \ - } \ -} - -#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \ -{ \ - VERIFY_SHMSEG(shmseg, shmdesc, client); \ - if ((offset & 3) || (offset > shmdesc->size)) \ - { \ - client->errorValue = offset; \ - return BadValue; \ - } \ - if (needwrite && !shmdesc->writable) \ - return BadAccess; \ -} - -#define VERIFY_SHMSIZE(shmdesc,offset,len,client) \ -{ \ - if ((offset + len) > shmdesc->size) \ - { \ - return BadAccess; \ - } \ -} - - -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) -#include <sys/signal.h> - -static Bool badSysCall = FALSE; - -static void -SigSysHandler(signo) -int signo; -{ - badSysCall = TRUE; -} - -static Bool CheckForShmSyscall() -{ - void (*oldHandler)(); - int shmid = -1; - - /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ - oldHandler = signal(SIGSYS, SigSysHandler); - - badSysCall = FALSE; - shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); - - if (shmid != -1) - { - /* Successful allocation - clean up */ - shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL); - } - else - { - /* Allocation failed */ - badSysCall = TRUE; - } - signal(SIGSYS, oldHandler); - return(!badSysCall); -} - -#define MUST_CHECK_FOR_SHM_SYSCALL - -#endif - void ShmExtensionInit(INITARGS) { @@ -318,245 +150,6 @@ ShmExtensionInit(INITARGS) } } -/*ARGSUSED*/ -static void -ShmResetProc (extEntry) -ExtensionEntry *extEntry; -{ - int i; - - for (i = 0; i < MAXSCREENS; i++) - { - shmFuncs[i] = (ShmFuncsPtr)NULL; - shmPixFormat[i] = 0; - } -} - -void -ShmRegisterFuncs( - ScreenPtr pScreen, - ShmFuncsPtr funcs) -{ - shmFuncs[pScreen->myNum] = funcs; -} - -void -ShmSetPixmapFormat( - ScreenPtr pScreen, - int format) -{ - shmPixFormat[pScreen->myNum] = format; -} - -static Bool -ShmDestroyPixmap (PixmapPtr pPixmap) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - Bool ret; - if (pPixmap->refcnt == 1) - { - ShmDescPtr shmdesc; -#ifdef PIXPRIV - shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr; -#else - char *base = (char *) pPixmap->devPrivate.ptr; - - if (base != (void *) (pPixmap + 1)) - { - for (shmdesc = Shmsegs; shmdesc; shmdesc = shmdesc->next) - { - if (shmdesc->addr <= base && base <= shmdesc->addr + shmdesc->size) - break; - } - } - else - shmdesc = 0; -#endif - if (shmdesc) - ShmDetachSegment ((void *) shmdesc, pPixmap->drawable.id); - } - - pScreen->DestroyPixmap = destroyPixmap[pScreen->myNum]; - ret = (*pScreen->DestroyPixmap) (pPixmap); - destroyPixmap[pScreen->myNum] = pScreen->DestroyPixmap; - pScreen->DestroyPixmap = ShmDestroyPixmap; - return ret; -} - -void -ShmRegisterFbFuncs(pScreen) - ScreenPtr pScreen; -{ - #ifdef TEST - fprintf(stderr, "ShmRegisterFbFuncs: Registering shmFuncs as fbFuncs.\n"); - #endif - shmFuncs[pScreen->myNum] = &fbFuncs; -} - -static int -ProcShmQueryVersion(client) - register ClientPtr client; -{ - xShmQueryVersionReply rep; - register int n; - - REQUEST_SIZE_MATCH(xShmQueryVersionReq); - memset(&rep, 0, sizeof(xShmQueryVersionReply)); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.sharedPixmaps = sharedPixmaps; - rep.pixmapFormat = pixmapFormat; - rep.majorVersion = SHM_MAJOR_VERSION; - rep.minorVersion = SHM_MINOR_VERSION; - rep.uid = geteuid(); - rep.gid = getegid(); - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.majorVersion, n); - swaps(&rep.minorVersion, n); - swaps(&rep.uid, n); - swaps(&rep.gid, n); - } - WriteToClient(client, sizeof(xShmQueryVersionReply), (char *)&rep); - return (client->noClientException); -} - -/* - * Simulate the access() system call for a shared memory segement, - * using the credentials from the client if available - */ -static int -shm_access(ClientPtr client, struct ipc_perm *perm, int readonly) -{ - int uid, gid; - mode_t mask; - - if (LocalClientCred(client, &uid, &gid) != -1) { - - /* User id 0 always gets access */ - if (uid == 0) { - return 0; - } - /* Check the owner */ - if (perm->uid == uid || perm->cuid == uid) { - mask = S_IRUSR; - if (!readonly) { - mask |= S_IWUSR; - } - return (perm->mode & mask) == mask ? 0 : -1; - } - /* Check the group */ - if (perm->gid == gid || perm->cgid == gid) { - mask = S_IRGRP; - if (!readonly) { - mask |= S_IWGRP; - } - return (perm->mode & mask) == mask ? 0 : -1; - } - } - /* Otherwise, check everyone else */ - mask = S_IROTH; - if (!readonly) { - mask |= S_IWOTH; - } - return (perm->mode & mask) == mask ? 0 : -1; -} - -static int -ProcShmAttach(client) - register ClientPtr client; -{ - struct shmid_ds buf; - ShmDescPtr shmdesc; - REQUEST(xShmAttachReq); - - REQUEST_SIZE_MATCH(xShmAttachReq); - LEGAL_NEW_RESOURCE(stuff->shmseg, client); - if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) - { - client->errorValue = stuff->readOnly; - return(BadValue); - } - for (shmdesc = Shmsegs; - shmdesc && (shmdesc->shmid != stuff->shmid); - shmdesc = shmdesc->next) - ; - if (shmdesc) - { - if (!stuff->readOnly && !shmdesc->writable) - return BadAccess; - shmdesc->refcnt++; - } - else - { - shmdesc = (ShmDescPtr) xalloc(sizeof(ShmDescRec)); - if (!shmdesc) - return BadAlloc; - shmdesc->addr = shmat(stuff->shmid, 0, - stuff->readOnly ? SHM_RDONLY : 0); - if ((shmdesc->addr == ((char *)-1)) || - shmctl(stuff->shmid, IPC_STAT, &buf)) - { - xfree(shmdesc); - return BadAccess; - } - - /* The attach was performed with root privs. We must - * do manual checking of access rights for the credentials - * of the client */ - - if (shm_access(client, &(buf.shm_perm), stuff->readOnly) == -1) { - shmdt(shmdesc->addr); - xfree(shmdesc); - return BadAccess; - } - - shmdesc->shmid = stuff->shmid; - shmdesc->refcnt = 1; - shmdesc->writable = !stuff->readOnly; - shmdesc->size = buf.shm_segsz; - shmdesc->next = Shmsegs; - Shmsegs = shmdesc; - } - if (!AddResource(stuff->shmseg, ShmSegType, (void *)shmdesc)) - return BadAlloc; - return(client->noClientException); -} - -/*ARGSUSED*/ -static int -ShmDetachSegment(value, shmseg) - void * value; /* must conform to DeleteType */ - XID shmseg; -{ - ShmDescPtr shmdesc = (ShmDescPtr)value; - ShmDescPtr *prev; - - if (--shmdesc->refcnt) - return TRUE; - shmdt(shmdesc->addr); - for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next) - ; - *prev = shmdesc->next; - xfree(shmdesc); - return Success; -} - -static int -ProcShmDetach(client) - register ClientPtr client; -{ - ShmDescPtr shmdesc; - REQUEST(xShmDetachReq); - - REQUEST_SIZE_MATCH(xShmDetachReq); - VERIFY_SHMSEG(stuff->shmseg, shmdesc, client); - FreeResource(stuff->shmseg, RT_NONE); - return(client->noClientException); -} - static void miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) DrawablePtr dst; @@ -668,266 +261,6 @@ fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) } } - -#ifdef PANORAMIX -static int -ProcPanoramiXShmPutImage(register ClientPtr client) -{ - int j, result = 0, orig_x, orig_y; - PanoramiXRes *draw, *gc; - Bool sendEvent, isRoot; - - REQUEST(xShmPutImageReq); - REQUEST_SIZE_MATCH(xShmPutImageReq); - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) - return BadGC; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - orig_x = stuff->dstX; - orig_y = stuff->dstY; - sendEvent = stuff->sendEvent; - stuff->sendEvent = 0; - FOR_NSCREENS(j) { - if(!j) stuff->sendEvent = sendEvent; - stuff->drawable = draw->info[j].id; - stuff->gc = gc->info[j].id; - if (isRoot) { - stuff->dstX = orig_x - panoramiXdataPtr[j].x; - stuff->dstY = orig_y - panoramiXdataPtr[j].y; - } - result = ProcShmPutImage(client); - if(result != client->noClientException) break; - } - return(result); -} - -static int -ProcPanoramiXShmGetImage(ClientPtr client) -{ - PanoramiXRes *draw; - DrawablePtr drawables[MAXSCREENS]; - DrawablePtr pDraw; - xShmGetImageReply xgi; - ShmDescPtr shmdesc; - int i, x, y, w, h, format; - Mask plane = 0, planemask; - long lenPer = 0, length, widthBytesLine; - Bool isRoot; - - REQUEST(xShmGetImageReq); - - REQUEST_SIZE_MATCH(xShmGetImageReq); - - if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { - client->errorValue = stuff->format; - return(BadValue); - } - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - - if (draw->type == XRT_PIXMAP) - return ProcShmGetImage(client); - - VERIFY_DRAWABLE(pDraw, stuff->drawable, client); - - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - - x = stuff->x; - y = stuff->y; - w = stuff->width; - h = stuff->height; - format = stuff->format; - planemask = stuff->planeMask; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - if(isRoot) { - if( /* check for being onscreen */ - x < 0 || x + w > PanoramiXPixWidth || - y < 0 || y + h > PanoramiXPixHeight ) - return(BadMatch); - } else { - if( /* check for being onscreen */ - panoramiXdataPtr[0].x + pDraw->x + x < 0 || - panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth || - panoramiXdataPtr[0].y + pDraw->y + y < 0 || - panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight || - /* check for being inside of border */ - x < - wBorderWidth((WindowPtr)pDraw) || - x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || - y < -wBorderWidth((WindowPtr)pDraw) || - y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height) - return(BadMatch); - } - - drawables[0] = pDraw; - for(i = 1; i < PanoramiXNumScreens; i++) - VERIFY_DRAWABLE(drawables[i], draw->info[i].id, client); - - xgi.visual = wVisual(((WindowPtr)pDraw)); - xgi.type = X_Reply; - xgi.length = 0; - xgi.sequenceNumber = client->sequence; - xgi.depth = pDraw->depth; - - if(format == ZPixmap) { - widthBytesLine = PixmapBytePad(w, pDraw->depth); - length = widthBytesLine * h; - } else { - widthBytesLine = PixmapBytePad(w, 1); - lenPer = widthBytesLine * h; - plane = ((Mask)1) << (pDraw->depth - 1); - length = lenPer * Ones(planemask & (plane | (plane - 1))); - } - - VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); - xgi.size = length; - - if (length == 0) {/* nothing to do */ } - else if (format == ZPixmap) { - XineramaGetImageData(drawables, x, y, w, h, format, planemask, - shmdesc->addr + stuff->offset, - widthBytesLine, isRoot); - } else { - - length = stuff->offset; - for (; plane; plane >>= 1) { - if (planemask & plane) { - XineramaGetImageData(drawables, x, y, w, h, - format, plane, shmdesc->addr + length, - widthBytesLine, isRoot); - length += lenPer; - } - } - } - - if (client->swapped) { - register int n; - swaps(&xgi.sequenceNumber, n); - swapl(&xgi.length, n); - swapl(&xgi.visual, n); - swapl(&xgi.size, n); - } - WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); - - return(client->noClientException); -} - -static int -ProcPanoramiXShmCreatePixmap( - register ClientPtr client) -{ - ScreenPtr pScreen = NULL; - PixmapPtr pMap = NULL; - DrawablePtr pDraw; - DepthPtr pDepth; - int i, j, result; - ShmDescPtr shmdesc; - REQUEST(xShmCreatePixmapReq); - unsigned int width, height, depth; - unsigned long size; - PanoramiXRes *newPix; - - REQUEST_SIZE_MATCH(xShmCreatePixmapReq); - client->errorValue = stuff->pid; - if (!sharedPixmaps) - return BadImplementation; - LEGAL_NEW_RESOURCE(stuff->pid, client); - VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - - width = stuff->width; - height = stuff->height; - depth = stuff->depth; - if (!width || !height || !depth) - { - client->errorValue = 0; - return BadValue; - } - if (width > 32767 || height > 32767) - return BadAlloc; - - if (stuff->depth != 1) - { - pDepth = pDraw->pScreen->allowedDepths; - for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++) - if (pDepth->depth == stuff->depth) - goto CreatePmap; - client->errorValue = stuff->depth; - return BadValue; - } - -CreatePmap: - size = PixmapBytePad(width, depth) * height; - if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) { - if (size < width * height) - return BadAlloc; - /* thankfully, offset is unsigned */ - if (stuff->offset + size < size) - return BadAlloc; - } - - VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); - - if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) - return BadAlloc; - - newPix->type = XRT_PIXMAP; - newPix->u.pix.shared = TRUE; - newPix->info[0].id = stuff->pid; - for(j = 1; j < PanoramiXNumScreens; j++) - newPix->info[j].id = FakeClientID(client->index); - - result = (client->noClientException); - - FOR_NSCREENS(j) { - pScreen = screenInfo.screens[j]; - - pMap = (*shmFuncs[j]->CreatePixmap)(pScreen, - stuff->width, stuff->height, stuff->depth, - shmdesc->addr + stuff->offset); - - if (pMap) { -#ifdef PIXPRIV - pMap->devPrivates[shmPixmapPrivate].ptr = (void *) shmdesc; -#endif - shmdesc->refcnt++; - pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pMap->drawable.id = newPix->info[j].id; - if (!AddResource(newPix->info[j].id, RT_PIXMAP, (void *)pMap)) { - (*pScreen->DestroyPixmap)(pMap); - result = BadAlloc; - break; - } - } else { - result = BadAlloc; - break; - } - } - - if(result == BadAlloc) { - while(j--) { - (*pScreen->DestroyPixmap)(pMap); - FreeResource(newPix->info[j].id, RT_NONE); - } - xfree(newPix); - } else - AddResource(stuff->pid, XRT_PIXMAP, newPix); - - return result; -} - -#endif - static int ProcShmPutImage(client) register ClientPtr client; @@ -1036,117 +369,6 @@ ProcShmPutImage(client) } - -static int -ProcShmGetImage(client) - register ClientPtr client; -{ - register DrawablePtr pDraw; - long lenPer = 0, length; - Mask plane = 0; - xShmGetImageReply xgi; - ShmDescPtr shmdesc; - int n; - - REQUEST(xShmGetImageReq); - - REQUEST_SIZE_MATCH(xShmGetImageReq); - if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) - { - client->errorValue = stuff->format; - return(BadValue); - } - VERIFY_DRAWABLE(pDraw, stuff->drawable, client); - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - if (pDraw->type == DRAWABLE_WINDOW) - { - if( /* check for being viewable */ - !((WindowPtr) pDraw)->realized || - /* check for being on screen */ - pDraw->x + stuff->x < 0 || - pDraw->x + stuff->x + (int)stuff->width > pDraw->pScreen->width || - pDraw->y + stuff->y < 0 || - pDraw->y + stuff->y + (int)stuff->height > pDraw->pScreen->height || - /* check for being inside of border */ - stuff->x < - wBorderWidth((WindowPtr)pDraw) || - stuff->x + (int)stuff->width > - wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || - stuff->y < -wBorderWidth((WindowPtr)pDraw) || - stuff->y + (int)stuff->height > - wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height - ) - return(BadMatch); - xgi.visual = wVisual(((WindowPtr)pDraw)); - } - else - { - if (stuff->x < 0 || - stuff->x+(int)stuff->width > pDraw->width || - stuff->y < 0 || - stuff->y+(int)stuff->height > pDraw->height - ) - return(BadMatch); - xgi.visual = None; - } - xgi.type = X_Reply; - xgi.length = 0; - xgi.sequenceNumber = client->sequence; - xgi.depth = pDraw->depth; - if(stuff->format == ZPixmap) - { - length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height; - } - else - { - lenPer = PixmapBytePad(stuff->width, 1) * stuff->height; - plane = ((Mask)1) << (pDraw->depth - 1); - /* only planes asked for */ - length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1))); - } - - VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); - xgi.size = length; - - if (length == 0) - { - /* nothing to do */ - } - else if (stuff->format == ZPixmap) - { - (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, stuff->planeMask, - shmdesc->addr + stuff->offset); - } - else - { - - length = stuff->offset; - for (; plane; plane >>= 1) - { - if (stuff->planeMask & plane) - { - (*pDraw->pScreen->GetImage)(pDraw, - stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, plane, - shmdesc->addr + length); - length += lenPer; - } - } - } - - if (client->swapped) { - swaps(&xgi.sequenceNumber, n); - swapl(&xgi.length, n); - swapl(&xgi.visual, n); - swapl(&xgi.size, n); - } - WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); - - return(client->noClientException); -} - static PixmapPtr fbShmCreatePixmap (pScreen, width, height, depth, addr) ScreenPtr pScreen; @@ -1191,78 +413,6 @@ fbShmCreatePixmap (pScreen, width, height, depth, addr) return pPixmap; } -static int -ProcShmCreatePixmap(client) - register ClientPtr client; -{ - PixmapPtr pMap; - register DrawablePtr pDraw; - DepthPtr pDepth; - register int i; - ShmDescPtr shmdesc; - REQUEST(xShmCreatePixmapReq); - unsigned int width, height, depth; - unsigned long size; - - REQUEST_SIZE_MATCH(xShmCreatePixmapReq); - client->errorValue = stuff->pid; - if (!sharedPixmaps) - return BadImplementation; - LEGAL_NEW_RESOURCE(stuff->pid, client); - VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); - VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); - - width = stuff->width; - height = stuff->height; - depth = stuff->depth; - if (!width || !height || !depth) - { - client->errorValue = 0; - return BadValue; - } - if (width > 32767 || height > 32767) - return BadAlloc; - - if (stuff->depth != 1) - { - pDepth = pDraw->pScreen->allowedDepths; - for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++) - if (pDepth->depth == stuff->depth) - goto CreatePmap; - client->errorValue = stuff->depth; - return BadValue; - } - -CreatePmap: - size = PixmapBytePad(width, depth) * height; - if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) { - if (size < width * height) - return BadAlloc; - /* thankfully, offset is unsigned */ - if (stuff->offset + size < size) - return BadAlloc; - } - - VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); - pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)( - pDraw->pScreen, stuff->width, - stuff->height, stuff->depth, - shmdesc->addr + stuff->offset); - if (pMap) - { -#ifdef PIXPRIV - pMap->devPrivates[shmPixmapPrivate].ptr = (void *) shmdesc; -#endif - shmdesc->refcnt++; - pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pMap->drawable.id = stuff->pid; - if (AddResource(stuff->pid, RT_PIXMAP, (void *)pMap)) - { - return(client->noClientException); - } - } - return (BadAlloc); -} static int ProcShmDispatch (client) @@ -1339,114 +489,6 @@ ProcShmDispatch (client) } } -static void -SShmCompletionEvent(from, to) - xShmCompletionEvent *from, *to; -{ - to->type = from->type; - cpswaps(from->sequenceNumber, to->sequenceNumber); - cpswapl(from->drawable, to->drawable); - cpswaps(from->minorEvent, to->minorEvent); - to->majorEvent = from->majorEvent; - cpswapl(from->shmseg, to->shmseg); - cpswapl(from->offset, to->offset); -} - -static int -SProcShmQueryVersion(client) - register ClientPtr client; -{ - register int n; - REQUEST(xShmQueryVersionReq); - - swaps(&stuff->length, n); - return ProcShmQueryVersion(client); -} - -static int -SProcShmAttach(client) - ClientPtr client; -{ - register int n; - REQUEST(xShmAttachReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmAttachReq); - swapl(&stuff->shmseg, n); - swapl(&stuff->shmid, n); - return ProcShmAttach(client); -} - -static int -SProcShmDetach(client) - ClientPtr client; -{ - register int n; - REQUEST(xShmDetachReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmDetachReq); - swapl(&stuff->shmseg, n); - return ProcShmDetach(client); -} - -static int -SProcShmPutImage(client) - ClientPtr client; -{ - register int n; - REQUEST(xShmPutImageReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmPutImageReq); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->totalWidth, n); - swaps(&stuff->totalHeight, 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); - swapl(&stuff->shmseg, n); - swapl(&stuff->offset, n); - return ProcShmPutImage(client); -} - -static int -SProcShmGetImage(client) - ClientPtr client; -{ - register int n; - REQUEST(xShmGetImageReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmGetImageReq); - swapl(&stuff->drawable, n); - swaps(&stuff->x, n); - swaps(&stuff->y, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->planeMask, n); - swapl(&stuff->shmseg, n); - swapl(&stuff->offset, n); - return ProcShmGetImage(client); -} - -static int -SProcShmCreatePixmap(client) - ClientPtr client; -{ - register int n; - REQUEST(xShmCreatePixmapReq); - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH(xShmCreatePixmapReq); - swapl(&stuff->pid, n); - swapl(&stuff->drawable, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - swapl(&stuff->shmseg, n); - swapl(&stuff->offset, n); - return ProcShmCreatePixmap(client); -} - static int SProcShmDispatch (client) register ClientPtr client; @@ -1496,4 +538,3 @@ SProcShmDispatch (client) return BadRequest; } } - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 5daa65443..28aafd644 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -97,38 +97,7 @@ Equipment Corporation. /* $XFree86: xc/programs/Xserver/dix/window.c,v 3.36 2003/11/14 23:52:50 torrey Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "misc.h" -#include "scrnintstr.h" -#include "os.h" -#include "regionstr.h" -#include "validate.h" -#include "windowstr.h" -#include "input.h" -#include "resource.h" -#include "colormapst.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "gcstruct.h" -#include "servermd.h" #include "selection.h" -#ifdef PANORAMIX -#include "../../Xext/panoramiX.h" -#include "../../Xext/panoramiXsrv.h" -#endif -#include "dixevents.h" -#include "globals.h" - -#ifdef XAPPGROUP -#include <nx-X11/extensions/Xagsrv.h> -#endif -#ifdef XCSECURITY -#define _SECURITY_SERVER -#include <nx-X11/extensions/security.h> -#endif #include "Screen.h" #include "Options.h" @@ -140,56 +109,14 @@ Equipment Corporation. #include "Drawable.h" #include "Colormap.h" -extern Bool nxagentWMIsRunning; -extern Bool nxagentScreenTrap; - -/****** - * Window stuff for server - * - * CreateRootWindow, CreateWindow, ChangeWindowAttributes, - * 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 +/* prototypes (only MakeRootTile() required here) */ -static Bool TileScreenSaver(int i, int kind); +static void MakeRootTile(WindowPtr pWin); +#include "../../dix/window.c" -#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)) - +extern Bool nxagentWMIsRunning; +extern Bool nxagentScreenTrap; /* * Set here the required log level. @@ -200,143 +127,8 @@ static Bool TileScreenSaver(int i, int kind); #undef TEST #undef DEBUG -int numSaveUndersViewable = 0; -int deltaSaveUndersViewable = 0; - WindowPtr nxagentRootTileWindow; -/* - * This block used the DEBUG symbol. - */ - -#ifdef WINDOW_TREE_DEBUG -/****** - * PrintWindowTree - * For debugging only - ******/ - -int -PrintChildren(WindowPtr p1, int indent) -{ - WindowPtr p2; - int i; - - while (p1) - { - p2 = p1->firstChild; - for (i=0; i<indent; i++) ErrorF( " "); - ErrorF( "%x\n", p1->drawable.id); - RegionPrint(&p1->clipList); - PrintChildren(p2, indent+4); - p1 = p1->nextSib; - } -} - -PrintWindowTree() -{ - int i; - WindowPtr pWin, p1; - - for (i=0; i<screenInfo.numScreens; i++) - { - ErrorF( "WINDOW %d\n", i); - pWin = screenInfo.screens[i]->root; - RegionPrint(&pWin->clipList); - p1 = pWin->firstChild; - PrintChildren(p1, 4); - } -} -#endif - -int -TraverseTree(register WindowPtr pWin, VisitWindowProcPtr func, void * 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(ScreenPtr pScreen, VisitWindowProcPtr func, void * data) -{ - return(TraverseTree(pScreen->root, 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; - pWin->optional = (WindowOptPtr)NULL; - pWin->cursorIsNone = TRUE; - - pWin->backingStore = NotUseful; - pWin->DIXsaveUnder = FALSE; - pWin->backStorage = (void *) NULL; - - pWin->mapped = FALSE; /* off */ - pWin->realized = FALSE; /* off */ - pWin->viewable = FALSE; - pWin->visibility = VisibilityNotViewable; - pWin->overrideRedirect = FALSE; - pWin->saveUnder = FALSE; - - pWin->bitGravity = ForgetGravity; - pWin->winGravity = NorthWestGravity; - - pWin->eventMask = 0; - pWin->deliverableEvents = 0; - pWin->dontPropagate = 0; - pWin->forcedBS = FALSE; -#ifdef NEED_DBE_BUF_BITS - pWin->srcBuffer = DBE_FRONT_BUFFER; - pWin->dstBuffer = DBE_FRONT_BUFFER; -#endif -#ifdef COMPOSITE - pWin->redirectDraw = 0; -#endif -} - -#ifdef NXAGENT_SERVER - void nxagentClearSplash(WindowPtr pW) { ScreenPtr pScreen; @@ -354,8 +146,6 @@ void nxagentClearSplash(WindowPtr pW) (*pScreen->ChangeWindowAttributes)(pW, CWBackPixmap|CWBackPixel); } -#endif /* NXAGENT_SERVER */ - static void MakeRootTile(WindowPtr pWin) { @@ -400,167 +190,9 @@ MakeRootTile(WindowPtr pWin) FreeScratchGC(pGC); -#ifdef NXAGENT_SERVER nxagentRootTileWindow = pWin; -#endif /* NXAGENT_SERVER */ -} - -WindowPtr -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 = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } - } - return pWin; -} - -/***** - * CreateRootWindow - * Makes a window at initialization time for specified screen - *****/ - -Bool -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; - - pScreen->root = pWin; - - pScreen->root = pWin; - - pWin->drawable.pScreen = pScreen; - pWin->drawable.type = DRAWABLE_WINDOW; - - pWin->drawable.depth = pScreen->rootDepth; - for (format = screenInfo.formats; - format->depth != pScreen->rootDepth; - format++) - ; - pWin->drawable.bitsPerPixel = format->bitsPerPixel; - - pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - pWin->parent = NullWindow; - SetWindowToDefaults(pWin); - - pWin->optional = (WindowOptRec *) xalloc (sizeof (WindowOptRec)); - if (!pWin->optional) - return FALSE; - - pWin->optional->dontPropagateMask = 0; - pWin->optional->otherEventMasks = 0; - pWin->optional->otherClients = NULL; - pWin->optional->passiveGrabs = NULL; - pWin->optional->userProps = NULL; - pWin->optional->backingBitPlanes = ~0L; - pWin->optional->backingPixel = 0; -#ifdef SHAPE - pWin->optional->boundingShape = NULL; - pWin->optional->clipShape = NULL; - pWin->optional->inputShape = NULL; -#endif -#ifdef XINPUT - pWin->optional->inputMasks = NULL; -#endif - pWin->optional->colormap = pScreen->defColormap; - pWin->optional->visual = pScreen->rootVisual; - - pWin->nextSib = NullWindow; - - pWin->drawable.id = FakeClientID(0); - - pWin->origin.x = pWin->origin.y = 0; - pWin->drawable.height = pScreen->height; - pWin->drawable.width = pScreen->width; - pWin->drawable.x = pWin->drawable.y = 0; - - box.x1 = 0; - box.y1 = 0; - box.x2 = pScreen->width; - box.y2 = pScreen->height; - RegionInit(&pWin->clipList, &box, 1); - RegionInit(&pWin->winSize, &box, 1); - RegionInit(&pWin->borderSize, &box, 1); - RegionInit(&pWin->borderClip, &box, 1); - - pWin->drawable.class = InputOutput; - pWin->optional->visual = pScreen->rootVisual; - - pWin->backgroundState = BackgroundPixel; - pWin->background.pixel = pScreen->whitePixel; - - pWin->borderIsPixel = TRUE; - pWin->border.pixel = pScreen->blackPixel; - pWin->borderWidth = 0; - - if (!AddResource(pWin->drawable.id, RT_WINDOW, (void *)pWin)) - return FALSE; - - if (disableBackingStore) - { - pScreen -> backingStoreSupport = NotUseful; - } - - if (enableBackingStore) - { - pScreen -> backingStoreSupport = Always; - } - - pScreen->saveUnderSupport = False; - -#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; } -#ifdef NXAGENT_SERVER - void InitRootWindow(WindowPtr pWin) { @@ -658,412 +290,6 @@ InitRootWindow(WindowPtr pWin) #endif } -#else /* NXAGENT_SERVER */ - -void -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); -} - -#endif /* NXAGENT_SERVER */ - -/* 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(register WindowPtr pWin, RegionPtr Rgn, - register int x, register int y, - register int w, register int h) -{ -#ifndef NXAGENT_SERVER - ScreenPtr pScreen = pWin->drawable.pScreen; -#endif /* NXAGENT_SERVER */ - BoxRec box; - - box = *(RegionExtents(&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; - RegionReset(Rgn, &box); - RegionIntersect(Rgn, Rgn, &pWin->winSize); -} - -static RealChildHeadProc realChildHeadProc = NULL; - -void -RegisterRealChildHeadProc (RealChildHeadProc proc) -{ - realChildHeadProc = proc; -} - -WindowPtr -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(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; - } - - if ((class != InputOnly) && (pParent->drawable.class == InputOnly)) - { - *error = BadMatch; - return NullWindow; - } - - if ((class == InputOnly) && ((bw != 0) || (depth != 0))) - { - *error = BadMatch; - return NullWindow; - } - - pScreen = pParent->drawable.pScreen; - if ((class == InputOutput) && (depth == 0)) - depth = pParent->drawable.depth; - ancwopt = pParent->optional; - if (!ancwopt) - ancwopt = FindWindowWithOptional(pParent)->optional; - if (visual == CopyFromParent) { -#ifdef XAPPGROUP - VisualID ag_visual; - - if (client->appgroup && !pParent->parent && - (ag_visual = XagRootVisual (client))) - visual = ag_visual; - else -#endif - visual = ancwopt->visual; - } - - /* Find out if the depth and visual are acceptable for this Screen */ - if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) - { - fOK = FALSE; - for(idepth = 0; idepth < pScreen->numDepths; idepth++) - { - pDepth = (DepthPtr) &pScreen->allowedDepths[idepth]; - if ((depth == pDepth->depth) || (depth == 0)) - { - for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) - { - if (visual == pDepth->vids[ivisual]) - { - fOK = TRUE; - break; - } - } - } - } - if (fOK == FALSE) - { - *error = BadMatch; - return NullWindow; - } - } - - if (((vmask & (CWBorderPixmap | CWBorderPixel)) == 0) && - (class != InputOnly) && - (depth != pParent->drawable.depth)) - { - *error = BadMatch; - return NullWindow; - } - - if (((vmask & CWColormap) == 0) && - (class != InputOnly) && - ((visual != ancwopt->visual) || (ancwopt->colormap == None))) - { - *error = BadMatch; - return NullWindow; - } - - pWin = AllocateWindow(pScreen); - if (!pWin) - { - *error = BadAlloc; - return NullWindow; - } - pWin->drawable = pParent->drawable; - pWin->drawable.depth = depth; - if (depth == pParent->drawable.depth) - pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel; - else - { - for (format = screenInfo.formats; format->depth != depth; format++) - ; - pWin->drawable.bitsPerPixel = format->bitsPerPixel; - } - if (class == InputOnly) - pWin->drawable.type = (short) UNDRAWABLE_WINDOW; - pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - pWin->drawable.id = wid; - pWin->drawable.class = class; - - pWin->parent = pParent; - SetWindowToDefaults(pWin); - - if (visual != ancwopt->visual) - { - if (!MakeWindowOptional (pWin)) - { - xfree (pWin); - *error = BadAlloc; - return NullWindow; - } - pWin->optional->visual = visual; - pWin->optional->colormap = None; - } - - pWin->borderWidth = bw; -#ifdef XCSECURITY - /* can't let untrusted clients have background None windows; - * they make it too easy to steal window contents - */ - if (client->trustLevel != XSecurityClientTrusted) - { - pWin->backgroundState = BackgroundPixel; - pWin->background.pixel = 0; - } - else -#endif - pWin->backgroundState = None; - - pWin->borderIsPixel = pParent->borderIsPixel; - pWin->border = pParent->border; - if (pWin->borderIsPixel == FALSE) - pWin->border.pixmap->refcnt++; - - pWin->origin.x = x + (int)bw; - pWin->origin.y = y + (int)bw; - pWin->drawable.width = w; - pWin->drawable.height = h; - pWin->drawable.x = pParent->drawable.x + x + (int)bw; - pWin->drawable.y = pParent->drawable.y + y + (int)bw; - - /* set up clip list correctly for unobscured WindowPtr */ - RegionNull(&pWin->clipList); - RegionNull(&pWin->borderClip); - RegionNull(&pWin->winSize); - RegionNull(&pWin->borderSize); - - pHead = RealChildHead(pParent); - if (pHead) - { - pWin->nextSib = pHead->nextSib; - if (pHead->nextSib) - pHead->nextSib->prevSib = pWin; - else - pParent->lastChild = pWin; - pHead->nextSib = pWin; - pWin->prevSib = pHead; - } - else - { - pWin->nextSib = pParent->firstChild; - if (pParent->firstChild) - pParent->firstChild->prevSib = pWin; - else - pParent->lastChild = pWin; - pParent->firstChild = pWin; - } - - SetWinSize (pWin); - SetBorderSize (pWin); - - /* We SHOULD check for an error value here XXX */ - if (!(*pScreen->CreateWindow)(pWin)) - { - *error = BadAlloc; - DeleteWindow(pWin, None); - return NullWindow; - } - /* We SHOULD check for an error value here XXX */ - (*pScreen->PositionWindow)(pWin, pWin->drawable.x, pWin->drawable.y); - - if (!(vmask & CWEventMask)) - RecalculateDeliverableEvents(pWin); - - if (vmask) - *error = ChangeWindowAttributes(pWin, vmask, vlist, wClient (pWin)); - else - *error = Success; - - if (*error != Success) - { - DeleteWindow(pWin, None); - return NullWindow; - } - if (!(vmask & CWBackingStore) && (defaultBackingStore != NotUseful)) - { - XID value = defaultBackingStore; - (void)ChangeWindowAttributes(pWin, CWBackingStore, &value, wClient (pWin)); - pWin->forcedBS = TRUE; - } - - if (SubSend(pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = CreateNotify; - event.u.createNotify.window = wid; - event.u.createNotify.parent = pParent->drawable.id; - event.u.createNotify.x = x; - event.u.createNotify.y = y; - event.u.createNotify.width = w; - event.u.createNotify.height = h; - event.u.createNotify.borderWidth = bw; - event.u.createNotify.override = pWin->overrideRedirect; - DeliverEvents(pParent, &event, 1, NullWindow); - } - return pWin; -} - -static void -FreeWindowResources(register WindowPtr pWin) -{ - register ScreenPtr pScreen = pWin->drawable.pScreen; - - DeleteWindowFromAnySaveSet(pWin); - DeleteWindowFromAnySelections(pWin); - DeleteWindowFromAnyEvents(pWin, TRUE); - RegionUninit(&pWin->clipList); - RegionUninit(&pWin->winSize); - RegionUninit(&pWin->borderClip); - RegionUninit(&pWin->borderSize); -#ifdef SHAPE - if (wBoundingShape (pWin)) - RegionDestroy(wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionDestroy(wClipShape (pWin)); - if (wInputShape (pWin)) - RegionDestroy(wInputShape (pWin)); -#endif - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - - DeleteAllWindowProperties(pWin); - /* We SHOULD check for an error value here XXX */ - (*pScreen->DestroyWindow)(pWin); - DisposeWindowOptional (pWin); -} - -static void -CrushTree(WindowPtr pWin) -{ - register WindowPtr pChild, pSib, pParent; - UnrealizeWindowProcPtr UnrealizeWindow; - xEvent event; - - if (!(pChild = pWin->firstChild)) - return; - UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow; - while (1) - { - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - while (1) - { - pParent = pChild->parent; - if (SubStrSend(pChild, pParent)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = DestroyNotify; - event.u.destroyNotify.window = pChild->drawable.id; - DeliverEvents(pChild, &event, 1, NullWindow); - } - FreeResource(pChild->drawable.id, RT_WINDOW); - pSib = pChild->nextSib; -#ifdef DO_SAVE_UNDERS - if (pChild->saveUnder && pChild->viewable) - deltaSaveUndersViewable--; -#endif - pChild->viewable = FALSE; - if (pChild->realized) - { - pChild->realized = FALSE; - (*UnrealizeWindow)(pChild); - } - 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 @@ -1114,883 +340,6 @@ DeleteWindow(void * value, XID wid) return Success; } -void -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(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; - - if ((pWin->drawable.class == InputOnly) && (vmask & (~INPUTONLY_LEGAL_MASK))) - return BadMatch; - - error = Success; - pScreen = pWin->drawable.pScreen; - pVlist = vlist; - tmask = vmask; - while (tmask) - { - index2 = (Mask) lowbit (tmask); - tmask &= ~index2; - switch (index2) - { - case CWBackPixmap: - pixID = (Pixmap )*pVlist; - pVlist++; - if (pWin->backgroundState == ParentRelative) - borderRelative = TRUE; - if (pixID == None) - { -#ifdef XCSECURITY - /* can't let untrusted clients have background None windows */ - if (client->trustLevel == XSecurityClientTrusted) - { -#endif - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - if (!pWin->parent) - MakeRootTile(pWin); - else - pWin->backgroundState = None; -#ifdef XCSECURITY - } - else - { /* didn't change the background to None, so don't tell ddx */ - index2 = 0; - } -#endif - } - else if (pixID == ParentRelative) - { - if (pWin->parent && - pWin->drawable.depth != pWin->parent->drawable.depth) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - if (!pWin->parent) - MakeRootTile(pWin); - else - pWin->backgroundState = ParentRelative; - borderRelative = TRUE; - /* Note that the parent's backgroundTile's refcnt is NOT - * incremented. */ - } - else - { - pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID, - RT_PIXMAP, SecurityReadAccess); - if (pPixmap != (PixmapPtr) NULL) - { - if ((pPixmap->drawable.depth != pWin->drawable.depth) || - (pPixmap->drawable.pScreen != pScreen)) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - pWin->backgroundState = BackgroundPixmap; - pWin->background.pixmap = pPixmap; - pPixmap->refcnt++; - } - else - { - error = BadPixmap; - client->errorValue = pixID; - goto PatchUp; - } - } - break; - case CWBackPixel: - if (pWin->backgroundState == ParentRelative) - borderRelative = TRUE; - if (pWin->backgroundState == BackgroundPixmap) - (*pScreen->DestroyPixmap)(pWin->background.pixmap); - pWin->backgroundState = BackgroundPixel; - pWin->background.pixel = (CARD32 ) *pVlist; - /* background pixel overrides background pixmap, - so don't let the ddx layer see both bits */ - vmaskCopy &= ~CWBackPixmap; - pVlist++; - break; - case CWBorderPixmap: - pixID = (Pixmap ) *pVlist; - pVlist++; - if (pixID == CopyFromParent) - { - if (!pWin->parent || - (pWin->drawable.depth != pWin->parent->drawable.depth)) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - pWin->border = pWin->parent->border; - if ((pWin->borderIsPixel = pWin->parent->borderIsPixel) == TRUE) - { - index2 = CWBorderPixel; - } - else - { - pWin->parent->border.pixmap->refcnt++; - } - } - else - { - pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID, - RT_PIXMAP, SecurityReadAccess); - if (pPixmap) - { - if ((pPixmap->drawable.depth != pWin->drawable.depth) || - (pPixmap->drawable.pScreen != pScreen)) - { - error = BadMatch; - goto PatchUp; - } - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - pWin->borderIsPixel = FALSE; - pWin->border.pixmap = pPixmap; - pPixmap->refcnt++; - } - else - { - error = BadPixmap; - client->errorValue = pixID; - goto PatchUp; - } - } - break; - case CWBorderPixel: - if (pWin->borderIsPixel == FALSE) - (*pScreen->DestroyPixmap)(pWin->border.pixmap); - pWin->borderIsPixel = TRUE; - pWin->border.pixel = (CARD32) *pVlist; - /* border pixel overrides border pixmap, - so don't let the ddx layer see both bits */ - vmaskCopy &= ~CWBorderPixmap; - pVlist++; - break; - case CWBitGravity: - val = (CARD8 )*pVlist; - pVlist++; - if (val > StaticGravity) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->bitGravity = val; - break; - case CWWinGravity: - val = (CARD8 )*pVlist; - pVlist++; - if (val > StaticGravity) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->winGravity = val; - break; - case CWBackingStore: - val = (CARD8 )*pVlist; - pVlist++; - if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->backingStore = val; - - #ifdef TEST - fprintf(stderr, "ChangeWindowAttributes: Changed backing store value to %d for window at %p.\n", - val, (void*)pWin); - #endif - - pWin->forcedBS = FALSE; - break; - case CWBackingPlanes: - if (pWin->optional || ((CARD32)*pVlist != (CARD32)~0L)) { - if (!pWin->optional && !MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - pWin->optional->backingBitPlanes = (CARD32) *pVlist; - if ((CARD32)*pVlist == (CARD32)~0L) - checkOptional = TRUE; - } - pVlist++; - break; - case CWBackingPixel: - if (pWin->optional || (CARD32) *pVlist) { - if (!pWin->optional && !MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - pWin->optional->backingPixel = (CARD32) *pVlist; - if (!*pVlist) - checkOptional = TRUE; - } - pVlist++; - break; - case CWSaveUnder: - val = (BOOL) *pVlist; - pVlist++; - if ((val != xTrue) && (val != xFalse)) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } -#ifdef DO_SAVE_UNDERS - if (pWin->parent && (pWin->saveUnder != val) && (pWin->viewable) && - DO_SAVE_UNDERS(pWin)) - { - /* - * Re-check all siblings and inferiors for obscurity or - * exposition (hee hee). - */ - if (pWin->saveUnder) - deltaSaveUndersViewable--; - else - deltaSaveUndersViewable++; - pWin->saveUnder = val; - - if (pWin->firstChild) - { - pLayerWin = (*pScreen->GetLayerWindow)(pWin); - if ((*pScreen->ChangeSaveUnder)(pLayerWin->parent, pWin->nextSib)) - (*pScreen->PostChangeSaveUnder)(pLayerWin->parent, - pWin->nextSib); - } - else - { - if ((*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib)) - (*pScreen->PostChangeSaveUnder)(pWin, - pWin->nextSib); - } - } - else - { - /* If we're changing the saveUnder attribute of the root - * window, all we do is set pWin->saveUnder so that - * GetWindowAttributes returns the right value. We don't - * do the "normal" save-under processing (as above). - * Hope that doesn't cause any problems. - */ - pWin->saveUnder = val; - } -#else - pWin->saveUnder = val; -#endif /* DO_SAVE_UNDERS */ - break; - case CWEventMask: - /* - * TODO: Some applications like java bean shell - * don' t work if they cannot monitor the root - * window for Structure Redirect events. However - * this doesn't seem to be the best solution, since - * also an X server with a window manager running, - * doesn't allow to monitor for those events, but - * the java bean shell works flawlessy on this - * server. - * - * if (nxagentCheckIllegalRootMonitoring(pWin, (Mask)*pVlist)) - * { - * return BadAccess; - * } - */ - - result = EventSelectForWindow(pWin, client, (Mask )*pVlist); - if (result) - { - error = result; - goto PatchUp; - } - pVlist++; - break; - case CWDontPropagate: - result = EventSuppressForWindow(pWin, client, (Mask )*pVlist, - &checkOptional); - if (result) - { - error = result; - goto PatchUp; - } - pVlist++; - break; - case CWOverrideRedirect: - val = (BOOL ) *pVlist; - pVlist++; - if ((val != xTrue) && (val != xFalse)) - { - error = BadValue; - client->errorValue = val; - goto PatchUp; - } - pWin->overrideRedirect = val; - break; - case CWColormap: - cmap = (Colormap) *pVlist; - pVlist++; - if (cmap == CopyFromParent) - { -#ifdef XAPPGROUP - Colormap ag_colormap; - ClientPtr win_owner; - - /* - * win_owner == client for CreateWindow, other clients - * can ChangeWindowAttributes - */ - win_owner = clients[CLIENT_ID(pWin->drawable.id)]; - - if ( win_owner && win_owner->appgroup && - !pWin->parent->parent && - (ag_colormap = XagDefaultColormap (win_owner))) - cmap = ag_colormap; - else -#endif - if (pWin->parent && - (!pWin->optional || - pWin->optional->visual == wVisual (pWin->parent))) - { - cmap = wColormap (pWin->parent); - } - else - cmap = None; - } - if (cmap == None) - { - error = BadMatch; - goto PatchUp; - } - pCmap = (ColormapPtr)SecurityLookupIDByType(client, cmap, - RT_COLORMAP, SecurityReadAccess); - if (!pCmap) - { - error = BadColor; - client->errorValue = cmap; - goto PatchUp; - } - if (pCmap->pVisual->vid != wVisual (pWin) || - pCmap->pScreen != pScreen) - { - error = BadMatch; - goto PatchUp; - } - if (cmap != wColormap (pWin)) - { - if (!pWin->optional) - { - if (!MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - } - else if (pWin->parent && cmap == wColormap (pWin->parent)) - checkOptional = TRUE; - - /* - * propagate the original colormap to any children - * inheriting it - */ - - for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (!pChild->optional && !MakeWindowOptional (pChild)) - { - error = BadAlloc; - goto PatchUp; - } - } - - pWin->optional->colormap = cmap; - - /* - * check on any children now matching the new colormap - */ - - for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (pChild->optional->colormap == cmap) - CheckWindowOptionalNeed (pChild); - } - - xE.u.u.type = ColormapNotify; - xE.u.colormap.window = pWin->drawable.id; - xE.u.colormap.colormap = cmap; - xE.u.colormap.new = xTrue; - xE.u.colormap.state = IsMapInstalled(cmap, pWin); - DeliverEvents(pWin, &xE, 1, NullWindow); - } - break; - case CWCursor: - cursorID = (Cursor ) *pVlist; - pVlist++; - /* - * install the new - */ - if ( cursorID == None) - { - if (pWin == pWin->drawable.pScreen->root) - pCursor = rootCursor; - else - pCursor = (CursorPtr) None; - } - else - { - pCursor = (CursorPtr)SecurityLookupIDByType(client, cursorID, - RT_CURSOR, SecurityReadAccess); - if (!pCursor) - { - error = BadCursor; - client->errorValue = cursorID; - goto PatchUp; - } - } - - if (pCursor != wCursor (pWin)) - { - /* - * patch up child windows so they don't lose cursors. - */ - - for (pChild = pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (!pChild->optional && !pChild->cursorIsNone && - !MakeWindowOptional (pChild)) - { - error = BadAlloc; - goto PatchUp; - } - } - - pOldCursor = 0; - if (pCursor == (CursorPtr) None) - { - pWin->cursorIsNone = TRUE; - if (pWin->optional) - { - pOldCursor = pWin->optional->cursor; - pWin->optional->cursor = (CursorPtr) None; - checkOptional = TRUE; - } - } else { - if (!pWin->optional) - { - if (!MakeWindowOptional (pWin)) - { - error = BadAlloc; - goto PatchUp; - } - } - else if (pWin->parent && pCursor == wCursor (pWin->parent)) - checkOptional = TRUE; - pOldCursor = pWin->optional->cursor; - pWin->optional->cursor = pCursor; - pCursor->refcnt++; - pWin->cursorIsNone = FALSE; - /* - * check on any children now matching the new cursor - */ - - for (pChild=pWin->firstChild; pChild; pChild=pChild->nextSib) - { - if (pChild->optional && - (pChild->optional->cursor == pCursor)) - CheckWindowOptionalNeed (pChild); - } - } - - if (pWin->realized) - WindowHasNewCursor( pWin); - - /* Can't free cursor until here - old cursor - * is needed in WindowHasNewCursor - */ - if (pOldCursor) - FreeCursor (pOldCursor, (Cursor)0); - } - break; - default: - error = BadValue; - client->errorValue = vmask; - goto PatchUp; - } - vmaskCopy |= index2; - } -PatchUp: - if (checkOptional) - CheckWindowOptionalNeed (pWin); - - /* We SHOULD check for an error value here XXX */ - (*pScreen->ChangeWindowAttributes)(pWin, vmaskCopy); - - /* - If the border contents have changed, redraw the border. - Note that this has to be done AFTER pScreen->ChangeWindowAttributes - for the tile to be rotated, and the correct function selected. - */ - if (((vmaskCopy & (CWBorderPixel | CWBorderPixmap)) || borderRelative) - && pWin->viewable && HasBorder (pWin)) - { - RegionRec exposed; - - RegionNull(&exposed); - RegionSubtract(&exposed, &pWin->borderClip, &pWin->winSize); - (*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER); - RegionUninit(&exposed); - } - return error; -} - - -/***** - * GetWindowAttributes - * Notice that this is different than ChangeWindowAttributes - *****/ - -void -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(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; - pWin->prevSib = pParent->lastChild; - pWin->nextSib = NullWindow; - pParent->lastChild = pWin; - } - else if (pParent->firstChild == pNextSib) /* move to top */ - { - pFirstChange = pWin; - if (pParent->lastChild == pWin) - pParent->lastChild = pWin->prevSib; - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - pWin->nextSib = pParent->firstChild; - pWin->prevSib = (WindowPtr ) NULL; - pNextSib->prevSib = pWin; - pParent->firstChild = pWin; - } - else /* move in middle of list */ - { - WindowPtr pOldNext = pWin->nextSib; - - pFirstChange = NullWindow; - if (pParent->firstChild == pWin) - pFirstChange = pParent->firstChild = pWin->nextSib; - if (pParent->lastChild == pWin) { - pFirstChange = pWin; - pParent->lastChild = pWin->prevSib; - } - if (pWin->nextSib) - pWin->nextSib->prevSib = pWin->prevSib; - if (pWin->prevSib) - pWin->prevSib->nextSib = pWin->nextSib; - pWin->nextSib = pNextSib; - pWin->prevSib = pNextSib->prevSib; - if (pNextSib->prevSib) - pNextSib->prevSib->nextSib = pWin; - pNextSib->prevSib = pWin; - if (!pFirstChange) { /* do we know it yet? */ - pFirstChange = pParent->firstChild; /* no, search from top */ - while ((pFirstChange != pWin) && (pFirstChange != pOldNext)) - pFirstChange = pFirstChange->nextSib; - } - } - 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 (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 = RegionCreate(&box, 1); -#ifdef SHAPE - if (wBoundingShape (pWin) || wClipShape (pWin)) { -#ifndef NXAGENT_SERVER - ScreenPtr pScreen = pWin->drawable.pScreen; -#endif /* NXAGENT_SERVER */ - RegionTranslate(pRgn, - pWin->drawable.x, - - pWin->drawable.y); - if (wBoundingShape (pWin)) - RegionIntersect(pRgn, pRgn, wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionIntersect(pRgn, pRgn, wClipShape (pWin)); - RegionTranslate(pRgn, pWin->drawable.x, pWin->drawable.y); - } -#endif - return pRgn; -} - -void -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; - RegionReset(&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)) { -#ifndef NXAGENT_SERVER - ScreenPtr pScreen = pWin->drawable.pScreen; -#endif /* NXAGENT_SERVER */ - RegionTranslate(&pWin->winSize, - pWin->drawable.x, - - pWin->drawable.y); - if (wBoundingShape (pWin)) - RegionIntersect(&pWin->winSize, &pWin->winSize, - wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionIntersect(&pWin->winSize, &pWin->winSize, - wClipShape (pWin)); - RegionTranslate(&pWin->winSize, pWin->drawable.x, - pWin->drawable.y); - } -#endif -} - -void -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; - RegionReset(&pWin->borderSize, &box); - } - else -#endif - ClippedRegionFromBox(pWin->parent, &pWin->borderSize, - pWin->drawable.x - bw, pWin->drawable.y - bw, - (int)(pWin->drawable.width + (bw<<1)), - (int)(pWin->drawable.height + (bw<<1))); -#ifdef SHAPE - if (wBoundingShape (pWin)) { -#ifndef NXAGENT_SERVER - ScreenPtr pScreen = pWin->drawable.pScreen; -#endif /* NXAGENT_SERVER */ - RegionTranslate(&pWin->borderSize, - pWin->drawable.x, - - pWin->drawable.y); - RegionIntersect(&pWin->borderSize, &pWin->borderSize, - wBoundingShape (pWin)); - RegionTranslate(&pWin->borderSize, pWin->drawable.x, - pWin->drawable.y); - RegionUnion(&pWin->borderSize, &pWin->borderSize, - &pWin->winSize); - } -#endif - } else { - RegionCopy(&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 (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; - *desty = y + dh / 2; - break; - case SouthWestGravity: - *destx = x; - *desty = y + dh; - break; - case SouthGravity: - *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(register WindowPtr pWin, int dx, int dy, int dw, int dh) @@ -2071,346 +420,6 @@ ResizeChildrenWinSize(register WindowPtr pWin, int dx, int dy, int dw, int dh) } } -#define GET_INT16(m, f) \ - if (m & mask) \ - { \ - f = (INT16) *pVlist;\ - pVlist++; \ - } -#define GET_CARD16(m, f) \ - if (m & mask) \ - { \ - f = (CARD16) *pVlist;\ - pVlist++;\ - } - -#define GET_CARD8(m, f) \ - if (m & mask) \ - { \ - f = (CARD8) *pVlist;\ - pVlist++;\ - } - -#define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight)) - -#define IllegalInputOnlyConfigureMask (CWBorderWidth) - -/* - * IsSiblingAboveMe - * returns Above if pSib above pMe in stack or Below otherwise - */ - -static int -IsSiblingAboveMe( - register WindowPtr pMe, - register WindowPtr pSib) -{ - register WindowPtr pWin; - - pWin = pMe->parent->firstChild; - while (pWin) - { - if (pWin == pSib) - return(Above); - else if (pWin == pMe) - return(Below); - pWin = pWin->nextSib; - } - return(Below); -} - -static BoxPtr -WindowExtents( - register WindowPtr pWin, - register BoxPtr pBox) -{ - pBox->x1 = pWin->drawable.x - wBorderWidth (pWin); - pBox->y1 = pWin->drawable.y - wBorderWidth (pWin); - pBox->x2 = pWin->drawable.x + (int)pWin->drawable.width - + wBorderWidth (pWin); - pBox->y2 = pWin->drawable.y + (int)pWin->drawable.height - + wBorderWidth (pWin); - return(pBox); -} - -#ifdef SHAPE -#define IS_SHAPED(pWin) (wBoundingShape (pWin) != (RegionPtr) NULL) - -static RegionPtr -MakeBoundingRegion ( - register WindowPtr pWin, - BoxPtr pBox) -{ - RegionPtr pRgn; -#ifndef NXAGENT_SERVER - ScreenPtr pScreen = pWin->drawable.pScreen; -#endif /* NXAGENT_SERVER */ - pRgn = RegionCreate(pBox, 1); - if (wBoundingShape (pWin)) { - RegionTranslate(pRgn, -pWin->origin.x, - -pWin->origin.y); - RegionIntersect(pRgn, pRgn, wBoundingShape (pWin)); - RegionTranslate(pRgn, pWin->origin.x, - pWin->origin.y); - } - return pRgn; -} - -static Bool -ShapeOverlap ( - WindowPtr pWin, - BoxPtr pWinBox, - WindowPtr pSib, - BoxPtr pSibBox) -{ - RegionPtr pWinRgn, pSibRgn; - Bool ret; - - if (!IS_SHAPED(pWin) && !IS_SHAPED(pSib)) - return TRUE; - pWinRgn = MakeBoundingRegion (pWin, pWinBox); - pSibRgn = MakeBoundingRegion (pSib, pSibBox); - RegionIntersect(pWinRgn, pWinRgn, pSibRgn); - ret = RegionNotEmpty(pWinRgn); - RegionDestroy(pWinRgn); - RegionDestroy(pSibRgn); - return ret; -} -#endif - -static Bool -AnyWindowOverlapsMe( - WindowPtr pWin, - WindowPtr pHead, - register BoxPtr box) -{ - register WindowPtr pSib; - BoxRec sboxrec; - register BoxPtr sbox; - - for (pSib = pWin->prevSib; pSib != pHead; pSib = pSib->prevSib) - { - if (pSib->mapped) - { - sbox = WindowExtents(pSib, &sboxrec); - if (BOXES_OVERLAP(sbox, box) -#ifdef SHAPE - && ShapeOverlap (pWin, box, pSib, sbox) -#endif - ) - return(TRUE); - } - } - return(FALSE); -} - -static Bool -IOverlapAnyWindow( - WindowPtr pWin, - register BoxPtr box) -{ - register WindowPtr pSib; - BoxRec sboxrec; - register BoxPtr sbox; - - for (pSib = pWin->nextSib; pSib; pSib = pSib->nextSib) - { - if (pSib->mapped) - { - sbox = WindowExtents(pSib, &sboxrec); - if (BOXES_OVERLAP(sbox, box) -#ifdef SHAPE - && ShapeOverlap (pWin, box, pSib, sbox) -#endif - ) - return(TRUE); - } - } - return(FALSE); -} - -/* - * WhereDoIGoInTheStack() - * Given pWin and pSib and the relationshipe smode, return - * the window that pWin should go ABOVE. - * If a pSib is specified: - * Above: pWin is placed just above pSib - * Below: pWin is placed just below pSib - * TopIf: if pSib occludes pWin, then pWin is placed - * at the top of the stack - * BottomIf: if pWin occludes pSib, then pWin is - * placed at the bottom of the stack - * Opposite: if pSib occludes pWin, then pWin is placed at the - * top of the stack, else if pWin occludes pSib, then - * pWin is placed at the bottom of the stack - * - * If pSib is NULL: - * Above: pWin is placed at the top of the stack - * Below: pWin is placed at the bottom of the stack - * TopIf: if any sibling occludes pWin, then pWin is placed at - * the top of the stack - * BottomIf: if pWin occludes any sibline, then pWin is placed at - * the bottom of the stack - * Opposite: if any sibling occludes pWin, then pWin is placed at - * the top of the stack, else if pWin occludes any - * sibling, then pWin is placed at the bottom of the stack - * - */ - -static WindowPtr -WhereDoIGoInTheStack( - register WindowPtr pWin, - register WindowPtr pSib, - short x, - short y, - unsigned short w, - unsigned short h, - int smode) -{ - BoxRec box; - WindowPtr pHead, pFirst; - - if ((pWin == pWin->parent->firstChild) && - (pWin == pWin->parent->lastChild)) - return((WindowPtr ) NULL); - pHead = RealChildHead(pWin->parent); - pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild; - box.x1 = x; - box.y1 = y; - box.x2 = x + (int)w; - box.y2 = y + (int)h; - switch (smode) - { - case Above: - if (pSib) - return(pSib); - else if (pWin == pFirst) - return(pWin->nextSib); - else - return(pFirst); - case Below: - if (pSib) - if (pSib->nextSib != pWin) - return(pSib->nextSib); - else - return(pWin->nextSib); - else - return NullWindow; - case TopIf: - if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs) - return(pWin->nextSib); - else if (pSib) - { - if ((IsSiblingAboveMe(pWin, pSib) == Above) && - (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) - return(pFirst); - else - return(pWin->nextSib); - } - else if (AnyWindowOverlapsMe(pWin, pHead, &box)) - return(pFirst); - else - return(pWin->nextSib); - case BottomIf: - if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs) - return(pWin->nextSib); - else if (pSib) - { - if ((IsSiblingAboveMe(pWin, pSib) == Below) && - (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT)) - return NullWindow; - else - return(pWin->nextSib); - } - else if (IOverlapAnyWindow(pWin, &box)) - return NullWindow; - else - return(pWin->nextSib); - case Opposite: - if ((!pWin->mapped || (pSib && !pSib->mapped)) && !permitOldBugs) - return(pWin->nextSib); - else if (pSib) - { - if (RegionContainsRect(&pSib->borderSize, &box) != rgnOUT) - { - if (IsSiblingAboveMe(pWin, pSib) == Above) - return(pFirst); - else - return NullWindow; - } - else - return(pWin->nextSib); - } - else if (AnyWindowOverlapsMe(pWin, pHead, &box)) - { - /* If I'm occluded, I can't possibly be the first child - * if (pWin == pWin->parent->firstChild) - * return pWin->nextSib; - */ - return(pFirst); - } - else if (IOverlapAnyWindow(pWin, &box)) - return NullWindow; - else - return pWin->nextSib; - default: - { - ErrorF("Internal error in ConfigureWindow, smode == %d\n",smode ); - return pWin->nextSib; - } - } -} - -static void -ReflectStackChange( - register WindowPtr pWin, - register WindowPtr pSib, - VTKind kind) -{ -/* Note that pSib might be NULL */ - - Bool WasViewable = (Bool)pWin->viewable; - Bool anyMarked; - WindowPtr pFirstChange; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif - WindowPtr pLayerWin; - ScreenPtr pScreen = pWin->drawable.pScreen; - - /* if this is a root window, can't be restacked */ - if (!pWin->parent) - return; - - pFirstChange = MoveWindowInStack(pWin, pSib); - - if (WasViewable) - { - anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, - &pLayerWin); - if (pLayerWin != pWin) pFirstChange = pLayerWin; -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange); - } -#endif /* DO_SAVE_UNDERS */ - if (anyMarked) - { - (*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 *****/ @@ -2432,10 +441,6 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP h = pWin->drawable.height, bw = pWin->borderWidth; int action, smode = Above; -#ifdef XAPPGROUP - ClientPtr win_owner; - ClientPtr ag_leader = NULL; -#endif xEvent event; if ((pWin->drawable.class == InputOnly) && (mask & IllegalInputOnlyConfigureMask)) @@ -2554,17 +559,9 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP else pSib = pWin->nextSib; -#ifdef XAPPGROUP - win_owner = clients[CLIENT_ID(pWin->drawable.id)]; - ag_leader = XagLeader (win_owner); -#endif if ((!pWin->overrideRedirect) && (RedirectSend(pParent) -#ifdef XAPPGROUP - || (win_owner->appgroup && ag_leader && - XagIsControlledRoot (client, pParent)) -#endif )) { memset(&event, 0, sizeof(xEvent)); @@ -2590,16 +587,6 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP event.u.configureRequest.height = h; event.u.configureRequest.borderWidth = bw; event.u.configureRequest.valueMask = mask; -#ifdef XAPPGROUP - /* make sure if the ag_leader maps the window it goes to the wm */ - if (ag_leader && ag_leader != client && - XagIsControlledRoot (client, pParent)) { - event.u.configureRequest.parent = XagId (win_owner); - (void) TryClientEvents (ag_leader, &event, 1, - NoEventMask, NoEventMask, NullGrab); - return Success; - } -#endif event.u.configureRequest.parent = pParent->drawable.id; if (MaybeDeliverEventsToClient(pParent, &event, 1, SubstructureRedirectMask, client) == 1) @@ -2717,99 +704,6 @@ ActuallyDoSomething: #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(WindowPtr pParent, int direction, ClientPtr client) -{ - register WindowPtr pWin, pHead, pFirst; - xEvent event; - BoxRec box; - - #ifdef TEST - fprintf(stderr, "CirculateWindow: pParent [%p] direction [%d] client [%p]\n", - pParent, direction, client); - #endif - - /* - * if (nxagentOption(Rootless) && nxagentWMIsRunning && - * nxagentWindowTopLevel(pWin) && pWin -> overrideRedirect == 0) - * { - * nxagentCirculateRootlessWindows(direction); - * return Success; - * } - */ - - 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; - pWin && - !(pWin->mapped && - IOverlapAnyWindow(pWin, WindowExtents(pWin, &box))); - pWin = pWin->nextSib) ; - if (!pWin) - return Success; - } - - event.u.circulate.window = pWin->drawable.id; - event.u.circulate.parent = pParent->drawable.id; - event.u.circulate.event = pParent->drawable.id; - if (direction == RaiseLowest) - event.u.circulate.place = PlaceOnTop; - else - event.u.circulate.place = PlaceOnBottom; - - if (RedirectSend(pParent)) - { - event.u.u.type = CirculateRequest; - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - return(Success); - } - - event.u.u.type = CirculateNotify; - DeliverEvents(pWin, &event, 1, NullWindow); - ReflectStackChange(pWin, - (direction == RaiseLowest) ? pFirst : NullWindow, - VTStack); - - return(Success); -} - -static int -CompareWIDs( - WindowPtr pWin, - void *value) /* must conform to VisitWindowProcPtr */ -{ - Window *wid = (Window *)value; - - if (pWin->drawable.id == *wid) - return(WT_STOPWALKING); - else - return(WT_WALKCHILDREN); -} - /***** * ReparentWindow *****/ @@ -2915,39 +809,6 @@ ReparentWindow(register WindowPtr pWin, register WindowPtr pParent, return(Success); } -static void -RealizeTree(WindowPtr pWin) -{ - register WindowPtr pChild; - RealizeWindowProcPtr Realize; - - Realize = pWin->drawable.pScreen->RealizeWindow; - pChild = pWin; - while (1) - { - if (pChild->mapped) - { - pChild->realized = TRUE; -#ifdef DO_SAVE_UNDERS - if (pChild->saveUnder) - deltaSaveUndersViewable++; -#endif - pChild->viewable = (pChild->drawable.class == InputOutput); - (* Realize)(pChild); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - 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 @@ -2992,32 +853,14 @@ MapWindow(register WindowPtr pWin, ClientPtr client) { xEvent event; Bool anyMarked; -#ifdef XAPPGROUP - ClientPtr win_owner = clients[CLIENT_ID(pWin->drawable.id)]; - ClientPtr ag_leader = XagLeader (win_owner); -#endif if ((!pWin->overrideRedirect) && (RedirectSend(pParent) -#ifdef XAPPGROUP - || (win_owner->appgroup && ag_leader && - XagIsControlledRoot (client, pParent)) -#endif )) { memset(&event, 0, sizeof(xEvent)); event.u.u.type = MapRequest; event.u.mapRequest.window = pWin->drawable.id; -#ifdef XAPPGROUP - /* make sure if the ag_leader maps the window it goes to the wm */ - if (ag_leader && ag_leader != client && - XagIsControlledRoot (client, pParent)) { - event.u.mapRequest.parent = XagId (win_owner); - (void) TryClientEvents (ag_leader, &event, 1, - NoEventMask, NoEventMask, NullGrab); - return Success; - } -#endif event.u.mapRequest.parent = pParent->drawable.id; if (MaybeDeliverEventsToClient(pParent, &event, 1, @@ -3086,187 +929,6 @@ MapWindow(register WindowPtr pWin, ClientPtr client) return(Success); } - -/***** - * MapSubwindows - * Performs a MapWindow all unmapped children of the window, in top - * to bottom stacking order. - *****/ - -void -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; - for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib) - { - if (!pWin->mapped) - { - if (parentRedirect && !pWin->overrideRedirect) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapRequest; - event.u.mapRequest.window = pWin->drawable.id; - event.u.mapRequest.parent = pParent->drawable.id; - - if (MaybeDeliverEventsToClient(pParent, &event, 1, - SubstructureRedirectMask, client) == 1) - continue; - } - - pWin->mapped = TRUE; - if (parentNotify || StrSend(pWin)) - { - memset(&event, 0, sizeof(xEvent)); - event.u.u.type = MapNotify; - event.u.mapNotify.window = pWin->drawable.id; - event.u.mapNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); - } - - if (!pFirstMapped) - pFirstMapped = pWin; - if (pParent->realized) - { - RealizeTree(pWin); - if (pWin->viewable) - { - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, - (WindowPtr *)NULL); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = TRUE; - } -#endif /* DO_SAVE_UNDERS */ - } - } - } - } - - if (pFirstMapped) - { - pLayerWin = (*pScreen->GetLayerWindow)(pParent); - if (pLayerWin->parent != pParent) { - anyMarked |= (*pScreen->MarkOverlappedWindows)(pLayerWin, - pLayerWin, - (WindowPtr *)NULL); - pFirstMapped = pLayerWin; - } - if (anyMarked) - { -#ifdef DO_SAVE_UNDERS - if (pLayerWin->parent != pParent) - { - if (dosave || (DO_SAVE_UNDERS(pLayerWin))) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, - pLayerWin); - } - } - else if (dosave) - { - dosave = FALSE; - for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib) - { - if (DO_SAVE_UNDERS(pWin)) - { - dosave |= (*pScreen->ChangeSaveUnder)(pWin, - pWin->nextSib); - if (dosave && !pFirstSaveUndered) - pFirstSaveUndered = pWin; - } - } - } -#endif /* DO_SAVE_UNDERS */ - (*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap); - (*pScreen->HandleExposures)(pLayerWin->parent); - } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, - pFirstSaveUndered->nextSib); -#endif /* DO_SAVE_UNDERS */ - if (anyMarked && pScreen->PostValidateTree) - (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped, - VTMap); - WindowsRestructured (); - } -} - -static void -UnrealizeTree( - WindowPtr pWin, - Bool fromConfigure) -{ - register WindowPtr pChild; - UnrealizeWindowProcPtr Unrealize; - MarkUnrealizedWindowProcPtr MarkUnrealizedWindow; - - Unrealize = pWin->drawable.pScreen->UnrealizeWindow; - MarkUnrealizedWindow = pWin->drawable.pScreen->MarkUnrealizedWindow; - pChild = pWin; - while (1) - { - if (pChild->realized) - { - pChild->realized = FALSE; - pChild->visibility = VisibilityNotViewable; -#ifdef PANORAMIX - if(!noPanoramiXExtension && !pChild->drawable.pScreen->myNum) { - PanoramiXRes *win; - win = (PanoramiXRes*)LookupIDByType(pChild->drawable.id, - XRT_WINDOW); - if(win) - win->u.win.visibility = VisibilityNotViewable; - } -#endif - (* Unrealize)(pChild); - DeleteWindowFromAnyEvents(pChild, FALSE); - if (pChild->viewable) - { -#ifdef DO_SAVE_UNDERS - if (pChild->saveUnder) - deltaSaveUndersViewable--; -#endif - pChild->viewable = FALSE; - if (pChild->backStorage) - (*pChild->drawable.pScreen->SaveDoomedAreas)( - pChild, &pChild->clipList, 0, 0); - (* MarkUnrealizedWindow)(pChild, pWin, fromConfigure); - pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; - } - if (pChild->firstChild) - { - 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. @@ -3336,275 +998,6 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure) 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(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) - { - if (pChild->mapped) - { - if (parentNotify || StrSend(pChild)) - { - event.u.u.type = UnmapNotify; - event.u.unmapNotify.window = pChild->drawable.id; - event.u.unmapNotify.fromConfigure = xFalse; - DeliverEvents(pChild, &event, 1, NullWindow); - } - if (pChild->viewable) - { - pChild->valdata = UnmapValData; - anyMarked = TRUE; - } - pChild->mapped = FALSE; - if (pChild->realized) - UnrealizeTree(pChild, FALSE); - if (wasViewable) - { -#ifdef DO_SAVE_UNDERS - pChild->DIXsaveUnder = FALSE; -#endif /* DO_SAVE_UNDERS */ - if (pChild->backStorage) - (*pScreen->SaveDoomedAreas)( - pChild, &pChild->clipList, 0, 0); - } - } - } - if (wasViewable) - { - if (anyMarked) - { - if (pLayerWin->parent == pWin) - (*pScreen->MarkWindow)(pWin); - else - { - WindowPtr ptmp; - (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin, - (WindowPtr *)NULL); - (*pScreen->MarkWindow)(pLayerWin->parent); - - /* Windows between pWin and pLayerWin may not have been marked */ - ptmp = pWin; - - while (ptmp != pLayerWin->parent) - { - (*pScreen->MarkWindow)(ptmp); - ptmp = ptmp->parent; - } - pHead = pWin->firstChild; - } - (*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(register ClientPtr client) -{ - register WindowPtr pParent, pWin; - register int j; - - for (j=0; j<client->numSaved; j++) - { - pWin = SaveSetWindow(client->saveSet[j]); -#ifdef XFIXES - if (SaveSetToRoot(client->saveSet[j])) - pParent = pWin->drawable.pScreen->root; - 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(register WindowPtr pWin, int x, int y, BoxPtr box) -{ - if (!pWin->realized) - return (FALSE); - if (RegionContainsPoint(&pWin->clipList, x, y, box)) - return(TRUE); - return(FALSE); -} - -/** - * - * \param x,y in root - */ -Bool -PointInWindowIsVisible(register WindowPtr pWin, int x, int y) -{ - BoxRec box; - - if (!pWin->realized) - return (FALSE); - if (RegionContainsPoint(&pWin->borderClip, - x, y, &box) - && (!wInputShape(pWin) || - RegionContainsPoint( - wInputShape(pWin), - x - pWin->drawable.x, - y - pWin->drawable.y, &box))) - return(TRUE); - return(FALSE); -} - - -RegionPtr -NotClippedByChildren(register WindowPtr pWin) -{ - RegionPtr pReg; - - pReg = RegionCreate(NullBox, 1); - if (pWin->parent || - screenIsSaved != SCREEN_SAVER_ON || - !HasSaverWindow (pWin->drawable.pScreen->myNum)) - { - RegionIntersect(pReg, &pWin->borderClip, &pWin->winSize); - } - return(pReg); -} - -void -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) { - case VisibilityUnobscured: - for(i = 0; i < PanoramiXNumScreens; i++) { - if(i == Scrnum) continue; - - pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW); - - if (pWin2) { - if(pWin2->visibility == VisibilityPartiallyObscured) - return; - - if(!i) pWin = pWin2; - } - } - break; - case VisibilityPartiallyObscured: - if(Scrnum) { - pWin2 = (WindowPtr)LookupIDByType(win->info[0].id, RT_WINDOW); - if (pWin2) pWin = pWin2; - } - break; - case VisibilityFullyObscured: - for(i = 0; i < PanoramiXNumScreens; i++) { - if(i == Scrnum) continue; - - pWin2 = (WindowPtr)LookupIDByType(win->info[i].id, RT_WINDOW); - - if (pWin2) { - if(pWin2->visibility != VisibilityFullyObscured) - return; - - if(!i) pWin = pWin2; - } - } - break; - } - - win->u.win.visibility = visibility; - } -#endif - - memset(&event, 0, sizeof(xEvent)); - 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 -); -#endif - void SaveScreens(int on, int mode) { @@ -3727,454 +1120,3 @@ SaveScreens(int on, int mode) if (mode == ScreenSaverReset) SetScreenSaverTimer(); } - -static Bool -TileScreenSaver(int i, int kind) -{ - int j; - int result; - XID attributes[3]; - Mask mask; - WindowPtr pWin; - CursorMetricRec cm; - unsigned char *srcbits, *mskbits; - CursorPtr cursor; - XID cursorID = 0; - int attri; - - mask = 0; - attri = 0; - switch (kind) { - case SCREEN_IS_TILED: - switch (screenInfo.screens[i]->root->backgroundState) { - case BackgroundPixel: - attributes[attri++] = screenInfo.screens[i]->root->background.pixel; - mask |= CWBackPixel; - break; - case BackgroundPixmap: - attributes[attri++] = None; - mask |= CWBackPixmap; - break; - default: - break; - } - break; - case SCREEN_IS_BLACK: - attributes[attri++] = screenInfo.screens[i]->root->drawable.pScreen->blackPixel; - mask |= CWBackPixel; - break; - } - mask |= CWOverrideRedirect; - attributes[attri++] = xTrue; - - /* - * create a blank cursor - */ - - cm.width=16; - cm.height=16; - cm.xhot=8; - cm.yhot=8; - srcbits = (unsigned char *)xalloc( BitmapBytePad(32)*16); - mskbits = (unsigned char *)xalloc( BitmapBytePad(32)*16); - if (!srcbits || !mskbits) - { - xfree(srcbits); - xfree(mskbits); - cursor = 0; - } - else - { - for (j=0; j<BitmapBytePad(32)*16; j++) - srcbits[j] = mskbits[j] = 0x0; - cursor = AllocCursor(srcbits, mskbits, &cm, 0, 0, 0, 0, 0, 0); - if (cursor) - { - cursorID = FakeClientID(0); - if (AddResource (cursorID, RT_CURSOR, (void *) cursor)) - { - attributes[attri] = cursorID; - mask |= CWCursor; - } - else - cursor = 0; - } - else - { - xfree (srcbits); - xfree (mskbits); - } - } - - pWin = savedScreenInfo[i].pWindow = - CreateWindow(savedScreenInfo[i].wid, - screenInfo.screens[i]->root, - -RANDOM_WIDTH, -RANDOM_WIDTH, - (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH, - (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH, - 0, InputOutput, mask, attributes, 0, serverClient, - wVisual (screenInfo.screens[i]->root), &result); - - if (cursor) - FreeResource (cursorID, RT_NONE); - - if (!pWin) - return FALSE; - - if (!AddResource(pWin->drawable.id, RT_WINDOW, - (void *)savedScreenInfo[i].pWindow)) - return FALSE; - - if (mask & CWBackPixmap) - { - 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 (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 (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) - return; -#ifdef SHAPE - if (optional->boundingShape != NULL) - return; - if (optional->clipShape != NULL) - return; - if (optional->inputShape != NULL) - return; -#endif -#ifdef XINPUT - if (optional->inputMasks != NULL) - return; -#endif - 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 (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; - optional->inputShape = 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 (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 - * an optional record. - */ - if (pWin->optional->cursor) - { - FreeCursor (pWin->optional->cursor, (Cursor)0); - pWin->cursorIsNone = FALSE; - } - else - pWin->cursorIsNone = TRUE; -/* FIXME - There is an error when disposing ClientResources on Agent exit - this xfree is not valid in some window at exit -*/ - - xfree (pWin->optional); - pWin->optional = NULL; -} - -#ifndef NOLOGOHACK -static void -DrawLogo(WindowPtr pWin) -{ - DrawablePtr pDraw; - ScreenPtr pScreen; - int x, y; - unsigned int width, height, size; - GC *pGC; - int thin, gap, d31; - DDXPointRec poly[4]; - ChangeGCVal fore[2], back[2]; - xrgb rgb[2]; - BITS32 fmask, bmask; - ColormapPtr cmap; - - pDraw = (DrawablePtr)pWin; - pScreen = pDraw->pScreen; - x = -pWin->origin.x; - y = -pWin->origin.y; - width = pScreen->width; - height = pScreen->height; - pGC = GetScratchGC(pScreen->rootDepth, pScreen); - if (!pGC) - return; - - if ((rand() % 100) <= 17) /* make the probability for white fairly low */ - fore[0].val = pScreen->whitePixel; - else - fore[0].val = pScreen->blackPixel; - if ((pWin->backgroundState == BackgroundPixel) && - (cmap = (ColormapPtr)LookupIDByType(wColormap (pWin), RT_COLORMAP))) { - Pixel querypixels[2]; - - querypixels[0] = fore[0].val; - querypixels[1] = pWin->background.pixel; - QueryColors(cmap, 2, querypixels, rgb); - if ((rgb[0].red == rgb[1].red) && - (rgb[0].green == rgb[1].green) && - (rgb[0].blue == rgb[1].blue)) { - if (fore[0].val == pScreen->blackPixel) - fore[0].val = pScreen->whitePixel; - else - fore[0].val = pScreen->blackPixel; - } - } - fore[1].val = FillSolid; - fmask = GCForeground|GCFillStyle; - if (pWin->backgroundState == BackgroundPixel) { - back[0].val = pWin->background.pixel; - back[1].val = FillSolid; - bmask = GCForeground|GCFillStyle; - } else { - back[0].val = 0; - back[1].val = 0; - dixChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin, - NULL, back); - back[0].val = FillTiled; - back[1].ptr = pWin->background.pixmap; - bmask = GCFillStyle|GCTile; - } - - /* should be the same as the reference function XmuDrawLogo() */ - - size = width; - if (height < width) - size = height; - size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH); - size &= ~1; - x += rand() % (width - size); - y += rand() % (height - size); - -/* - * Draw what will be the thin strokes. - * - * ----- - * / / - * / / - * / / - * / / - * /____/ - * d - * - * Point d is 9/44 (~1/5) of the way across. - */ - - thin = (size / 11); - if (thin < 1) thin = 1; - gap = (thin+3) / 4; - d31 = thin + thin + gap; - poly[0].x = x + size; poly[0].y = y; - poly[1].x = x + size-d31; poly[1].y = y; - poly[2].x = x + 0; poly[2].y = y + size; - poly[3].x = x + d31; poly[3].y = y + size; - dixChangeGC(NullClient, pGC, fmask, NULL, fore); - ValidateGC(pDraw, pGC); - (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly); - -/* - * Erase area not needed for lower thin stroke. - * - * ------ - * / / - * / __ / - * / / / - * / / / - * /__/__/ - */ - - poly[0].x = x + d31/2; poly[0].y = y + size; - poly[1].x = x + size / 2; poly[1].y = y + size/2; - poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2; - poly[3].x = x + d31; poly[3].y = y + size; - dixChangeGC(NullClient, pGC, bmask, NULL, back); - ValidateGC(pDraw, pGC); - (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly); - -/* - * Erase area not needed for upper thin stroke. - * - * ------ - * / / / - * /--/ / - * / / - * / / - * /_____/ - */ - - poly[0].x = x + size - d31/2; poly[0].y = y; - poly[1].x = x + size / 2; poly[1].y = y + size/2; - poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2; - poly[3].x = x + size - d31; poly[3].y = y; - ValidateGC(pDraw, pGC); - (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly); - -/* - * Draw thick stroke. - * Point b is 1/4 of the way across. - * - * b - * ----- - * \ \ - * \ \ - * \ \ - * \ \ - * \____\ - */ - - poly[0].x = x; poly[0].y = y; - poly[1].x = x + size/4; poly[1].y = y; - poly[2].x = x + size; poly[2].y = y + size; - poly[3].x = x + size - size/4; poly[3].y = y + size; - dixChangeGC(NullClient, pGC, fmask, NULL, fore); - ValidateGC(pDraw, pGC); - (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly); - -/* - * Erase to create gap. - * - * / - * / - * / - * / - * / - */ - - poly[0].x = x + size- thin; poly[0].y = y; - poly[1].x = x + size-( thin+gap); poly[1].y = y; - poly[2].x = x + thin; poly[2].y = y + size; - poly[3].x = x + thin + gap; poly[3].y = y + size; - dixChangeGC(NullClient, pGC, bmask, NULL, back); - ValidateGC(pDraw, pGC); - (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly); - - FreeScratchGC(pGC); -} - -#endif - diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c b/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c index 1724374a0..ee95da66c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXxvdisp.c @@ -41,206 +41,15 @@ SOFTWARE. ******************************************************************/ /* $XFree86: xc/programs/Xserver/Xext/xvdisp.c,v 1.27 2003/07/16 01:38:31 dawes Exp $ */ -/* -** File: -** -** xvdisp.c --- Xv server extension dispatch module. -** -** Author: -** -** David Carver (Digital Workstation Engineering/Project Athena) -** -** Revisions: -** -** 11.06.91 Carver -** - changed SetPortControl to SetPortAttribute -** - changed GetPortControl to GetPortAttribute -** - changed QueryBestSize -** -** 15.05.91 Carver -** - version 2.0 upgrade -** -** 24.01.91 Carver -** - version 1.4 upgrade -** -*/ - #if !defined(__sun) && !defined(__CYGWIN__) -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <nx-X11/X.h> -#include <nx-X11/Xproto.h> -#include "misc.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include "gcstruct.h" -#include "dixstruct.h" -#include "resource.h" -#include "opaque.h" - -#include <nx-X11/extensions/Xv.h> -#include <nx-X11/extensions/Xvproto.h> -#include "xvdix.h" -#ifdef MITSHM -#define _XSHM_SERVER_ -#include <nx-X11/extensions/shmstr.h> -#endif - #include "Trap.h" +#include "../../Xext/xvdisp.c" + #undef TEST #undef DEBUG -#ifdef EXTMODULE -#include "xf86_ansic.h" -#endif - -#include "xvdisp.h" - -#ifdef PANORAMIX -#include "panoramiX.h" -#include "panoramiXsrv.h" - -unsigned long XvXRTPort; - -#ifdef MITSHM -static int XineramaXvShmPutImage(ClientPtr); -#endif -static int XineramaXvPutImage(ClientPtr); -static int XineramaXvPutVideo(ClientPtr); -static int XineramaXvPutStill(ClientPtr); -static int XineramaXvSetPortAttribute(ClientPtr); -static int XineramaXvStopVideo(ClientPtr); -#endif - -/* INTERNAL */ - -static int ProcXvQueryExtension(ClientPtr); -static int ProcXvQueryAdaptors(ClientPtr); -static int ProcXvQueryEncodings(ClientPtr); -static int ProcXvPutVideo(ClientPtr); -static int ProcXvPutStill(ClientPtr); -static int ProcXvGetVideo(ClientPtr); -static int ProcXvGetStill(ClientPtr); -static int ProcXvGrabPort(ClientPtr); -static int ProcXvUngrabPort(ClientPtr); -static int ProcXvSelectVideoNotify(ClientPtr); -static int ProcXvSelectPortNotify(ClientPtr); -static int ProcXvStopVideo(ClientPtr); -static int ProcXvSetPortAttribute(ClientPtr); -static int ProcXvGetPortAttribute(ClientPtr); -static int ProcXvQueryBestSize(ClientPtr); -static int ProcXvQueryPortAttributes(ClientPtr); -static int ProcXvPutImage(ClientPtr); -#ifdef MITSHM -static int ProcXvShmPutImage(ClientPtr); -#endif -static int ProcXvQueryImageAttributes(ClientPtr); -static int ProcXvListImageFormats(ClientPtr); - -static int SProcXvQueryExtension(ClientPtr); -static int SProcXvQueryAdaptors(ClientPtr); -static int SProcXvQueryEncodings(ClientPtr); -static int SProcXvPutVideo(ClientPtr); -static int SProcXvPutStill(ClientPtr); -static int SProcXvGetVideo(ClientPtr); -static int SProcXvGetStill(ClientPtr); -static int SProcXvGrabPort(ClientPtr); -static int SProcXvUngrabPort(ClientPtr); -static int SProcXvSelectVideoNotify(ClientPtr); -static int SProcXvSelectPortNotify(ClientPtr); -static int SProcXvStopVideo(ClientPtr); -static int SProcXvSetPortAttribute(ClientPtr); -static int SProcXvGetPortAttribute(ClientPtr); -static int SProcXvQueryBestSize(ClientPtr); -static int SProcXvQueryPortAttributes(ClientPtr); -static int SProcXvPutImage(ClientPtr); -#ifdef MITSHM -static int SProcXvShmPutImage(ClientPtr); -#endif -static int SProcXvQueryImageAttributes(ClientPtr); -static int SProcXvListImageFormats(ClientPtr); - -static int SWriteQueryAdaptorsReply(ClientPtr, xvQueryAdaptorsReply *); -static int SWriteQueryExtensionReply(ClientPtr, xvQueryExtensionReply *); -static int SWriteQueryEncodingsReply(ClientPtr, xvQueryEncodingsReply *); -static int SWriteAdaptorInfo(ClientPtr, xvAdaptorInfo *); -static int SWriteEncodingInfo(ClientPtr, xvEncodingInfo *); -static int SWriteFormat(ClientPtr, xvFormat *); -static int SWriteAttributeInfo(ClientPtr, xvAttributeInfo *); -static int SWriteGrabPortReply(ClientPtr, xvGrabPortReply *); -static int SWriteGetPortAttributeReply(ClientPtr, xvGetPortAttributeReply *); -static int SWriteQueryBestSizeReply(ClientPtr, xvQueryBestSizeReply *); -static int SWriteQueryPortAttributesReply( - ClientPtr, xvQueryPortAttributesReply *); -static int SWriteQueryImageAttributesReply( - ClientPtr, xvQueryImageAttributesReply*); -static int SWriteListImageFormatsReply(ClientPtr, xvListImageFormatsReply*); -static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*); - -#define _WriteQueryAdaptorsReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d) - -#define _WriteQueryExtensionReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d) - -#define _WriteQueryEncodingsReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d) - -#define _WriteAdaptorInfo(_c,_d) \ - if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \ - else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d) - -#define _WriteAttributeInfo(_c,_d) \ - if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \ - else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d) - -#define _WriteEncodingInfo(_c,_d) \ - if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \ - else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d) - -#define _WriteFormat(_c,_d) \ - if ((_c)->swapped) SWriteFormat(_c, _d); \ - else WriteToClient(_c, sz_xvFormat, (char*)_d) - -#define _WriteGrabPortReply(_c,_d) \ - if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \ - else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d) - -#define _WriteGetPortAttributeReply(_c,_d) \ - if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \ - else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d) - -#define _WriteQueryBestSizeReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d) - -#define _WriteQueryPortAttributesReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d) - -#define _WriteQueryImageAttributesReply(_c,_d) \ - if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \ - else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d) - -#define _WriteListImageFormatsReply(_c,_d) \ - if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \ - else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d) - -#define _WriteImageFormatInfo(_c,_d) \ - if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \ - else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d) - -#define _AllocatePort(_i,_p) \ - ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success - /* ** ProcXvDispatch ** @@ -427,1889 +236,4 @@ SProcXvDispatch(ClientPtr client) return result; } - -static int -ProcXvQueryExtension(ClientPtr client) -{ - xvQueryExtensionReply rep; - /* REQUEST(xvQueryExtensionReq); */ - REQUEST_SIZE_MATCH(xvQueryExtensionReq); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.version = XvVersion; - rep.revision = XvRevision; - - _WriteQueryExtensionReply(client, &rep); - - return Success; - -} - -static int -ProcXvQueryAdaptors(ClientPtr client) -{ - xvFormat format; - xvAdaptorInfo ainfo; - xvQueryAdaptorsReply rep; - int totalSize; - int na; - XvAdaptorPtr pa; - int nf; - XvFormatPtr pf; - WindowPtr pWin; - ScreenPtr pScreen; - XvScreenPtr pxvs; - - REQUEST(xvQueryAdaptorsReq); - REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); - - if(!(pWin = (WindowPtr)LookupWindow(stuff->window, client) )) - { - client->errorValue = stuff->window; - return (BadWindow); - } - - pScreen = pWin->drawable.pScreen; - pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr; - - if (!pxvs) - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_adaptors = 0; - rep.length = 0; - - _WriteQueryAdaptorsReply(client, &rep); - - return Success; - } - - (* pxvs->ddQueryAdaptors)(pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_adaptors = pxvs->nAdaptors; - - /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */ - - totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo; - - /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */ - - na = pxvs->nAdaptors; - pa = pxvs->pAdaptors; - while (na--) - { - totalSize += (strlen(pa->name) + 3) & ~3; - totalSize += pa->nFormats * sz_xvFormat; - pa++; - } - - rep.length = totalSize >> 2; - - _WriteQueryAdaptorsReply(client, &rep); - - na = pxvs->nAdaptors; - pa = pxvs->pAdaptors; - while (na--) - { - - ainfo.base_id = pa->base_id; - ainfo.num_ports = pa->nPorts; - ainfo.type = pa->type; - ainfo.name_size = strlen(pa->name); - ainfo.num_formats = pa->nFormats; - - _WriteAdaptorInfo(client, &ainfo); - - WriteToClient(client, ainfo.name_size, pa->name); - - nf = pa->nFormats; - pf = pa->pFormats; - while (nf--) - { - format.depth = pf->depth; - format.visual = pf->visual; - _WriteFormat(client, &format); - pf++; - } - - pa++; - - } - - return (client->noClientException); - -} - -static int -ProcXvQueryEncodings(ClientPtr client) -{ - xvEncodingInfo einfo; - xvQueryEncodingsReply rep; - int totalSize; - XvPortPtr pPort; - int ne; - XvEncodingPtr pe; - int status; - - REQUEST(xvQueryEncodingsReq); - REQUEST_SIZE_MATCH(xvQueryEncodingsReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_encodings = pPort->pAdaptor->nEncodings; - - /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */ - - ne = pPort->pAdaptor->nEncodings; - pe = pPort->pAdaptor->pEncodings; - totalSize = ne * sz_xvEncodingInfo; - while (ne--) - { - totalSize += (strlen(pe->name) + 3) & ~3; - pe++; - } - - rep.length = totalSize >> 2; - - _WriteQueryEncodingsReply(client, &rep); - - ne = pPort->pAdaptor->nEncodings; - pe = pPort->pAdaptor->pEncodings; - while (ne--) - { - einfo.encoding = pe->id; - einfo.name_size = strlen(pe->name); - einfo.width = pe->width; - einfo.height = pe->height; - einfo.rate.numerator = pe->rate.numerator; - einfo.rate.denominator = pe->rate.denominator; - _WriteEncodingInfo(client, &einfo); - WriteToClient(client, einfo.name_size, pe->name); - pe++; - } - - return (client->noClientException); - -} - -static int -ProcXvPutVideo(ClientPtr client) -{ - register DrawablePtr pDraw; - XvPortPtr pPort; - register GCPtr pGC; - int status; - - REQUEST(xvPutVideoReq); - REQUEST_SIZE_MATCH(xvPutVideoReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!(pPort->pAdaptor->type & XvInputMask) || - !(pPort->pAdaptor->type & XvVideoMask)) - { - client->errorValue = stuff->port; - return (BadMatch); - } - - status = XVCALL(diMatchPort)(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XVCALL(diPutVideo)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); - -} - -static int -ProcXvPutStill(ClientPtr client) -{ - register DrawablePtr pDraw; - XvPortPtr pPort; - register GCPtr pGC; - int status; - - REQUEST(xvPutStillReq); - REQUEST_SIZE_MATCH(xvPutStillReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!(pPort->pAdaptor->type & XvInputMask) || - !(pPort->pAdaptor->type & XvStillMask)) - { - client->errorValue = stuff->port; - return (BadMatch); - } - - status = XVCALL(diMatchPort)(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XVCALL(diPutStill)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); - -} - - -static int -ProcXvGetVideo(ClientPtr client) -{ - register DrawablePtr pDraw; - XvPortPtr pPort; - register GCPtr pGC; - int status; - - REQUEST(xvGetVideoReq); - REQUEST_SIZE_MATCH(xvGetVideoReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!(pPort->pAdaptor->type & XvOutputMask) || - !(pPort->pAdaptor->type & XvVideoMask)) - { - client->errorValue = stuff->port; - return (BadMatch); - } - - status = XVCALL(diMatchPort)(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XVCALL(diGetVideo)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); - -} - - -static int -ProcXvGetStill(ClientPtr client) -{ - register DrawablePtr pDraw; - XvPortPtr pPort; - register GCPtr pGC; - int status; - - REQUEST(xvGetStillReq); - REQUEST_SIZE_MATCH(xvGetStillReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!(pPort->pAdaptor->type & XvOutputMask) || - !(pPort->pAdaptor->type & XvStillMask)) - { - client->errorValue = stuff->port; - return (BadMatch); - } - - status = XVCALL(diMatchPort)(pPort, pDraw); - if (status != Success) - { - return status; - } - - return XVCALL(diGetStill)(client, pDraw, pPort, pGC, - stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); - -} - -static int -ProcXvSelectVideoNotify(ClientPtr client) -{ - register DrawablePtr pDraw; - REQUEST(xvSelectVideoNotifyReq); - REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); - - if(!(pDraw = (DrawablePtr)LOOKUP_DRAWABLE(stuff->drawable, client) )) - { - client->errorValue = stuff->drawable; - return (BadWindow); - } - - return XVCALL(diSelectVideoNotify)(client, pDraw, stuff->onoff); - -} - -static int -ProcXvSelectPortNotify(ClientPtr client) -{ - int status; - XvPortPtr pPort; - REQUEST(xvSelectPortNotifyReq); - REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - return XVCALL(diSelectPortNotify)(client, pPort, stuff->onoff); - -} - -static int -ProcXvGrabPort(ClientPtr client) -{ - int result, status; - XvPortPtr pPort; - xvGrabPortReply rep; - REQUEST(xvGrabPortReq); - REQUEST_SIZE_MATCH(xvGrabPortReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - status = XVCALL(diGrabPort)(client, pPort, stuff->time, &result); - - if (status != Success) - { - return status; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.result = result; - - _WriteGrabPortReply(client, &rep); - - return Success; - -} - -static int -ProcXvUngrabPort(ClientPtr client) -{ - int status; - XvPortPtr pPort; - REQUEST(xvGrabPortReq); - REQUEST_SIZE_MATCH(xvGrabPortReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - return XVCALL(diUngrabPort)(client, pPort, stuff->time); - -} - - -static int -ProcXvStopVideo(ClientPtr client) -{ - int status; - register DrawablePtr pDraw; - XvPortPtr pPort; - REQUEST(xvStopVideoReq); - REQUEST_SIZE_MATCH(xvStopVideoReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if(!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client) )) - { - client->errorValue = stuff->drawable; - return (BadDrawable); - } - - return XVCALL(diStopVideo)(client, pPort, pDraw); - -} - -static int -ProcXvSetPortAttribute(ClientPtr client) -{ - int status; - XvPortPtr pPort; - REQUEST(xvSetPortAttributeReq); - REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!ValidAtom(stuff->attribute)) - { - client->errorValue = stuff->attribute; - return(BadAtom); - } - - status = XVCALL(diSetPortAttribute)(client, pPort, - stuff->attribute, stuff->value); - - if (status == BadMatch) - client->errorValue = stuff->attribute; - else - client->errorValue = stuff->value; - - return status; -} - -static int -ProcXvGetPortAttribute(ClientPtr client) -{ - INT32 value; - int status; - XvPortPtr pPort; - xvGetPortAttributeReply rep; - REQUEST(xvGetPortAttributeReq); - REQUEST_SIZE_MATCH(xvGetPortAttributeReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!ValidAtom(stuff->attribute)) - { - client->errorValue = stuff->attribute; - return(BadAtom); - } - - status = XVCALL(diGetPortAttribute)(client, pPort, stuff->attribute, &value); - if (status != Success) - { - client->errorValue = stuff->attribute; - return status; - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.value = value; - - _WriteGetPortAttributeReply(client, &rep); - - return Success; -} - -static int -ProcXvQueryBestSize(ClientPtr client) -{ - int status; - unsigned int actual_width, actual_height; - XvPortPtr pPort; - xvQueryBestSizeReply rep; - REQUEST(xvQueryBestSizeReq); - REQUEST_SIZE_MATCH(xvQueryBestSizeReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - - (* pPort->pAdaptor->ddQueryBestSize)(client, pPort, stuff->motion, - stuff->vid_w, stuff->vid_h, - stuff->drw_w, stuff->drw_h, - &actual_width, &actual_height); - - rep.actual_width = actual_width; - rep.actual_height = actual_height; - - _WriteQueryBestSizeReply(client, &rep); - - return Success; -} - - -static int -ProcXvQueryPortAttributes(ClientPtr client) -{ - int status, size, i; - XvPortPtr pPort; - XvAttributePtr pAtt; - xvQueryPortAttributesReply rep; - xvAttributeInfo Info; - REQUEST(xvQueryPortAttributesReq); - REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_attributes = pPort->pAdaptor->nAttributes; - rep.text_size = 0; - - for(i = 0, pAtt = pPort->pAdaptor->pAttributes; - i < rep.num_attributes; i++, pAtt++) - { - rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L; - } - - rep.length = (rep.num_attributes * sz_xvAttributeInfo) + rep.text_size; - rep.length >>= 2; - - _WriteQueryPortAttributesReply(client, &rep); - - for(i = 0, pAtt = pPort->pAdaptor->pAttributes; - i < rep.num_attributes; i++, pAtt++) - { - size = strlen(pAtt->name) + 1; /* pass the NULL */ - Info.flags = pAtt->flags; - Info.min = pAtt->min_value; - Info.max = pAtt->max_value; - Info.size = (size + 3) & ~3L; - - _WriteAttributeInfo(client, &Info); - - WriteToClient(client, size, pAtt->name); - } - - return Success; -} - - - -static int -ProcXvPutImage(ClientPtr client) -{ - DrawablePtr pDraw; - XvPortPtr pPort; - XvImagePtr pImage = NULL; - GCPtr pGC; - int status, i, size; - CARD16 width, height; - - REQUEST(xvPutImageReq); - REQUEST_AT_LEAST_SIZE(xvPutImageReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!(pPort->pAdaptor->type & XvImageMask) || - !(pPort->pAdaptor->type & XvInputMask)) - { - client->errorValue = stuff->port; - return (BadMatch); - } - - status = XVCALL(diMatchPort)(pPort, pDraw); - if (status != Success) - { - return status; - } - - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } - - if(!pImage) - return BadMatch; - - width = stuff->width; - height = stuff->height; - size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, - pPort, pImage, &width, &height, NULL, NULL); - size += sizeof(xvPutImageReq); - size = (size + 3) >> 2; - - if((width < stuff->width) || (height < stuff->height)) - return BadValue; - - if(client->req_len < size) - return BadLength; - - return XVCALL(diPutImage)(client, pDraw, pPort, pGC, - stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, - pImage, (unsigned char*)(&stuff[1]), FALSE, - stuff->width, stuff->height); -} - -#ifdef MITSHM -/* redefined here since it's not in any header file */ -typedef struct _ShmDesc { - struct _ShmDesc *next; - int shmid; - int refcnt; - char *addr; - Bool writable; - unsigned long size; -} ShmDescRec, *ShmDescPtr; - -extern RESTYPE ShmSegType; -extern int BadShmSegCode; -extern int ShmCompletionCode; - -static int -ProcXvShmPutImage(ClientPtr client) -{ - ShmDescPtr shmdesc; - DrawablePtr pDraw; - XvPortPtr pPort; - XvImagePtr pImage = NULL; - GCPtr pGC; - int status, size_needed, i; - CARD16 width, height; - - REQUEST(xvShmPutImageReq); - REQUEST_SIZE_MATCH(xvShmPutImageReq); - - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return (status); - } - - if (!(pPort->pAdaptor->type & XvImageMask) || - !(pPort->pAdaptor->type & XvInputMask)) - { - client->errorValue = stuff->port; - return (BadMatch); - } - - status = XVCALL(diMatchPort)(pPort, pDraw); - if (status != Success) - { - return status; - } - - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } - - if(!pImage) - return BadMatch; - - if(!(shmdesc = (ShmDescPtr)LookupIDByType(stuff->shmseg, ShmSegType))) - { - client->errorValue = stuff->shmseg; - return BadShmSegCode; - } - - width = stuff->width; - height = stuff->height; - size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client, - pPort, pImage, &width, &height, NULL, NULL); - if((size_needed + stuff->offset) > shmdesc->size) - return BadAccess; - - if((width < stuff->width) || (height < stuff->height)) - return BadValue; - - status = XVCALL(diPutImage)(client, pDraw, pPort, pGC, - stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, - stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, pImage, - (unsigned char *)shmdesc->addr + stuff->offset, - stuff->send_event, stuff->width, stuff->height); - - if((status == Success) && stuff->send_event) { - xShmCompletionEvent ev; - - ev.type = ShmCompletionCode; - ev.drawable = stuff->drawable; - ev.sequenceNumber = client->sequence; - ev.minorEvent = xv_ShmPutImage; - ev.majorEvent = XvReqCode; - ev.shmseg = stuff->shmseg; - ev.offset = stuff->offset; - WriteEventsToClient(client, 1, (xEvent *) &ev); - } - - return status; -} -#endif - -#ifdef XvMCExtension -#include "xvmcext.h" -#endif - -static int -ProcXvQueryImageAttributes(ClientPtr client) -{ - xvQueryImageAttributesReply rep; - int size, num_planes, i; - CARD16 width, height; - XvImagePtr pImage = NULL; - XvPortPtr pPort; - int *offsets; - int *pitches; - REQUEST(xvQueryImageAttributesReq); - - REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } - -#ifdef XvMCExtension - if(!pImage) - pImage = XvMCFindXvImage(pPort, stuff->id); -#endif - - if(!pImage) - return BadMatch; - - num_planes = pImage->num_planes; - - if(!(offsets = xalloc(num_planes << 3))) - return BadAlloc; - pitches = offsets + num_planes; - - width = stuff->width; - height = stuff->height; - - size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage, - &width, &height, offsets, pitches); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = num_planes << 1; - rep.num_planes = num_planes; - rep.width = width; - rep.height = height; - rep.data_size = size; - - _WriteQueryImageAttributesReply(client, &rep); - if(client->swapped) - SwapLongs((CARD32*)offsets, rep.length); - WriteToClient(client, rep.length << 2, (char*)offsets); - - xfree(offsets); - - return Success; -} - -static int -ProcXvListImageFormats(ClientPtr client) -{ - XvPortPtr pPort; - XvImagePtr pImage; - int i; - xvListImageFormatsReply rep; - xvImageFormatInfo info; - REQUEST(xvListImageFormatsReq); - - REQUEST_SIZE_MATCH(xvListImageFormatsReq); - - if(!(pPort = LOOKUP_PORT(stuff->port, client) )) - { - client->errorValue = stuff->port; - return (_XvBadPort); - } - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_formats = pPort->pAdaptor->nImages; - rep.length = rep.num_formats * sz_xvImageFormatInfo >> 2; - - _WriteListImageFormatsReply(client, &rep); - - pImage = pPort->pAdaptor->pImages; - - for(i = 0; i < rep.num_formats; i++, pImage++) { - info.id = pImage->id; - info.type = pImage->type; - info.byte_order = pImage->byte_order; - memcpy(&info.guid, pImage->guid, 16); - info.bpp = pImage->bits_per_pixel; - info.num_planes = pImage->num_planes; - info.depth = pImage->depth; - info.red_mask = pImage->red_mask; - info.green_mask = pImage->green_mask; - info.blue_mask = pImage->blue_mask; - info.format = pImage->format; - info.y_sample_bits = pImage->y_sample_bits; - info.u_sample_bits = pImage->u_sample_bits; - info.v_sample_bits = pImage->v_sample_bits; - info.horz_y_period = pImage->horz_y_period; - info.horz_u_period = pImage->horz_u_period; - info.horz_v_period = pImage->horz_v_period; - info.vert_y_period = pImage->vert_y_period; - info.vert_u_period = pImage->vert_u_period; - info.vert_v_period = pImage->vert_v_period; - memcpy(&info.comp_order, pImage->component_order, 32); - info.scanline_order = pImage->scanline_order; - _WriteImageFormatInfo(client, &info); - } - - return Success; -} - - - -/* Swapped Procs */ - -static int -SProcXvQueryExtension(ClientPtr client) -{ - register char n; - REQUEST(xvQueryExtensionReq); - REQUEST_SIZE_MATCH(xvQueryExtensionReq); - swaps(&stuff->length, n); - return ProcXvQueryExtension(client); -} - -static int -SProcXvQueryAdaptors(ClientPtr client) -{ - register char n; - REQUEST(xvQueryAdaptorsReq); - REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); - swaps(&stuff->length, n); - swapl(&stuff->window, n); - return ProcXvQueryAdaptors(client); -} - -static int -SProcXvQueryEncodings(ClientPtr client) -{ - register char n; - REQUEST(xvQueryEncodingsReq); - REQUEST_SIZE_MATCH(xvQueryEncodingsReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return ProcXvQueryEncodings(client); -} - -static int -SProcXvGrabPort(ClientPtr client) -{ - register char n; - REQUEST(xvGrabPortReq); - REQUEST_SIZE_MATCH(xvGrabPortReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->time, n); - return ProcXvGrabPort(client); -} - -static int -SProcXvUngrabPort(ClientPtr client) -{ - register char n; - REQUEST(xvUngrabPortReq); - REQUEST_SIZE_MATCH(xvUngrabPortReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->time, n); - return ProcXvUngrabPort(client); -} - -static int -SProcXvPutVideo(ClientPtr client) -{ - register char n; - REQUEST(xvPutVideoReq); - REQUEST_SIZE_MATCH(xvPutVideoReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return ProcXvPutVideo(client); -} - -static int -SProcXvPutStill(ClientPtr client) -{ - register char n; - REQUEST(xvPutStillReq); - REQUEST_SIZE_MATCH(xvPutStillReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return ProcXvPutStill(client); -} - -static int -SProcXvGetVideo(ClientPtr client) -{ - register char n; - REQUEST(xvGetVideoReq); - REQUEST_SIZE_MATCH(xvGetVideoReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return ProcXvGetVideo(client); -} - -static int -SProcXvGetStill(ClientPtr client) -{ - register char n; - REQUEST(xvGetStillReq); - REQUEST_SIZE_MATCH(xvGetStillReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swaps(&stuff->vid_x, n); - swaps(&stuff->vid_y, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return ProcXvGetStill(client); -} - -static int -SProcXvPutImage(ClientPtr client) -{ - register char n; - REQUEST(xvPutImageReq); - REQUEST_AT_LEAST_SIZE(xvPutImageReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swapl(&stuff->id, n); - swaps(&stuff->src_x, n); - swaps(&stuff->src_y, n); - swaps(&stuff->src_w, n); - swaps(&stuff->src_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return ProcXvPutImage(client); -} - -#ifdef MITSHM -static int -SProcXvShmPutImage(ClientPtr client) -{ - register char n; - REQUEST(xvShmPutImageReq); - REQUEST_SIZE_MATCH(xvShmPutImageReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - swapl(&stuff->gc, n); - swapl(&stuff->shmseg, n); - swapl(&stuff->id, n); - swaps(&stuff->src_x, n); - swaps(&stuff->src_y, n); - swaps(&stuff->src_w, n); - swaps(&stuff->src_h, n); - swaps(&stuff->drw_x, n); - swaps(&stuff->drw_y, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - swaps(&stuff->offset, n); - swaps(&stuff->width, n); - swaps(&stuff->height, n); - return ProcXvShmPutImage(client); -} -#endif - - -static int -SProcXvSelectVideoNotify(ClientPtr client) -{ - register char n; - REQUEST(xvSelectVideoNotifyReq); - REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); - swaps(&stuff->length, n); - swapl(&stuff->drawable, n); - return ProcXvSelectVideoNotify(client); -} - -static int -SProcXvSelectPortNotify(ClientPtr client) -{ - register char n; - REQUEST(xvSelectPortNotifyReq); - REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return ProcXvSelectPortNotify(client); -} - -static int -SProcXvStopVideo(ClientPtr client) -{ - register char n; - REQUEST(xvStopVideoReq); - REQUEST_SIZE_MATCH(xvStopVideoReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->drawable, n); - return ProcXvStopVideo(client); -} - -static int -SProcXvSetPortAttribute(ClientPtr client) -{ - register char n; - REQUEST(xvSetPortAttributeReq); - REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->attribute, n); - return ProcXvSetPortAttribute(client); -} - -static int -SProcXvGetPortAttribute(ClientPtr client) -{ - register char n; - REQUEST(xvGetPortAttributeReq); - REQUEST_SIZE_MATCH(xvGetPortAttributeReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swapl(&stuff->attribute, n); - return ProcXvGetPortAttribute(client); -} - -static int -SProcXvQueryBestSize(ClientPtr client) -{ - register char n; - REQUEST(xvQueryBestSizeReq); - REQUEST_SIZE_MATCH(xvQueryBestSizeReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - swaps(&stuff->vid_w, n); - swaps(&stuff->vid_h, n); - swaps(&stuff->drw_w, n); - swaps(&stuff->drw_h, n); - return ProcXvQueryBestSize(client); -} - -static int -SProcXvQueryPortAttributes(ClientPtr client) -{ - register char n; - REQUEST(xvQueryPortAttributesReq); - REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return ProcXvQueryPortAttributes(client); -} - -static int -SProcXvQueryImageAttributes(ClientPtr client) -{ - register char n; - REQUEST(xvQueryImageAttributesReq); - REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); - swaps(&stuff->length, n); - swapl(&stuff->id, n); - swaps(&stuff->width, n); - swaps(&stuff->width, n); - return ProcXvQueryImageAttributes(client); -} - -static int -SProcXvListImageFormats(ClientPtr client) -{ - register char n; - REQUEST(xvListImageFormatsReq); - REQUEST_SIZE_MATCH(xvListImageFormatsReq); - swaps(&stuff->length, n); - swapl(&stuff->port, n); - return ProcXvListImageFormats(client); -} - - -static int -SWriteQueryExtensionReply( - ClientPtr client, - xvQueryExtensionReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->version, n); - swaps(&rep->revision, n); - - (void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryAdaptorsReply( - ClientPtr client, - xvQueryAdaptorsReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->num_adaptors, n); - - (void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryEncodingsReply( - ClientPtr client, - xvQueryEncodingsReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->num_encodings, n); - - (void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)&rep); - - return Success; -} - -static int -SWriteAdaptorInfo( - ClientPtr client, - xvAdaptorInfo *pAdaptor -){ - register char n; - - swapl(&pAdaptor->base_id, n); - swaps(&pAdaptor->name_size, n); - swaps(&pAdaptor->num_ports, n); - swaps(&pAdaptor->num_formats, n); - - (void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor); - - return Success; -} - -static int -SWriteEncodingInfo( - ClientPtr client, - xvEncodingInfo *pEncoding -){ - register char n; - - swapl(&pEncoding->encoding, n); - swaps(&pEncoding->name_size, n); - swaps(&pEncoding->width, n); - swaps(&pEncoding->height, n); - swapl(&pEncoding->rate.numerator, n); - swapl(&pEncoding->rate.denominator, n); - (void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding); - - return Success; -} - -static int -SWriteFormat( - ClientPtr client, - xvFormat *pFormat -){ - register char n; - - swapl(&pFormat->visual, n); - (void)WriteToClient(client, sz_xvFormat, (char *)pFormat); - - return Success; -} - -static int -SWriteAttributeInfo( - ClientPtr client, - xvAttributeInfo *pAtt -){ - register char n; - - swapl(&pAtt->flags, n); - swapl(&pAtt->size, n); - swapl(&pAtt->min, n); - swapl(&pAtt->max, n); - (void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt); - - return Success; -} - -static int -SWriteImageFormatInfo( - ClientPtr client, - xvImageFormatInfo *pImage -){ - register char n; - - swapl(&pImage->id, n); - swapl(&pImage->red_mask, n); - swapl(&pImage->green_mask, n); - swapl(&pImage->blue_mask, n); - swapl(&pImage->y_sample_bits, n); - swapl(&pImage->u_sample_bits, n); - swapl(&pImage->v_sample_bits, n); - swapl(&pImage->horz_y_period, n); - swapl(&pImage->horz_u_period, n); - swapl(&pImage->horz_v_period, n); - swapl(&pImage->vert_y_period, n); - swapl(&pImage->vert_u_period, n); - swapl(&pImage->vert_v_period, n); - - (void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage); - - return Success; -} - - - -static int -SWriteGrabPortReply( - ClientPtr client, - xvGrabPortReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - - (void)WriteToClient(client, sz_xvGrabPortReply, (char *)&rep); - - return Success; -} - -static int -SWriteGetPortAttributeReply( - ClientPtr client, - xvGetPortAttributeReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->value, n); - - (void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryBestSizeReply( - ClientPtr client, - xvQueryBestSizeReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swaps(&rep->actual_width, n); - swaps(&rep->actual_height, n); - - (void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryPortAttributesReply( - ClientPtr client, - xvQueryPortAttributesReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_attributes, n); - swapl(&rep->text_size, n); - - (void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)&rep); - - return Success; -} - -static int -SWriteQueryImageAttributesReply( - ClientPtr client, - xvQueryImageAttributesReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_planes, n); - swapl(&rep->data_size, n); - swaps(&rep->width, n); - swaps(&rep->height, n); - - (void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)&rep); - - return Success; -} - - -static int -SWriteListImageFormatsReply( - ClientPtr client, - xvListImageFormatsReply *rep -){ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - swapl(&rep->num_formats, n); - - (void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)&rep); - - return Success; -} - - -#ifdef PANORAMIX - - - - -static int -XineramaXvStopVideo(ClientPtr client) -{ - int result = Success, i; - PanoramiXRes *draw, *port; - REQUEST(xvStopVideoReq); - REQUEST_SIZE_MATCH(xvStopVideoReq); - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) - return _XvBadPort; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - result = ProcXvStopVideo(client); - } - } - - return result; -} - -static int -XineramaXvSetPortAttribute(ClientPtr client) -{ - REQUEST(xvSetPortAttributeReq); - PanoramiXRes *port; - int result = Success, i; - - REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) - return _XvBadPort; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->port = port->info[i].id; - result = ProcXvSetPortAttribute(client); - } - } - return result; -} - - -#ifdef MITSHM -static int -XineramaXvShmPutImage(ClientPtr client) -{ - REQUEST(xvShmPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool send_event = stuff->send_event; - Bool isRoot; - int result = Success, i, x, y; - - REQUEST_SIZE_MATCH(xvShmPutImageReq); - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) - return BadGC; - - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) - return _XvBadPort; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= panoramiXdataPtr[i].x; - stuff->drw_y -= panoramiXdataPtr[i].y; - } - stuff->send_event = (send_event && !i) ? 1 : 0; - - result = ProcXvShmPutImage(client); - } - } - return result; -} -#endif - -static int -XineramaXvPutImage(ClientPtr client) -{ - REQUEST(xvPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool isRoot; - int result = Success, i, x, y; - - REQUEST_AT_LEAST_SIZE(xvPutImageReq); - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) - return BadGC; - - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) - return _XvBadPort; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= panoramiXdataPtr[i].x; - stuff->drw_y -= panoramiXdataPtr[i].y; - } - - result = ProcXvPutImage(client); - } - } - return result; -} - -static int -XineramaXvPutVideo(ClientPtr client) -{ - REQUEST(xvPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool isRoot; - int result = Success, i, x, y; - - REQUEST_AT_LEAST_SIZE(xvPutVideoReq); - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) - return BadGC; - - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) - return _XvBadPort; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= panoramiXdataPtr[i].x; - stuff->drw_y -= panoramiXdataPtr[i].y; - } - - result = ProcXvPutVideo(client); - } - } - return result; -} - -static int -XineramaXvPutStill(ClientPtr client) -{ - REQUEST(xvPutImageReq); - PanoramiXRes *draw, *gc, *port; - Bool isRoot; - int result = Success, i, x, y; - - REQUEST_AT_LEAST_SIZE(xvPutImageReq); - - if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( - client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) - return BadDrawable; - - if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->gc, XRT_GC, SecurityReadAccess))) - return BadGC; - - if(!(port = (PanoramiXRes *)SecurityLookupIDByType( - client, stuff->port, XvXRTPort, SecurityReadAccess))) - return _XvBadPort; - - isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; - - x = stuff->drw_x; - y = stuff->drw_y; - - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= panoramiXdataPtr[i].x; - stuff->drw_y -= panoramiXdataPtr[i].y; - } - - result = ProcXvPutStill(client); - } - } - return result; -} - - -void XineramifyXv(void) -{ - ScreenPtr pScreen, screen0 = screenInfo.screens[0]; - XvScreenPtr xvsp0 = (XvScreenPtr)screen0->devPrivates[XvScreenIndex].ptr; - XvAdaptorPtr refAdapt, pAdapt; - XvAttributePtr pAttr; - XvScreenPtr xvsp; - Bool isOverlay, hasOverlay; - PanoramiXRes *port; - XvAdaptorPtr MatchingAdaptors[MAXSCREENS]; - int i, j, k, l; - - XvXRTPort = CreateNewResourceType(XineramaDeleteResource); - - if(!xvsp0) return; - - for(i = 0; i < xvsp0->nAdaptors; i++) { - refAdapt = xvsp0->pAdaptors + i; - - bzero(MatchingAdaptors, sizeof(XvAdaptorPtr) * MAXSCREENS); - - MatchingAdaptors[0] = refAdapt; - - if(!(refAdapt->type & XvInputMask)) continue; - - isOverlay = FALSE; - for(j = 0; j < refAdapt->nAttributes; j++) { - pAttr = refAdapt->pAttributes + j; - if(!strcmp(pAttr->name, "XV_COLORKEY")) { - isOverlay = TRUE; - break; - } - } - - for(j = 1; j < PanoramiXNumScreens; j++) { - pScreen = screenInfo.screens[j]; - xvsp = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr; - - /* Do not try to go on if xv is not supported on this screen */ - if (xvsp==NULL) continue ; - - /* if the adaptor has the same name it's a perfect match */ - for(k = 0; k < xvsp->nAdaptors; k++) { - pAdapt = xvsp->pAdaptors + k; - if(!strcmp(refAdapt->name, pAdapt->name)) { - MatchingAdaptors[j] = pAdapt; - break; - } - } - if(MatchingAdaptors[j]) continue; /* found it */ - - /* otherwise we only look for XvImage adaptors */ - if(!(refAdapt->type & XvImageMask)) continue; - if(refAdapt->nImages <= 0) continue; - - /* prefer overlay/overlay non-overlay/non-overlay pairing */ - for(k = 0; k < xvsp->nAdaptors; k++) { - pAdapt = xvsp->pAdaptors + k; - if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) { - hasOverlay = FALSE; - for(l = 0; l < pAdapt->nAttributes; l++) { - if(!strcmp(pAdapt->name, "XV_COLORKEY")) { - hasOverlay = TRUE; - break; - } - } - if(isOverlay && hasOverlay) { - MatchingAdaptors[j] = pAdapt; - break; - } - else if(!isOverlay && !hasOverlay) { - MatchingAdaptors[j] = pAdapt; - break; - } - } - } - - if(MatchingAdaptors[j]) continue; /* found it */ - - /* but we'll take any XvImage pairing if we can get it */ - - for(k = 0; k < xvsp->nAdaptors; k++) { - pAdapt = xvsp->pAdaptors + k; - if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) { - MatchingAdaptors[j] = pAdapt; - break; - } - } - } - - /* now create a resource for each port */ - for(j = 0; j < refAdapt->nPorts; j++) { - if(!(port = xalloc(sizeof(PanoramiXRes)))) - break; - port->info[0].id = MatchingAdaptors[0]->base_id + j; - AddResource(port->info[0].id, XvXRTPort, port); - - for(k = 1; k < PanoramiXNumScreens; k++) { - if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j)) - port->info[k].id = MatchingAdaptors[k]->base_id + j; - else - port->info[k].id = 0; - } - } - } -} - -#endif - #endif /* !defined(__sun) && !defined(__CYGWIN__) */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h b/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h index b42956fcf..fcfc133d5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h @@ -18,6 +18,7 @@ #ifndef __Pixmap_H__ #define __Pixmap_H__ +#include "resource.h" #include "Split.h" extern RESTYPE RT_NX_PIXMAP; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index d5f64d05b..72da2df19 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -15,8 +15,8 @@ /* */ /**************************************************************************/ -#include "NXpicturestr.h" -#include "NXglyphstr.h" +#include "picturestr.h" +#include "glyphstr.h" #include "Render.h" @@ -39,7 +39,7 @@ #define Atom XlibAtom #define Pixmap XlibPixmap -#include "NXrenderint.h" +#include "X11/include/Xrenderint_nxagent.h" #undef Atom #undef Pixmap diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.h b/nx-X11/programs/Xserver/hw/nxagent/Render.h index 70f0ef20f..54fe5452a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.h @@ -19,10 +19,11 @@ #define __Render_H__ #include "screenint.h" +#include "cursor.h" #include "picture.h" #include "renderproto.h" -#include "NXglyphstr.h" +#include "glyphstr.h" #include "Agent.h" diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 305d5648f..aab2a5e7c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -32,6 +32,8 @@ is" without express or implied warranty. #ifndef __Screen_H__ #define __Screen_H__ +#include "scrnintstr.h" + #define MIN_NXAGENT_WIDTH 80 #define MIN_NXAGENT_HEIGHT 60 #define NXAGENT_FRAME_WIDTH 2000 diff --git a/nx-X11/programs/Xserver/hw/nxagent/X11/include/Xcomposite_nxagent.h b/nx-X11/programs/Xserver/hw/nxagent/X11/include/Xcomposite_nxagent.h new file mode 100644 index 000000000..ba3668015 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/nxagent/X11/include/Xcomposite_nxagent.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/* + * Copyright © 2003 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file is a reduced version of the header file of + * <X11/extensions/Xcomposite.h> + * + * This copy of code has been introduced to allow a clear namespace + * separation between <X11/...> and <nx-X11/...> header files. + * + * This version of the Xcomposite library header file only contains symbols + * required by nxagent and strictly avoids indirectly including + * from an X11 library that is also shipped in nx-X11/lib/. + * + * When using <X11/extensions/Xcomposite.h> instead for inclusion in + * nxagent, it will attempt pulling in the <X11/extensions/Xlib.h>. + * However, the headers of the same name from <nx-X11/...> should be + * used instead. + * + * FIXME: Once the nxagent Xserver starts using libX11 from X.Org, this + * hack can be removed. + * + * 2016/04/07, Mike Gabriel <mike.gabriel@das-netzwerkteam.de> + */ + +#ifndef _XCOMPOSITE_H_ +#define _XCOMPOSITE_H_ + +#include <X11/extensions/composite.h> +#include <nx-X11/Xfuncproto.h> + +/* + * This revision number also appears in configure.ac, they have + * to be manually synchronized + */ +#define XCOMPOSITE_MAJOR COMPOSITE_MAJOR +#define XCOMPOSITE_MINOR COMPOSITE_MINOR +#define XCOMPOSITE_REVISION 2 +#define XCOMPOSITE_VERSION ((XCOMPOSITE_MAJOR * 10000) + (XCOMPOSITE_MINOR * 100) + (XCOMPOSITE_REVISION)) + +_XFUNCPROTOBEGIN + +Bool XCompositeQueryExtension (Display *dpy, + int *event_base_return, + int *error_base_return); + +Status XCompositeQueryVersion (Display *dpy, + int *major_version_return, + int *minor_version_return); + +void +XCompositeRedirectWindow (Display *dpy, Window window, int update); + +void +XCompositeRedirectSubwindows (Display *dpy, Window window, int update); + +void +XCompositeUnredirectWindow (Display *dpy, Window window, int update); + +void +XCompositeUnredirectSubwindows (Display *dpy, Window window, int update); + +_XFUNCPROTOEND + +#endif /* _XCOMPOSITE_H_ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrenderint.h b/nx-X11/programs/Xserver/hw/nxagent/X11/include/Xrenderint_nxagent.h index f67922c6b..823d1e427 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrenderint.h +++ b/nx-X11/programs/Xserver/hw/nxagent/X11/include/Xrenderint_nxagent.h @@ -28,7 +28,7 @@ #include <nx-X11/Xlibint.h> #include <nx-X11/Xutil.h> #include <nx-X11/extensions/renderproto.h> -#include "X11/include/Xrender_nxagent.h" +#include "Xrender_nxagent.h" typedef struct { Visual *visual; |