diff options
Diffstat (limited to 'Xext/panoramiXprocs.c')
-rw-r--r-- | Xext/panoramiXprocs.c | 3996 |
1 files changed, 1668 insertions, 2328 deletions
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c index cd54bdcb3..37b54f4bc 100644 --- a/Xext/panoramiXprocs.c +++ b/Xext/panoramiXprocs.c @@ -24,6 +24,10 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ +/* Massively rewritten by Mark Vojkovich <markv@valinux.com> */ + +/* $XFree86: xc/programs/Xserver/Xext/panoramiXprocs.c,v 3.33 2002/04/10 21:38:53 mvojkovi Exp $ */ + #include <stdio.h> #include "X.h" #define NEED_REPLIES @@ -40,757 +44,485 @@ Equipment Corporation. #include "misc.h" #include "dixstruct.h" #include "panoramiX.h" +#include "panoramiXsrv.h" +#include "resource.h" + +#define XINERAMA_IMAGE_BUFSIZE (256*1024) +#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ + CWDontPropagate | CWOverrideRedirect | CWCursor ) -extern Bool noPanoramiXExtension; -extern Bool PanoramiXVisibilityNotifySent; -extern Bool PanoramiXMapped; -extern int PanoramiXNumScreens; -extern int PanoramiXPixWidth; -extern int PanoramiXPixHeight; -extern PanoramiXWindow *PanoramiXWinRoot; -extern PanoramiXGC *PanoramiXGCRoot; -extern PanoramiXCmap *PanoramiXCmapRoot; -extern PanoramiXPmap *PanoramiXPmapRoot; -extern PanoramiXData *panoramiXdataPtr; -extern PanoramiXCDT PanoramiXColorDepthTable[MAXSCREENS]; extern ScreenInfo *GlobalScrInfo; -extern int (* SavedProcVector[256])(); -extern void (* ReplySwapVector[256])(); -extern WindowPtr *WindowTable; extern char *ConnectionInfo; extern int connBlockScreenStart; -extern XID clientErrorValue; - -extern void Swap32Write(); - -extern long defaultScreenSaverTime; -extern long defaultScreenSaverInterval; -extern int defaultScreenSaverBlanking; -extern int defaultScreenSaverAllowExposures; -static ClientPtr onlyClient; -static Bool grabbingClient = FALSE; -#ifdef __alpha /* THIS NEEDS TO BE LONG !!!! Change driver! */ -int *checkForInput[2]; -#else -long *checkForInput[2]; -#endif -extern int connBlockScreenStart; - -extern int (* InitialVector[3]) (); -extern int (* ProcVector[256]) (); -extern int (* SwappedProcVector[256]) (); +extern int (* SavedProcVector[256]) (); extern void (* EventSwapVector[128]) (); -extern void (* ReplySwapVector[256]) (); extern void Swap32Write(), SLHostsExtend(), SQColorsExtend(), WriteSConnectionInfo(); extern void WriteSConnSetupPrefix(); -extern char *ClientAuthorized(); -extern Bool InsertFakeRequest(); -static void KillAllClients(); -static void DeleteClientFromAnySelections(); -extern void ProcessWorkQueue(); - - -static int nextFreeClientID; /* always MIN free client ID */ - -static int nClients; /* number active clients */ - -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)) +extern XID clientErrorValue; /* XXX this is a kludge */ - - -extern int Ones(); - -int PanoramiXCreateWindow(register ClientPtr client) +int PanoramiXCreateWindow(ClientPtr client) { - register WindowPtr pParent, pWin; + PanoramiXRes *parent, *newWin; + PanoramiXRes *backPix = NULL; + PanoramiXRes *bordPix = NULL; + PanoramiXRes *cmap = NULL; REQUEST(xCreateWindowReq); - int result, j = 0; - unsigned len; - Bool FoundIt = FALSE; - Window winID; - Window parID; - PanoramiXWindow *localWin; - PanoramiXWindow *parentWin = PanoramiXWinRoot; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXCmap *pPanoramiXCmap = NULL; - PanoramiXPmap *pBackgndPmap = NULL; - PanoramiXPmap *pBorderPmap = NULL; - VisualID orig_visual; - XID orig_wid; - int orig_x, orig_y; - register Mask orig_mask; - int cmap_offset = 0; - int pback_offset = 0; - int pbord_offset = 0; - int class_index, this_class_index; - int vid_index, this_vid_index; + int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; + int result = 0, len, j; + int orig_x, orig_y; + XID orig_visual, tmp; + Bool parentIsRoot; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); len = client->req_len - (sizeof(xCreateWindowReq) >> 2); - IF_RETURN((Ones((Mask)stuff->mask) != len), BadLength); - orig_mask = stuff->mask; - PANORAMIXFIND_ID(parentWin, stuff->parent); - if (parentWin) { - localWin = (PanoramiXWindow *)Xcalloc(sizeof(PanoramiXWindow)); - IF_RETURN(!localWin, BadAlloc); - } else { - return BadWindow; - } - if ((PanoramiXNumScreens - 1) && ((Mask)stuff->mask & CWBackPixmap)) { - XID pmapID; + if (Ones(stuff->mask) != len) + return BadLength; + + if (!(parent = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->parent, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + if(stuff->class == CopyFromParent) + stuff->class = parent->u.win.class; + + if((stuff->class == InputOnly) && (stuff->mask & (~INPUTONLY_LEGAL_MASK))) + return BadMatch; + if ((Mask)stuff->mask & CWBackPixmap) { pback_offset = Ones((Mask)stuff->mask & (CWBackPixmap - 1)); - pmapID = *((CARD32 *) &stuff[1] + pback_offset); - if (pmapID) { - pBackgndPmap = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pBackgndPmap, pmapID); + tmp = *((CARD32 *) &stuff[1] + pback_offset); + if ((tmp != None) && (tmp != ParentRelative)) { + if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } - if ((PanoramiXNumScreens - 1) && ((Mask)stuff->mask & CWBorderPixmap)) { - XID pmapID; - + if ((Mask)stuff->mask & CWBorderPixmap) { pbord_offset = Ones((Mask)stuff->mask & (CWBorderPixmap - 1)); - pmapID = *((CARD32 *) &stuff[1] + pbord_offset); - if (pmapID) { - pBorderPmap = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pBorderPmap, pmapID); + tmp = *((CARD32 *) &stuff[1] + pbord_offset); + if (tmp != CopyFromParent) { + if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } - if ((PanoramiXNumScreens - 1) && ((Mask)stuff->mask & CWColormap)) { - Colormap cmapID; - + if ((Mask)stuff->mask & CWColormap) { cmap_offset = Ones((Mask)stuff->mask & (CWColormap - 1)); - cmapID = *((CARD32 *) &stuff[1] + cmap_offset); - if (cmapID) { - pPanoramiXCmap = PanoramiXCmapRoot; - PANORAMIXFIND_ID(pPanoramiXCmap, cmapID); + tmp = *((CARD32 *) &stuff[1] + cmap_offset); + if ((tmp != CopyFromParent) && (tmp != None)) { + if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_COLORMAP, SecurityReadAccess))) + return BadColor; } } + + if(!(newWin = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newWin->type = XRT_WINDOW; + newWin->u.win.visibility = VisibilityNotViewable; + newWin->u.win.class = stuff->class; + newWin->info[0].id = stuff->wid; + for(j = 1; j < PanoramiXNumScreens; j++) + newWin->info[j].id = FakeClientID(client->index); + + if (stuff->class == InputOnly) + stuff->visual = CopyFromParent; + orig_visual = stuff->visual; orig_x = stuff->x; orig_y = stuff->y; - orig_wid = stuff->wid; - orig_visual = stuff->visual; - for (j = 0; j <= PanoramiXNumScreens - 1; j++) { - winID = j ? FakeClientID(client->index) : orig_wid; - localWin->info[j].id = winID; - } - localWin->FreeMe = FALSE; - localWin->visibility = VisibilityNotViewable; - localWin->VisibilitySent = FALSE; - PANORAMIXFIND_LAST(pPanoramiXWin, PanoramiXWinRoot); - pPanoramiXWin->next = localWin; - if ( (stuff->visual != CopyFromParent) && (stuff->depth != 0)) - { - /* Find the correct visual for this screen */ - for (class_index = 0; class_index < PanoramiXColorDepthTable[0].numVisuals; -class_index++) - { - for (vid_index = 0; vid_index < PanoramiXColorDepthTable[0].panoramiXScreenMap[class_index].vmap[stuff->depth].numVids; vid_index++) - { - if ( stuff->visual == PanoramiXColorDepthTable[0].panoramiXScreenMap[class_index].vmap[stuff->depth].vid[vid_index] ) - { - this_class_index = class_index; - this_vid_index = vid_index; - FoundIt = TRUE; - break; - } - } - } - } - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - if (parentWin == PanoramiXWinRoot) { + parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id); + FOR_NSCREENS_BACKWARD(j) { + stuff->wid = newWin->info[j].id; + stuff->parent = parent->info[j].id; + if (parentIsRoot) { stuff->x = orig_x - panoramiXdataPtr[j].x; stuff->y = orig_y - panoramiXdataPtr[j].y; } - stuff->wid = localWin->info[j].id; - parID = (XID)(parentWin->info[j].id); - pParent = (WindowPtr)SecurityLookupWindow(parID, client,SecurityReadAccess); - IF_RETURN((!pParent),BadWindow); - stuff->parent = parID; - if ( (orig_visual != CopyFromParent) && (stuff->depth != 0) && FoundIt ) - { - stuff->visual = PanoramiXColorDepthTable[j].panoramiXScreenMap[this_class_index].vmap[stuff->depth].vid[this_vid_index]; - } - if (pBackgndPmap) - *((CARD32 *) &stuff[1] + pback_offset) = pBackgndPmap->info[j].id; - if (pBorderPmap) - *((CARD32 *) &stuff[1] + pbord_offset) = pBorderPmap->info[j].id; - if (pPanoramiXCmap) - *((CARD32 *) &stuff[1] + cmap_offset) = pPanoramiXCmap->info[j].id; - stuff->mask = orig_mask; - result = (*SavedProcVector[X_CreateWindow])(client); - BREAK_IF(result != Success); - } - if (result != Success) { - pPanoramiXWin->next = NULL; - if (localWin) - Xfree(localWin); - } + if (backPix) + *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; + if (bordPix) + *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; + if (cmap) + *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; + if ( orig_visual != CopyFromParent ) + stuff->visual = PanoramiXVisualTable[(orig_visual*MAXSCREENS) + j]; + result = (*SavedProcVector[X_CreateWindow])(client); + if(result != Success) break; + } + + if (result == Success) + AddResource(newWin->info[0].id, XRT_WINDOW, newWin); + else + xfree(newWin); + return (result); } - -int PanoramiXChangeWindowAttributes(register ClientPtr client) +int PanoramiXChangeWindowAttributes(ClientPtr client) { - register WindowPtr pWin; + PanoramiXRes *win; + PanoramiXRes *backPix = NULL; + PanoramiXRes *bordPix = NULL; + PanoramiXRes *cmap = NULL; REQUEST(xChangeWindowAttributesReq); - register int result; - int len; - int j; - Window winID; - Mask orig_valueMask; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXWindow *pPanoramiXWinback = NULL; - PanoramiXCmap *pPanoramiXCmap = NULL; - PanoramiXPmap *pBackgndPmap = NULL; - PanoramiXPmap *pBorderPmap = NULL; - int cmap_offset = 0; - int pback_offset = 0; - int pbord_offset = 0; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; + int pback_offset = 0, pbord_offset = 0, cmap_offset = 0; + int result = 0, len, j; + XID tmp; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); + len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2); - IF_RETURN((len != Ones((Mask) stuff->valueMask)), BadLength); - orig_valueMask = stuff->valueMask; - winID = stuff->window; - for (; pPanoramiXWin && (pPanoramiXWin->info[0].id != stuff->window); - pPanoramiXWin = pPanoramiXWin->next) - pPanoramiXWinback = pPanoramiXWin; - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, winID); - IF_RETURN(!pPanoramiXWin, BadWindow); - if ((PanoramiXNumScreens - 1) && ((Mask)stuff->valueMask & CWBackPixmap)) { - XID pmapID; + if (Ones(stuff->valueMask) != len) + return BadLength; + if (!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + if((win->u.win.class == InputOnly) && + (stuff->valueMask & (~INPUTONLY_LEGAL_MASK))) + return BadMatch; + + if ((Mask)stuff->valueMask & CWBackPixmap) { pback_offset = Ones((Mask)stuff->valueMask & (CWBackPixmap - 1)); - pmapID = *((CARD32 *) &stuff[1] + pback_offset); - if (pmapID) { - pBackgndPmap = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pBackgndPmap, pmapID); + tmp = *((CARD32 *) &stuff[1] + pback_offset); + if ((tmp != None) && (tmp != ParentRelative)) { + if(!(backPix = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } - if ((PanoramiXNumScreens - 1) && ((Mask)stuff->valueMask & CWBorderPixmap)) { - XID pmapID; - + if ((Mask)stuff->valueMask & CWBorderPixmap) { pbord_offset = Ones((Mask)stuff->valueMask & (CWBorderPixmap - 1)); - pmapID = *((CARD32 *) &stuff[1] + pbord_offset); - if (pmapID) { - pBorderPmap = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pBorderPmap, pmapID); + tmp = *((CARD32 *) &stuff[1] + pbord_offset); + if (tmp != CopyFromParent) { + if(!(bordPix = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } - if ((PanoramiXNumScreens - 1) && ((Mask)stuff->valueMask & CWColormap )) { - Colormap cmapID; - + if ((Mask)stuff->valueMask & CWColormap) { cmap_offset = Ones((Mask)stuff->valueMask & (CWColormap - 1)); - cmapID = *((CARD32 *) &stuff[1] + cmap_offset); - if (cmapID) { - pPanoramiXCmap = PanoramiXCmapRoot; - PANORAMIXFIND_ID(pPanoramiXCmap, cmapID); + tmp = *((CARD32 *) &stuff[1] + cmap_offset); + if ((tmp != CopyFromParent) && (tmp != None)) { + if(!(cmap = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_COLORMAP, SecurityReadAccess))) + return BadColor; } } - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->window = pPanoramiXWin->info[j].id; - stuff->valueMask = orig_valueMask; - if (pBackgndPmap) - *((CARD32 *) &stuff[1] + pback_offset) = pBackgndPmap->info[j].id; - if (pBorderPmap) - *((CARD32 *) &stuff[1] + pbord_offset) = pBorderPmap->info[j].id; - if (pPanoramiXCmap) - *((CARD32 *) &stuff[1] + cmap_offset) = pPanoramiXCmap->info[j].id; - result = (*SavedProcVector[X_ChangeWindowAttributes])(client); - BREAK_IF(result != Success); - } - if ((result == Success) && pPanoramiXWinback && - pPanoramiXWin && pPanoramiXWin->FreeMe) { - pPanoramiXWinback->next = pPanoramiXWin->next; - Xfree(pPanoramiXWin); - } + + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + if (backPix) + *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id; + if (bordPix) + *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id; + if (cmap) + *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id; + result = (*SavedProcVector[X_ChangeWindowAttributes])(client); + } + return (result); } int PanoramiXDestroyWindow(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xResourceReq); - int j, result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXWindow *pPanoramiXWinback = NULL; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - for (; pPanoramiXWin && (pPanoramiXWin->info[0].id != stuff->id); - pPanoramiXWin = pPanoramiXWin->next) - pPanoramiXWinback = pPanoramiXWin; - IF_RETURN(!pPanoramiXWin,BadWindow); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->id = pPanoramiXWin->info[j].id; - result = (* SavedProcVector[X_DestroyWindow])(client); - BREAK_IF(result != Success); - } - if ((result == Success) && pPanoramiXWinback && - pPanoramiXWin && pPanoramiXWin->FreeMe) { - pPanoramiXWinback->next = pPanoramiXWin->next; - Xfree(pPanoramiXWin); - } - PANORAMIX_FREE(client); + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_WINDOW, SecurityDestroyAccess))) + return BadWindow; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_DestroyWindow])(client); + if(result != Success) break; + } + + /* Since ProcDestroyWindow is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + return (result); } int PanoramiXDestroySubwindows(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xResourceReq); - int j,result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXWindow *pPanoramiXWinback = NULL; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - for (; pPanoramiXWin && (pPanoramiXWin->info[0].id != stuff->id); - pPanoramiXWin = pPanoramiXWin->next) - pPanoramiXWinback = pPanoramiXWin; - IF_RETURN(!pPanoramiXWin, BadWindow); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->id = pPanoramiXWin->info[j].id; - result = (* SavedProcVector[X_DestroySubwindows])(client); - } - if ((result == Success) && pPanoramiXWinback && - pPanoramiXWin && pPanoramiXWin->FreeMe) { - pPanoramiXWinback->next = pPanoramiXWin->next; - Xfree(pPanoramiXWin); - } - PANORAMIX_FREE(client); + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_WINDOW, SecurityDestroyAccess))) + return BadWindow; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_DestroySubwindows])(client); + if(result != Success) break; + } + + /* DestroySubwindows is using FreeResource which will free + our resources for us on the last pass through the loop above */ + return (result); } int PanoramiXChangeSaveSet(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xChangeSaveSetReq); - int j, result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; REQUEST_SIZE_MATCH(xChangeSaveSetReq); - if (!stuff->window) - result = (* SavedProcVector[X_ChangeSaveSet])(client); - else { - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - IF_RETURN(!pPanoramiXWin, BadWindow); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->window = pPanoramiXWin->info[j].id; - result = (* SavedProcVector[X_ChangeSaveSet])(client); - } + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->window, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + result = (*SavedProcVector[X_ChangeSaveSet])(client); + if(result != Success) break; } + return (result); } -int PanoramiXReparentWindow(register ClientPtr client) +int PanoramiXReparentWindow(ClientPtr client) { - register WindowPtr pWin, pParent; + PanoramiXRes *win, *parent; + int result = 0, j; + int x, y; + Bool parentIsRoot; REQUEST(xReparentWindowReq); - register int result; - int j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXWindow *pPanoramiXPar = PanoramiXWinRoot; REQUEST_SIZE_MATCH(xReparentWindowReq); - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - IF_RETURN(!pPanoramiXWin, BadWindow); - PANORAMIXFIND_ID(pPanoramiXPar, stuff->parent); - IF_RETURN(!pPanoramiXPar, BadWindow); - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXPar), j) { - stuff->window = pPanoramiXWin->info[j].id; - stuff->parent = pPanoramiXPar->info[j].id; + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + if(!(parent = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->parent, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + x = stuff->x; + y = stuff->y; + parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id); + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + stuff->parent = parent->info[j].id; + if(parentIsRoot) { + stuff->x = x - panoramiXdataPtr[j].x; + stuff->y = y - panoramiXdataPtr[j].y; + } result = (*SavedProcVector[X_ReparentWindow])(client); - BREAK_IF(result != Success); + if(result != Success) break; } + return (result); } -int PanoramiXMapWindow(register ClientPtr client) +int PanoramiXMapWindow(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xResourceReq); - int j,result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - register WindowPtr pWin, pChild; - Window winID; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - /* initialize visibility */ - pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client, -SecurityReadAccess); - IF_RETURN(!pWin, BadWindow); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pChild->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; - } - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->id); - IF_RETURN(!pPanoramiXWin, BadWindow); - PanoramiXMapped = TRUE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - for (j = 0; j <= (PanoramiXNumScreens - 1); j++) - { - winID = pPanoramiXWin->info[j].id; - pWin = (WindowPtr) SecurityLookupWindow(winID, -client,SecurityReadAccess); - IF_RETURN((!pWin), BadWindow); - stuff->id = winID; - result = (*SavedProcVector[X_MapWindow])(client); - } - /* clean up */ - PanoramiXMapped = FALSE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - pWin = (WindowPtr) SecurityLookupWindow(stuff->id, -client,SecurityReadAccess); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib){ - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pChild->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_MapWindow])(client); + if(result != Success) break; } + return (result); } -int PanoramiXMapSubwindows(register ClientPtr client) +int PanoramiXMapSubwindows(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xResourceReq); - int j,result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - register WindowPtr pWin, pChild; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - /* initialize visibility values */ - pWin = (WindowPtr) SecurityLookupWindow(stuff->id, -client,SecurityReadAccess); - IF_RETURN(!pWin, BadWindow); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib){ - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pChild->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; - } - - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->id); - IF_RETURN(!pPanoramiXWin, BadWindow); - PanoramiXMapped = TRUE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - for (j = 0; j <= (PanoramiXNumScreens - 1); j++) - { - stuff->id = pPanoramiXWin->info[j].id; + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; result = (*SavedProcVector[X_MapSubwindows])(client); + if(result != Success) break; } - /* clean up */ - PanoramiXMapped = FALSE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - pWin = (WindowPtr) SecurityLookupWindow(stuff->id, -client,SecurityReadAccess); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pChild->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; - } - PANORAMIX_FREE(client); + return (result); } -int PanoramiXUnmapWindow(register ClientPtr client) +int PanoramiXUnmapWindow(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xResourceReq); - int j, result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - register WindowPtr pWin, pChild; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - /* initialize visibility values */ - pWin = (WindowPtr) SecurityLookupWindow(stuff->id, -client,SecurityReadAccess); - IF_RETURN(!pWin, BadWindow); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib){ - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pWin->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; - } - - PANORAMIXFIND_ID(pPanoramiXWin, stuff->id); - IF_RETURN(!pPanoramiXWin, BadWindow); - PanoramiXMapped = TRUE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - for (j = 0; j <= (PanoramiXNumScreens - 1); j++) - { - stuff->id = pPanoramiXWin->info[j].id; - result = (*SavedProcVector[X_UnmapWindow])(client); - } - - /* clean up */ - PanoramiXMapped = FALSE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - pWin = (WindowPtr) SecurityLookupWindow(stuff->id, -client,SecurityReadAccess); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pChild->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; - } - PANORAMIX_FREE(client); - return (client->noClientException); + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; + result = (*SavedProcVector[X_UnmapWindow])(client); + if(result != Success) break; + } + + return (result); } -int PanoramiXUnmapSubwindows(register ClientPtr client) +int PanoramiXUnmapSubwindows(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xResourceReq); - int j, result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - register WindowPtr pWin, pChild; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - /* initialize visibility values */ - pWin = (WindowPtr) SecurityLookupWindow(stuff->id, -client,SecurityReadAccess); - IF_RETURN(!pWin, BadWindow); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib){ - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pWin->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; - } - - PANORAMIXFIND_ID(pPanoramiXWin, stuff->id); - IF_RETURN(!pPanoramiXWin, BadWindow); - PanoramiXMapped = TRUE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - for (j = 0; j <= (PanoramiXNumScreens - 1); j++) - { - stuff->id = pPanoramiXWin->info[j].id; + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + + FOR_NSCREENS_FORWARD(j) { + stuff->id = win->info[j].id; result = (*SavedProcVector[X_UnmapSubwindows])(client); + if(result != Success) break; } - /* clean up */ - PanoramiXMapped = FALSE; - PanoramiXVisibilityNotifySent = FALSE; - pPanoramiXWin->VisibilitySent = FALSE; - pWin = (WindowPtr) SecurityLookupWindow(stuff->id, -client,SecurityReadAccess); - for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib){ - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, pWin->drawable.id); - if (pPanoramiXWin) - pPanoramiXWin->VisibilitySent = FALSE; - } - PANORAMIX_FREE(client); - return (client->noClientException); + return (result); } -int PanoramiXConfigureWindow(register ClientPtr client) +int PanoramiXConfigureWindow(ClientPtr client) { - register WindowPtr pWin; + PanoramiXRes *win; + PanoramiXRes *sib = NULL; + WindowPtr pWin; + int result = 0, j, len, sib_offset = 0, x = 0, y = 0; + int x_offset = -1; + int y_offset = -1; REQUEST(xConfigureWindowReq); - register int result; - unsigned len, i, things; - XID changes[32]; - register Mask orig_mask; - int j, sib_position; - Window winID; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXWindow *pPanoramiXSib = NULL; - int x_off = 0, y_off = 0; - XID *pStuff; - XID *origStuff, *modStuff; - Mask local_mask; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); + len = client->req_len - (sizeof(xConfigureWindowReq) >> 2); - things = Ones((Mask)stuff->mask); - IF_RETURN((things != len), BadLength); - orig_mask = stuff->mask; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - if (!pPanoramiXWin) { - client->errorValue = stuff->window; - return (BadWindow); - } - if (things > 0) { - pStuff = (XID *) ALLOCATE_LOCAL(things * sizeof(XID)); - memcpy((char *) pStuff, (char *) &stuff[1], things * sizeof(XID)); - local_mask = (CWSibling | CWX | CWY) & ((Mask) stuff->mask); - if (local_mask & CWSibling) { - sib_position = Ones((Mask) stuff->mask & (CWSibling - 1)); - pPanoramiXSib = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXSib, *(pStuff + sib_position)); - } - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - winID = pPanoramiXWin->info[j].id; - pWin = (WindowPtr)SecurityLookupWindow(winID, client,SecurityReadAccess); - if (!pWin) { - client->errorValue = pPanoramiXWin->info[0].id; - return (BadWindow); - } - stuff->window = winID; - if (pWin->parent - && (pWin->parent->drawable.id == PanoramiXWinRoot->info[j].id)) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } - modStuff = (XID *) &stuff[1]; - origStuff = pStuff; - i = things; - if (local_mask & CWX) { - *modStuff++ = *origStuff++ - x_off; - i--; - } - if (local_mask & CWY) { - *modStuff++ = *origStuff++ - y_off; - i--; - } - for ( ; i; i--) - *modStuff++ = *origStuff++; - if (pPanoramiXSib) - *((XID *) &stuff[1] + sib_position) = pPanoramiXSib->info[j].id; - stuff->mask = orig_mask; - result = (*SavedProcVector[X_ConfigureWindow])(client); - } - DEALLOCATE_LOCAL(pStuff); - PANORAMIX_FREE(client); + if (Ones(stuff->mask) != len) + return BadLength; + + /* because we need the parent */ + if (!(pWin = (WindowPtr)SecurityLookupIDByType( + client, stuff->window, RT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + if (!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + if ((Mask)stuff->mask & CWSibling) { + XID tmp; + sib_offset = Ones((Mask)stuff->mask & (CWSibling - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + sib_offset))) { + if(!(sib = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + } + } + + if(pWin->parent && (pWin->parent == WindowTable[0])) { + if ((Mask)stuff->mask & CWX) { + x_offset = 0; + x = *((CARD32 *)&stuff[1]); + } + if ((Mask)stuff->mask & CWY) { + y_offset = (x_offset == -1) ? 0 : 1; + y = *((CARD32 *) &stuff[1] + y_offset); + } + } + + /* have to go forward or you get expose events before + ConfigureNotify events */ + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; + if(sib) + *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id; + if(x_offset >= 0) + *((CARD32 *) &stuff[1] + x_offset) = x - panoramiXdataPtr[j].x; + if(y_offset >= 0) + *((CARD32 *) &stuff[1] + y_offset) = y - panoramiXdataPtr[j].y; + result = (*SavedProcVector[X_ConfigureWindow])(client); + if(result != Success) break; + } + return (result); - } else - return (client->noClientException); } -int PanoramiXCirculateWindow(register ClientPtr client) +int PanoramiXCirculateWindow(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j; REQUEST(xCirculateWindowReq); - int j,result; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xCirculateWindowReq); - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - IF_RETURN(!pPanoramiXWin, BadWindow); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->window = pPanoramiXWin->info[j].id; + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + FOR_NSCREENS_FORWARD(j) { + stuff->window = win->info[j].id; result = (*SavedProcVector[X_CirculateWindow])(client); + if(result != Success) break; } + return (result); } -int PanoramiXGetGeometry(register ClientPtr client) +int PanoramiXGetGeometry(ClientPtr client) { xGetGeometryReply rep; - register DrawablePtr pDraw; + DrawablePtr pDraw; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -798,1883 +530,1489 @@ int PanoramiXGetGeometry(register ClientPtr client) rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; - rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id; + rep.root = WindowTable[0]->drawable.id; rep.depth = pDraw->depth; + rep.width = pDraw->width; + rep.height = pDraw->height; + rep.x = rep.y = rep.borderWidth = 0; - if (stuff->id == PanoramiXWinRoot->info[0].id) { - xConnSetup *setup = (xConnSetup *) ConnectionInfo; + if (stuff->id == rep.root) { xWindowRoot *root = (xWindowRoot *) (ConnectionInfo + connBlockScreenStart); rep.width = root->pixWidth; rep.height = root->pixHeight; - } else { - 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; + } else + if ((pDraw->type == UNDRAWABLE_WINDOW) || (pDraw->type == DRAWABLE_WINDOW)) + { + WindowPtr pWin = (WindowPtr)pDraw; rep.x = pWin->origin.x - wBorderWidth (pWin); rep.y = pWin->origin.y - wBorderWidth (pWin); + if(pWin->parent == WindowTable[0]) { + rep.x += panoramiXdataPtr[0].x; + rep.y += panoramiXdataPtr[0].y; + } rep.borderWidth = pWin->borderWidth; - } else { /* DRAWABLE_PIXMAP or DRAWABLE_BUFFER */ - rep.x = rep.y = rep.borderWidth = 0; } + WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); return (client->noClientException); } +int PanoramiXTranslateCoords(ClientPtr client) +{ + INT16 x, y; + REQUEST(xTranslateCoordsReq); -int PanoramiXChangeProperty(ClientPtr client) -{ - int result, j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - REQUEST(xChangePropertyReq); - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; - - REQUEST_AT_LEAST_SIZE(xChangePropertyReq); - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - IF_RETURN(!pPanoramiXWin, BadWindow); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->window = pPanoramiXWin->info[j].id; - result = (* SavedProcVector[X_ChangeProperty])(client); - if (result != Success) { - stuff->window = pPanoramiXWin->info[0].id; - break; - } - } - return (result); -} - - -int PanoramiXDeleteProperty(ClientPtr client) -{ - int result, j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - REQUEST(xDeletePropertyReq); - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; - - REQUEST_SIZE_MATCH(xDeletePropertyReq); - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - IF_RETURN(!pPanoramiXWin, BadWindow); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->window = pPanoramiXWin->info[j].id; - result = (* SavedProcVector[X_DeleteProperty])(client); - BREAK_IF(result != Success); - } - PANORAMIX_FREE(client); - return (result); -} + register WindowPtr pWin, pDst; + xTranslateCoordsReply rep; + REQUEST_SIZE_MATCH(xTranslateCoordsReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, + SecurityReadAccess); + if (!pWin) + return(BadWindow); + pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, + SecurityReadAccess); + if (!pDst) + return(BadWindow); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.sameScreen = xTrue; + rep.child = None; -int PanoramiXSendEvent(ClientPtr client) -{ - int result, j; - BYTE orig_type; - Mask orig_eventMask; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - REQUEST(xSendEventReq); - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; - - REQUEST_SIZE_MATCH(xSendEventReq); - PANORAMIXFIND_ID(pPanoramiXWin, stuff->destination); - orig_type = stuff->event.u.u.type; - orig_eventMask = stuff->eventMask; - if (!pPanoramiXWin) { - noPanoramiXExtension = TRUE; - result = (* SavedProcVector[X_SendEvent])(client); - noPanoramiXExtension = FALSE; + if(pWin == WindowTable[0]) { + x = stuff->srcX - panoramiXdataPtr[0].x; + y = stuff->srcY - panoramiXdataPtr[0].y; + } else { + x = pWin->drawable.x + stuff->srcX; + y = pWin->drawable.y + stuff->srcY; } - else { - noPanoramiXExtension = FALSE; - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->destination = pPanoramiXWin->info[j].id; - stuff->eventMask = orig_eventMask; - stuff->event.u.u.type = orig_type; - if (!j) - noPanoramiXExtension = TRUE; - result = (* SavedProcVector[X_SendEvent])(client); - noPanoramiXExtension = FALSE; - } + 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) || + POINT_IN_REGION(pWin->drawable.pScreen, + wBoundingShape(pWin), + x - pWin->drawable.x, + y - pWin->drawable.y, &box)) +#endif + ) + { + rep.child = pWin->drawable.id; + pWin = (WindowPtr) NULL; + } + else + pWin = pWin->nextSib; + } + rep.dstX = x - pDst->drawable.x; + rep.dstY = y - pDst->drawable.y; + if(pDst == WindowTable[0]) { + rep.dstX += panoramiXdataPtr[0].x; + rep.dstY += panoramiXdataPtr[0].y; } - return (result); -} + WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); + return(client->noClientException); +} -int PanoramiXCreatePixmap(register ClientPtr client) +int PanoramiXCreatePixmap(ClientPtr client) { - PixmapPtr pMap; - register DrawablePtr pDraw; + PanoramiXRes *refDraw, *newPix; + int result = 0, j; REQUEST(xCreatePixmapReq); - DepthPtr pDepth; - int result, j; - Pixmap pmapID; - PanoramiXWindow *pPanoramiXWin; - PanoramiXPmap *pPanoramiXPmap; - PanoramiXPmap *localPmap; - XID orig_pid; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; - localPmap =(PanoramiXPmap *) Xcalloc(sizeof(PanoramiXPmap)); - IF_RETURN(!localPmap, BadAlloc); - - pDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!pDraw, BadDrawable); - - pPanoramiXWin = (pDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadWindow); - - orig_pid = stuff->pid; - FOR_NSCREENS_OR_ONCE(pPanoramiXPmap, j) { - pmapID = j ? FakeClientID(client->index) : orig_pid; - localPmap->info[j].id = pmapID; - } - localPmap->FreeMe = FALSE; - PANORAMIXFIND_LAST(pPanoramiXPmap, PanoramiXPmapRoot); - pPanoramiXPmap->next = localPmap; - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->pid = localPmap->info[j].id; - stuff->drawable = pPanoramiXWin->info[j].id; - result = (* SavedProcVector[X_CreatePixmap])(client); - BREAK_IF(result != Success); - } - if (result != Success) { - pPanoramiXPmap->next = NULL; - if (localPmap) - Xfree(localPmap); + if(!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityReadAccess))) + return BadDrawable; + + if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newPix->type = XRT_PIXMAP; + newPix->u.pix.shared = FALSE; + newPix->info[0].id = stuff->pid; + for(j = 1; j < PanoramiXNumScreens; j++) + newPix->info[j].id = FakeClientID(client->index); + + FOR_NSCREENS_BACKWARD(j) { + stuff->pid = newPix->info[j].id; + stuff->drawable = refDraw->info[j].id; + result = (*SavedProcVector[X_CreatePixmap])(client); + if(result != Success) break; } + + if (result == Success) + AddResource(newPix->info[0].id, XRT_PIXMAP, newPix); + else + xfree(newPix); + return (result); } int PanoramiXFreePixmap(ClientPtr client) { - PixmapPtr pMap; - int result, j; - PanoramiXPmap *pPanoramiXPmap = PanoramiXPmapRoot; - PanoramiXPmap *pPanoramiXPmapback = NULL; + PanoramiXRes *pix; + int result = 0, j; REQUEST(xResourceReq); - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; - REQUEST_SIZE_MATCH(xResourceReq); - for (; pPanoramiXPmap && (pPanoramiXPmap->info[0].id != stuff->id); - pPanoramiXPmap = pPanoramiXPmap->next) - pPanoramiXPmapback = pPanoramiXPmap; - if (!pPanoramiXPmap) - result = (* SavedProcVector[X_FreePixmap])(client); - else { - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->id = pPanoramiXPmap->info[j].id; - result = (* SavedProcVector[X_FreePixmap])(client); - } - if ((result == Success) && pPanoramiXPmapback && - pPanoramiXPmap && pPanoramiXPmap->FreeMe ) { - pPanoramiXPmapback->next = pPanoramiXPmap->next; - Xfree(pPanoramiXPmap); - } + + client->errorValue = stuff->id; + + if(!(pix = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_PIXMAP, SecurityDestroyAccess))) + return BadPixmap; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = pix->info[j].id; + result = (*SavedProcVector[X_FreePixmap])(client); + if(result != Success) break; } + + /* Since ProcFreePixmap is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + return (result); } -int PanoramiXCreateGC(register ClientPtr client) +int PanoramiXCreateGC(ClientPtr client) { - int result, j; - GC *pGC; - DrawablePtr pDraw; - unsigned len, i; + PanoramiXRes *refDraw; + PanoramiXRes *newGC; + PanoramiXRes *stip = NULL; + PanoramiXRes *tile = NULL; + PanoramiXRes *clip = NULL; REQUEST(xCreateGCReq); - GContext GCID; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *localGC; - PanoramiXGC *pPanoramiXGC; - PanoramiXPmap *pPanoramiXTile = NULL, *pPanoramiXStip = NULL; - PanoramiXPmap *pPanoramiXClip = NULL; - int tile_offset, stip_offset, clip_offset; - XID orig_GC; + int tile_offset = 0, stip_offset = 0, clip_offset = 0; + int result = 0, len, j; + XID tmp; REQUEST_AT_LEAST_SIZE(xCreateGCReq); + client->errorValue = stuff->gc; - pDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!pDraw, BadDrawable); - pPanoramiXWin = (pDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - - len = client->req_len - (sizeof(xCreateGCReq) >> 2); - IF_RETURN((len != Ones((Mask)stuff->mask)), BadLength); - localGC = (PanoramiXGC *) Xcalloc(sizeof(PanoramiXGC)); - IF_RETURN(!localGC, BadAlloc); - orig_GC = stuff->gc; - if ((Mask)stuff->mask & GCTile) { - XID tileID; + len = client->req_len - (sizeof(xCreateGCReq) >> 2); + if (Ones(stuff->mask) != len) + return BadLength; + + if (!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityReadAccess))) + return BadDrawable; + if ((Mask)stuff->mask & GCTile) { tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); - tileID = *((CARD32 *) &stuff[1] + tile_offset); - if (tileID) { - pPanoramiXTile = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXTile, tileID); + if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { + if(!(tile = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } if ((Mask)stuff->mask & GCStipple) { - XID stipID; - stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); - stipID = *((CARD32 *) &stuff[1] + stip_offset); - if (stipID) { - pPanoramiXStip = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXStip, stipID); + if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { + if(!(stip = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } if ((Mask)stuff->mask & GCClipMask) { - XID clipID; - clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); - clipID = *((CARD32 *) &stuff[1] + clip_offset); - if (clipID) { - pPanoramiXClip = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXClip, clipID); + if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { + if(!(clip = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } - FOR_NSCREENS_OR_ONCE(pPanoramiXGC, j) { - GCID = j ? FakeClientID(client->index) : orig_GC; - localGC->info[j].id = GCID; - } - localGC->FreeMe = FALSE; - PANORAMIXFIND_LAST(pPanoramiXGC, PanoramiXGCRoot); - pPanoramiXGC->next = localGC; - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->gc = localGC->info[j].id; - stuff->drawable = pPanoramiXWin->info[j].id; - if (pPanoramiXTile) - *((CARD32 *) &stuff[1] + tile_offset) = pPanoramiXTile->info[j].id; - if (pPanoramiXStip) - *((CARD32 *) &stuff[1] + stip_offset) = pPanoramiXStip->info[j].id; - if (pPanoramiXClip) - *((CARD32 *) &stuff[1] + clip_offset) = pPanoramiXClip->info[j].id; - result = (* SavedProcVector[X_CreateGC])(client); - BREAK_IF(result != Success); - } - if (result != Success) { - pPanoramiXGC->next = NULL; - Xfree(localGC); + + if(!(newGC = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newGC->type = XRT_GC; + newGC->info[0].id = stuff->gc; + for(j = 1; j < PanoramiXNumScreens; j++) + newGC->info[j].id = FakeClientID(client->index); + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = newGC->info[j].id; + stuff->drawable = refDraw->info[j].id; + if (tile) + *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; + if (stip) + *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; + if (clip) + *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; + result = (*SavedProcVector[X_CreateGC])(client); + if(result != Success) break; } + + if (result == Success) + AddResource(newGC->info[0].id, XRT_GC, newGC); + else + xfree(newGC); + return (result); } - int PanoramiXChangeGC(ClientPtr client) { - GC *pGC; + PanoramiXRes *gc; + PanoramiXRes *stip = NULL; + PanoramiXRes *tile = NULL; + PanoramiXRes *clip = NULL; REQUEST(xChangeGCReq); - int result, j; - unsigned len; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - PanoramiXPmap *pPanoramiXTile = NULL, *pPanoramiXStip = NULL; - PanoramiXPmap *pPanoramiXClip = NULL; - int tile_offset, stip_offset, clip_offset; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; + int tile_offset = 0, stip_offset = 0, clip_offset = 0; + int result = 0, len, j; + XID tmp; REQUEST_AT_LEAST_SIZE(xChangeGCReq); - VERIFY_GC(pGC, stuff->gc, client); - len = client->req_len - (sizeof(xChangeGCReq) >> 2); - IF_RETURN((len != Ones((Mask)stuff->mask)), BadLength); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); - if ((Mask)stuff->mask & GCTile) { - XID tileID; + + len = client->req_len - (sizeof(xChangeGCReq) >> 2); + if (Ones(stuff->mask) != len) + return BadLength; + + if (!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; - tile_offset = Ones((Mask)stuff->mask & (GCTile -1) ); - tileID = *((CARD32 *) &stuff[1] + tile_offset); - if (tileID) { - pPanoramiXTile = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXTile, tileID); + if ((Mask)stuff->mask & GCTile) { + tile_offset = Ones((Mask)stuff->mask & (GCTile - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + tile_offset))) { + if(!(tile = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } if ((Mask)stuff->mask & GCStipple) { - XID stipID; - - stip_offset = Ones((Mask)stuff->mask & (GCStipple -1 )); - stipID = *((CARD32 *) &stuff[1] + stip_offset); - if (stipID) { - pPanoramiXStip = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXStip, stipID); + stip_offset = Ones((Mask)stuff->mask & (GCStipple - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + stip_offset))) { + if(!(stip = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } if ((Mask)stuff->mask & GCClipMask) { - XID clipID; - - clip_offset = Ones((Mask)stuff->mask & (GCClipMask -1)); - clipID = *((CARD32 *) &stuff[1] + clip_offset); - if (clipID) { - pPanoramiXClip = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXClip, clipID); + clip_offset = Ones((Mask)stuff->mask & (GCClipMask - 1)); + if ((tmp = *((CARD32 *) &stuff[1] + clip_offset))) { + if(!(clip = (PanoramiXRes*) SecurityLookupIDByType( + client, tmp, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; } } - FOR_NSCREENS_OR_ONCE(pPanoramiXGC, j) { - stuff->gc = pPanoramiXGC->info[j].id; - if (pPanoramiXTile) - *((CARD32 *) &stuff[1] + tile_offset) = pPanoramiXTile->info[j].id; - if (pPanoramiXStip) - *((CARD32 *) &stuff[1] + stip_offset) = pPanoramiXStip->info[j].id; - if (pPanoramiXClip) - *((CARD32 *) &stuff[1] + clip_offset) = pPanoramiXClip->info[j].id; - result = (* SavedProcVector[X_ChangeGC])(client); - BREAK_IF(result != Success); - } - PANORAMIX_FREE(client); + + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + if (tile) + *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id; + if (stip) + *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id; + if (clip) + *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id; + result = (*SavedProcVector[X_ChangeGC])(client); + if(result != Success) break; + } + return (result); } int PanoramiXCopyGC(ClientPtr client) { - int j, result; - PanoramiXGC *pPanoramiXGCSrc = PanoramiXGCRoot; - PanoramiXGC *pPanoramiXGCDst = PanoramiXGCRoot; + PanoramiXRes *srcGC, *dstGC; + int result = 0, j; REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); - PANORAMIXFIND_ID(pPanoramiXGCSrc, stuff->srcGC); - IF_RETURN(!pPanoramiXGCSrc, BadGC); - PANORAMIXFIND_ID(pPanoramiXGCDst, stuff->dstGC); - IF_RETURN(!pPanoramiXGCDst, BadGC); - FOR_NSCREENS_OR_ONCE(pPanoramiXGCDst, j) { - stuff->srcGC = pPanoramiXGCSrc->info[j].id; - stuff->dstGC = pPanoramiXGCDst->info[j].id; - result = (* SavedProcVector[X_CopyGC])(client); - BREAK_IF(result != Success); + + if(!(srcGC = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->srcGC, XRT_GC, SecurityReadAccess))) + return BadGC; + + if(!(dstGC = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->dstGC, XRT_GC, SecurityWriteAccess))) + return BadGC; + + FOR_NSCREENS(j) { + stuff->srcGC = srcGC->info[j].id; + stuff->dstGC = dstGC->info[j].id; + result = (*SavedProcVector[X_CopyGC])(client); + if(result != Success) break; } + return (result); } int PanoramiXSetDashes(ClientPtr client) { - GC *pGC; + PanoramiXRes *gc; + int result = 0, j; REQUEST(xSetDashesReq); - int result, j; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); - VERIFY_GC(pGC, stuff->gc, client); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); - FOR_NSCREENS_OR_ONCE(pPanoramiXGC, j) { - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_SetDashes])(client); - BREAK_IF(result != Success); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityWriteAccess))) + return BadGC; + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_SetDashes])(client); + if(result != Success) break; } + return (result); } -int PanoramiXSetClipRectangles(register ClientPtr client) +int PanoramiXSetClipRectangles(ClientPtr client) { - int result; - register GC *pGC; + PanoramiXRes *gc; + int result = 0, j; REQUEST(xSetClipRectanglesReq); - int j; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); - FOR_NSCREENS_OR_ONCE(pPanoramiXGC, j) { - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_SetClipRectangles])(client); - BREAK_IF(result != Success); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityWriteAccess))) + return BadGC; + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + result = (*SavedProcVector[X_SetClipRectangles])(client); + if(result != Success) break; } + return (result); } int PanoramiXFreeGC(ClientPtr client) { - register GC *pGC; + PanoramiXRes *gc; + int result = 0, j; REQUEST(xResourceReq); - int result, j; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - PanoramiXGC *pPanoramiXGCback = NULL; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - for (; pPanoramiXGC && (pPanoramiXGC->info[0].id != stuff->id); - pPanoramiXGC = pPanoramiXGC->next) - pPanoramiXGCback = pPanoramiXGC; - IF_RETURN(!pPanoramiXGC, BadGC); - FOR_NSCREENS_OR_ONCE(pPanoramiXGC, j) { - stuff->id = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_FreeGC])(client); - BREAK_IF(result != Success); - } - if ((result == Success) && pPanoramiXGCback && - pPanoramiXGC && pPanoramiXGC->FreeMe) { - pPanoramiXGCback->next = pPanoramiXGC->next; - if (pPanoramiXGC) - Xfree(pPanoramiXGC); - } - PANORAMIX_FREE(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_GC, SecurityDestroyAccess))) + return BadGC; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = gc->info[j].id; + result = (*SavedProcVector[X_FreeGC])(client); + if(result != Success) break; + } + + /* Since ProcFreeGC is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + return (result); } -int PanoramiXClearToBackground(register ClientPtr client) +int PanoramiXClearToBackground(ClientPtr client) { + PanoramiXRes *win; + int result = 0, j, x, y; + Bool isRoot; REQUEST(xClearAreaReq); - register WindowPtr pWin; - int result, j; - Window winID; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - int orig_x, orig_y; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xClearAreaReq); - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - IF_RETURN(!pPanoramiXWin, BadWindow); - orig_x = stuff->x; - orig_y = stuff->y; - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - winID = pPanoramiXWin->info[j].id; - pWin = (WindowPtr) SecurityLookupWindow(winID, client, SecurityReadAccess); - if (!pWin) { - client->errorValue = pPanoramiXWin->info[0].id; - return (BadWindow); - } - stuff->window = winID; - if (pWin->drawable.id == PanoramiXWinRoot->info[j].id) { - stuff->x = orig_x - panoramiXdataPtr[j].x; - stuff->y = orig_y - panoramiXdataPtr[j].y; + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->window, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + x = stuff->x; + y = stuff->y; + isRoot = (stuff->window == WindowTable[0]->drawable.id); + FOR_NSCREENS_BACKWARD(j) { + stuff->window = win->info[j].id; + if(isRoot) { + stuff->x = x - panoramiXdataPtr[j].x; + stuff->y = y - panoramiXdataPtr[j].y; } result = (*SavedProcVector[X_ClearArea])(client); + if(result != Success) break; } - PANORAMIX_FREE(client); + return (result); } +/* + For Window to Pixmap copies you're screwed since each screen's + pixmap will look like what it sees on its screen. Unless the + screens overlap and the window lies on each, the two copies + will be out of sync. To remedy this we do a GetImage and PutImage + in place of the copy. Doing this as a single Image isn't quite + correct since it will include the obscured areas but we will + have to fix this later. (MArk). +*/ + int PanoramiXCopyArea(ClientPtr client) { - int j, result; - Window srcID, dstID; - DrawablePtr pSrc, pDst; - GContext GCID; - GC *pGC; - PanoramiXWindow *pPanoramiXSrcRoot; - PanoramiXWindow *pPanoramiXDstRoot; - PanoramiXWindow *pPanoramiXSrc; - PanoramiXWindow *pPanoramiXDst; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; + int j, result = 0, srcx, srcy, dstx, dsty; + PanoramiXRes *gc, *src, *dst; + Bool srcIsRoot = FALSE; + Bool dstIsRoot = FALSE; + Bool srcShared, dstShared; REQUEST(xCopyAreaReq); - int srcx = stuff->srcX, srcy = stuff->srcY; - int dstx = stuff->dstX, dsty = stuff->dstY; REQUEST_SIZE_MATCH(xCopyAreaReq); - VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); - if (stuff->dstDrawable != stuff->srcDrawable) { - VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client); - if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { - client->errorValue = stuff->dstDrawable; - return (BadMatch); - } + if(!(src = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->srcDrawable, XRC_DRAWABLE, SecurityReadAccess))) + return BadDrawable; + + srcShared = IS_SHARED_PIXMAP(src); + + if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->dstDrawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + dstShared = IS_SHARED_PIXMAP(dst); + + if(dstShared && srcShared) + return (* SavedProcVector[X_CopyArea])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + if((dst->type == XRT_WINDOW) && + (stuff->dstDrawable == WindowTable[0]->drawable.id)) + dstIsRoot = TRUE; + if((src->type == XRT_WINDOW) && + (stuff->srcDrawable == WindowTable[0]->drawable.id)) + srcIsRoot = TRUE; + + srcx = stuff->srcX; srcy = stuff->srcY; + dstx = stuff->dstX; dsty = stuff->dstY; + if((dst->type == XRT_PIXMAP) && (src->type == XRT_WINDOW)) { + DrawablePtr drawables[MAXSCREENS]; + DrawablePtr pDst; + GCPtr pGC; + char *data; + int pitch; + + FOR_NSCREENS(j) + VERIFY_DRAWABLE(drawables[j], src->info[j].id, client); + + pitch = PixmapBytePad(stuff->width, drawables[0]->depth); + if(!(data = xcalloc(1, stuff->height * pitch))) + return BadAlloc; + + XineramaGetImageData(drawables, srcx, srcy, + stuff->width, stuff->height, ZPixmap, ~0, data, pitch, + srcIsRoot); + + FOR_NSCREENS_BACKWARD(j) { + stuff->gc = gc->info[j].id; + VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, pGC, client); + + if(drawables[0]->depth != pDst->depth) { + client->errorValue = stuff->dstDrawable; + xfree(data); + return (BadMatch); + } + + (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty, + stuff->width, stuff->height, + 0, ZPixmap, data); + + if(dstShared) break; + } + + xfree(data); + + result = Success; } else { - pSrc = pDst; - } - pPanoramiXSrcRoot = (pSrc->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXDstRoot = (pDst->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXSrc = pPanoramiXSrcRoot; - pPanoramiXDst = pPanoramiXDstRoot; - PANORAMIXFIND_ID(pPanoramiXSrc, stuff->srcDrawable); - IF_RETURN(!pPanoramiXSrc, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXDst, stuff->dstDrawable); - IF_RETURN(!pPanoramiXDst, BadDrawable); - GCID = stuff->gc; - PANORAMIXFIND_ID(pPanoramiXGC, GCID); - IF_RETURN(!pPanoramiXGC, BadGC); - - FOR_NSCREENS_OR_ONCE(pPanoramiXSrc, j) { - stuff->dstDrawable = pPanoramiXDst->info[j].id; - stuff->srcDrawable = pPanoramiXSrc->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - if (pPanoramiXSrc == pPanoramiXSrcRoot) { - stuff->srcX = srcx - panoramiXdataPtr[j].x; - stuff->srcY = srcy - panoramiXdataPtr[j].y; + DrawablePtr pDst = NULL, pSrc = NULL; + GCPtr pGC = NULL; + RegionPtr pRgn[MAXSCREENS]; + + FOR_NSCREENS_BACKWARD(j) { + stuff->dstDrawable = dst->info[j].id; + stuff->srcDrawable = src->info[j].id; + stuff->gc = gc->info[j].id; + if (srcIsRoot) { + stuff->srcX = srcx - panoramiXdataPtr[j].x; + stuff->srcY = srcy - panoramiXdataPtr[j].y; + } + if (dstIsRoot) { + stuff->dstX = dstx - panoramiXdataPtr[j].x; + stuff->dstY = dsty - panoramiXdataPtr[j].y; + } + + 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; + + pRgn[j] = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, + stuff->srcX, stuff->srcY, + stuff->width, stuff->height, + stuff->dstX, stuff->dstY); + + if(dstShared) { + while(j--) pRgn[j] = NULL; + break; + } } - if (pPanoramiXDst == pPanoramiXDstRoot) { - stuff->dstX = dstx - panoramiXdataPtr[j].x; - stuff->dstY = dsty - panoramiXdataPtr[j].y; + + if(pGC->graphicsExposures) { + ScreenPtr pScreen = pDst->pScreen; + RegionRec totalReg; + Bool overlap; + + REGION_INIT(pScreen, &totalReg, NullBox, 1); + FOR_NSCREENS_BACKWARD(j) { + if(pRgn[j]) { + if(srcIsRoot) { + REGION_TRANSLATE(pScreen, pRgn[j], + panoramiXdataPtr[j].x, panoramiXdataPtr[j].y); + } + REGION_APPEND(pScreen, &totalReg, pRgn[j]); + REGION_DESTROY(pScreen, pRgn[j]); + } + } + REGION_VALIDATE(pScreen, &totalReg, &overlap); + (*pScreen->SendGraphicsExpose)( + client, &totalReg, stuff->dstDrawable, X_CopyArea, 0); + REGION_UNINIT(pScreen, &totalReg); } - result = (* SavedProcVector[X_CopyArea])(client); - BREAK_IF(result != Success); + + result = client->noClientException; } + return (result); } + int PanoramiXCopyPlane(ClientPtr client) { - int SrcScr = -1, DstScr = -1; - PixmapPtr pMap = NULL; - Pixmap pmapID; - PanoramiXRect SrcRect, DstRect; - int i, j, k; - Window srcID, dstID; - DrawablePtr pSrc, pDst; - GContext GCID; - GContext GCIDbase; - GC *pGC; - PanoramiXWindow *pPanoramiXSrc; - PanoramiXWindow *pPanoramiXDst; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - RegionPtr *PanoramiXRgnPtrs; - RegionPtr *FetchRgnPtrs = NULL; - RegionPtr pRgn; + int j, srcx, srcy, dstx, dsty; + PanoramiXRes *gc, *src, *dst; + Bool srcIsRoot = FALSE; + Bool dstIsRoot = FALSE; + Bool srcShared, dstShared; + DrawablePtr psrcDraw, pdstDraw = NULL; + GCPtr pGC = NULL; + RegionPtr pRgn[MAXSCREENS]; REQUEST(xCopyPlaneReq); - int srcx = stuff->srcX, srcy = stuff->srcY; - int dstx = stuff->dstX, dsty = stuff->dstY; - int width = stuff->width, height = stuff->height; REQUEST_SIZE_MATCH(xCopyPlaneReq); - VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); - if (stuff->dstDrawable != stuff->srcDrawable) { - VERIFY_DRAWABLE(pSrc, stuff->srcDrawable, client); - if (pDst->pScreen != pSrc->pScreen) { - client->errorValue = stuff->dstDrawable; - return (BadMatch); - } - } else { - pSrc = pDst; - } + if(!(src = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->srcDrawable, XRC_DRAWABLE, SecurityReadAccess))) + return BadDrawable; - /* - * Check to see if stuff->bitPlane has exactly ONE good bit set - */ + srcShared = IS_SHARED_PIXMAP(src); + if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->dstDrawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; - if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || - (stuff->bitPlane > (1L << (pSrc->depth - 1)))) - { - client->errorValue = stuff->bitPlane; - return(BadValue); - } - - pPanoramiXSrc = (pSrc->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXDst = (pDst->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXSrc, stuff->srcDrawable); - IF_RETURN(!pPanoramiXSrc, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXDst, stuff->dstDrawable); - IF_RETURN(!pPanoramiXDst, BadDrawable); - GCIDbase = stuff->gc; - PANORAMIXFIND_ID(pPanoramiXGC, GCIDbase); - IF_RETURN(!pPanoramiXGC, BadGC); - - /* - * Unless both are pixmaps, need to do special things to accomodate - * being on multiple screens, different screens, etc. - */ - - if (pSrc->type != DRAWABLE_PIXMAP) { - SrcRect.x = pSrc->x + srcx; - SrcRect.y = pSrc->y + srcy; - SrcRect.width = width; - SrcRect.height = height; - for (SrcScr = PanoramiXNumScreens - 1; SrcScr>=0; SrcScr-- ) - if (RECTA_SUBSUMES_RECTB(panoramiXdataPtr[SrcScr], SrcRect)) - break; - } - if (pDst->type != DRAWABLE_PIXMAP) { - DstRect.x = pDst->x + dstx; - DstRect.y = pDst->y + dsty; - DstRect.width = width; - DstRect.height = height; - for (DstScr = PanoramiXNumScreens - 1; DstScr>=0; DstScr--) - if (RECTA_SUBSUMES_RECTB(panoramiXdataPtr[DstScr], DstRect)) - break; - } - - /* - * If source is on multiple screens, different screen from destination, - * destination is on multiple screens, or destination is a pixmap, - * need to get info into local pixmap for subsequent transfer. - */ - - - if ((pSrc->type != DRAWABLE_PIXMAP) && - (SrcScr < 0 || DstScr < 0 || SrcScr != DstScr - || pDst->type == DRAWABLE_PIXMAP)) { - unsigned char save_alu; - RegionRec tempReg; - RegionPtr pCompositeClip; - PanoramiXPmap *pPanoramiXPmap = PanoramiXPmapRoot; - - pMap = (PixmapPtr) (*pSrc->pScreen->CreatePixmap)(pSrc->pScreen, - width, height, pGC->depth); - PANORAMIXFIND_LAST(pPanoramiXPmap, PanoramiXPmapRoot); - pPanoramiXPmap->next = - (PanoramiXPmap *)Xcalloc(sizeof(PanoramiXPmap)); - pPanoramiXPmap = pPanoramiXPmap->next; - pmapID = FakeClientID(0); - AddResource(pmapID, RT_PIXMAP, (pointer)pMap); - for (j = PanoramiXNumScreens - 1; j>=0; j--) - pPanoramiXPmap->info[j].id = pmapID; - tempReg.extents.x1 = 0; - tempReg.extents.y1 = 0; - tempReg.extents.x2 = width; - tempReg.extents.y2 = height; - tempReg.data = NULL; - FetchRgnPtrs = - (RegionPtr *) ALLOCATE_LOCAL(PanoramiXNumScreens * sizeof(RegionPtr)); - i = 0; - FOR_NSCREENS_OR_ONCE(pPanoramiXSrc, j) { - if ((SrcScr >= 0) && pPanoramiXSrc) - j = SrcScr; - srcID = pPanoramiXSrc->info[j].id; - pSrc = (DrawablePtr) SecurityLookupIDByClass(client, srcID, RC_DRAWABLE, - SecurityReadAccess); - GCID = pPanoramiXGC->info[j].id; - pGC = (GC *) LookupIDByType(GCID, RT_GC); - pMap->drawable.pScreen = pSrc->pScreen; - pGC->pScreen = pSrc->pScreen; - save_alu = pGC->alu; - pGC->alu = GXcopy; - pCompositeClip = ((miPrivGC*) - (pGC->devPrivates[miGCPrivateIndex].ptr))->pCompositeClip; - ((miPrivGC*)(pGC->devPrivates[miGCPrivateIndex].ptr))->pCompositeClip = -&tempReg; - FetchRgnPtrs[i++] = (*pGC->ops->CopyPlane)(pSrc, (DrawablePtr) pMap, - pGC, srcx, srcy, width, height, 0, 0, stuff->bitPlane); - pGC->alu = save_alu; - ((miPrivGC*) (pGC->devPrivates[miGCPrivateIndex].ptr))->pCompositeClip = -pCompositeClip; - if (SrcScr >= 0) - j = 0; - } - } + dstShared = IS_SHARED_PIXMAP(dst); - if (pMap) { - pSrc = (DrawablePtr) pMap; - srcx = 0; - srcy = 0; - } - PanoramiXRgnPtrs = - (RegionPtr *) ALLOCATE_LOCAL(PanoramiXNumScreens * sizeof(RegionPtr)); - k = 0; - /* if src and dst are entirely on one screen, - then we only need one simple transfer */ - if ((DstScr >= 0) && (pMap || (SrcScr >=0))) { - dstID = pPanoramiXDst->info[DstScr].id; - pDst = (DrawablePtr) SecurityLookupIDByClass(client, dstID, RC_DRAWABLE, - SecurityReadAccess); - GCID = pPanoramiXGC->info[DstScr].id; - pGC = (GC *) LookupIDByType(GCID, RT_GC); - ValidateGC(pDst, pGC); - if (pMap) { - pMap->drawable.pScreen = pDst->pScreen; - } else { - srcID = pPanoramiXSrc->info[SrcScr].id; - if (srcID != dstID) { - pSrc = (DrawablePtr) SecurityLookupIDByClass(client, srcID, RC_DRAWABLE, - SecurityReadAccess); - } else - pSrc = pDst; + if(dstShared && srcShared) + return (* SavedProcVector[X_CopyPlane])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + if((dst->type == XRT_WINDOW) && + (stuff->dstDrawable == WindowTable[0]->drawable.id)) + dstIsRoot = TRUE; + if((src->type == XRT_WINDOW) && + (stuff->srcDrawable == WindowTable[0]->drawable.id)) + srcIsRoot = TRUE; + + srcx = stuff->srcX; srcy = stuff->srcY; + dstx = stuff->dstX; dsty = stuff->dstY; + + FOR_NSCREENS_BACKWARD(j) { + stuff->dstDrawable = dst->info[j].id; + stuff->srcDrawable = src->info[j].id; + stuff->gc = gc->info[j].id; + if (srcIsRoot) { + stuff->srcX = srcx - panoramiXdataPtr[j].x; + stuff->srcY = srcy - panoramiXdataPtr[j].y; } - if (pMap) - PanoramiXRgnPtrs[k++] = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, - srcx, srcy, width, height, dstx, dsty, - 1); - else - PanoramiXRgnPtrs[k++] = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, - srcx, srcy, width, height, dstx, dsty, - stuff->bitPlane); - }else { - FOR_NSCREENS_OR_ONCE(pPanoramiXDst, j) { - if (DstScr >= 0) { - dstID = pPanoramiXDst->info[DstScr].id; - GCID = pPanoramiXGC->info[DstScr].id; - } else { - dstID = pPanoramiXDst->info[j].id; - GCID = pPanoramiXGC->info[j].id; + if (dstIsRoot) { + stuff->dstX = dstx - panoramiXdataPtr[j].x; + stuff->dstY = dsty - panoramiXdataPtr[j].y; } - pDst = (DrawablePtr) SecurityLookupIDByClass(client, dstID, RC_DRAWABLE, - SecurityReadAccess); - pGC = (GC *) LookupIDByType(GCID, RT_GC); - ValidateGC(pDst, pGC); - if (pMap) { - pMap->drawable.pScreen = pDst->pScreen; - } else { - srcID = pPanoramiXSrc->info[j].id; - if (srcID != dstID) { - pSrc = (DrawablePtr) SecurityLookupIDByClass(client, srcID, RC_DRAWABLE, - SecurityReadAccess); - } else { - pSrc = pDst; + + 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; + + if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) || + (stuff->bitPlane > (1L << (psrcDraw->depth - 1)))) { + client->errorValue = stuff->bitPlane; + return(BadValue); } - if (pMap) - PanoramiXRgnPtrs[k++] = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, - srcx, srcy, width, height, dstx, dsty, - 1); - else - PanoramiXRgnPtrs[k++] = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, - srcx, srcy, width, height, dstx, dsty, - stuff->bitPlane); - } - } - - if (pMap) { - for (j = PanoramiXNumScreens - 1; j>=0; j--) - if (PanoramiXRgnPtrs[j]) - (*pDst->pScreen->RegionDestroy) (PanoramiXRgnPtrs[j]); - DEALLOCATE_LOCAL(PanoramiXRgnPtrs); - PanoramiXRgnPtrs = FetchRgnPtrs; - k = i; - } - j = 1; - i = 0; - pRgn = PanoramiXRgnPtrs[i]; - while ((j < k) && pRgn && !REGION_NIL(pRgn)) { - if (PanoramiXRgnPtrs[j]) { - (*pGC->pScreen->Intersect)(pRgn, pRgn, PanoramiXRgnPtrs[j++]); - } else { - pRgn = PanoramiXRgnPtrs[i++]; + + pRgn[j] = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, + stuff->srcX, stuff->srcY, + stuff->width, stuff->height, + stuff->dstX, stuff->dstY, stuff->bitPlane); + + if(dstShared) { + while(j--) pRgn[j] = NULL; + break; } } - for (j = 0 ; j < k; j++) { - pRgn = PanoramiXRgnPtrs[j]; - GCID = pPanoramiXGC->info[j].id; - pGC = (GC *) LookupIDByType(GCID, RT_GC); - if (pGC && pGC->graphicsExposures) - (*pDst->pScreen->SendGraphicsExpose) (client, pRgn, - stuff->dstDrawable, X_CopyPlane, 0); - if (pRgn) - (*pDst->pScreen->RegionDestroy) (pRgn); - } - DEALLOCATE_LOCAL(PanoramiXRgnPtrs); - if (pMap) { - PanoramiXPmap *pPanoramiXPmap = PanoramiXPmapRoot; - PanoramiXPmap *pback = PanoramiXPmapRoot; - - for (; pPanoramiXPmap && (pPanoramiXPmap->info[0].id != pmapID); - pPanoramiXPmap = pPanoramiXPmap->next) - pback = pPanoramiXPmap; - FreeResource(pPanoramiXPmap->info[0].id, RT_NONE); - if (pback) { - pback->next = pPanoramiXPmap->next; - Xfree(pPanoramiXPmap); + + if(pGC->graphicsExposures) { + ScreenPtr pScreen = pdstDraw->pScreen; + RegionRec totalReg; + Bool overlap; + + REGION_INIT(pScreen, &totalReg, NullBox, 1); + FOR_NSCREENS_BACKWARD(j) { + if(pRgn[j]) { + REGION_APPEND(pScreen, &totalReg, pRgn[j]); + REGION_DESTROY(pScreen, pRgn[j]); + } } + REGION_VALIDATE(pScreen, &totalReg, &overlap); + (*pScreen->SendGraphicsExpose)( + client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0); + REGION_UNINIT(pScreen, &totalReg); } + return (client->noClientException); } int PanoramiXPolyPoint(ClientPtr client) { - int result, npoint, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - int x_off = 0, y_off = 0; + PanoramiXRes *gc, *draw; + int result = 0, npoint, j; xPoint *origPts; - xPoint *origPtr, *modPtr; + Bool isRoot; REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, locDraw->id); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyPoint])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2; if (npoint > 0) { origPts = (xPoint *) ALLOCATE_LOCAL(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } - } - modPtr = (xPoint *) &stuff[1]; - origPtr = origPts; - for (i = npoint; i; i--) { - modPtr->x = origPtr->x - x_off; - modPtr++->y = origPtr++->y - y_off; - } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PolyPoint])(client); - BREAK_IF(result != Success); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + if(x_off || y_off) { + xPoint *pnts = (xPoint*)&stuff[1]; + int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; + + while(i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyPoint])(client); + if(result != Success) break; } DEALLOCATE_LOCAL(origPts); return (result); - }else + } else return (client->noClientException); - } int PanoramiXPolyLine(ClientPtr client) { - int result, npoint, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - int x_off = 0, y_off = 0; + PanoramiXRes *gc, *draw; + int result = 0, npoint, j; xPoint *origPts; - xPoint *origPtr, *modPtr; + Bool isRoot; REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, locDraw->id); - /* In the case of Multibuffering, we need to make sure the drawable - isn't really a pixmap associated to a drawable */ - if (!pPanoramiXWin && (stuff->drawable != locDraw->id)) { - pPanoramiXWin = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - } - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyLine])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2; if (npoint > 0){ origPts = (xPoint *) ALLOCATE_LOCAL(npoint * sizeof(xPoint)); memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint)); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } - } - modPtr = (xPoint *) &stuff[1]; - origPtr = origPts; - for (i = npoint; i; i--) { - modPtr->x = origPtr->x - x_off; - modPtr++->y = origPtr++->y - y_off; - } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PolyLine])(client); - BREAK_IF(result != Success); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + if(x_off || y_off) { + xPoint *pnts = (xPoint*)&stuff[1]; + int i = (stuff->coordMode==CoordModePrevious) ? 1 : npoint; + + while(i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyLine])(client); + if(result != Success) break; } DEALLOCATE_LOCAL(origPts); return (result); - }else + } else return (client->noClientException); } int PanoramiXPolySegment(ClientPtr client) { - int result, nsegs, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - int x_off = 0, y_off = 0; + int result = 0, nsegs, i, j; + PanoramiXRes *gc, *draw; xSegment *origSegs; - xSegment *origPtr, *modPtr; + Bool isRoot; REQUEST(xPolySegmentReq); REQUEST_AT_LEAST_SIZE(xPolySegmentReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - /* In the case of Multibuffering, we need to make sure the drawable - isn't really a pixmap associated to a drawable */ - if (!pPanoramiXWin && (stuff->drawable != locDraw->id)) { - pPanoramiXWin = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - } - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolySegment])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); - IF_RETURN((nsegs & 4), BadLength); + if(nsegs & 4) return BadLength; nsegs >>= 3; if (nsegs > 0) { - origSegs = (xSegment *) ALLOCATE_LOCAL(nsegs * sizeof(xSegment)); - memcpy((char *) origSegs, (char *) &stuff[1], nsegs * -sizeof(xSegment)); - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } - } - modPtr = (xSegment *) &stuff[1]; - origPtr = origSegs; - for (i = nsegs; i; i--) { - modPtr->x1 = origPtr->x1 - x_off; - modPtr->y1 = origPtr->y1 - y_off; - modPtr->x2 = origPtr->x2 - x_off; - modPtr++->y2 = origPtr++->y2 - y_off; - } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PolySegment])(client); - BREAK_IF(result != Success); + origSegs = (xSegment *) ALLOCATE_LOCAL(nsegs * sizeof(xSegment)); + memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + if(x_off || y_off) { + xSegment *segs = (xSegment*)&stuff[1]; + + for (i = nsegs; i--; segs++) { + segs->x1 -= x_off; + segs->x2 -= x_off; + segs->y1 -= y_off; + segs->y2 -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolySegment])(client); + if(result != Success) break; } - DEALLOCATE_LOCAL(origSegs); - return (result); - }else + DEALLOCATE_LOCAL(origSegs); + return (result); + } else return (client->noClientException); } int PanoramiXPolyRectangle(ClientPtr client) { - int result, nrects, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - int x_off = 0, y_off = 0; + int result = 0, nrects, i, j; + PanoramiXRes *gc, *draw; + Bool isRoot; xRectangle *origRecs; - xRectangle *origPtr, *modPtr; REQUEST(xPolyRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyRectangle])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); - IF_RETURN((nrects & 4), BadLength); + if(nrects & 4) return BadLength; nrects >>= 3; if (nrects > 0){ - origRecs = (xRectangle *) ALLOCATE_LOCAL(nrects * sizeof(xRectangle)); - memcpy((char *) origRecs, (char *) &stuff[1], nrects * -sizeof(xRectangle)); - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } - } - modPtr = (xRectangle *) &stuff[1]; - origPtr = origRecs; - for (i = nrects; i; i--) { - modPtr->x = origPtr->x - x_off; - modPtr->y = origPtr->y - y_off; - modPtr->width = origPtr->width - x_off; - modPtr++->height = origPtr++->height - y_off; + origRecs = (xRectangle *) ALLOCATE_LOCAL(nrects * sizeof(xRectangle)); + memcpy((char *)origRecs,(char *)&stuff[1],nrects * sizeof(xRectangle)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + + if(x_off || y_off) { + xRectangle *rects = (xRectangle *) &stuff[1]; + + for (i = nrects; i--; rects++) { + rects->x -= x_off; + rects->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyRectangle])(client); + if(result != Success) break; } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PolyRectangle])(client); - BREAK_IF(result != Success); - } - DEALLOCATE_LOCAL(origRecs); - return (result); - }else + DEALLOCATE_LOCAL(origRecs); + return (result); + } else return (client->noClientException); } int PanoramiXPolyArc(ClientPtr client) { - int result, narcs, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - GCPtr locGC; - int x_off = 0, y_off = 0; + int result = 0, narcs, i, j; + PanoramiXRes *gc, *draw; + Bool isRoot; xArc *origArcs; - xArc *origPtr, *modPtr; REQUEST(xPolyArcReq); REQUEST_AT_LEAST_SIZE(xPolyArcReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : -PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyArc])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + narcs = (client->req_len << 2) - sizeof(xPolyArcReq); - IF_RETURN((narcs % sizeof(xArc)), BadLength); + if(narcs % sizeof(xArc)) return BadLength; narcs /= sizeof(xArc); if (narcs > 0){ - origArcs = (xArc *) ALLOCATE_LOCAL(narcs * sizeof(xArc)); - memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } - } - modPtr = (xArc *) &stuff[1]; - origPtr = origArcs; - for (i = narcs; i; i--) { - modPtr->x = origPtr->x - x_off; - modPtr++->y = origPtr++->y - y_off; + origArcs = (xArc *) ALLOCATE_LOCAL(narcs * sizeof(xArc)); + memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + if(x_off || y_off) { + xArc *arcs = (xArc *) &stuff[1]; + + for (i = narcs; i--; arcs++) { + arcs->x -= x_off; + arcs->y -= y_off; + } + } + } + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyArc])(client); + if(result != Success) break; } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PolyArc])(client); - BREAK_IF(result != Success); - } - DEALLOCATE_LOCAL(origArcs); - return (result); - }else + DEALLOCATE_LOCAL(origArcs); + return (result); + } else return (client->noClientException); } int PanoramiXFillPoly(ClientPtr client) { - int result, count, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - GCPtr locGC; - int x_off = 0, y_off = 0; + int result = 0, count, j; + PanoramiXRes *gc, *draw; + Bool isRoot; DDXPointPtr locPts; - DDXPointPtr origPts, modPts; REQUEST(xFillPolyReq); REQUEST_AT_LEAST_SIZE(xFillPolyReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_FillPoly])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2; if (count > 0){ - locPts = (DDXPointPtr) ALLOCATE_LOCAL(count * sizeof(DDXPointRec)); - memcpy((char *) locPts, (char *) &stuff[1], count * -sizeof(DDXPointRec)); - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } - } - modPts = (DDXPointPtr) &stuff[1]; - origPts = locPts; - for (i = count; i; i--) { - modPts->x = origPts->x - x_off; - modPts++->y = origPts++->y - y_off; + locPts = (DDXPointPtr) ALLOCATE_LOCAL(count * sizeof(DDXPointRec)); + memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + if(x_off || y_off) { + DDXPointPtr pnts = (DDXPointPtr)&stuff[1]; + int i = (stuff->coordMode==CoordModePrevious) ? 1 : count; + + while(i--) { + pnts->x -= x_off; + pnts->y -= y_off; + pnts++; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_FillPoly])(client); + if(result != Success) break; } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_FillPoly])(client); - BREAK_IF(result != Success); - } - DEALLOCATE_LOCAL(locPts); - return (result); - }else + DEALLOCATE_LOCAL(locPts); + return (result); + } else return (client->noClientException); } int PanoramiXPolyFillRectangle(ClientPtr client) { - int result, things, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - GCPtr locGC; - int x_off = 0, y_off = 0; - xRectangle *origThings; - xRectangle *origPtr, *modPtr; + int result = 0, things, i, j; + PanoramiXRes *gc, *draw; + Bool isRoot; + xRectangle *origRects; REQUEST(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : -PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyFillRectangle])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); - IF_RETURN((things & 4), BadLength); + if(things & 4) return BadLength; things >>= 3; if (things > 0){ - origThings = (xRectangle *) ALLOCATE_LOCAL(things * sizeof(xRectangle)); - memcpy((char *) origThings, (char *)&stuff[1], things * -sizeof(xRectangle)); - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } + origRects = (xRectangle *) ALLOCATE_LOCAL(things * sizeof(xRectangle)); + memcpy((char*)origRects,(char*)&stuff[1], things * sizeof(xRectangle)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + if(x_off || y_off) { + xRectangle *rects = (xRectangle *) &stuff[1]; + + for (i = things; i--; rects++) { + rects->x -= x_off; + rects->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyFillRectangle])(client); + if(result != Success) break; } - modPtr = (xRectangle *) &stuff[1]; - origPtr = origThings; - for (i = things; i; i--) { - modPtr->x = origPtr->x - x_off; - modPtr++->y = origPtr++->y - y_off; - } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PolyFillRectangle])(client); - BREAK_IF(result != Success); - } - DEALLOCATE_LOCAL(origThings); - return (result); - }else + DEALLOCATE_LOCAL(origRects); + return (result); + } else return (client->noClientException); } int PanoramiXPolyFillArc(ClientPtr client) { - int result, arcs, i, j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr locDraw; - GCPtr locGC; - int x_off = 0, y_off = 0; + PanoramiXRes *gc, *draw; + Bool isRoot; + int result = 0, narcs, i, j; xArc *origArcs; - xArc *origPtr, *modPtr; REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!locDraw, BadDrawable); - pPanoramiXWin = (locDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : -PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); - arcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); - IF_RETURN((arcs % sizeof(xArc)), BadLength); - arcs /= sizeof(xArc); - if (arcs > 0) { - origArcs = (xArc *) ALLOCATE_LOCAL(arcs * sizeof(xArc)); - memcpy((char *) origArcs, (char *)&stuff[1], arcs * sizeof(xArc)); - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - if (pPanoramiXWin == PanoramiXWinRoot) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - }else { - if ( (locDraw->type == DRAWABLE_PIXMAP) && - /* add special case check for root window */ - (locDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - x_off = panoramiXdataPtr[j].x; - y_off = panoramiXdataPtr[j].y; - } + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyFillArc])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + + narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); + IF_RETURN((narcs % sizeof(xArc)), BadLength); + narcs /= sizeof(xArc); + if (narcs > 0) { + origArcs = (xArc *) ALLOCATE_LOCAL(narcs * sizeof(xArc)); + memcpy((char *) origArcs, (char *)&stuff[1], narcs * sizeof(xArc)); + FOR_NSCREENS_FORWARD(j){ + + if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc)); + + if (isRoot) { + int x_off = panoramiXdataPtr[j].x; + int y_off = panoramiXdataPtr[j].y; + + if(x_off || y_off) { + xArc *arcs = (xArc *) &stuff[1]; + + for (i = narcs; i--; arcs++) { + arcs->x -= x_off; + arcs->y -= y_off; + } + } + } + + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PolyFillArc])(client); + if(result != Success) break; } - modPtr = (xArc *) &stuff[1]; - origPtr = origArcs; - for (i = arcs; i; i--) { - modPtr->x = origPtr->x - x_off; - modPtr++->y = origPtr++->y - y_off; - } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PolyFillArc])(client); - BREAK_IF(result != Success); - } - DEALLOCATE_LOCAL(origArcs); - return (result); - }else + DEALLOCATE_LOCAL(origArcs); + return (result); + } else return (client->noClientException); } -/* 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 PanoramiXPutImage(register ClientPtr client) +int PanoramiXPutImage(ClientPtr client) { - register GC *pGC; - register DrawablePtr pDraw; - long lengthProto, /* length of scanline protocl padded */ - length; /* length of scanline server padded */ - char *tmpImage; - int j; - PanoramiXWindow *pPanoramiXWin; - PanoramiXWindow *pPanoramiXRoot; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - int orig_x, orig_y; - int result; - - + PanoramiXRes *gc, *draw; + Bool isRoot; + int j, result = 0, orig_x, orig_y; REQUEST(xPutImageReq); REQUEST_AT_LEAST_SIZE(xPutImageReq); - pDraw = (DrawablePtr) SecurityLookupIDByClass(client, stuff->drawable, -RC_DRAWABLE, - SecurityReadAccess); - IF_RETURN(!pDraw, BadDrawable); - pPanoramiXRoot = (pDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXWin = pPanoramiXRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin,BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PutImage])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + orig_x = stuff->dstX; orig_y = stuff->dstY; - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - if (pPanoramiXWin == pPanoramiXRoot) { + FOR_NSCREENS_BACKWARD(j){ + if (isRoot) { stuff->dstX = orig_x - panoramiXdataPtr[j].x; stuff->dstY = orig_y - panoramiXdataPtr[j].y; - } - if (pDraw->type == DRAWABLE_PIXMAP) { - if (stuff->width > panoramiXdataPtr[j].width) - stuff->dstX = orig_x - panoramiXdataPtr[j].x; - if (stuff->height > panoramiXdataPtr[j].height) - stuff->dstY = orig_y - panoramiXdataPtr[j].y; - } - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - result = (* SavedProcVector[X_PutImage])(client); - } - return(result); + } + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + result = (* SavedProcVector[X_PutImage])(client); + if(result != Success) break; + } + return (result); } -typedef struct _SrcParts{ - int x1, y1, x2, y2, width, ByteWidth; - char *buf; -} SrcPartsRec; - - -int PanoramiXGetImage(register ClientPtr client) +int PanoramiXGetImage(ClientPtr client) { - register DrawablePtr pDraw; - int nlines, linesPerBuf; - register int height, linesDone; - long widthBytesLine, length; -#ifdef INTERNAL_VS_EXTERNAL_PADDING - long widthBytesLineProto, lengthProto; - char *tmpImage; -#endif - Mask plane; - char *pBuf; + DrawablePtr drawables[MAXSCREENS]; + DrawablePtr pDraw; + PanoramiXRes *draw; xGetImageReply xgi; - int j, k, ScrNum; - DrawablePtr locDraw; - SrcPartsRec srcParts; - BoxRec SrcBox; - char *BufPtr, *PartPtr; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; + Bool isRoot; + char *pBuf; + int i, x, y, w, h, format; + Mask plane = 0, planemask; + int linesDone, nlines, linesPerBuf; + long widthBytesLine, length; REQUEST(xGetImageReq); - height = stuff->height; REQUEST_SIZE_MATCH(xGetImageReq); + 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 (*SavedProcVector[X_GetImage])(client); + VERIFY_DRAWABLE(pDraw, stuff->drawable, client); - ScrNum = 0; - if (stuff->drawable == PanoramiXWinRoot->info[0].id) { - for (j = 0; j <= (PanoramiXNumScreens - 1); j++) { - ScrNum = j; - VERIFY_DRAWABLE(pDraw, pPanoramiXWin->info[ScrNum].id, client); - if (stuff->x < panoramiXdataPtr[ScrNum].x && - stuff->y < panoramiXdataPtr[ScrNum].y ) - break; - } - } - if (pDraw->type == DRAWABLE_WINDOW) { - if (!((WindowPtr) pDraw)->realized /* Check for viewable */ - || pDraw->x + stuff->x < 0 /* Check for on screen */ - || pDraw->x + stuff->x + (int)stuff->width > PanoramiXPixWidth - || pDraw->y + stuff->y < 0 - || pDraw->y + stuff->y + height > PanoramiXPixHeight - || stuff->x < - wBorderWidth((WindowPtr)pDraw) /* Inside border */ - || stuff->x + (int)stuff->width > - wBorderWidth((WindowPtr)pDraw) + (int) pDraw->width - + panoramiXdataPtr[ScrNum].x - || stuff->y < -wBorderWidth((WindowPtr)pDraw) - || stuff->y + height > - wBorderWidth ((WindowPtr)pDraw) + (int) pDraw->height - + panoramiXdataPtr[ScrNum].y) + + if(!((WindowPtr)pDraw)->realized) + return(BadMatch); + + x = stuff->x; + y = stuff->y; + w = stuff->width; + h = stuff->height; + format = stuff->format; + planemask = stuff->planeMask; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + + if(isRoot) { + if( /* check for being onscreen */ + x < 0 || x + w > PanoramiXPixWidth || + y < 0 || y + h > PanoramiXPixHeight ) return(BadMatch); - VERIFY_DRAWABLE(pDraw, stuff->drawable, client); - xgi.visual = wVisual (((WindowPtr) pDraw)); - pPanoramiXWin = PanoramiXWinRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadWindow); } else { - if (stuff->x < 0 || stuff->x + (int)stuff->width > pDraw->width - || stuff->y < 0 || stuff->y + height > pDraw->height) + 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); - xgi.visual = None; } + + 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.sequenceNumber = client->sequence; xgi.depth = pDraw->depth; - if (stuff->format == ZPixmap) { - widthBytesLine = PixmapBytePad(stuff->width, pDraw->depth); - length = widthBytesLine * height; + if(format == ZPixmap) { + widthBytesLine = PixmapBytePad(w, pDraw->depth); + length = widthBytesLine * h; + -#ifdef INTERNAL_VS_EXTERNAL_PADDING - widthBytesLineProto = PixmapBytePadProto(stuff->width, pDraw->depth); - lengthProto = widthBytesLineProto * height; -#endif } else { - widthBytesLine = BitmapBytePad(stuff->width); + widthBytesLine = BitmapBytePad(w); plane = ((Mask)1) << (pDraw->depth - 1); /* only planes asked for */ - length = widthBytesLine * height * - Ones(stuff->planeMask & (plane | (plane - 1))); + length = widthBytesLine * h * + Ones(planemask & (plane | (plane - 1))); -#ifdef INTERNAL_VS_EXTERNAL_PADDING - widthBytesLineProto = BitmapBytePadProto(stuff->width); - lengthProto = widthBytesLineProto * height * - Ones(stuff->planeMask & (plane | (plane - 1))); -#endif } -#ifdef INTERNAL_VS_EXTERNAL_PADDING - xgi.length = (lengthProto + 3) >> 2; -#else xgi.length = (length + 3) >> 2; -#endif - if (widthBytesLine == 0 || height == 0) { + if (widthBytesLine == 0 || h == 0) linesPerBuf = 0; - } else if (widthBytesLine >= IMAGE_BUFSIZE) { + else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE) linesPerBuf = 1; - } else { - linesPerBuf = IMAGE_BUFSIZE / widthBytesLine; - if (linesPerBuf > height) - linesPerBuf = height; + else { + linesPerBuf = XINERAMA_IMAGE_BUFSIZE / widthBytesLine; + if (linesPerBuf > h) + linesPerBuf = h; } length = linesPerBuf * widthBytesLine; - if (linesPerBuf < height) { - - /* - * Have to make sure intermediate buffers don't need padding - */ - - while ((linesPerBuf > 1) - && (length & ((1 << LOG2_BYTES_PER_SCANLINE_PAD)-1))) { - linesPerBuf--; - length -= widthBytesLine; - } - while (length & ((1 << LOG2_BYTES_PER_SCANLINE_PAD)-1)) { - linesPerBuf++; - length += widthBytesLine; - } - } - IF_RETURN((!(pBuf = (char *) ALLOCATE_LOCAL(length))), BadAlloc); - -#ifdef INTERNAL_VS_EXTERNAL_PADDING - /* - * Check for protocol/server padding differences - */ - - if (widthBytesLine != widthBytesLineProto) - if (!(tmpImage = (char *) ALLOCATE_LOCAL(length))) { - DEALLOCATE_LOCAL(pBuf); - return (BadAlloc); - } -#endif + if(!(pBuf = xalloc(length))) + return (BadAlloc); WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); if (linesPerBuf == 0) { - - /* - * Nothing to do - */ - - } else if (stuff->format == ZPixmap) { + /* nothing to do */ + } + else if (format == ZPixmap) { linesDone = 0; - while (height - linesDone > 0) { - nlines = min(linesPerBuf, height - linesDone); - if (pDraw->type == DRAWABLE_WINDOW) { - SrcBox.x1 = pDraw->x + stuff->x; - SrcBox.y1 = pDraw->y + stuff->y + linesDone; - SrcBox.x2 = SrcBox.x1 + stuff->width; - SrcBox.y2 = SrcBox.y1 + nlines; - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - - /* - * If it isn't even on this screen, just continue. - */ + while (h - linesDone > 0) { + nlines = min(linesPerBuf, h - linesDone); - if ((SrcBox.x1 >= panoramiXdataPtr[j].x + panoramiXdataPtr[j].width) - || (SrcBox.x2 <= panoramiXdataPtr[j].x) - || (SrcBox.y1 >= panoramiXdataPtr[j].y+panoramiXdataPtr[j].height) - || (SrcBox.y2 <= panoramiXdataPtr[j].y)) - continue; - - srcParts.x1 = max(SrcBox.x1 - panoramiXdataPtr[j].x, 0); - srcParts.x2 = min(SrcBox.x2 - panoramiXdataPtr[j].x, - panoramiXdataPtr[j].width); - srcParts.y1 = max(SrcBox.y1 - panoramiXdataPtr[j].y, 0); - srcParts.y2 = min(SrcBox.y2 - panoramiXdataPtr[j].y, - panoramiXdataPtr[j].height); - srcParts.width = srcParts.x2 - srcParts.x1; - srcParts.ByteWidth = PixmapBytePad(srcParts.width,pDraw->depth); - srcParts.buf = (char *) Xalloc(nlines * srcParts.ByteWidth); - locDraw = (DrawablePtr) SecurityLookupIDByClass(client, - pPanoramiXWin->info[j].id, - RC_DRAWABLE, - SecurityReadAccess); - (*pDraw->pScreen->GetImage)(locDraw, - srcParts.x1 - locDraw->x, - srcParts.y1 - locDraw->y, - srcParts.width, - srcParts.y2 - srcParts.y1, - stuff->format, - (unsigned long)stuff->planeMask, - srcParts.buf); - BufPtr = pBuf - + srcParts.x1 - stuff->x - (pDraw->x - panoramiXdataPtr[j].x) - + widthBytesLine * (srcParts.y1 - stuff->y - - (pDraw->y + linesDone - panoramiXdataPtr[j].y)); - PartPtr = srcParts.buf; - for (k = (srcParts.y2 - srcParts.y1); k; k--) { - bcopy(PartPtr, BufPtr, srcParts.width); - BufPtr += widthBytesLine; - PartPtr += srcParts.ByteWidth; - } - Xfree(srcParts.buf); - } - } else { - (*pDraw->pScreen->GetImage) (pDraw, stuff->x, stuff->y + linesDone, - stuff->width, nlines, stuff->format, - (unsigned long)stuff->planeMask, pBuf); - } - -#ifdef INTERNAL_VS_EXTERNAL_PADDING - /* - * For 64-bit server, convert image to pad to 32 bits - */ - - if ( widthBytesLine != widthBytesLineProto ) { - register char * bufPtr, * protoPtr; - register int i; - - bzero(tmpImage,length); - - for (i = 0, bufPtr = pBuf, protoPtr = tmpImage; i < nlines; - bufPtr += widthBytesLine, protoPtr += widthBytesLineProto, - i++) - memmove(protoPtr,bufPtr,widthBytesLineProto); - - /* - * Note this is NOT a call to WriteSwappedDataToClient, - * as we do NOT byte swap - */ - - (void)WriteToClient(client, - (int)(nlines * widthBytesLineProto), tmpImage); - } else -#endif - { + if(pDraw->depth == 1) + bzero(pBuf, nlines * widthBytesLine); - /* - * Note this is NOT a call to WriteSwappedDataToClient, - * as we do NOT byte swap - */ + XineramaGetImageData(drawables, x, y + linesDone, w, nlines, + format, planemask, pBuf, widthBytesLine, isRoot); - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), pBuf); - } + (void)WriteToClient(client, + (int)(nlines * widthBytesLine), + pBuf); linesDone += nlines; } - } else { /* XYPixmap */ + } else { /* XYPixmap */ for (; plane; plane >>= 1) { - if (stuff->planeMask & plane) { + if (planemask & plane) { linesDone = 0; - while (height - linesDone > 0) { - nlines = min(linesPerBuf, height - linesDone); - (*pDraw->pScreen->GetImage) (pDraw, - stuff->x, - stuff->y + linesDone, - stuff->width, - nlines, - stuff->format, - (unsigned long)plane, - pBuf); - -#ifdef INTERNAL_VS_EXTERNAL_PADDING - /* - * For 64-bit server, convert image to pad to 32 bits - */ - - if (widthBytesLine != widthBytesLineProto) { - register char * bufPtr, * protoPtr; - register int i; - - bzero(tmpImage, length); - - for (i = 0,bufPtr = pBuf,protoPtr =tmpImage; i < nlines; - bufPtr += widthBytesLine, - protoPtr += widthBytesLineProto, - i++) - bcopy(bufPtr, protoPtr, widthBytesLineProto); - - /* - * Note: NOT a call to WriteSwappedDataToClient, - * as we do NOT byte swap - */ - - (void)WriteToClient(client, - (int)(nlines * widthBytesLineProto), tmpImage); - } else -#endif - { + while (h - linesDone > 0) { + nlines = min(linesPerBuf, h - linesDone); - /* - * Note: NOT a call to WriteSwappedDataToClient, - * as we do NOT byte swap - */ + bzero(pBuf, nlines * widthBytesLine); + + XineramaGetImageData(drawables, x, y + linesDone, w, + nlines, format, plane, pBuf, + widthBytesLine, isRoot); + + (void)WriteToClient(client, + (int)(nlines * widthBytesLine), + pBuf); - (void)WriteToClient(client, - (int)(nlines * widthBytesLine), pBuf); - } linesDone += nlines; } } } } - DEALLOCATE_LOCAL(pBuf); -#ifdef INTERNAL_VS_EXTERNAL_PADDING - if (widthBytesLine != widthBytesLineProto) - DEALLOCATE_LOCAL(tmpImage); -#endif + xfree(pBuf); return (client->noClientException); } +/* The text stuff should be rewritten so that duplication happens + at the GlyphBlt level. That is, loading the font and getting + the glyphs should only happen once */ + int -PanoramiXPolyText8(register ClientPtr client) +PanoramiXPolyText8(ClientPtr client) { - int result, j; - - PanoramiXWindow *pPanoramiXRoot; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr pDraw; - PixmapPtr pPixmap; - GC *pGC; - int orig_x, orig_y; + PanoramiXRes *gc, *draw; + Bool isRoot; + int result = 0, j; + int orig_x, orig_y; REQUEST(xPolyTextReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - pPanoramiXRoot = (pDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXWin = pPanoramiXRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - /* In the case of Multibuffering, we need to make sure the drawable - isn't really a pixmap associated to a drawable */ - if (!pPanoramiXWin && (stuff->drawable != pDraw->id)) { - pPanoramiXWin = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - } - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + REQUEST_AT_LEAST_SIZE(xPolyTextReq); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyText8])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - stuff->x = orig_x; - stuff->y = orig_y; - if (pPanoramiXWin == pPanoramiXRoot) { + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { stuff->x = orig_x - panoramiXdataPtr[j].x; stuff->y = orig_y - panoramiXdataPtr[j].y; - } else { - if ( (pDraw->type == DRAWABLE_PIXMAP) && - /* special case root window bitmap */ - (pDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - stuff->x = orig_x - panoramiXdataPtr[j].x; - stuff->y = orig_y - panoramiXdataPtr[j].y; - } } - if (!j) - noPanoramiXExtension = TRUE; result = (*SavedProcVector[X_PolyText8])(client); - noPanoramiXExtension = FALSE; - BREAK_IF(result != Success); + if(result != Success) break; } return (result); } int -PanoramiXPolyText16(register ClientPtr client) +PanoramiXPolyText16(ClientPtr client) { - int result, j; - - PanoramiXWindow *pPanoramiXRoot; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr pDraw; - GC *pGC; - int orig_x, orig_y; + PanoramiXRes *gc, *draw; + Bool isRoot; + int result = 0, j; + int orig_x, orig_y; REQUEST(xPolyTextReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - pPanoramiXRoot = (pDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXWin = pPanoramiXRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - /* In the case of Multibuffering, we need to make sure the drawable - isn't really a pixmap associated to a drawable */ - if (!pPanoramiXWin && (stuff->drawable != pDraw->id)) { - pPanoramiXWin = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - } - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + REQUEST_AT_LEAST_SIZE(xPolyTextReq); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_PolyText16])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - stuff->x = orig_x; - stuff->y = orig_y; - if (pPanoramiXWin == pPanoramiXRoot) { + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { stuff->x = orig_x - panoramiXdataPtr[j].x; stuff->y = orig_y - panoramiXdataPtr[j].y; - } else { - if ( (pDraw->type == DRAWABLE_PIXMAP) && - /* special case root window bitmap */ - (pDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - stuff->x = orig_x - panoramiXdataPtr[j].x; - stuff->y = orig_y - panoramiXdataPtr[j].y; - } } - if (!j) - noPanoramiXExtension = TRUE; result = (*SavedProcVector[X_PolyText16])(client); - noPanoramiXExtension = FALSE; - BREAK_IF(result != Success); + if(result != Success) break; } return (result); } - int PanoramiXImageText8(ClientPtr client) { - int result, j; - PanoramiXWindow *pPanoramiXRoot; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr pDraw; - GCPtr pGC; + int result = 0, j; + PanoramiXRes *gc, *draw; + Bool isRoot; int orig_x, orig_y; REQUEST(xImageTextReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - pPanoramiXRoot = (pDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXWin = pPanoramiXRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_ImageText8])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - if (pPanoramiXWin == pPanoramiXRoot) { + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { stuff->x = orig_x - panoramiXdataPtr[j].x; stuff->y = orig_y - panoramiXdataPtr[j].y; - }else { - if ( (pDraw->type == DRAWABLE_PIXMAP) && - /* special case root window bitmap */ - (pDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - stuff->x = orig_x - panoramiXdataPtr[j].x; - stuff->y = orig_y - panoramiXdataPtr[j].y; - } } result = (*SavedProcVector[X_ImageText8])(client); - BREAK_IF(result != Success); + if(result != Success) break; } return (result); } @@ -2682,249 +2020,217 @@ int PanoramiXImageText8(ClientPtr client) int PanoramiXImageText16(ClientPtr client) { - int result, j; - PanoramiXWindow *pPanoramiXRoot; - PanoramiXWindow *pPanoramiXWin; - PanoramiXGC *pPanoramiXGC = PanoramiXGCRoot; - DrawablePtr pDraw; - GCPtr pGC; + int result = 0, j; + PanoramiXRes *gc, *draw; + Bool isRoot; int orig_x, orig_y; REQUEST(xImageTextReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); - pPanoramiXRoot = (pDraw->type == DRAWABLE_PIXMAP) - ? PanoramiXPmapRoot : PanoramiXWinRoot; - pPanoramiXWin = pPanoramiXRoot; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->drawable); - IF_RETURN(!pPanoramiXWin, BadDrawable); - PANORAMIXFIND_ID(pPanoramiXGC, stuff->gc); - IF_RETURN(!pPanoramiXGC, BadGC); + REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(IS_SHARED_PIXMAP(draw)) + return (*SavedProcVector[X_ImageText16])(client); + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + orig_x = stuff->x; orig_y = stuff->y; - FOR_NSCREENS_OR_ONCE((pPanoramiXWin && pPanoramiXGC), j) { - stuff->drawable = pPanoramiXWin->info[j].id; - stuff->gc = pPanoramiXGC->info[j].id; - if (pPanoramiXWin == pPanoramiXRoot) { + FOR_NSCREENS_BACKWARD(j){ + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { stuff->x = orig_x - panoramiXdataPtr[j].x; stuff->y = orig_y - panoramiXdataPtr[j].y; - }else { - if ( (pDraw->type == DRAWABLE_PIXMAP) && - /* special case root window bitmap */ - (pDraw->width == (panoramiXdataPtr[PanoramiXNumScreens-1].x + - panoramiXdataPtr[PanoramiXNumScreens-1].width)) ) { - stuff->x = orig_x - panoramiXdataPtr[j].x; - stuff->y = orig_y - panoramiXdataPtr[j].y; - } } result = (*SavedProcVector[X_ImageText16])(client); - BREAK_IF(result != Success); + if(result != Success) break; } return (result); } -int PanoramiXCreateColormap(register ClientPtr client) -{ - VisualPtr pVisual; - ColormapPtr pmap; - Colormap mid; - register WindowPtr pWin; - ScreenPtr pScreen; - DepthPtr pDepth; +int PanoramiXCreateColormap(ClientPtr client) +{ + PanoramiXRes *win, *newCmap; + int result = 0, j, orig_visual; REQUEST(xCreateColormapReq); - int i, result; - int vid_index, class_index; - int this_vid_index, this_class_index, this_depth; - int j = 0; - VisualID orig_visual; - Colormap cmapID; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXCmap *localCmap; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; - short VisualClass; - Bool ClassKnown; - Bool FoundIt = FALSE; - REQUEST_SIZE_MATCH(xCreateColormapReq); - mid = stuff->mid; + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->window, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + + if(!stuff->visual || (stuff->visual > 255)) + return BadValue; + + if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newCmap->type = XRT_COLORMAP; + newCmap->info[0].id = stuff->mid; + for(j = 1; j < PanoramiXNumScreens; j++) + newCmap->info[j].id = FakeClientID(client->index); + orig_visual = stuff->visual; - j = 0; - PANORAMIXFIND_ID(pPanoramiXWin, stuff->window); - if (pPanoramiXWin) { - localCmap = (PanoramiXCmap *)Xcalloc(sizeof(PanoramiXCmap)); - IF_RETURN(!localCmap, BadAlloc); - } else { - return BadWindow; - } - for (j = 0; j <= PanoramiXNumScreens - 1; j++) { - cmapID = j ? FakeClientID(client->index) : mid; - localCmap->info[j].id = cmapID; - } - localCmap->FreeMe = FALSE; - PANORAMIXFIND_LAST(pPanoramiXCmap, PanoramiXCmapRoot); - pPanoramiXCmap->next = localCmap; - - /* Use Screen 0 to get the matching Visual ID */ - pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, - SecurityReadAccess); - if ( stuff->visual != CopyFromParent) - { - /* Find the correct visual for screen 0 */ - for (class_index = 0; class_index < PanoramiXColorDepthTable[0].numVisuals; -class_index++) - { - for (j = 0; j < PanoramiXColorDepthTable[0].panoramiXScreenMap[class_index -].numDepths; j++ ) - { - pDepth = (DepthPtr) &pWin->drawable.pScreen->allowedDepths[j]; - for (vid_index = 0; vid_index < PanoramiXColorDepthTable[0].panoramiXScreenMap[class_index].vmap[pDepth->depth].numVids; vid_index++) - { - if ( stuff->visual == PanoramiXColorDepthTable[0].panoramiXScreenMap[class_index].vmap[pDepth->depth].vid[vid_index] ) - { - this_class_index = class_index; - this_vid_index = vid_index; - this_depth = pDepth->depth; - FoundIt = TRUE; - break; - } - } - } - } - } - if (!pWin) - return(BadWindow); - pScreen = pWin->drawable.pScreen; - FOR_NSCREENS_OR_ONCE(pPanoramiXWin, j) { - stuff->mid = localCmap->info[j].id; - stuff->window = pPanoramiXWin->info[j].id; - /* Look for the matching visual class, and use its - visual id for creating this colormap. */ - if ( orig_visual != CopyFromParent && FoundIt ) - { - stuff->visual = PanoramiXColorDepthTable[j].panoramiXScreenMap[this_class_index].vmap[this_depth].vid[this_vid_index]; - } + FOR_NSCREENS_BACKWARD(j){ + stuff->mid = newCmap->info[j].id; + stuff->window = win->info[j].id; + stuff->visual = PanoramiXVisualTable[(orig_visual * MAXSCREENS) + j]; result = (* SavedProcVector[X_CreateColormap])(client); - BREAK_IF(result != Success); - } - if (result != Success) { - pPanoramiXCmap->next = NULL ; - if (localCmap) - Xfree(localCmap); + if(result != Success) break; } + + if (result == Success) + AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); + else + xfree(newCmap); + return (result); } int PanoramiXFreeColormap(ClientPtr client) { - ColormapPtr pmap; + PanoramiXRes *cmap; + int result = 0, j; REQUEST(xResourceReq); - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; - PanoramiXCmap *pPanoramiXCmapback = NULL; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; REQUEST_SIZE_MATCH(xResourceReq); - for (; pPanoramiXCmap && (pPanoramiXCmap->info[0].id != stuff->id); - pPanoramiXCmap = pPanoramiXCmap->next) - pPanoramiXCmapback = pPanoramiXCmap; - IF_RETURN(!pPanoramiXCmap, BadColor); - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->id = pPanoramiXCmap->info[j].id; + client->errorValue = stuff->id; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_COLORMAP, SecurityDestroyAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = cmap->info[j].id; result = (* SavedProcVector[X_FreeColormap])(client); - BREAK_IF(result != Success); + if(result != Success) break; } - if ((result == Success) && pPanoramiXCmapback && - pPanoramiXCmap && pPanoramiXCmap->FreeMe) { - pPanoramiXCmapback->next = pPanoramiXCmap->next; - Xfree(pPanoramiXCmap); + + /* Since ProcFreeColormap is using FreeResource, it will free + our resource for us on the last pass through the loop above */ + + return (result); +} + + +int +PanoramiXCopyColormapAndFree(ClientPtr client) +{ + PanoramiXRes *cmap, *newCmap; + int result = 0, j; + REQUEST(xCopyColormapAndFreeReq); + + REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); + + client->errorValue = stuff->srcCmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->srcCmap, XRT_COLORMAP, + SecurityReadAccess | SecurityWriteAccess))) + return BadColor; + + if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newCmap->type = XRT_COLORMAP; + newCmap->info[0].id = stuff->mid; + for(j = 1; j < PanoramiXNumScreens; j++) + newCmap->info[j].id = FakeClientID(client->index); + + FOR_NSCREENS_BACKWARD(j){ + stuff->srcCmap = cmap->info[j].id; + stuff->mid = newCmap->info[j].id; + result = (* SavedProcVector[X_CopyColormapAndFree])(client); + if(result != Success) break; } - PANORAMIX_FREE(client); + + if (result == Success) + AddResource(newCmap->info[0].id, XRT_COLORMAP, newCmap); + else + xfree(newCmap); + return (result); } -int PanoramiXInstallColormap(register ClientPtr client) +int PanoramiXInstallColormap(ClientPtr client) { - ColormapPtr pcmp; REQUEST(xResourceReq); - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; + int result = 0, j; + PanoramiXRes *cmap; REQUEST_SIZE_MATCH(xResourceReq); - PANORAMIXFIND_ID(pPanoramiXCmap, stuff->id); - IF_RETURN(!pPanoramiXCmap, BadColor); - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->id = pPanoramiXCmap->info[j].id; + + client->errorValue = stuff->id; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_COLORMAP, SecurityReadAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j){ + stuff->id = cmap->info[j].id; result = (* SavedProcVector[X_InstallColormap])(client); - BREAK_IF(result != Success); + if(result != Success) break; } return (result); } -int PanoramiXUninstallColormap(register ClientPtr client) +int PanoramiXUninstallColormap(ClientPtr client) { - ColormapPtr pcmp; REQUEST(xResourceReq); - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; - - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; + int result = 0, j; + PanoramiXRes *cmap; REQUEST_SIZE_MATCH(xResourceReq); - PANORAMIXFIND_ID(pPanoramiXCmap, stuff->id); - IF_RETURN(!pPanoramiXCmap, BadColor); - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->id = pPanoramiXCmap->info[j].id; + + client->errorValue = stuff->id; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->id, XRT_COLORMAP, SecurityReadAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j) { + stuff->id = cmap->info[j].id; result = (* SavedProcVector[X_UninstallColormap])(client); - BREAK_IF(result != Success); + if(result != Success) break; } - PANORAMIX_FREE(client); return (result); } int PanoramiXAllocColor(ClientPtr client) { - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; + int result = 0, j; + PanoramiXRes *cmap; REQUEST(xAllocColorReq); REQUEST_SIZE_MATCH(xAllocColorReq); - PANORAMIXFIND_ID(pPanoramiXCmap, stuff->cmap); - if (!pPanoramiXCmap){ - noPanoramiXExtension = TRUE; + + client->errorValue = stuff->cmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; result = (* SavedProcVector[X_AllocColor])(client); - noPanoramiXExtension = FALSE; - }else { - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->cmap = pPanoramiXCmap->info[j].id; - if (!j) - noPanoramiXExtension = TRUE; - result = (* SavedProcVector[X_AllocColor])(client); - noPanoramiXExtension = FALSE; - BREAK_IF(result != Success); - } + if(result != Success) break; } return (result); } @@ -2932,20 +2238,22 @@ int PanoramiXAllocColor(ClientPtr client) int PanoramiXAllocNamedColor(ClientPtr client) { - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; + int result = 0, j; + PanoramiXRes *cmap; REQUEST(xAllocNamedColorReq); REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes); - PANORAMIXFIND_ID(pPanoramiXCmap, stuff->cmap); - IF_RETURN(!pPanoramiXCmap, BadColor); - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->cmap = pPanoramiXCmap->info[j].id; - if (!j) - noPanoramiXExtension = TRUE; + + client->errorValue = stuff->cmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; result = (* SavedProcVector[X_AllocNamedColor])(client); - noPanoramiXExtension = FALSE; - BREAK_IF(result != Success); + if(result != Success) break; } return (result); } @@ -2953,82 +2261,114 @@ int PanoramiXAllocNamedColor(ClientPtr client) int PanoramiXAllocColorCells(ClientPtr client) { - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; + int result = 0, j; + PanoramiXRes *cmap; REQUEST(xAllocColorCellsReq); REQUEST_SIZE_MATCH(xAllocColorCellsReq); - PANORAMIXFIND_ID(pPanoramiXCmap, stuff->cmap); - if (!pPanoramiXCmap) { - noPanoramiXExtension = TRUE; + + client->errorValue = stuff->cmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; result = (* SavedProcVector[X_AllocColorCells])(client); - noPanoramiXExtension = FALSE; - }else { - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->cmap = pPanoramiXCmap->info[j].id; - if (!j) - noPanoramiXExtension = TRUE; - result = (* SavedProcVector[X_AllocColorCells])(client); - noPanoramiXExtension = FALSE; - /* Because id's are eventually searched for in - some client list, we don't check for success - on fake id's last id will be real, we really - only care about results related to real id's - BREAK_IF(result != Success); - */ - } + if(result != Success) break; } return (result); } -int PanoramiXFreeColors(register ClientPtr client) +int PanoramiXAllocColorPlanes(ClientPtr client) { - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; - REQUEST(xFreeColorsReq); + int result = 0, j; + PanoramiXRes *cmap; + REQUEST(xAllocColorPlanesReq); - PanoramiXGC *pPanoramiXFreeGC; - PanoramiXGC *pPanoramiXFreeGCback = NULL; - PanoramiXWindow *pPanoramiXFreeWin; - PanoramiXWindow *pPanoramiXFreeWinback = NULL; - PanoramiXCmap *pPanoramiXFreeCmap; - PanoramiXCmap *pPanoramiXFreeCmapback = NULL; - PanoramiXPmap *pPanoramiXFreePmap; - PanoramiXPmap *pPanoramiXFreePmapback = NULL; + REQUEST_SIZE_MATCH(xAllocColorPlanesReq); + + client->errorValue = stuff->cmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_AllocColorPlanes])(client); + if(result != Success) break; + } + return (result); +} + + + +int PanoramiXFreeColors(ClientPtr client) +{ + int result = 0, j; + PanoramiXRes *cmap; + REQUEST(xFreeColorsReq); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); - PANORAMIXFIND_ID(pPanoramiXCmap, stuff->cmap); - IF_RETURN(!pPanoramiXCmap, BadColor); - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->cmap = pPanoramiXCmap->info[j].id; + + client->errorValue = stuff->cmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j) { + stuff->cmap = cmap->info[j].id; result = (* SavedProcVector[X_FreeColors])(client); - /* Because id's are eventually searched for in - some client list, we don't check for success - on fake id's last id will be real, we really - only care about results related to real id's */ } - PANORAMIX_FREE(client); return (result); } int PanoramiXStoreColors(ClientPtr client) { - int result, j; - PanoramiXCmap *pPanoramiXCmap = PanoramiXCmapRoot; + int result = 0, j; + PanoramiXRes *cmap; REQUEST(xStoreColorsReq); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); - PANORAMIXFIND_ID(pPanoramiXCmap, stuff->cmap); - if (!pPanoramiXCmap) + + client->errorValue = stuff->cmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; result = (* SavedProcVector[X_StoreColors])(client); - else { - FOR_NSCREENS_OR_ONCE(pPanoramiXCmap, j) { - stuff->cmap = pPanoramiXCmap->info[j].id; - result = (* SavedProcVector[X_StoreColors])(client); - BREAK_IF(result != Success); - } + if(result != Success) break; + } + return (result); +} + + +int PanoramiXStoreNamedColor(ClientPtr client) +{ + int result = 0, j; + PanoramiXRes *cmap; + REQUEST(xStoreNamedColorReq); + + REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); + + client->errorValue = stuff->cmap; + + if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->cmap, XRT_COLORMAP, SecurityWriteAccess))) + return BadColor; + + FOR_NSCREENS_BACKWARD(j){ + stuff->cmap = cmap->info[j].id; + result = (* SavedProcVector[X_StoreNamedColor])(client); + if(result != Success) break; } return (result); } |