diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:22 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:22 +0000 |
commit | d568221710959cf7d783e6ff0fb80fb43a231124 (patch) | |
tree | 8d6f039393294c6ffac8533639afdebe5d68bfc1 /Xext | |
parent | 9508a382f8a9f241dab097d921b6d290c1c3a776 (diff) |
XFree86 4.3.0.1
Diffstat (limited to 'Xext')
-rw-r--r-- | Xext/EVI.c | 10 | ||||
-rw-r--r-- | Xext/appgroup.c | 18 | ||||
-rw-r--r-- | Xext/bigreq.c | 18 | ||||
-rw-r--r-- | Xext/cup.c | 17 | ||||
-rw-r--r-- | Xext/dpms.c | 88 | ||||
-rw-r--r-- | Xext/dpmsstubs.c | 8 | ||||
-rw-r--r-- | Xext/mbuf.c | 558 | ||||
-rw-r--r-- | Xext/mbufbf.c | 1 | ||||
-rw-r--r-- | Xext/mbufpx.c | 1 | ||||
-rw-r--r-- | Xext/mitmisc.c | 24 | ||||
-rw-r--r-- | Xext/panoramiX.c | 1301 | ||||
-rw-r--r-- | Xext/panoramiXSwap.c | 89 | ||||
-rw-r--r-- | Xext/panoramiXprocs.c | 3996 | ||||
-rw-r--r-- | Xext/security.c | 25 | ||||
-rw-r--r-- | Xext/shape.c | 370 | ||||
-rw-r--r-- | Xext/shm.c | 719 | ||||
-rw-r--r-- | Xext/sleepuntil.c | 48 | ||||
-rw-r--r-- | Xext/sync.c | 298 | ||||
-rw-r--r-- | Xext/xcmisc.c | 32 | ||||
-rw-r--r-- | Xext/xprint.c | 578 | ||||
-rw-r--r-- | Xext/xtest.c | 52 | ||||
-rw-r--r-- | Xext/xtest1dd.c | 127 | ||||
-rw-r--r-- | Xext/xtest1di.c | 87 |
23 files changed, 4332 insertions, 4133 deletions
diff --git a/Xext/EVI.c b/Xext/EVI.c index 8ccc31af2..aa3734b02 100644 --- a/Xext/EVI.c +++ b/Xext/EVI.c @@ -21,6 +21,8 @@ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/programs/Xserver/Xext/EVI.c,v 3.9 2001/10/28 03:32:50 tsi Exp $ */ + #include "X.h" #include "Xproto.h" #include "dixstruct.h" @@ -34,7 +36,7 @@ static EviPrivPtr eviPriv; static int ProcEVIQueryVersion(ClientPtr client) { - REQUEST(xEVIQueryVersionReq); + /* REQUEST(xEVIQueryVersionReq); */ xEVIQueryVersionReply rep; register int n; REQUEST_SIZE_MATCH (xEVIQueryVersionReq); @@ -167,11 +169,11 @@ EVIResetProc(ExtensionEntry *extEntry) void EVIExtensionInit(void) { - ExtensionEntry *extEntry, *AddExtension(); - if (extEntry = AddExtension(EVINAME, 0, 0, + ExtensionEntry *extEntry; + if ((extEntry = AddExtension(EVINAME, 0, 0, ProcEVIDispatch, SProcEVIDispatch, - EVIResetProc, StandardMinorOpcode)) + EVIResetProc, StandardMinorOpcode))) { XEVIReqCode = (unsigned char)extEntry->base; eviPriv = eviDDXInit(); diff --git a/Xext/appgroup.c b/Xext/appgroup.c index 71e74da38..37e6ee0bc 100644 --- a/Xext/appgroup.c +++ b/Xext/appgroup.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/Xext/appgroup.c,v 1.9 2001/12/17 20:52:25 dawes Exp $ */ /* Copyright 1996, 1998, 2001 The Open Group @@ -74,9 +75,9 @@ static int XagCallbackRefCount = 0; static RESTYPE RT_APPGROUP; static AppGroupPtr appGrpList = NULL; -extern WindowPtr* WindowTable; extern xConnSetupPrefix connSetupPrefix; extern char* ConnectionInfo; +extern int connBlockScreenStart; static int XagAppGroupFree (what, id) @@ -121,7 +122,7 @@ void XagClientStateChange (pcbl, nulldata, calldata) NewClientInfoRec* pci = (NewClientInfoRec*) calldata; ClientPtr pClient = pci->client; AppGroupPtr pAppGrp; - XID authId; + XID authId = 0; if (!pClient->appgroup) { switch (pClient->clientState) { @@ -220,13 +221,13 @@ XagExtensionInit () { ExtensionEntry* extEntry; - if (extEntry = AddExtension (XAGNAME, + if ((extEntry = AddExtension (XAGNAME, 0, XagNumberErrors, ProcXagDispatch, SProcXagDispatch, XagResetProc, - StandardMinorOpcode)) { + StandardMinorOpcode))) { XagReqCode = (unsigned char)extEntry->base; XagErrorBase = extEntry->errorBase; RT_APPGROUP = CreateNewResourceType (XagAppGroupFree); @@ -247,7 +248,7 @@ static int ProcXagQueryVersion (client) register ClientPtr client; { - REQUEST (xXagQueryVersionReq); + /* REQUEST (xXagQueryVersionReq); */ xXagQueryVersionReply rep; register int n; @@ -309,8 +310,6 @@ static void CreateConnectionInfo (pAppGrp) AppGroupPtr pAppGrp; { - extern int connBlockScreenStart; - xConnSetup *setup = (xConnSetup*) ConnectionInfo; xWindowRoot* rootp; xWindowRoot* roots[MAXSCREENS]; unsigned int rootlens[MAXSCREENS]; @@ -376,7 +375,6 @@ AppGroupPtr CreateAppGroup (client, appgroupId, attrib_mask, attribs) CARD32* attribs; { AppGroupPtr pAppGrp; - int i; pAppGrp = (AppGroupPtr) xalloc (sizeof(AppGroupRec)); if (pAppGrp) { @@ -570,7 +568,7 @@ int ProcXagCreateAssoc (client) if (stuff->window_type != XagWindowTypeX11) #endif return BadMatch; -#ifdef WIN32 /* and Mac, etc */ +#if defined(WIN32) || defined(__CYGWIN__) /* and Mac, etc */ if (!LocalClient (client)) return BadAccess; #endif @@ -584,7 +582,7 @@ static int ProcXagDestroyAssoc (client) register ClientPtr client; { - REQUEST (xXagDestroyAssocReq); + /* REQUEST (xXagDestroyAssocReq); */ REQUEST_SIZE_MATCH (xXagDestroyAssocReq); /* Macintosh, OS/2, and MS-Windows servers have some work to do here */ diff --git a/Xext/bigreq.c b/Xext/bigreq.c index 4f4bf5c02..0d2dc5178 100644 --- a/Xext/bigreq.c +++ b/Xext/bigreq.c @@ -26,7 +26,9 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/Xserver/Xext/bigreq.c,v 3.5 2001/12/14 19:58:48 dawes Exp $ */ +#define NEED_EVENTS #include "X.h" #include "Xproto.h" #include "misc.h" @@ -36,17 +38,23 @@ from The Open Group. #include "bigreqstr.h" static unsigned char XBigReqCode; -static int ProcBigReqDispatch(); -static void BigReqResetProc(); + +static void BigReqResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif +); + +static DISPATCH_PROC(ProcBigReqDispatch); void BigReqExtensionInit() { - ExtensionEntry *extEntry, *AddExtension(); + ExtensionEntry *extEntry; - if (extEntry = AddExtension(XBigReqExtensionName, 0, 0, + if ((extEntry = AddExtension(XBigReqExtensionName, 0, 0, ProcBigReqDispatch, ProcBigReqDispatch, - BigReqResetProc, StandardMinorOpcode)) + BigReqResetProc, StandardMinorOpcode)) != 0) XBigReqCode = (unsigned char)extEntry->base; DeclareExtensionSecurity(XBigReqExtensionName, TRUE); } diff --git a/Xext/cup.c b/Xext/cup.c index 4e8cf66b4..2159417bb 100644 --- a/Xext/cup.c +++ b/Xext/cup.c @@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/Xserver/Xext/cup.c,v 1.10 2001/12/14 19:58:48 dawes Exp $ */ #define NEED_REPLIES #define NEED_EVENTS @@ -35,11 +36,16 @@ in this Software without prior written authorization from The Open Group. #include "colormapst.h" #include "scrnintstr.h" #include "servermd.h" +#include "swapreq.h" #define _XCUP_SERVER_ #include "Xcupstr.h" #include "Xfuncproto.h" +#ifndef EXTMODULE #include "../os/osdep.h" +#else +#include "xf86_ansic.h" +#endif static int ProcDispatch (), SProcDispatch (); static void ResetProc (); @@ -121,13 +127,13 @@ XcupExtensionInit () { ExtensionEntry* extEntry; - if (extEntry = AddExtension (XCUPNAME, + if ((extEntry = AddExtension (XCUPNAME, 0, XcupNumberErrors, ProcDispatch, SProcDispatch, ResetProc, - StandardMinorOpcode)) { + StandardMinorOpcode))) { ReqCode = (unsigned char)extEntry->base; ErrorBase = extEntry->errorBase; } @@ -146,7 +152,7 @@ static int ProcQueryVersion (client) register ClientPtr client; { - REQUEST (xXcupQueryVersionReq); + /* REQUEST (xXcupQueryVersionReq); */ xXcupQueryVersionReply rep; register int n; @@ -214,7 +220,6 @@ int ProcStoreColors (client) int ncolors, n; xXcupStoreColorsReply rep; xColorItem* cptr; - Pixel pixel; if (!(pcmp->class & DynamicClass)) return BadMatch; @@ -302,7 +307,7 @@ int SProcGetReservedColormapEntries (client) } static -int SProcStoreColors (client) +int SProcXcupStoreColors (client) ClientPtr client; { register int n; @@ -331,7 +336,7 @@ int SProcDispatch (client) case X_XcupGetReservedColormapEntries: return SProcGetReservedColormapEntries (client); case X_XcupStoreColors: - return SProcStoreColors (client); + return SProcXcupStoreColors (client); default: return BadRequest; } diff --git a/Xext/dpms.c b/Xext/dpms.c index ebc992dc2..23c377fb4 100644 --- a/Xext/dpms.c +++ b/Xext/dpms.c @@ -27,43 +27,55 @@ Equipment Corporation. ******************************************************************/ +/* + * HISTORY + * + * @(#)RCSfile: dpms.c,v Revision: 1.1.4.5 (DEC) Date: 1996/03/04 15:27:00 + */ + +/* $XFree86: xc/programs/Xserver/Xext/dpms.c,v 3.9 2001/10/28 03:32:50 tsi Exp $ */ + #include "X.h" #include "Xproto.h" #include "misc.h" #include "os.h" #include "dixstruct.h" #include "extnsionst.h" +#include "opaque.h" +#define DPMS_SERVER #include "dpms.h" #include "dpmsstr.h" -#include <stdio.h> +#include "dpmsproc.h" static unsigned char DPMSCode; -static int ProcDPMSDispatch(), SProcDPMSDispatch(); -static void DPMSResetProc(); -static int ProcDPMSGetVersion(), SProcDPMSGetVersion(); -static int ProcDPMSGetTimeouts(), SProcDPMSGetTimeouts(); -static int ProcDPMSSetTimeouts(), ProcDPMSSetTimeouts(); -static int ProcDPMSEnable(), ProcDPMSEnable(); -static int ProcDPMSDisable(), ProcDPMSDisable(); -static int ProcDPMSForceLevel(), ProcDPMSForceLevel(); - -extern void Swap32Write(); /* XXX should be in header file */ -extern CARD32 ScreenSaverTime; -extern CARD32 DPMSStandbyTime; -extern CARD32 DPMSSuspendTime; -extern CARD32 DPMSOffTime; -extern BOOL DPMSCapableFlag; -extern BOOL DPMSEnabled; -extern CARD16 DPMSPowerLevel; +static DISPATCH_PROC(ProcDPMSDispatch); +static DISPATCH_PROC(SProcDPMSDispatch); +static DISPATCH_PROC(ProcDPMSGetVersion); +static DISPATCH_PROC(SProcDPMSGetVersion); +static DISPATCH_PROC(ProcDPMSGetTimeouts); +static DISPATCH_PROC(SProcDPMSGetTimeouts); +static DISPATCH_PROC(ProcDPMSSetTimeouts); +static DISPATCH_PROC(SProcDPMSSetTimeouts); +static DISPATCH_PROC(ProcDPMSEnable); +static DISPATCH_PROC(SProcDPMSEnable); +static DISPATCH_PROC(ProcDPMSDisable); +static DISPATCH_PROC(SProcDPMSDisable); +static DISPATCH_PROC(ProcDPMSForceLevel); +static DISPATCH_PROC(SProcDPMSForceLevel); +static DISPATCH_PROC(ProcDPMSInfo); +static DISPATCH_PROC(SProcDPMSInfo); +static DISPATCH_PROC(ProcDPMSCapable); +static DISPATCH_PROC(SProcDPMSCapable); +static void DPMSResetProc(ExtensionEntry* extEntry); void DPMSExtensionInit() { - ExtensionEntry *extEntry, *AddExtension(); + ExtensionEntry *extEntry; - if (extEntry = AddExtension(DPMSExtensionName, 0, 0, + if ((extEntry = AddExtension(DPMSExtensionName, 0, 0, ProcDPMSDispatch, SProcDPMSDispatch, - DPMSResetProc, StandardMinorOpcode)) + DPMSResetProc, StandardMinorOpcode))) DPMSCode = (unsigned char)extEntry->base; return; } @@ -79,7 +91,7 @@ static int ProcDPMSGetVersion(client) register ClientPtr client; { - REQUEST(xDPMSGetVersionReq); + /* REQUEST(xDPMSGetVersionReq); */ xDPMSGetVersionReply rep; register int n; @@ -100,10 +112,9 @@ ProcDPMSGetVersion(client) } static int -ProcDPMSCapable(client) - register ClientPtr client; +ProcDPMSCapable(register ClientPtr client) { - REQUEST(xDPMSCapableReq); + /* REQUEST(xDPMSCapableReq); */ xDPMSCapableReply rep; register int n; @@ -114,6 +125,9 @@ ProcDPMSCapable(client) rep.sequenceNumber = client->sequence; rep.capable = DPMSCapableFlag; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + } WriteToClient(client, sizeof(xDPMSCapableReply), (char *)&rep); return(client->noClientException); } @@ -122,7 +136,7 @@ static int ProcDPMSGetTimeouts(client) register ClientPtr client; { - REQUEST(xDPMSGetTimeoutsReq); + /* REQUEST(xDPMSGetTimeoutsReq); */ xDPMSGetTimeoutsReply rep; register int n; @@ -150,7 +164,6 @@ ProcDPMSSetTimeouts(client) register ClientPtr client; { REQUEST(xDPMSSetTimeoutsReq); - register int n; REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq); @@ -176,7 +189,7 @@ static int ProcDPMSEnable(client) register ClientPtr client; { - REQUEST(xDPMSEnableReq); + /* REQUEST(xDPMSEnableReq); */ REQUEST_SIZE_MATCH(xDPMSEnableReq); @@ -190,13 +203,11 @@ static int ProcDPMSDisable(client) register ClientPtr client; { - REQUEST(xDPMSDisableReq); + /* REQUEST(xDPMSDisableReq); */ REQUEST_SIZE_MATCH(xDPMSDisableReq); -#ifdef DPMSExtension DPMSSet(DPMSModeOn); -#endif DPMSEnabled = FALSE; @@ -217,9 +228,7 @@ ProcDPMSForceLevel(client) if (stuff->level == DPMSModeOn) { lastDeviceEventTime.milliseconds = GetTimeInMillis(); - } -#if 0 - else if (stuff->level == DPMSModeStandby) { + } else if (stuff->level == DPMSModeStandby) { lastDeviceEventTime.milliseconds = GetTimeInMillis() - DPMSStandbyTime; } else if (stuff->level == DPMSModeSuspend) { @@ -232,20 +241,16 @@ ProcDPMSForceLevel(client) client->errorValue = stuff->level; return BadValue; } -#endif -#ifdef DPMSExtension DPMSSet(stuff->level); -#endif return(client->noClientException); } static int -ProcDPMSInfo(client) - register ClientPtr client; +ProcDPMSInfo(register ClientPtr client) { - REQUEST(xDPMSInfoReq); + /* REQUEST(xDPMSInfoReq); */ xDPMSInfoReply rep; register int n; @@ -309,8 +314,7 @@ SProcDPMSGetVersion(client) } static int -SProcDPMSCapable(client) - register ClientPtr client; +SProcDPMSCapable(register ClientPtr client) { REQUEST(xDPMSCapableReq); register int n; diff --git a/Xext/dpmsstubs.c b/Xext/dpmsstubs.c index 6f635f42b..ac1ee352a 100644 --- a/Xext/dpmsstubs.c +++ b/Xext/dpmsstubs.c @@ -26,23 +26,23 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ +/* $XFree86: xc/programs/Xserver/Xext/dpmsstubs.c,v 3.4 2001/01/17 22:13:15 dawes Exp $ */ typedef int Bool; #define FALSE 0 -Bool DPMSSupported() +Bool DPMSSupported(void) { return FALSE; } -int DPSMGet(level) - int *level; +int DPSMGet(int *level) { return -1; } -void DPMSSet(level) +void DPMSSet(int level) { } diff --git a/Xext/mbuf.c b/Xext/mbuf.c index c65ed3dd2..16a59e58e 100644 --- a/Xext/mbuf.c +++ b/Xext/mbuf.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/Xext/mbuf.c,v 3.14 2001/12/14 19:58:49 dawes Exp $ */ /************************************************************ Copyright 1989, 1998 The Open Group @@ -27,29 +28,29 @@ in this Software without prior written authorization from The Open Group. /* $Xorg: mbuf.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */ #define NEED_REPLIES #define NEED_EVENTS -#include <stdio.h> #include "X.h" #include "Xproto.h" -#include "misc.h" +#include "window.h" #include "os.h" #include "windowstr.h" #include "scrnintstr.h" #include "pixmapstr.h" +#include "gcstruct.h" #include "extnsionst.h" #include "dixstruct.h" #include "resource.h" #include "opaque.h" +#include "sleepuntil.h" #define _MULTIBUF_SERVER_ /* don't want Xlib structures */ #include "multibufst.h" -#include "regionstr.h" -#include "gcstruct.h" -#include "inputstr.h" -#ifndef WIN32 + +#ifdef EXTMODULE +#include "xf86_ansic.h" +#else +#include <stdio.h> +#if !defined(WIN32) && !defined(Lynx) #include <sys/time.h> #endif - -#ifdef PANORAMIX -#include "panoramiX.h" #endif /* given an OtherClientPtr obj, get the ClientPtr */ @@ -60,121 +61,99 @@ in this Software without prior written authorization from The Open Group. #define ValidEventMasks (ExposureMask|MultibufferClobberNotifyMask|MultibufferUpdateNotifyMask) -#ifdef PANORAMIX -extern int PanoramiXNumScreens; -extern Bool noPanoramiXExtension; -extern PanoramiXWindow *PanoramiXWinRoot; -extern PanoramiXPmap *PanoramiXPmapRoot; -extern PanoramiXData *panoramiXdataPtr; -#endif - -/* The _Multibuffer and _Multibuffers structures below refer to each other, - * so we need this forward declaration - */ - -typedef struct _Multibuffers *MultibuffersPtr; - -/* - * per-Multibuffer data - */ - -typedef struct _Multibuffer { - MultibuffersPtr pMultibuffers; /* associated window data */ - Mask eventMask; /* MultibufferClobberNotifyMask|ExposureMask|MultibufferUpdateNotifyMask */ - Mask otherEventMask; /* mask of all other clients event masks */ - OtherClients *otherClients; /* other clients that want events */ - int number; /* index of this buffer into array */ - int side; /* always Mono */ - int clobber; /* Unclobbered, PartiallyClobbered, FullClobbered */ - PixmapPtr pPixmap; /* associated pixmap */ -} MultibufferRec, *MultibufferPtr; - -/* - * per-window data - */ - -typedef struct _Multibuffers { - WindowPtr pWindow; /* associated window */ - int numMultibuffer; /* count of buffers */ - int refcnt; /* ref count for delete */ - int displayedMultibuffer; /* currently active buffer */ - int updateAction; /* Undefined, Background, Untouched, Copied */ - int updateHint; /* Frequent, Intermittent, Static */ - int windowMode; /* always Mono */ - - TimeStamp lastUpdate; /* time of last update */ - - unsigned short width, height; /* last known window size */ - short x, y; /* for static gravity */ - - MultibufferPtr buffers; /* array of numMultibuffer buffers */ -} MultibuffersRec; - -/* - * per-screen data - */ -typedef struct _MultibufferScreen { - Bool (*PositionWindow)(); -} MultibufferScreenRec, *MultibufferScreenPtr; - -/* - * per display-image-buffers request data. - */ - -typedef struct _DisplayRequest { - struct _DisplayRequest *next; - TimeStamp activateTime; - ClientPtr pClient; - XID id; -} DisplayRequestRec, *DisplayRequestPtr; - static unsigned char MultibufferReqCode; static int MultibufferEventBase; static int MultibufferErrorBase; int MultibufferScreenIndex = -1; int MultibufferWindowIndex = -1; -static void PerformDisplayRequest (); -static void DisposeDisplayRequest (); -static Bool QueueDisplayRequest (); - -static void BumpTimeStamp (); +static void PerformDisplayRequest ( +#if NeedFunctionPrototypes + MultibuffersPtr * /* ppMultibuffers */, + MultibufferPtr * /* pMultibuffer */, + int /* nbuf */ +#endif + ); +static Bool QueueDisplayRequest ( +#if NeedFunctionPrototypes + ClientPtr /* client */, + TimeStamp /* activateTime */ +#endif + ); -void MultibufferExpose (); -void MultibufferUpdate (); -static void AliasMultibuffer (); -int CreateImageBuffers (); -void DestroyImageBuffers (); -int DisplayImageBuffers (); -static void RecalculateMultibufferOtherEvents (); -static int EventSelectForMultibuffer(); +static void BumpTimeStamp ( +#if NeedFunctionPrototypes + TimeStamp * /* ts */, + CARD32 /* inc */ +#endif + ); +static void AliasMultibuffer ( +#if NeedFunctionPrototypes + MultibuffersPtr /* pMultibuffers */, + int /* i */ +#endif + ); +static void RecalculateMultibufferOtherEvents ( +#if NeedFunctionPrototypes + MultibufferPtr /* pMultibuffer */ +#endif + ); +static int EventSelectForMultibuffer( +#if NeedFunctionPrototypes + MultibufferPtr /* pMultibuffer */, + ClientPtr /* client */, + Mask /* mask */ +#endif + ); /* * The Pixmap associated with a buffer can be found as a resource * with this type */ RESTYPE MultibufferDrawableResType; -static int MultibufferDrawableDelete (); +static int MultibufferDrawableDelete ( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif + ); /* * The per-buffer data can be found as a resource with this type. * the resource id of the per-buffer data is the same as the resource * id of the pixmap */ static RESTYPE MultibufferResType; -static int MultibufferDelete (); +static int MultibufferDelete ( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif + ); + /* * The per-window data can be found as a resource with this type, * using the window resource id */ static RESTYPE MultibuffersResType; -static int MultibuffersDelete (); +static int MultibuffersDelete ( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif + ); + /* * Clients other than the buffer creator attach event masks in * OtherClient structures; each has a resource of this type. */ static RESTYPE OtherClientResType; -static int OtherClientDelete (); +static int OtherClientDelete ( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif + ); /**************** * MultibufferExtensionInit @@ -183,10 +162,70 @@ static int OtherClientDelete (); * ****************/ -static int ProcMultibufferDispatch(), SProcMultibufferDispatch(); -static void MultibufferResetProc(); -static void SClobberNotifyEvent(), SUpdateNotifyEvent(); -static Bool MultibufferPositionWindow(); +extern DISPATCH_PROC(ProcGetBufferAttributes); + +static DISPATCH_PROC(ProcClearImageBufferArea); +static DISPATCH_PROC(ProcCreateImageBuffers); +static DISPATCH_PROC(ProcDestroyImageBuffers); +static DISPATCH_PROC(ProcDisplayImageBuffers); +static DISPATCH_PROC(ProcGetBufferInfo); +static DISPATCH_PROC(ProcGetBufferVersion); +static DISPATCH_PROC(ProcGetMBufferAttributes); +static DISPATCH_PROC(ProcMultibufferDispatch); +static DISPATCH_PROC(ProcSetBufferAttributes); +static DISPATCH_PROC(ProcSetMBufferAttributes); +static DISPATCH_PROC(SProcClearImageBufferArea); +static DISPATCH_PROC(SProcCreateImageBuffers); +static DISPATCH_PROC(SProcDestroyImageBuffers); +static DISPATCH_PROC(SProcDisplayImageBuffers); +static DISPATCH_PROC(SProcGetBufferAttributes); +static DISPATCH_PROC(SProcGetBufferInfo); +static DISPATCH_PROC(SProcGetBufferVersion); +static DISPATCH_PROC(SProcGetMBufferAttributes); +static DISPATCH_PROC(SProcMultibufferDispatch); +static DISPATCH_PROC(SProcSetBufferAttributes); +static DISPATCH_PROC(SProcSetMBufferAttributes); + +static void MultibufferResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif + ); +static void SClobberNotifyEvent( +#if NeedFunctionPrototypes + xMbufClobberNotifyEvent * /* from */, + xMbufClobberNotifyEvent * /* to */ +# endif + ); +static void SUpdateNotifyEvent( +#if NeedFunctionPrototypes + xMbufUpdateNotifyEvent * /* from */, + xMbufUpdateNotifyEvent * /* to */ +#endif + ); +static Bool MultibufferPositionWindow( +#if NeedFunctionPrototypes + WindowPtr /* pWin */, + int /* x */, + int /* y */ +#endif + ); + +static void SetupBackgroundPainter ( +#if NeedFunctionPrototypes + WindowPtr /* pWin */, + GCPtr /* pGC */ +#endif + ); + +static int DeliverEventsToMultibuffer ( +#if NeedFunctionPrototypes + MultibufferPtr /* pMultibuffer */, + xEvent * /* pEvents */, + int /* count */, + Mask /* filter */ +#endif + ); void MultibufferExtensionInit() @@ -243,8 +282,8 @@ MultibufferExtensionInit() MultibufferReqCode = (unsigned char)extEntry->base; MultibufferEventBase = extEntry->eventBase; MultibufferErrorBase = extEntry->errorBase; - EventSwapVector[MultibufferEventBase + MultibufferClobberNotify] = SClobberNotifyEvent; - EventSwapVector[MultibufferEventBase + MultibufferUpdateNotify] = SUpdateNotifyEvent; + EventSwapVector[MultibufferEventBase + MultibufferClobberNotify] = (EventSwapPtr) SClobberNotifyEvent; + EventSwapVector[MultibufferEventBase + MultibufferUpdateNotify] = (EventSwapPtr) SUpdateNotifyEvent; } } @@ -275,7 +314,6 @@ static int ProcGetBufferVersion (client) register ClientPtr client; { - REQUEST(xMbufGetBufferVersionReq); xMbufGetBufferVersionReply rep; register int n; @@ -331,8 +369,8 @@ SetupBackgroundPainter (pWin, pGC) case BackgroundPixmap: gcvalues[0] = (pointer) FillTiled; gcvalues[1] = (pointer) background.pixmap; - gcvalues[2] = (pointer) ts_x_origin; - gcvalues[3] = (pointer) ts_y_origin; + gcvalues[2] = (pointer)(long) ts_x_origin; + gcvalues[3] = (pointer)(long) ts_y_origin; gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin; break; @@ -430,80 +468,8 @@ CreateImageBuffers (pWin, nbuf, ids, action, hint) return Success; } -#ifdef PANORAMIX -static int -ProcPanoramiXCreateImageBuffers (client) - register ClientPtr client; -{ - REQUEST(xMbufCreateImageBuffersReq); - - register int result; - int i, j, k, len; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXWindow *next; - PanoramiXWindow *pPanoramiXids; - PanoramiXWindow *pPanoramiXPrev_ids; - PanoramiXPmap *local; - PanoramiXPmap *pPanoramiXPmap = PanoramiXPmapRoot; - CARD32 *value, *orig_ids; - XID *ids; - XID ID; - DrawablePtr pDrawable; - - REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq); - PANORAMIXFIND_ID(pPanoramiXWin,stuff->window); - IF_RETURN(!pPanoramiXWin, BadRequest); - len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2); - ids = (XID *)ALLOCATE_LOCAL(sizeof(XID)*len); - orig_ids = (XID *)ALLOCATE_LOCAL(sizeof(XID)*len); - if (!ids) - return BadAlloc; - memcpy((char *)orig_ids, (char *) &stuff[1], len * sizeof(XID)); - value = (CARD32 *)&stuff[1]; - /* New resources are pixmaps */ - FOR_NSCREENS_OR_ONCE(pPanoramiXWin , j) { - stuff->window = pPanoramiXWin->info[j].id; - for (i = 0; i < len; i++) { - ids[i] = (XID)orig_ids[i]; - /* These will be MultibufferDrawableResType & MultibufferResType */ - pPanoramiXPmap = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXPmap, ids[i]); - if (!pPanoramiXPmap) { - local = (PanoramiXWindow *)Xcalloc(sizeof(PanoramiXWindow)); - for (k = 0; k <= PanoramiXNumScreens - 1; k++) { - ID = k ? FakeClientID(client->index) : ids[i]; - local->info[k].id = ID; - } - local->FreeMe = FALSE; - PANORAMIXFIND_LAST(pPanoramiXPmap, PanoramiXPmapRoot); - pPanoramiXPmap->next = local; - value[i] = local->info[j].id; - }else - value[i] = pPanoramiXPmap->info[j].id; - } - if (!j) - noPanoramiXExtension = TRUE; - result = ProcCreateImageBuffers (client); - noPanoramiXExtension = FALSE; - BREAK_IF(result != Success); - } - if (result != Success) { - if (ids) - Xfree(ids); - if (orig_ids) - Xfree(orig_ids); - if (local) - Xfree(local); - } - return (result); -} -#endif -#ifdef PANORAMIX -int -#else static int -#endif ProcCreateImageBuffers (client) register ClientPtr client; { @@ -565,10 +531,7 @@ ProcCreateImageBuffers (client) swapl(&rep.length, n); swaps(&rep.numberBuffer, n); } -#ifdef PANORAMIX - if (noPanoramiXExtension) -#endif - WriteToClient(client, sizeof (xMbufCreateImageBuffersReply), (char*)&rep); + WriteToClient(client, sizeof (xMbufCreateImageBuffersReply), (char*)&rep); return (client->noClientException); } @@ -585,16 +548,6 @@ ProcDisplayImageBuffers (client) CARD32 minDelay; TimeStamp activateTime, bufferTime; -#ifdef PANORAMIX - WindowPtr pWndw; - PanoramiXPmap *pPanoramiXPmap = PanoramiXPmapRoot; - MultibufferPtr *pScrn0Multibuffer; - MultibuffersPtr *ppScrn0Multibuffers; - int k; - int panoramiX_buf = 0; - Bool FoundScreen; - -#endif REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq); nbuf = stuff->length - (sizeof (xMbufDisplayImageBuffersReq) >> 2); @@ -602,23 +555,6 @@ ProcDisplayImageBuffers (client) return Success; minDelay = stuff->minDelay; ids = (XID *) &stuff[1]; -#ifdef PANORAMIX - if (!noPanoramiXExtension) - { - int maxbuf = 0; - maxbuf = nbuf * PanoramiXNumScreens; - ppScrn0Multibuffers = (MultibuffersPtr *) xalloc(maxbuf * sizeof (MultibuffersPtr)); - pScrn0Multibuffer = (MultibufferPtr *) xalloc (maxbuf * sizeof(MultibufferPtr)); - if (!ppScrn0Multibuffers || !pScrn0Multibuffer) - { - if ( sizeof (long) != sizeof(CARD32) ) DEALLOCATE_LOCAL(ids); - xfree (ppScrn0Multibuffers); - xfree (pScrn0Multibuffer); - client->errorValue = 0; - return BadAlloc; - } - } -#endif ppMultibuffers = (MultibuffersPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibuffersPtr)); pMultibuffer = (MultibufferPtr *) ALLOCATE_LOCAL(nbuf * sizeof (MultibufferPtr)); if (!ppMultibuffers || !pMultibuffer) @@ -632,81 +568,6 @@ ProcDisplayImageBuffers (client) activateTime.milliseconds = 0; for (i = 0; i < nbuf; i++) { -#ifdef PANORAMIX - if (!noPanoramiXExtension) { - pPanoramiXPmap = PanoramiXPmapRoot; - PANORAMIXFIND_ID(pPanoramiXPmap, ids[i]); - if (!pPanoramiXPmap){ - if ( sizeof (long) != sizeof(CARD32) ) DEALLOCATE_LOCAL(ids); - xfree (ppMultibuffers); - xfree (pMultibuffer); - client->errorValue = ids[i]; - return MultibufferErrorBase + MultibufferBadBuffer; - } - FoundScreen = FALSE; - pScrn0Multibuffer[panoramiX_buf] = (MultibufferPtr) - LookupIDByType (ids[i], MultibufferResType); - ppScrn0Multibuffers[i] = pScrn0Multibuffer[i]->pMultibuffers; - pWndw = ppScrn0Multibuffers[i]->pWindow; - for (k = 0; (k < PanoramiXNumScreens && !FoundScreen); k++) { - pMultibuffer[panoramiX_buf] = (MultibufferPtr) - LookupIDByType (pPanoramiXPmap->info[k].id, MultibufferResType); - if (!pMultibuffer[i]) - { - if ( sizeof (long) != sizeof(CARD32) ) DEALLOCATE_LOCAL(ids); - xfree (ppMultibuffers); - xfree (pMultibuffer); - client->errorValue = ids[i]; - return MultibufferErrorBase + MultibufferBadBuffer; - } - ppMultibuffers[panoramiX_buf] = pMultibuffer[panoramiX_buf]->pMultibuffers; - /* Figure out where the buffer resides, which screens */ - if ( ((pWndw->drawable.x < 0) && - (pWndw->drawable.x + pWndw->drawable.width < 0)) - || ( (pWndw->drawable.x > - panoramiXdataPtr[k].x + panoramiXdataPtr[k].width) && - (pWndw->drawable.x + pWndw->drawable.width > - panoramiXdataPtr[k].x + panoramiXdataPtr[k].width))) - /* its not on screen - k -, try next screen */ - continue; - if ( ((pWndw->drawable.y < 0) && - (pWndw->drawable.y + pWndw->drawable.height < 0)) - || ( (pWndw->drawable.y > - panoramiXdataPtr[k].y + panoramiXdataPtr[k].height) && - (pWndw->drawable.y + pWndw->drawable.height > - panoramiXdataPtr[k].y + panoramiXdataPtr[k].height))) - /* its not on screen - k -, try next screen */ - continue; - - /* The window resides on screen k, which means we need to - keep the buffer information for this screen */ - panoramiX_buf++; - - /* Is it only on this screen, or does it enter onto another - screen */ - if ( ((pWndw->drawable.x + pWndw->drawable.width) <= - (panoramiXdataPtr[k].x + panoramiXdataPtr[k].width)) && - ((pWndw->drawable.y + pWndw->drawable.height) <= - (panoramiXdataPtr[k].y + - panoramiXdataPtr[k].height )) ) - FoundScreen = TRUE; - } /* for each screen k */ - for (j = 0; j < i; j++) - { - if (ppScrn0Multibuffers[i] == ppScrn0Multibuffers[j]) - { - if ( sizeof (long) != sizeof(CARD32) ) DEALLOCATE_LOCAL(ids); - DEALLOCATE_LOCAL(ppScrn0Multibuffers); - DEALLOCATE_LOCAL(pScrn0Multibuffer); - DEALLOCATE_LOCAL(ppMultibuffers); - DEALLOCATE_LOCAL(pMultibuffer); - client->errorValue = ids[i]; - return BadMatch; - } - } - bufferTime = ppScrn0Multibuffers[i]->lastUpdate; - }else { -#endif pMultibuffer[i] = (MultibufferPtr) LookupIDByType (ids[i], MultibufferResType); if (!pMultibuffer[i]) @@ -728,9 +589,6 @@ MultibufferResType); } } bufferTime = ppMultibuffers[i]->lastUpdate; -#ifdef PANORAMIX - } -#endif BumpTimeStamp (&bufferTime, minDelay); if (CompareTimeStamps (bufferTime, activateTime) == LATER) activateTime = bufferTime; @@ -742,54 +600,15 @@ MultibufferResType); ; } else -#ifdef PANORAMIX - if (!noPanoramiXExtension){ - PerformDisplayRequest (ppMultibuffers, pMultibuffer, panoramiX_buf); - }else -#endif PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf); -#ifdef PANORAMIX - if (!noPanoramiXExtension){ - DEALLOCATE_LOCAL(ppScrn0Multibuffers); - DEALLOCATE_LOCAL(pScrn0Multibuffer); - } -#endif - DEALLOCATE_LOCAL(ppMultibuffers); DEALLOCATE_LOCAL(pMultibuffer); return Success; } -#ifdef PANORAMIX -static int -ProcPanoramiXDestroyImageBuffers (client) - ClientPtr client; -{ - REQUEST (xMbufDestroyImageBuffersReq); - WindowPtr pWin; - - register int result; - int j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - - REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq); - PANORAMIXFIND_ID(pPanoramiXWin,stuff->window); - IF_RETURN(!pPanoramiXWin, BadRequest); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin , j) { - stuff->window = pPanoramiXWin->info[j].id; - result = ProcDestroyImageBuffers (client); - BREAK_IF(result != Success); - } - return (result); -} -#endif -#ifdef PANORAMIX -int -#else static int -#endif ProcDestroyImageBuffers (client) register ClientPtr client; { @@ -803,34 +622,7 @@ ProcDestroyImageBuffers (client) return Success; } -#ifdef PANORAMIX -static int -ProcPanoramiXSetMBufferAttributes (client) - ClientPtr client; -{ - REQUEST (xMbufSetMBufferAttributesReq); - WindowPtr pWin; - - register int result; - int j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - - REQUEST_SIZE_MATCH (xMbufSetMBufferAttributesReq); - PANORAMIXFIND_ID(pPanoramiXWin,stuff->window); - IF_RETURN(!pPanoramiXWin, BadRequest); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin , j) { - stuff->window = pPanoramiXWin->info[j].id; - result = ProcSetMBufferAttributes (client); - BREAK_IF(result != Success); - } - return (result); -} -#endif -#ifdef PANORAMIX -int -#else static int -#endif ProcSetMBufferAttributes (client) register ClientPtr client; { @@ -839,7 +631,7 @@ ProcSetMBufferAttributes (client) MultibuffersPtr pMultibuffers; int len; Mask vmask; - Mask index; + Mask index2; CARD32 updateHint; XID *vlist; @@ -857,9 +649,9 @@ ProcSetMBufferAttributes (client) vlist = (XID *) &stuff[1]; while (vmask) { - index = (Mask) lowbit (vmask); - vmask &= ~index; - switch (index) + index2 = (Mask) lowbit (vmask); + vmask &= ~index2; + switch (index2) { case MultibufferWindowUpdateHint: updateHint = (CARD32) *vlist; @@ -936,7 +728,7 @@ ProcSetBufferAttributes (client) REQUEST(xMbufSetBufferAttributesReq); MultibufferPtr pMultibuffer; int len; - Mask vmask, index; + Mask vmask, index2; XID *vlist; Mask eventMask; int result; @@ -952,9 +744,9 @@ ProcSetBufferAttributes (client) vlist = (XID *) &stuff[1]; while (vmask) { - index = (Mask) lowbit (vmask); - vmask &= ~index; - switch (index) + index2 = (Mask) lowbit (vmask); + vmask &= ~index2; + switch (index2) { case MultibufferBufferEventMask: eventMask = (Mask) *vlist; @@ -971,6 +763,7 @@ ProcSetBufferAttributes (client) return Success; } +int ProcGetBufferAttributes (client) register ClientPtr client; { @@ -1150,34 +943,13 @@ ProcMultibufferDispatch (client) case X_MbufGetBufferVersion: return ProcGetBufferVersion (client); case X_MbufCreateImageBuffers: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXCreateImageBuffers (client); - else - return ProcCreateImageBuffers (client); -#else return ProcCreateImageBuffers (client); -#endif case X_MbufDisplayImageBuffers: return ProcDisplayImageBuffers (client); case X_MbufDestroyImageBuffers: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXDestroyImageBuffers (client); - else - return ProcDestroyImageBuffers (client); -#else return ProcDestroyImageBuffers (client); -#endif case X_MbufSetMBufferAttributes: -#ifdef PANORAMIX - if ( !noPanoramiXExtension ) - return ProcPanoramiXSetMBufferAttributes (client); - else - return ProcSetMBufferAttributes (client); -#else return ProcSetMBufferAttributes (client); -#endif case X_MbufGetMBufferAttributes: return ProcGetMBufferAttributes (client); case X_MbufSetBufferAttributes: @@ -1447,8 +1219,6 @@ PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf) if (pExposed) { RegionPtr pWinSize; - ScreenPtr pScreen = pWin->drawable.pScreen; - extern RegionPtr CreateUnclippedWinSize(); pWinSize = CreateUnclippedWinSize (pWin); /* pExposed is window-relative, but at this point @@ -1456,13 +1226,13 @@ PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf) * window-relative so that region ops involving * pExposed and pWinSize behave sensibly. */ - REGION_TRANSLATE(pScreen, pWinSize, - -pWin->drawable.x, - -pWin->drawable.y); - REGION_INTERSECT(pScreen, pExposed, pExposed, pWinSize); - REGION_DESTROY(pScreen, pWinSize); + REGION_TRANSLATE(pWin->drawable.pScreen, pWinSize, + -pWin->drawable.x, -pWin->drawable.y); + REGION_INTERSECT(pWin->drawable.pScreen, pExposed, + pExposed, pWinSize); + REGION_DESTROY(pWin->drawable.pScreen, pWinSize); MultibufferExpose (pPrevMultibuffer, pExposed); - REGION_DESTROY(pScreen, pExposed); + REGION_DESTROY(pWin->drawable.pScreen, pExposed); } graphicsExpose = FALSE; DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE); @@ -1590,8 +1360,8 @@ DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter) return 0; /* maybe send event to owner */ - if (attempt = TryClientEvents( - bClient(pMultibuffer), pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) + if ((attempt = TryClientEvents( + bClient(pMultibuffer), pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0) { if (attempt > 0) deliveries++; @@ -1602,8 +1372,8 @@ DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter) /* maybe send event to other clients */ for (other = pMultibuffer->otherClients; other; other=other->next) { - if (attempt = TryClientEvents( - rClient(other), pEvents, count, other->mask, filter, (GrabPtr) 0)) + if ((attempt = TryClientEvents( + rClient(other), pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0) { if (attempt > 0) deliveries++; @@ -1664,15 +1434,15 @@ MultibufferExpose (pMultibuffer, pRegion) /* send UpdateNotify event */ void -MultibufferUpdate (pMultibuffer, time) +MultibufferUpdate (pMultibuffer, time2) MultibufferPtr pMultibuffer; - CARD32 time; + CARD32 time2; { xMbufUpdateNotifyEvent event; event.type = MultibufferEventBase + MultibufferUpdateNotify; event.buffer = pMultibuffer->pPixmap->drawable.id; - event.timeStamp = time; + event.timeStamp = time2; (void) DeliverEventsToMultibuffer (pMultibuffer, (xEvent *)&event, 1, (Mask)MultibufferUpdateNotifyMask); } diff --git a/Xext/mbufbf.c b/Xext/mbufbf.c index 3c873086f..925745712 100644 --- a/Xext/mbufbf.c +++ b/Xext/mbufbf.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/Xext/mbufbf.c,v 3.4 2001/12/14 19:58:49 dawes Exp $ */ /* Copyright 1989, 1998 The Open Group diff --git a/Xext/mbufpx.c b/Xext/mbufpx.c index 9474cc9aa..9c531c292 100644 --- a/Xext/mbufpx.c +++ b/Xext/mbufpx.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/Xext/mbufpx.c,v 3.4 2001/12/14 19:58:49 dawes Exp $ */ /************************************************************ Copyright 1989, 1998 The Open Group diff --git a/Xext/mitmisc.c b/Xext/mitmisc.c index 63e496209..b6038edba 100644 --- a/Xext/mitmisc.c +++ b/Xext/mitmisc.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/Xext/mitmisc.c,v 3.4 2001/12/14 19:58:49 dawes Exp $ */ /************************************************************ Copyright 1989, 1998 The Open Group @@ -28,6 +29,7 @@ in this Software without prior written authorization from The Open Group. /* $Xorg: mitmisc.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */ +#define NEED_EVENTS #include "X.h" #include "Xproto.h" #include "misc.h" @@ -40,17 +42,28 @@ in this Software without prior written authorization from The Open Group. extern Bool permitOldBugs; static unsigned char MITReqCode; -static int ProcMITDispatch(), SProcMITDispatch(); -static void MITResetProc(); + +static void MITResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif +); + +static DISPATCH_PROC(ProcMITDispatch); +static DISPATCH_PROC(ProcMITGetBugMode); +static DISPATCH_PROC(ProcMITSetBugMode); +static DISPATCH_PROC(SProcMITDispatch); +static DISPATCH_PROC(SProcMITGetBugMode); +static DISPATCH_PROC(SProcMITSetBugMode); void MITMiscExtensionInit() { - ExtensionEntry *extEntry, *AddExtension(); + ExtensionEntry *extEntry; - if (extEntry = AddExtension(MITMISCNAME, 0, 0, + if ((extEntry = AddExtension(MITMISCNAME, 0, 0, ProcMITDispatch, SProcMITDispatch, - MITResetProc, StandardMinorOpcode)) + MITResetProc, StandardMinorOpcode)) != 0) MITReqCode = (unsigned char)extEntry->base; } @@ -81,7 +94,6 @@ static int ProcMITGetBugMode(client) register ClientPtr client; { - REQUEST(xMITGetBugModeReq); xMITGetBugModeReply rep; register int n; diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 2d3eb7c42..fb0b9c541 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -23,11 +23,13 @@ shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ +/* $XFree86: xc/programs/Xserver/Xext/panoramiX.c,v 3.32 2002/08/01 00:30:34 mvojkovi Exp $ */ #define NEED_REPLIES #include <stdio.h> #include "X.h" #include "Xproto.h" +#include "Xarch.h" #include "misc.h" #include "cursor.h" #include "cursorstr.h" @@ -39,32 +41,44 @@ Equipment Corporation. #include "window.h" #include "windowstr.h" #include "pixmapstr.h" -#if 0 -#include <sys/workstation.h> -#include <X11/Xserver/ws.h> -#endif #include "panoramiX.h" #include "panoramiXproto.h" +#include "panoramiXsrv.h" +#include "globals.h" +#include "servermd.h" +#include "resource.h" +#ifdef RENDER +#include "picturestr.h" +#endif + static unsigned char PanoramiXReqCode = 0; /* * PanoramiX data declarations */ -int PanoramiXPixWidth; -int PanoramiXPixHeight; -int PanoramiXNumScreens; +int PanoramiXPixWidth = 0; +int PanoramiXPixHeight = 0; +int PanoramiXNumScreens = 0; + +PanoramiXData *panoramiXdataPtr = NULL; -PanoramiXData *panoramiXdataPtr; -PanoramiXWindow *PanoramiXWinRoot; -PanoramiXGC *PanoramiXGCRoot; -PanoramiXCmap *PanoramiXCmapRoot; -PanoramiXPmap *PanoramiXPmapRoot; -PanoramiXEdge panoramiXEdgePtr[MAXSCREENS]; -RegionRec PanoramiXScreenRegion[MAXSCREENS]; -PanoramiXCDT PanoramiXColorDepthTable[MAXSCREENS]; -PanoramiXDepth PanoramiXLargestScreenDepth; +RegionRec PanoramiXScreenRegion; + +int PanoramiXNumDepths; +DepthPtr PanoramiXDepths; +int PanoramiXNumVisuals; +VisualPtr PanoramiXVisuals; +/* We support at most 256 visuals */ +XID *PanoramiXVisualTable = NULL; + +unsigned long XRC_DRAWABLE; +unsigned long XRT_WINDOW; +unsigned long XRT_PIXMAP; +unsigned long XRT_GC; +unsigned long XRT_COLORMAP; + int (* SavedProcVector[256]) (); ScreenInfo *GlobalScrInfo; @@ -75,7 +89,6 @@ static int ProcPanoramiXDispatch(); * Function prototypes */ -static void locate_neighbors(int); static void PanoramiXResetProc(ExtensionEntry*); /* @@ -83,16 +96,9 @@ static void PanoramiXResetProc(ExtensionEntry*); */ extern int SProcPanoramiXDispatch(); -extern Bool noPanoramiXExtension; -extern Bool PanoramiXVisibilityNotifySent; -extern WindowPtr *WindowTable; -#if 0 -extern ScreenArgsRec screenArgs[MAXSCREENS]; -#endif -extern int defaultBackingStore; extern char *ConnectionInfo; extern int connBlockScreenStart; -extern int (* ProcVector[256]) (); +extern xConnSetupPrefix connSetupPrefix; /* * Server dispatcher function replacements @@ -104,11 +110,10 @@ int PanoramiXChangeSaveSet(), PanoramiXReparentWindow(); int PanoramiXMapWindow(), PanoramiXMapSubwindows(); int PanoramiXUnmapWindow(), PanoramiXUnmapSubwindows(); int PanoramiXConfigureWindow(), PanoramiXCirculateWindow(); -int PanoramiXGetGeometry(), PanoramiXChangeProperty(); -int PanoramiXDeleteProperty(), PanoramiXSendEvent(); +int PanoramiXGetGeometry(), PanoramiXTranslateCoords(); int PanoramiXCreatePixmap(), PanoramiXFreePixmap(); int PanoramiXCreateGC(), PanoramiXChangeGC(); -int PanoramiXCopyGC(); +int PanoramiXCopyGC(), PanoramiXCopyColormapAndFree(); int PanoramiXSetDashes(), PanoramiXSetClipRectangles(); int PanoramiXFreeGC(), PanoramiXClearToBackground(); int PanoramiXCopyArea(), PanoramiXCopyPlane(); @@ -122,8 +127,326 @@ int PanoramiXImageText8(), PanoramiXImageText16(); int PanoramiXCreateColormap(), PanoramiXFreeColormap(); int PanoramiXInstallColormap(), PanoramiXUninstallColormap(); int PanoramiXAllocColor(), PanoramiXAllocNamedColor(); -int PanoramiXAllocColorCells(); +int PanoramiXAllocColorCells(), PanoramiXStoreNamedColor(); int PanoramiXFreeColors(), PanoramiXStoreColors(); +int PanoramiXAllocColorPlanes(); + +static int PanoramiXGCIndex = -1; +static int PanoramiXScreenIndex = -1; + +typedef struct { + DDXPointRec clipOrg; + DDXPointRec patOrg; + GCFuncs *wrapFuncs; +} PanoramiXGCRec, *PanoramiXGCPtr; + +typedef struct { + CreateGCProcPtr CreateGC; + CloseScreenProcPtr CloseScreen; +} PanoramiXScreenRec, *PanoramiXScreenPtr; + +RegionRec XineramaScreenRegions[MAXSCREENS]; + +static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr); +static void XineramaChangeGC(GCPtr, unsigned long); +static void XineramaCopyGC(GCPtr, unsigned long, GCPtr); +static void XineramaDestroyGC(GCPtr); +static void XineramaChangeClip(GCPtr, int, pointer, int); +static void XineramaDestroyClip(GCPtr); +static void XineramaCopyClip(GCPtr, GCPtr); + +GCFuncs XineramaGCFuncs = { + XineramaValidateGC, XineramaChangeGC, XineramaCopyGC, XineramaDestroyGC, + XineramaChangeClip, XineramaDestroyClip, XineramaCopyClip +}; + +#define Xinerama_GC_FUNC_PROLOGUE(pGC)\ + PanoramiXGCPtr pGCPriv = \ + (PanoramiXGCPtr) (pGC)->devPrivates[PanoramiXGCIndex].ptr;\ + (pGC)->funcs = pGCPriv->wrapFuncs; + +#define Xinerama_GC_FUNC_EPILOGUE(pGC)\ + pGCPriv->wrapFuncs = (pGC)->funcs;\ + (pGC)->funcs = &XineramaGCFuncs; + + +static Bool +XineramaCloseScreen (int i, ScreenPtr pScreen) +{ + PanoramiXScreenPtr pScreenPriv = + (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr; + + pScreen->CloseScreen = pScreenPriv->CloseScreen; + pScreen->CreateGC = pScreenPriv->CreateGC; + + REGION_UNINIT(pScreen, &XineramaScreenRegions[pScreen->myNum]); + if (pScreen->myNum == 0) + REGION_UNINIT(pScreen, &PanoramiXScreenRegion); + + xfree ((pointer) pScreenPriv); + + return (*pScreen->CloseScreen) (i, pScreen); +} + +Bool +XineramaCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + PanoramiXScreenPtr pScreenPriv = + (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr; + Bool ret; + + pScreen->CreateGC = pScreenPriv->CreateGC; + if((ret = (*pScreen->CreateGC)(pGC))) { + PanoramiXGCPtr pGCPriv = + (PanoramiXGCPtr) pGC->devPrivates[PanoramiXGCIndex].ptr; + + pGCPriv->wrapFuncs = pGC->funcs; + pGC->funcs = &XineramaGCFuncs; + + pGCPriv->clipOrg.x = pGC->clipOrg.x; + pGCPriv->clipOrg.y = pGC->clipOrg.y; + pGCPriv->patOrg.x = pGC->patOrg.x; + pGCPriv->patOrg.y = pGC->patOrg.y; + } + pScreen->CreateGC = XineramaCreateGC; + + return ret; +} + +static void +XineramaValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + Xinerama_GC_FUNC_PROLOGUE (pGC); + + if((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr)pDraw)->parent)) { + /* the root window */ + int x_off = panoramiXdataPtr[pGC->pScreen->myNum].x; + int y_off = panoramiXdataPtr[pGC->pScreen->myNum].y; + int new_val; + + new_val = pGCPriv->clipOrg.x - x_off; + if(pGC->clipOrg.x != new_val) { + pGC->clipOrg.x = new_val; + changes |= GCClipXOrigin; + } + new_val = pGCPriv->clipOrg.y - y_off; + if(pGC->clipOrg.y != new_val) { + pGC->clipOrg.y = new_val; + changes |= GCClipYOrigin; + } + new_val = pGCPriv->patOrg.x - x_off; + if(pGC->patOrg.x != new_val) { + pGC->patOrg.x = new_val; + changes |= GCTileStipXOrigin; + } + new_val = pGCPriv->patOrg.y - y_off; + if(pGC->patOrg.y != new_val) { + pGC->patOrg.y = new_val; + changes |= GCTileStipYOrigin; + } + } else { + if(pGC->clipOrg.x != pGCPriv->clipOrg.x) { + pGC->clipOrg.x = pGCPriv->clipOrg.x; + changes |= GCClipXOrigin; + } + if(pGC->clipOrg.y != pGCPriv->clipOrg.y) { + pGC->clipOrg.y = pGCPriv->clipOrg.y; + changes |= GCClipYOrigin; + } + if(pGC->patOrg.x != pGCPriv->patOrg.x) { + pGC->patOrg.x = pGCPriv->patOrg.x; + changes |= GCTileStipXOrigin; + } + if(pGC->patOrg.y != pGCPriv->patOrg.y) { + pGC->patOrg.y = pGCPriv->patOrg.y; + changes |= GCTileStipYOrigin; + } + } + + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + Xinerama_GC_FUNC_EPILOGUE (pGC); +} + +static void +XineramaDestroyGC(GCPtr pGC) +{ + Xinerama_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->DestroyGC)(pGC); + Xinerama_GC_FUNC_EPILOGUE (pGC); +} + +static void +XineramaChangeGC ( + GCPtr pGC, + unsigned long mask +){ + Xinerama_GC_FUNC_PROLOGUE (pGC); + + if(mask & GCTileStipXOrigin) + pGCPriv->patOrg.x = pGC->patOrg.x; + if(mask & GCTileStipYOrigin) + pGCPriv->patOrg.y = pGC->patOrg.y; + if(mask & GCClipXOrigin) + pGCPriv->clipOrg.x = pGC->clipOrg.x; + if(mask & GCClipYOrigin) + pGCPriv->clipOrg.y = pGC->clipOrg.y; + + (*pGC->funcs->ChangeGC) (pGC, mask); + Xinerama_GC_FUNC_EPILOGUE (pGC); +} + +static void +XineramaCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst +){ + PanoramiXGCPtr pSrcPriv = + (PanoramiXGCPtr) pGCSrc->devPrivates[PanoramiXGCIndex].ptr; + Xinerama_GC_FUNC_PROLOGUE (pGCDst); + + if(mask & GCTileStipXOrigin) + pGCPriv->patOrg.x = pSrcPriv->patOrg.x; + if(mask & GCTileStipYOrigin) + pGCPriv->patOrg.y = pSrcPriv->patOrg.y; + if(mask & GCClipXOrigin) + pGCPriv->clipOrg.x = pSrcPriv->clipOrg.x; + if(mask & GCClipYOrigin) + pGCPriv->clipOrg.y = pSrcPriv->clipOrg.y; + + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + Xinerama_GC_FUNC_EPILOGUE (pGCDst); +} + +static void +XineramaChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects +){ + Xinerama_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + Xinerama_GC_FUNC_EPILOGUE (pGC); +} + +static void +XineramaCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + Xinerama_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + Xinerama_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +XineramaDestroyClip(GCPtr pGC) +{ + Xinerama_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + Xinerama_GC_FUNC_EPILOGUE (pGC); +} + + + +int +XineramaDeleteResource(pointer data, XID id) +{ + xfree(data); + return 1; +} + + +static Bool +XineramaFindIDOnAnyScreen(pointer resource, XID id, pointer privdata) +{ + PanoramiXRes *res = (PanoramiXRes*)resource; + int j; + + FOR_NSCREENS(j) + if(res->info[j].id == *((XID*)privdata)) return TRUE; + + return FALSE; +} + +PanoramiXRes * +PanoramiXFindIDOnAnyScreen(RESTYPE type, XID id) +{ + return LookupClientResourceComplex(clients[CLIENT_ID(id)], type, + XineramaFindIDOnAnyScreen, &id); +} + +typedef struct { + int screen; + int id; +} PanoramiXSearchData; + + +static Bool +XineramaFindIDByScrnum(pointer resource, XID id, pointer privdata) +{ + PanoramiXRes *res = (PanoramiXRes*)resource; + PanoramiXSearchData *data = (PanoramiXSearchData*)privdata; + + return (res->info[data->screen].id == data->id); +} + +PanoramiXRes * +PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen) +{ + PanoramiXSearchData data; + + if(!screen) + return LookupIDByType(id, type); + + data.screen = screen; + data.id = id; + + return LookupClientResourceComplex(clients[CLIENT_ID(id)], type, + XineramaFindIDByScrnum, &data); +} + +WindowPtr +PanoramiXChangeWindow(int ScrnNum, WindowPtr pWin) +{ + int num = pWin->drawable.pScreen->myNum; + + if(num != ScrnNum) { + PanoramiXRes *win; + + win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, num); + + if (win) + pWin = (WindowPtr) LookupIDByType(win->info[ScrnNum].id, RT_WINDOW); + } + + return pWin; +} + +typedef struct _connect_callback_list { + void (*func)(void); + struct _connect_callback_list *next; +} XineramaConnectionCallbackList; + +static XineramaConnectionCallbackList *ConnectionCallbackList = NULL; + +Bool +XineramaRegisterConnectionBlockCallback(void (*func)(void)) +{ + XineramaConnectionCallbackList *newlist; + + if(!(newlist = xalloc(sizeof(XineramaConnectionCallbackList)))) + return FALSE; + + newlist->next = ConnectionCallbackList; + newlist->func = func; + ConnectionCallbackList = newlist; + + return TRUE; +} /* * PanoramiXExtensionInit(): @@ -134,14 +457,16 @@ int PanoramiXFreeColors(), PanoramiXStoreColors(); void PanoramiXExtensionInit(int argc, char *argv[]) { - int i, j, PhyScrNum, ArgScrNum; - Bool success = FALSE; - ExtensionEntry *extEntry, *AddExtension(); - PanoramiXData *panoramiXtempPtr; - ScreenPtr pScreen; + int i; + Bool success = FALSE; + ExtensionEntry *extEntry; + ScreenPtr pScreen; + PanoramiXScreenPtr pScreenPriv; + int w, h; - if (!noPanoramiXExtension) - { + if (noPanoramiXExtension) + return; + GlobalScrInfo = &screenInfo; /* For debug visibility */ PanoramiXNumScreens = screenInfo.numScreens; if (PanoramiXNumScreens == 1) { /* Only 1 screen */ @@ -165,13 +490,43 @@ void PanoramiXExtensionInit(int argc, char *argv[]) * run in non-PanoramiXeen mode. */ - panoramiXdataPtr = (PanoramiXData *) Xcalloc(PanoramiXNumScreens * sizeof(PanoramiXData)); - PanoramiXWinRoot = (PanoramiXWindow *) Xcalloc(sizeof(PanoramiXWindow)); - PanoramiXGCRoot = (PanoramiXGC *) Xcalloc(sizeof(PanoramiXGC)); - PanoramiXCmapRoot = (PanoramiXCmap *) Xcalloc(sizeof(PanoramiXCmap)); - PanoramiXPmapRoot = (PanoramiXPmap *) Xcalloc(sizeof(PanoramiXPmap)); - BREAK_IF(!(panoramiXdataPtr && PanoramiXWinRoot && PanoramiXGCRoot && - PanoramiXCmapRoot && PanoramiXPmapRoot)); + panoramiXdataPtr = (PanoramiXData *) + xcalloc(PanoramiXNumScreens, sizeof(PanoramiXData)); + + BREAK_IF(!panoramiXdataPtr); + BREAK_IF((PanoramiXGCIndex = AllocateGCPrivateIndex()) < 0); + BREAK_IF((PanoramiXScreenIndex = AllocateScreenPrivateIndex()) < 0); + + for (i = 0; i < PanoramiXNumScreens; i++) { + pScreen = screenInfo.screens[i]; + if(!AllocateGCPrivate(pScreen, PanoramiXGCIndex, + sizeof(PanoramiXGCRec))) { + noPanoramiXExtension = TRUE; + return; + } + + pScreenPriv = xalloc(sizeof(PanoramiXScreenRec)); + pScreen->devPrivates[PanoramiXScreenIndex].ptr = + (pointer)pScreenPriv; + if(!pScreenPriv) { + noPanoramiXExtension = TRUE; + return; + } + + pScreenPriv->CreateGC = pScreen->CreateGC; + pScreenPriv->CloseScreen = pScreen->CloseScreen; + + pScreen->CreateGC = XineramaCreateGC; + pScreen->CloseScreen = XineramaCloseScreen; + } + + XRC_DRAWABLE = CreateNewResourceClass(); + XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource) | + XRC_DRAWABLE; + XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource) | + XRC_DRAWABLE; + XRT_GC = CreateNewResourceType(XineramaDeleteResource); + XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource); panoramiXGeneration = serverGeneration; success = TRUE; @@ -182,117 +537,40 @@ void PanoramiXExtensionInit(int argc, char *argv[]) ErrorF("%s Extension failed to initialize\n", PANORAMIX_PROTOCOL_NAME); return; } - - /* Set up a default configuration base on horizontal ordering */ - for (i = PanoramiXNumScreens -1; i >= 0 ; i--) { - panoramiXdataPtr[i].above = panoramiXdataPtr[i].below = -1; - panoramiXdataPtr[i].left = panoramiXdataPtr[i].right = -1; - panoramiXEdgePtr[i].no_edges = TRUE; - } - for (i = PanoramiXNumScreens - 1; i >= 0; i--) { - panoramiXdataPtr[i].left = i - 1; - panoramiXdataPtr[i].right = i + 1; - } - panoramiXdataPtr[PanoramiXNumScreens - 1].right = -1; + - /* - * Position the screens relative to each other based on - * command line options. - */ + REGION_INIT(pScreen, &PanoramiXScreenRegion, NullBox, 1); + for (i = 0; i < PanoramiXNumScreens; i++) { + BoxRec TheBox; -#if 0 - for (PhyScrNum = PanoramiXNumScreens - 1; PhyScrNum >= 0; PhyScrNum--) { - if (wsRemapPhysToLogScreens) - i = wsPhysToLogScreens[PhyScrNum]; - else - i = PhyScrNum; - if (i < 0) - continue; - panoramiXdataPtr[i].width = (screenInfo.screens[i])->width; - panoramiXdataPtr[i].height = (screenInfo.screens[i])->height; - if (screenArgs[i].flags & ARG_EDGE_L) { - ArgScrNum = screenArgs[PhyScrNum].edge_left; - if (ArgScrNum < 0) - j = -1; - else { - if (wsRemapPhysToLogScreens) - j = wsPhysToLogScreens[ArgScrNum]; - else - j = ArgScrNum; - } - panoramiXdataPtr[i].left = j; - panoramiXEdgePtr[i].no_edges = FALSE; - if ( j >= 0) - panoramiXdataPtr[j].right = i; - else { - if ( i >= 1 ) - panoramiXdataPtr[i - 1].right = -1; - } - } - if (screenArgs[i].flags & ARG_EDGE_R) { - ArgScrNum = screenArgs[PhyScrNum].edge_right; - if (ArgScrNum < 0) - j = -1; - else { - if (wsRemapPhysToLogScreens) - j = wsPhysToLogScreens[ArgScrNum]; - else - j = ArgScrNum; - } - panoramiXdataPtr[i].right = j; - panoramiXEdgePtr[i].no_edges = FALSE; - if ( j >= 0) - panoramiXdataPtr[j].left = i; - } - if (screenArgs[i].flags & ARG_EDGE_T) { - ArgScrNum = screenArgs[PhyScrNum].edge_top; - if (ArgScrNum < 0) - j = -1; - else { - if (wsRemapPhysToLogScreens) - j = wsPhysToLogScreens[ArgScrNum]; - else - j = ArgScrNum; - } - panoramiXdataPtr[i].above = j; - panoramiXEdgePtr[i].no_edges = FALSE; - if ( j >= 0) - panoramiXdataPtr[j].below = i; - } - if (screenArgs[i].flags & ARG_EDGE_B) { - ArgScrNum = screenArgs[PhyScrNum].edge_bottom; - if (ArgScrNum < 0) - j = -1; - else { - if (wsRemapPhysToLogScreens) - j = wsPhysToLogScreens[ArgScrNum]; - else - j = ArgScrNum; - } - panoramiXdataPtr[i].below = j; - panoramiXEdgePtr[i].no_edges = FALSE; - if ( j >= 0) - panoramiXdataPtr[j].above = i; - } - } -#else - for (PhyScrNum = PanoramiXNumScreens - 1; PhyScrNum >= 0; PhyScrNum--) { - i = PhyScrNum; - if (i < 0) - continue; + panoramiXdataPtr[i].x = dixScreenOrigins[i].x; + panoramiXdataPtr[i].y = dixScreenOrigins[i].y; panoramiXdataPtr[i].width = (screenInfo.screens[i])->width; panoramiXdataPtr[i].height = (screenInfo.screens[i])->height; + + TheBox.x1 = panoramiXdataPtr[i].x; + TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width; + TheBox.y1 = panoramiXdataPtr[i].y; + TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height; + + REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1); + REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion, + &XineramaScreenRegions[i]); } -#endif - /* - * Find the upper-left screen and then locate all the others - */ - panoramiXtempPtr = panoramiXdataPtr; - for (i = PanoramiXNumScreens; i; i--, panoramiXtempPtr++) - if (panoramiXtempPtr->above == -1 && panoramiXtempPtr->left == -1) - break; - locate_neighbors(PanoramiXNumScreens - i); + + PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width; + PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height; + + for (i = 1; i < PanoramiXNumScreens; i++) { + w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width; + h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height; + + if(PanoramiXPixWidth < w) + PanoramiXPixWidth = w; + if(PanoramiXPixHeight < h) + PanoramiXPixHeight = h; + } /* * Put our processes into the ProcVector @@ -314,9 +592,7 @@ void PanoramiXExtensionInit(int argc, char *argv[]) ProcVector[X_ConfigureWindow] = PanoramiXConfigureWindow; ProcVector[X_CirculateWindow] = PanoramiXCirculateWindow; ProcVector[X_GetGeometry] = PanoramiXGetGeometry; - ProcVector[X_ChangeProperty] = PanoramiXChangeProperty; - ProcVector[X_DeleteProperty] = PanoramiXDeleteProperty; - ProcVector[X_SendEvent] = PanoramiXSendEvent; + ProcVector[X_TranslateCoords] = PanoramiXTranslateCoords; ProcVector[X_CreatePixmap] = PanoramiXCreatePixmap; ProcVector[X_FreePixmap] = PanoramiXFreePixmap; ProcVector[X_CreateGC] = PanoramiXCreateGC; @@ -344,252 +620,262 @@ void PanoramiXExtensionInit(int argc, char *argv[]) ProcVector[X_ImageText16] = PanoramiXImageText16; ProcVector[X_CreateColormap] = PanoramiXCreateColormap; ProcVector[X_FreeColormap] = PanoramiXFreeColormap; + ProcVector[X_CopyColormapAndFree] = PanoramiXCopyColormapAndFree; ProcVector[X_InstallColormap] = PanoramiXInstallColormap; ProcVector[X_UninstallColormap] = PanoramiXUninstallColormap; ProcVector[X_AllocColor] = PanoramiXAllocColor; ProcVector[X_AllocNamedColor] = PanoramiXAllocNamedColor; ProcVector[X_AllocColorCells] = PanoramiXAllocColorCells; + ProcVector[X_AllocColorPlanes] = PanoramiXAllocColorPlanes; ProcVector[X_FreeColors] = PanoramiXFreeColors; - ProcVector[X_StoreColors] = PanoramiXStoreColors; + ProcVector[X_StoreColors] = PanoramiXStoreColors; + ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor; - } - else - return; +#ifdef RENDER + PanoramiXRenderInit (); +#endif } -extern + +extern Bool CreateConnectionBlock(void); + Bool PanoramiXCreateConnectionBlock(void) { - int i; + int i, j, length; + Bool disableBackingStore = FALSE; + Bool disableSaveUnders = FALSE; int old_width, old_height; - int width_mult, height_mult; + float width_mult, height_mult; xWindowRoot *root; xConnSetup *setup; + xVisualType *visual; + xDepth *depth; + VisualPtr pVisual; + ScreenPtr pScreen; /* * Do normal CreateConnectionBlock but faking it for only one screen */ + if(!PanoramiXNumDepths) { + ErrorF("PanoramiX error: Incompatible screens. No common visuals\n"); + return FALSE; + } + + for(i = 1; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + if(pScreen->rootDepth != screenInfo.screens[0]->rootDepth) { + ErrorF("PanoramiX error: Incompatible screens. Root window depths differ\n"); + return FALSE; + } + if(pScreen->backingStoreSupport != screenInfo.screens[0]->backingStoreSupport) + disableBackingStore = TRUE; + if(pScreen->saveUnderSupport != screenInfo.screens[0]->saveUnderSupport) + disableSaveUnders = TRUE; + } + + if(disableBackingStore || disableSaveUnders) { + for(i = 0; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + if(disableBackingStore) + pScreen->backingStoreSupport = NotUseful; + if(disableSaveUnders) + pScreen->saveUnderSupport = NotUseful; + } + } + + i = screenInfo.numScreens; + screenInfo.numScreens = 1; if (!CreateConnectionBlock()) { + screenInfo.numScreens = i; return FALSE; } + screenInfo.numScreens = i; + + setup = (xConnSetup *) ConnectionInfo; + root = (xWindowRoot *) (ConnectionInfo + connBlockScreenStart); + length = connBlockScreenStart + sizeof(xWindowRoot); + + /* overwrite the connection block */ + root->nDepths = PanoramiXNumDepths; + + for (i = 0; i < PanoramiXNumDepths; i++) { + depth = (xDepth *) (ConnectionInfo + length); + depth->depth = PanoramiXDepths[i].depth; + depth->nVisuals = PanoramiXDepths[i].numVids; + length += sizeof(xDepth); + visual = (xVisualType *)(ConnectionInfo + length); + + for (j = 0; j < depth->nVisuals; j++, visual++) { + visual->visualID = PanoramiXDepths[i].vids[j]; + + for (pVisual = PanoramiXVisuals; + pVisual->vid != visual->visualID; + pVisual++) + ; + + visual->class = pVisual->class; + visual->bitsPerRGB = pVisual->bitsPerRGBValue; + visual->colormapEntries = pVisual->ColormapEntries; + visual->redMask = pVisual->redMask; + visual->greenMask = pVisual->greenMask; + visual->blueMask = pVisual->blueMask; + } + + length += (depth->nVisuals * sizeof(xVisualType)); + } + + connSetupPrefix.length = length >> 2; + + xfree(PanoramiXVisuals); + for (i = 0; i < PanoramiXNumDepths; i++) + xfree(PanoramiXDepths[i].vids); + xfree(PanoramiXDepths); + /* * OK, change some dimensions so it looks as if it were one big screen */ - - setup = (xConnSetup *) ConnectionInfo; - setup->numRoots = 1; - root = (xWindowRoot *) (ConnectionInfo + connBlockScreenStart); old_width = root->pixWidth; old_height = root->pixHeight; - for (i = PanoramiXNumScreens - 1; i >= 0; i--) { - if (panoramiXdataPtr[i].right == -1 ) - root->pixWidth = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width; - if (panoramiXdataPtr[i].below == -1) - root->pixHeight = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height; - } - PanoramiXPixWidth = root->pixWidth; - PanoramiXPixHeight = root->pixHeight; - width_mult = root->pixWidth / old_width; - height_mult = root->pixHeight / old_height; + + root->pixWidth = PanoramiXPixWidth; + root->pixHeight = PanoramiXPixHeight; + width_mult = (1.0 * root->pixWidth) / old_width; + height_mult = (1.0 * root->pixHeight) / old_height; root->mmWidth *= width_mult; root->mmHeight *= height_mult; - return TRUE; -} -extern -Bool PanoramiXCreateScreenRegion(pWin) -WindowPtr pWin; -{ - ScreenPtr pScreen; - BoxRec box; - int i; - Bool ret; - - pScreen = pWin->drawable.pScreen; - for (i = 0; i < PanoramiXNumScreens; i++) { - box.x1 = 0 - panoramiXdataPtr[i].x; - box.x2 = box.x1 + PanoramiXPixWidth; - box.y1 = 0 - panoramiXdataPtr[i].y; - box.y2 = box.y1 + PanoramiXPixHeight; - REGION_INIT(pScreen, &PanoramiXScreenRegion[i], &box, 1); - ret = REGION_NOTEMPTY(pScreen, &PanoramiXScreenRegion[i]); - if (!ret) - return ret; - } - return ret; -} + while(ConnectionCallbackList) { + pointer tmp; -extern -void PanoramiXDestroyScreenRegion(pWin) -WindowPtr pWin; -{ - ScreenPtr pScreen; - int i; - Bool ret; + tmp = (pointer)ConnectionCallbackList; + (*ConnectionCallbackList->func)(); + ConnectionCallbackList = ConnectionCallbackList->next; + xfree(tmp); + } - pScreen = pWin->drawable.pScreen; - for (i = 0; i < PanoramiXNumScreens; i++) - REGION_DESTROY(pScreen, &PanoramiXScreenRegion[i]); + return TRUE; } -/* - * Assign the Root window and colormap ID's in the PanoramiXScreen Root - * linked lists. Note: WindowTable gets setup in dix_main by - * InitRootWindow, and GlobalScrInfo is screenInfo which gets setup - * by InitOutput. - */ extern void PanoramiXConsolidate(void) { - int i,j,k,v,d,n, thisMaxDepth; - int depthIndex; - DepthPtr pDepth, pLargeDepth; - VisualPtr pVisual; - VisualID it; - register WindowPtr pWin, pLargeWin; - Bool SameDepth; - - PanoramiXLargestScreenDepth.numDepths = (screenInfo.screens[PanoramiXNumScreens -1])->numDepths; - PanoramiXLargestScreenDepth.screenNum = PanoramiXNumScreens - 1; - SameDepth = TRUE; - for (i = 0; i < 2; i++) - { - for (j =0; j < 6; j++) - { - PanoramiXColorDepthTable[i].panoramiXScreenMap[j].numDepths=0; - for (n = 0; n < 6; n++) - { - PanoramiXColorDepthTable[i].panoramiXScreenMap[j].listDepths[n]=0; + int i, j, k; + VisualPtr pVisual, pVisual2; + ScreenPtr pScreen, pScreen2; + PanoramiXRes *root, *defmap; + + if(!PanoramiXVisualTable) + PanoramiXVisualTable = xcalloc(256 * MAXSCREENS, sizeof(XID)); + + pScreen = screenInfo.screens[0]; + pVisual = pScreen->visuals; + + PanoramiXNumDepths = 0; + PanoramiXDepths = xcalloc(pScreen->numDepths,sizeof(DepthRec)); + PanoramiXNumVisuals = 0; + PanoramiXVisuals = xcalloc(pScreen->numVisuals,sizeof(VisualRec)); + + for (i = 0; i < pScreen->numVisuals; i++, pVisual++) { + PanoramiXVisualTable[pVisual->vid * MAXSCREENS] = pVisual->vid; + + /* check if the visual exists on all screens */ + for (j = 1; j < PanoramiXNumScreens; j++) { + pScreen2 = screenInfo.screens[j]; + pVisual2 = pScreen2->visuals; + + for (k = 0; k < pScreen2->numVisuals; k++, pVisual2++) { + if ((pVisual->class == pVisual2->class) && + (pVisual->ColormapEntries == pVisual2->ColormapEntries) && + (pVisual->nplanes == pVisual2->nplanes) && + (pVisual->redMask == pVisual2->redMask) && + (pVisual->greenMask == pVisual2->greenMask) && + (pVisual->blueMask == pVisual2->blueMask) && + (pVisual->offsetRed == pVisual2->offsetRed) && + (pVisual->offsetGreen == pVisual2->offsetGreen) && + (pVisual->offsetBlue == pVisual2->offsetBlue)) + { + Bool AlreadyUsed = FALSE; +#if 0 +/* Open GL should do this reduction, not us */ + for (l = 0; l < 256; l++) { + if (pVisual2->vid == + PanoramiXVisualTable[(l * MAXSCREENS) + j]) + { + AlreadyUsed = TRUE; + break; + } + } +#endif + if (!AlreadyUsed) { + PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] = + pVisual2->vid; + break; + } + } + } } - for (k = 0; k < 33; k++) - { - PanoramiXColorDepthTable[i].panoramiXScreenMap[j].vmap[k].numVids=0; - for (v = 0; v < 10; v++) - { - PanoramiXColorDepthTable[i].panoramiXScreenMap[j].vmap[k].vid[v]=0; + + /* if it doesn't exist on all screens we can't use it */ + for (j = 0; j < PanoramiXNumScreens; j++) { + if (!PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j]) { + PanoramiXVisualTable[pVisual->vid * MAXSCREENS] = 0; + break; } } - } - } - for (i = PanoramiXNumScreens - 1; i >= 0; i--) - { - PanoramiXWinRoot->info[i].id = WindowTable[i]->drawable.id; - PanoramiXCmapRoot->info[i].id = (screenInfo.screens[i])->defColormap; - - /* Create a Color-Depth-Table, this will help us deal - with mixing graphics boards and visuals, of course - given that the boards support multi-screen to begin - with. Fill the panoramiXCDT table by screen, then - visual type and allowable depths. - */ - pWin = WindowTable[i]; - if ( (screenInfo.screens[i])->numDepths > - PanoramiXLargestScreenDepth.numDepths ) - { - PanoramiXLargestScreenDepth.numDepths = (screenInfo.screens[i])->numDepths; - PanoramiXLargestScreenDepth.screenNum = i; - SameDepth = FALSE; - } - for (v = 0, pVisual = pWin->drawable.pScreen->visuals; - v < pWin->drawable.pScreen->numVisuals; v++, pVisual++) - { - PanoramiXColorDepthTable[i].panoramiXScreenMap[pVisual->class].numDepths = (screenInfo.screens[i])->numDepths; - for ( j = 0; j < (screenInfo.screens[i])->numDepths; j++) - { - pDepth = (DepthPtr) &pWin->drawable.pScreen->allowedDepths[j]; - PanoramiXColorDepthTable[i].panoramiXScreenMap[pVisual->class].listDepths[j] = pDepth->depth; - for (d = 0; d < pDepth->numVids; d++) - { - if (pVisual->vid == pDepth->vids[d]) - { - PanoramiXColorDepthTable[i]. - panoramiXScreenMap[pVisual->class].vmap[pDepth->depth]. - vid[ - PanoramiXColorDepthTable[i]. - panoramiXScreenMap[pVisual->class]. - vmap[pDepth->depth].numVids++ - ] - = pDepth->vids[d]; - } - } - } - } - PanoramiXColorDepthTable[i].numVisuals = 6; - } /* for each screen */ - /* Fill in ColorDepthTable for mixed visuals with varying depth. - Can't do that until we figure out how to handle mixed visuals - and varying card visual/depth initialization. If we can decide - how to map the relationship, then we can use this table to - shove the information into and use for cross-referencing when - necessary. - - In the meantime, check to see if the screens are the same, - if they don't then disable panoramiX, print out a message, - don't support this mode. - */ -} -/* Since locate_neighbors is recursive, a quick simple example - is in order.This mostly so you can see what the initial values are. - - Given 3 screens: - upperleft screen[0] - panoramiXdataPtr[0].x = 0 - panoramiXdataPtr[0].y = 0 - panoramiXdataPtr[0].width = 640 - panoramiXdataPtr[0].height = 480 - panoramiXdataPtr[0].below = -1 - panoramiXdataPtr[0].right = 1 - panoramiXdataPtr[0].above = -1 - panoramiXdataPtr[0].left = -1 - middle screen[1] - panoramiXdataPtr[1].x = 0 - panoramiXdataPtr[1].y = 0 - panoramiXdataPtr[1].width = 640 - panoramiXdataPtr[1].height = 480 - panoramiXdataPtr[1].below = -1 - panoramiXdataPtr[1].right = 2 - panoramiXdataPtr[1].above = -1 - panoramiXdataPtr[1].left = 0 - last right screen[2] - panoramiXdataPtr[2].x = 0 - panoramiXdataPtr[2].y = 0 - panoramiXdataPtr[2].width = 640 - panoramiXdataPtr[2].height = 480 - panoramiXdataPtr[2].below = -1 - panoramiXdataPtr[2].right = -1 - panoramiXdataPtr[2].above = -1 - panoramiXdataPtr[2].left = 1 - - Calling locate_neighbors(0) results in: - panoramiXdataPtr[0].x = 0 - panoramiXdataPtr[0].y = 0 - panoramiXdataPtr[1].x = 640 - panoramiXdataPtr[1].y = 0 - panoramiXdataPtr[2].x = 1280 - panoramiXdataPtr[2].y = 0 -*/ - -static void locate_neighbors(int i) -{ - int j; - - j = panoramiXdataPtr[i].right; - if ((j != -1) && !panoramiXdataPtr[j].x && !panoramiXdataPtr[j].y) { - panoramiXdataPtr[j].x = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width; - panoramiXdataPtr[j].y = panoramiXdataPtr[i].y; - locate_neighbors(j); - } - j = panoramiXdataPtr[i].below; - if ((j != -1) && !panoramiXdataPtr[j].x && !panoramiXdataPtr[j].y) { - panoramiXdataPtr[j].y = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height; - panoramiXdataPtr[j].x = panoramiXdataPtr[i].x; - locate_neighbors(j); + /* if it does, make sure it's in the list of supported depths and visuals */ + if(PanoramiXVisualTable[pVisual->vid * MAXSCREENS]) { + Bool GotIt = FALSE; + + PanoramiXVisuals[PanoramiXNumVisuals].vid = pVisual->vid; + PanoramiXVisuals[PanoramiXNumVisuals].class = pVisual->class; + PanoramiXVisuals[PanoramiXNumVisuals].bitsPerRGBValue = pVisual->bitsPerRGBValue; + PanoramiXVisuals[PanoramiXNumVisuals].ColormapEntries = pVisual->ColormapEntries; + PanoramiXVisuals[PanoramiXNumVisuals].nplanes = pVisual->nplanes; + PanoramiXVisuals[PanoramiXNumVisuals].redMask = pVisual->redMask; + PanoramiXVisuals[PanoramiXNumVisuals].greenMask = pVisual->greenMask; + PanoramiXVisuals[PanoramiXNumVisuals].blueMask = pVisual->blueMask; + PanoramiXVisuals[PanoramiXNumVisuals].offsetRed = pVisual->offsetRed; + PanoramiXVisuals[PanoramiXNumVisuals].offsetGreen = pVisual->offsetGreen; + PanoramiXVisuals[PanoramiXNumVisuals].offsetBlue = pVisual->offsetBlue; + PanoramiXNumVisuals++; + + for (j = 0; j < PanoramiXNumDepths; j++) { + if (PanoramiXDepths[j].depth == pVisual->nplanes) { + PanoramiXDepths[j].vids[PanoramiXDepths[j].numVids] = pVisual->vid; + PanoramiXDepths[j].numVids++; + GotIt = TRUE; + break; + } + } + + if (!GotIt) { + PanoramiXDepths[PanoramiXNumDepths].depth = pVisual->nplanes; + PanoramiXDepths[PanoramiXNumDepths].numVids = 1; + PanoramiXDepths[PanoramiXNumDepths].vids = xalloc(sizeof(VisualID) * 256); + PanoramiXDepths[PanoramiXNumDepths].vids[0] = pVisual->vid; + PanoramiXNumDepths++; + } + } + } + + + root = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)); + root->type = XRT_WINDOW; + defmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)); + defmap->type = XRT_COLORMAP; + + for (i = 0; i < PanoramiXNumScreens; i++) { + root->info[i].id = WindowTable[i]->drawable.id; + root->u.win.class = InputOutput; + defmap->info[i].id = (screenInfo.screens[i])->defColormap; } -} + AddResource(root->info[0].id, XRT_WINDOW, root); + AddResource(defmap->info[0].id, XRT_COLORMAP, defmap); +} /* @@ -597,46 +883,25 @@ static void locate_neighbors(int i) * Exit, deallocating as needed. */ -static void PanoramiXResetProc(extEntry) - ExtensionEntry* extEntry; +static void PanoramiXResetProc(ExtensionEntry* extEntry) { int i; - PanoramiXList *pPanoramiXList; - PanoramiXList *tempList; - for (pPanoramiXList = PanoramiXPmapRoot; pPanoramiXList; pPanoramiXList = tempList){ - tempList = pPanoramiXList->next; - Xfree(pPanoramiXList); - } - for (pPanoramiXList = PanoramiXCmapRoot; pPanoramiXList; pPanoramiXList = tempList){ - tempList = pPanoramiXList->next; - Xfree(pPanoramiXList); - } - for (pPanoramiXList = PanoramiXGCRoot; pPanoramiXList; pPanoramiXList = tempList) { - tempList = pPanoramiXList->next; - Xfree(pPanoramiXList); - } - for (pPanoramiXList = PanoramiXWinRoot; pPanoramiXList; pPanoramiXList = tempList) { - tempList = pPanoramiXList->next; - Xfree(pPanoramiXList); - } +#ifdef RENDER + PanoramiXRenderReset (); +#endif screenInfo.numScreens = PanoramiXNumScreens; for (i = 256; i--; ) ProcVector[i] = SavedProcVector[i]; - Xfree(panoramiXdataPtr); - + + Xfree(panoramiXdataPtr); } int -#if NeedFunctionPrototypes ProcPanoramiXQueryVersion (ClientPtr client) -#else -ProcPanoramiXQueryVersion (client) - register ClientPtr client; -#endif { - REQUEST(xPanoramiXQueryVersionReq); + /* REQUEST(xPanoramiXQueryVersionReq); */ xPanoramiXQueryVersionReply rep; register int n; @@ -649,18 +914,15 @@ ProcPanoramiXQueryVersion (client) if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); } WriteToClient(client, sizeof (xPanoramiXQueryVersionReply), (char *)&rep); return (client->noClientException); } int -#if NeedFunctionPrototypes ProcPanoramiXGetState(ClientPtr client) -#else -ProcPanoramiXGetState(client) - register ClientPtr client; -#endif { REQUEST(xPanoramiXGetStateReq); WindowPtr pWin; @@ -686,12 +948,7 @@ ProcPanoramiXGetState(client) } int -#if NeedFunctionPrototypes ProcPanoramiXGetScreenCount(ClientPtr client) -#else -ProcPanoramiXGetScreenCount(client) - register ClientPtr client; -#endif { REQUEST(xPanoramiXGetScreenCountReq); WindowPtr pWin; @@ -716,12 +973,7 @@ ProcPanoramiXGetScreenCount(client) } int -#if NeedFunctionPrototypes ProcPanoramiXGetScreenSize(ClientPtr client) -#else -ProcPanoramiXGetScreenSize(client) - register ClientPtr client; -#endif { REQUEST(xPanoramiXGetScreenSizeReq); WindowPtr pWin; @@ -741,29 +993,84 @@ ProcPanoramiXGetScreenSize(client) if (client->swapped) { swaps (&rep.sequenceNumber, n); swapl (&rep.length, n); - swaps (rep.width, n); - swaps (rep.height, n); + swaps (&rep.width, n); + swaps (&rep.height, n); } WriteToClient (client, sizeof (xPanoramiXGetScreenSizeReply), (char *) &rep); return client->noClientException; } -void PrintList(PanoramiXList *head) +int +ProcXineramaIsActive(ClientPtr client) +{ + /* REQUEST(xXineramaIsActiveReq); */ + xXineramaIsActiveReply rep; + + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.state = !noPanoramiXExtension; + if (client->swapped) { + register int n; + swaps (&rep.sequenceNumber, n); + swapl (&rep.length, n); + swapl (&rep.state, n); + } + WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep); + return client->noClientException; +} + + +int +ProcXineramaQueryScreens(ClientPtr client) { - int i = 0; + /* REQUEST(xXineramaQueryScreensReq); */ + xXineramaQueryScreensReply rep; + + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens; + rep.length = rep.number * sz_XineramaScreenInfo >> 2; + if (client->swapped) { + register int n; + swaps (&rep.sequenceNumber, n); + swapl (&rep.length, n); + swapl (&rep.number, n); + } + WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep); - for (; head; i++, head = head->next) - fprintf(stderr, "%2d next = 0x%010lx, id[0] = 0x%08x, id[1] = 0x%08x\n", - i, head->next, head->info[0].id, head->info[1].id); + if(!noPanoramiXExtension) { + xXineramaScreenInfo scratch; + int i; + + for(i = 0; i < PanoramiXNumScreens; i++) { + scratch.x_org = panoramiXdataPtr[i].x; + scratch.y_org = panoramiXdataPtr[i].y; + scratch.width = panoramiXdataPtr[i].width; + scratch.height = panoramiXdataPtr[i].height; + + if(client->swapped) { + register int n; + swaps (&scratch.x_org, n); + swaps (&scratch.y_org, n); + swaps (&scratch.width, n); + swaps (&scratch.height, n); + } + WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch); + } + } + + return client->noClientException; } + + static int -#if NeedFunctionPrototypes ProcPanoramiXDispatch (ClientPtr client) -#else -ProcPanoramiXDispatch (client) - ClientPtr client; -#endif { REQUEST(xReq); switch (stuff->data) { @@ -775,6 +1082,184 @@ ProcPanoramiXDispatch (client) return ProcPanoramiXGetScreenCount(client); case X_PanoramiXGetScreenSize: return ProcPanoramiXGetScreenSize(client); + case X_XineramaIsActive: + return ProcXineramaIsActive(client); + case X_XineramaQueryScreens: + return ProcXineramaQueryScreens(client); } return BadRequest; } + + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN +#define SHIFT_L(v,s) (v) << (s) +#define SHIFT_R(v,s) (v) >> (s) +#else +#define SHIFT_L(v,s) (v) >> (s) +#define SHIFT_R(v,s) (v) << (s) +#endif + +static void +CopyBits(char *dst, int shiftL, char *src, int bytes) +{ + /* Just get it to work. Worry about speed later */ + int shiftR = 8 - shiftL; + + while(bytes--) { + *dst |= SHIFT_L(*src, shiftL); + *(dst + 1) |= SHIFT_R(*src, shiftR); + dst++; src++; + } +} + + +/* Caution. This doesn't support 2 and 4 bpp formats. We expect + 1 bpp and planar data to be already cleared when presented + to this function */ + +void +XineramaGetImageData( + DrawablePtr *pDrawables, + int left, + int top, + int width, + int height, + unsigned int format, + unsigned long planemask, + char *data, + int pitch, + Bool isRoot +){ + RegionRec SrcRegion, GrabRegion; + BoxRec SrcBox, *pbox; + int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth; + DrawablePtr pDraw = pDrawables[0]; + char *ScratchMem = NULL; + + size = 0; + + /* find box in logical screen space */ + SrcBox.x1 = left; + SrcBox.y1 = top; + if(!isRoot) { + SrcBox.x1 += pDraw->x + panoramiXdataPtr[0].x; + SrcBox.y1 += pDraw->y + panoramiXdataPtr[0].y; + } + SrcBox.x2 = SrcBox.x1 + width; + SrcBox.y2 = SrcBox.y1 + height; + + REGION_INIT(pScreen, &SrcRegion, &SrcBox, 1); + REGION_INIT(pScreen, &GrabRegion, NullBox, 1); + + depth = (format == XYPixmap) ? 1 : pDraw->depth; + + for(i = 0; i < PanoramiXNumScreens; i++) { + pDraw = pDrawables[i]; + + inOut = RECT_IN_REGION(pScreen,&XineramaScreenRegions[i],&SrcBox); + + if(inOut == rgnIN) { + (*pDraw->pScreen->GetImage)(pDraw, + SrcBox.x1 - pDraw->x - panoramiXdataPtr[i].x, + SrcBox.y1 - pDraw->y - panoramiXdataPtr[i].y, + width, height, format, planemask, data); + break; + } else if (inOut == rgnOUT) + continue; + + REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, + &XineramaScreenRegions[i]); + + nbox = REGION_NUM_RECTS(&GrabRegion); + + if(nbox) { + pbox = REGION_RECTS(&GrabRegion); + + while(nbox--) { + w = pbox->x2 - pbox->x1; + h = pbox->y2 - pbox->y1; + ScratchPitch = PixmapBytePad(w, depth); + sizeNeeded = ScratchPitch * h; + + if(sizeNeeded > size) { + char *tmpdata = ScratchMem; + ScratchMem = xrealloc(ScratchMem, sizeNeeded); + if(ScratchMem) + size = sizeNeeded; + else { + ScratchMem = tmpdata; + break; + } + } + + x = pbox->x1 - pDraw->x - panoramiXdataPtr[i].x; + y = pbox->y1 - pDraw->y - panoramiXdataPtr[i].y; + + (*pDraw->pScreen->GetImage)(pDraw, x, y, w, h, + format, planemask, ScratchMem); + + /* copy the memory over */ + + if(depth == 1) { + int k, shift, leftover, index, index2; + + x = pbox->x1 - SrcBox.x1; + y = pbox->y1 - SrcBox.y1; + shift = x & 7; + x >>= 3; + leftover = w & 7; + w >>= 3; + + /* clean up the edge */ + if(leftover) { + int mask = (1 << leftover) - 1; + for(j = h, k = w; j--; k += ScratchPitch) + ScratchMem[k] &= mask; + } + + for(j = 0, index = (pitch * y) + x, index2 = 0; j < h; + j++, index += pitch, index2 += ScratchPitch) + { + if(w) { + if(!shift) + memcpy(data + index, ScratchMem + index2, w); + else + CopyBits(data + index, shift, + ScratchMem + index2, w); + } + + if(leftover) { + data[index + w] |= + SHIFT_L(ScratchMem[index2 + w], shift); + if((shift + leftover) > 8) + data[index + w + 1] |= + SHIFT_R(ScratchMem[index2 + w],(8 - shift)); + } + } + } else { + j = BitsPerPixel(depth) >> 3; + x = (pbox->x1 - SrcBox.x1) * j; + y = pbox->y1 - SrcBox.y1; + w *= j; + + for(j = 0; j < h; j++) { + memcpy(data + (pitch * (y + j)) + x, + ScratchMem + (ScratchPitch * j), w); + } + } + pbox++; + } + + REGION_SUBTRACT(pScreen, &SrcRegion, &SrcRegion, &GrabRegion); + if(!REGION_NOTEMPTY(pScreen, &SrcRegion)) + break; + } + + } + + if(ScratchMem) + xfree(ScratchMem); + + REGION_UNINIT(pScreen, &SrcRegion); + REGION_UNINIT(pScreen, &GrabRegion); +} diff --git a/Xext/panoramiXSwap.c b/Xext/panoramiXSwap.c index c6bb5071e..e78624187 100644 --- a/Xext/panoramiXSwap.c +++ b/Xext/panoramiXSwap.c @@ -23,6 +23,7 @@ shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ +/* $XFree86: xc/programs/Xserver/Xext/panoramiXSwap.c,v 3.8 2001/08/23 13:01:36 alanh Exp $ */ #include <stdio.h> #include "X.h" @@ -44,20 +45,16 @@ Equipment Corporation. #endif #include "panoramiX.h" #include "panoramiXproto.h" +#include "panoramiXsrv.h" +#include "globals.h" /* -/* * External references for data variables */ -extern Bool noPanoramiXExtension; -extern Bool PanoramiXVisibilityNotifySent; -extern WindowPtr *WindowTable; -extern int defaultBackingStore; extern char *ConnectionInfo; extern int connBlockScreenStart; -extern int (* ProcVector[256]) (); #if NeedFunctionPrototypes #define PROC_EXTERN(pfunc) extern int pfunc(ClientPtr) @@ -68,50 +65,38 @@ extern int (* ProcVector[256]) (); PROC_EXTERN(ProcPanoramiXQueryVersion); PROC_EXTERN(ProcPanoramiXGetState); PROC_EXTERN(ProcPanoramiXGetScreenCount); -PROC_EXTERN(PropPanoramiXGetScreenSize); +PROC_EXTERN(ProcPanoramiXGetScreenSize); + +PROC_EXTERN(ProcXineramaIsActive); +PROC_EXTERN(ProcXineramaQueryScreens); static int -#if NeedFunctionPrototypes SProcPanoramiXQueryVersion (ClientPtr client) -#else -SProcPanoramiXQueryVersion (client) - register ClientPtr client; -#endif { - register int n; - REQUEST(xPanoramiXQueryVersionReq); + REQUEST(xPanoramiXQueryVersionReq); + register int n; - swaps(&stuff->length,n); - REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); - return ProcPanoramiXQueryVersion(client); + swaps(&stuff->length,n); + REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq); + return ProcPanoramiXQueryVersion(client); } static int -#if NeedFunctionPrototypes SProcPanoramiXGetState(ClientPtr client) -#else -SProcPanoramiXGetState(client) - register ClientPtr client; -#endif { REQUEST(xPanoramiXGetStateReq); - register int n; + register int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); - + return ProcPanoramiXGetState(client); } static int -#if NeedFunctionPrototypes SProcPanoramiXGetScreenCount(ClientPtr client) -#else -SProcPanoramixGetScreenCount(client) - register ClientPtr client; -#endif { REQUEST(xPanoramiXGetScreenCountReq); - register int n; + register int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); @@ -119,29 +104,43 @@ SProcPanoramixGetScreenCount(client) } static int -#if NeedFunctionPrototypes SProcPanoramiXGetScreenSize(ClientPtr client) -#else -SProcPanoramiXGetScreenSize(client) - register ClientPtr client; -#endif { REQUEST(xPanoramiXGetScreenSizeReq); - WindowPtr pWin; - register int n; + register int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); return ProcPanoramiXGetScreenSize(client); } + +static int +SProcXineramaIsActive(ClientPtr client) +{ + REQUEST(xXineramaIsActiveReq); + register int n; + + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xXineramaIsActiveReq); + return ProcXineramaIsActive(client); +} + + +static int +SProcXineramaQueryScreens(ClientPtr client) +{ + REQUEST(xXineramaQueryScreensReq); + register int n; + + swaps (&stuff->length, n); + REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); + return ProcXineramaQueryScreens(client); +} + + int -#if NeedFunctionPrototypes SProcPanoramiXDispatch (ClientPtr client) -#else -SProcPanoramiXDispatch (client) - ClientPtr client; -#endif { REQUEST(xReq); switch (stuff->data) { @@ -153,6 +152,10 @@ SProcPanoramiXDispatch (client) return SProcPanoramiXGetScreenCount(client); case X_PanoramiXGetScreenSize: return SProcPanoramiXGetScreenSize(client); - return BadRequest; + case X_XineramaIsActive: + return SProcXineramaIsActive(client); + case X_XineramaQueryScreens: + return SProcXineramaQueryScreens(client); } + return BadRequest; } 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); } diff --git a/Xext/security.c b/Xext/security.c index c2db8f4dd..9af380dd6 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/Xserver/Xext/security.c,v 1.11 2002/05/31 18:45:53 dawes Exp $ */ #include "dixstruct.h" #include "extnsionst.h" @@ -50,7 +51,7 @@ extern unsigned char LbxReqCode; #ifndef DEFAULTPOLICYFILE # define DEFAULTPOLICYFILE NULL #endif -#ifdef WIN32 +#if defined(WIN32) || defined(__CYGWIN__) #include <X11/Xos.h> #undef index #endif @@ -82,9 +83,6 @@ int (*SwappedUntrustedProcVector[256])( #endif ); -extern int ProcBadRequest(); - - /* SecurityAudit * * Arguments: @@ -150,7 +148,7 @@ SecurityDeleteAuthorization(value, id) /* send revoke events */ - while (pEventClient = pAuth->eventClients) + while ((pEventClient = pAuth->eventClients)) { /* send revocation event event */ ClientPtr client = rClient(pEventClient); @@ -318,7 +316,7 @@ static int ProcSecurityQueryVersion(client) ClientPtr client; { - REQUEST(xSecurityQueryVersionReq); + /* REQUEST(xSecurityQueryVersionReq); */ xSecurityQueryVersionReply rep; /* paranoia: this "can't happen" because this extension is hidden @@ -395,7 +393,6 @@ ProcSecurityGenerateAuthorization(client) Bool removeAuth = FALSE; /* if bailout, call RemoveAuthorization? */ SecurityAuthorizationPtr pAuth = NULL; /* auth we are creating */ int err; /* error to return from this function */ - int status; /* return value from os functions */ XID authId; /* authorization ID assigned by os layer */ xSecurityGenerateAuthorizationReply rep; /* reply struct */ unsigned int trustLevel; /* trust level of new auth */ @@ -788,7 +785,7 @@ SecurityCheckDeviceAccess(client, dev, fromRequest) Bool untrusted_got_event; Bool found_event_window; Mask eventmask; - int reqtype; + int reqtype = 0; /* trusted clients always allowed to do anything */ if (client->trustLevel == XSecurityClientTrusted) @@ -1361,8 +1358,11 @@ SecurityFreePropertyAccessList() } } /* SecurityFreePropertyAccessList */ - +#ifndef __UNIXOS2__ #define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') ) +#else +#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') ) +#endif static char * SecuritySkipWhitespace(p) @@ -1441,7 +1441,6 @@ SecurityParsePropertyAccessRule(p) char action = SecurityDefaultAction; char readAction, writeAction, destroyAction; PropertyAccessPtr pacl, prev, cur; - ATOM atom; char *mustHaveProperty = NULL; char *mustHaveValue = NULL; Bool invalid; @@ -1641,7 +1640,11 @@ SecurityLoadPropertyAccessList() if (!SecurityPolicyFile) return; +#ifndef __UNIXOS2__ f = fopen(SecurityPolicyFile, "r"); +#else + f = fopen((char*)__XOS2RedirRoot(SecurityPolicyFile), "r"); +#endif if (!f) { ErrorF("error opening security policy file %s\n", @@ -1969,7 +1972,7 @@ SecurityExtensionInit() SecurityEventBase = extEntry->eventBase; EventSwapVector[SecurityEventBase + XSecurityAuthorizationRevoked] = - SwapSecurityAuthorizationRevokedEvent; + (EventSwapPtr)SwapSecurityAuthorizationRevokedEvent; /* initialize untrusted proc vectors */ diff --git a/Xext/shape.c b/Xext/shape.c index bff7d2502..7bd161dcc 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/Xext/shape.c,v 3.16 2001/12/14 19:58:50 dawes Exp $ */ /************************************************************ Copyright 1989, 1998 The Open Group @@ -27,7 +28,6 @@ in this Software without prior written authorization from The Open Group. /* $Xorg: shape.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */ #define NEED_REPLIES #define NEED_EVENTS -#include <stdio.h> #include "X.h" #include "Xproto.h" #include "misc.h" @@ -43,26 +43,101 @@ in this Software without prior written authorization from The Open Group. #include "shapestr.h" #include "regionstr.h" #include "gcstruct.h" +#ifdef EXTMODULE +#include "xf86_ansic.h" +#endif + +typedef RegionPtr (*CreateDftPtr)( +#if NeedNestedPrototypes + WindowPtr /* pWin */ +#endif + ); + +static int ShapeFreeClient( +#if NeedFunctionPrototypes + pointer /* data */, + XID /* id */ +#endif + ); +static int ShapeFreeEvents( +#if NeedFunctionPrototypes + pointer /* data */, + XID /* id */ +#endif + ); +static void SendShapeNotify( +#if NeedFunctionPrototypes + WindowPtr /* pWin */, + int /* which */ +#endif + ); +static void ShapeResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif + ); +static void SShapeNotifyEvent( +#if NeedFunctionPrototypes + xShapeNotifyEvent * /* from */, + xShapeNotifyEvent * /* to */ +#endif + ); +static int +RegionOperate ( +#if NeedFunctionPrototypes + ClientPtr /* client */, + WindowPtr /* pWin */, + int /* kind */, + RegionPtr * /* destRgnp */, + RegionPtr /* srcRgn */, + int /* op */, + int /* xoff */, + int /* yoff */, + CreateDftPtr /* create */ +#endif + ); + +#if NeedFunctionPrototypes +#define CREATE_PROC(func) RegionPtr func(WindowPtr /* pWin */) +#else +#define CREATE_PROC(func) RegionPtr func(/* WindowPtr pWin */) +#endif + +static CREATE_PROC(CreateBoundingShape); +static CREATE_PROC(CreateClipShape); + +#undef CREATE_PROC + +static DISPATCH_PROC(ProcShapeCombine); +static DISPATCH_PROC(ProcShapeDispatch); +static DISPATCH_PROC(ProcShapeGetRectangles); +static DISPATCH_PROC(ProcShapeInputSelected); +static DISPATCH_PROC(ProcShapeMask); +static DISPATCH_PROC(ProcShapeOffset); +static DISPATCH_PROC(ProcShapeQueryExtents); +static DISPATCH_PROC(ProcShapeQueryVersion); +static DISPATCH_PROC(ProcShapeRectangles); +static DISPATCH_PROC(ProcShapeSelectInput); +static DISPATCH_PROC(SProcShapeCombine); +static DISPATCH_PROC(SProcShapeDispatch); +static DISPATCH_PROC(SProcShapeGetRectangles); +static DISPATCH_PROC(SProcShapeInputSelected); +static DISPATCH_PROC(SProcShapeMask); +static DISPATCH_PROC(SProcShapeOffset); +static DISPATCH_PROC(SProcShapeQueryExtents); +static DISPATCH_PROC(SProcShapeQueryVersion); +static DISPATCH_PROC(SProcShapeRectangles); +static DISPATCH_PROC(SProcShapeSelectInput); #ifdef PANORAMIX #include "panoramiX.h" +#include "panoramiXsrv.h" #endif -static int ShapeFreeClient(), ShapeFreeEvents(); -static void SendShapeNotify(); -static int ProcShapeDispatch(), SProcShapeDispatch(); -static void ShapeResetProc(), SShapeNotifyEvent(); - static unsigned char ShapeReqCode = 0; static int ShapeEventBase = 0; static RESTYPE ClientType, EventType; /* resource types for event masks */ -#ifdef PANORAMIX -extern int PanoramiXNumScreens; -extern Bool noPanoramiXExtension; -extern PanoramiXWindow *PanoramiXWinRoot; -extern PanoramiXPmap *PanoramiXPmapRoot; -#endif /* * each window has a list of clients requesting * ShapeNotify events. Each client has a resource @@ -91,7 +166,7 @@ typedef struct _ShapeEvent { void ShapeExtensionInit() { - ExtensionEntry *extEntry, *AddExtension(); + ExtensionEntry *extEntry; ClientType = CreateNewResourceType(ShapeFreeClient); EventType = CreateNewResourceType(ShapeFreeEvents); @@ -102,7 +177,7 @@ ShapeExtensionInit() { ShapeReqCode = (unsigned char)extEntry->base; ShapeEventBase = extEntry->eventBase; - EventSwapVector[ShapeEventBase] = SShapeNotifyEvent; + EventSwapVector[ShapeEventBase] = (EventSwapPtr) SShapeNotifyEvent; } } @@ -113,7 +188,7 @@ ExtensionEntry *extEntry; { } -static +static int RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create) ClientPtr client; WindowPtr pWin; @@ -121,7 +196,7 @@ RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create) RegionPtr *destRgnp, srcRgn; int op; int xoff, yoff; - RegionPtr (*create)(); /* creates a reasonable *destRgnp */ + CreateDftPtr create; /* creates a reasonable *destRgnp */ { ScreenPtr pScreen = pWin->drawable.pScreen; @@ -133,7 +208,31 @@ RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create) REGION_DESTROY(pScreen, srcRgn); return Success; } - switch (op) { + + /* May/30/2001: + * The shape.PS specs say if src is None, existing shape is to be + * removed (and so the op-code has no meaning in such removal); + * see shape.PS, page 3, ShapeMask. + */ + if (srcRgn == NULL) { + if (*destRgnp != NULL) { + REGION_DESTROY (pScreen, *destRgnp); + *destRgnp = 0; + /* go on to remove shape and generate ShapeNotify */ + } + else { + /* May/30/2001: + * The target currently has no shape in effect, so nothing to + * do here. The specs say that ShapeNotify is generated whenever + * the client region is "modified"; since no modification is done + * here, we do not generate that event. The specs does not say + * "it is an error to request removal when there is no shape in + * effect", so we return good status. + */ + return Success; + } + } + else switch (op) { case ShapeSet: if (*destRgnp) REGION_DESTROY(pScreen, *destRgnp); @@ -204,7 +303,6 @@ static int ProcShapeQueryVersion (client) register ClientPtr client; { - REQUEST(xShapeQueryVersionReq); xShapeQueryVersionReply rep; register int n; @@ -228,42 +326,8 @@ ProcShapeQueryVersion (client) * ProcShapeRectangles * *****************/ -#ifdef PANORAMIX -static int -ProcPanoramiXShapeRectangles (client) - register ClientPtr client; -{ - WindowPtr pWin; - ScreenPtr pScreen; - REQUEST(xShapeRectanglesReq); - xRectangle *prects; - int nrects, ctype; - RegionPtr srcRgn; - RegionPtr *destRgn; - RegionPtr (*createDefault)(); - int destBounding; - - register int result; - int j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - - REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq); - PANORAMIXFIND_ID(pPanoramiXWin,stuff->dest); - IF_RETURN(!pPanoramiXWin, BadRequest); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin , j) { - stuff->dest = pPanoramiXWin->info[j].id; - result = ProcShapeRectangles (client); - BREAK_IF(result != Success); - } - return (result); -} -#endif -#ifdef PANORAMIX -int -#else static int -#endif ProcShapeRectangles (client) register ClientPtr client; { @@ -274,7 +338,7 @@ ProcShapeRectangles (client) int nrects, ctype; RegionPtr srcRgn; RegionPtr *destRgn; - RegionPtr (*createDefault)(); + CreateDftPtr createDefault; int destBounding; REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq); @@ -324,49 +388,37 @@ ProcShapeRectangles (client) stuff->xOff, stuff->yOff, createDefault); } -/************** - * ProcShapeMask - **************/ - #ifdef PANORAMIX static int -ProcPanoramiXShapeMask (client) +ProcPanoramiXShapeRectangles (client) register ClientPtr client; { - WindowPtr pWin; - ScreenPtr pScreen; - REQUEST(xShapeMaskReq); - RegionPtr srcRgn; - RegionPtr *destRgn; - PixmapPtr pPixmap; - RegionPtr (*createDefault)(); - int destBounding; + REQUEST(xShapeRectanglesReq); + PanoramiXRes *win; + int j, result = 0; - register int result; - int j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; - PanoramiXPmap *pPmap = PanoramiXPmapRoot; + REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq); - REQUEST_SIZE_MATCH (xShapeMaskReq); - PANORAMIXFIND_ID(pPanoramiXWin,stuff->dest); - IF_RETURN(!pPanoramiXWin, BadRequest); - PANORAMIXFIND_ID(pPmap, stuff->src); - IF_RETURN(!pPmap, BadRequest); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin , j) { - stuff->dest = pPanoramiXWin->info[j].id; - stuff->src = pPmap->info[j].id; - result = ProcShapeMask (client); + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + FOR_NSCREENS(j) { + stuff->dest = win->info[j].id; + result = ProcShapeRectangles (client); BREAK_IF(result != Success); } return (result); } #endif -#ifdef PANORAMIX -int -#else + +/************** + * ProcShapeMask + **************/ + + static int -#endif ProcShapeMask (client) register ClientPtr client; { @@ -376,7 +428,7 @@ ProcShapeMask (client) RegionPtr srcRgn; RegionPtr *destRgn; PixmapPtr pPixmap; - RegionPtr (*createDefault)(); + CreateDftPtr createDefault; int destBounding; REQUEST_SIZE_MATCH (xShapeMaskReq); @@ -425,45 +477,45 @@ ProcShapeMask (client) stuff->xOff, stuff->yOff, createDefault); } -/************ - * ProcShapeCombine - ************/ #ifdef PANORAMIX static int -ProcPanoramiXShapeCombine (client) +ProcPanoramiXShapeMask (client) register ClientPtr client; { - WindowPtr pSrcWin, pDestWin; - ScreenPtr pScreen; - REQUEST(xShapeCombineReq); - RegionPtr srcRgn; - RegionPtr *destRgn; - RegionPtr (*createDefault)(); - RegionPtr (*createSrc)(); - RegionPtr tmp; - int destBounding; + REQUEST(xShapeMaskReq); + PanoramiXRes *win, *pmap; + int j, result = 0; - register int result; - int j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; + REQUEST_SIZE_MATCH (xShapeMaskReq); - REQUEST_AT_LEAST_SIZE (xShapeCombineReq); - PANORAMIXFIND_ID(pPanoramiXWin,stuff->dest); - IF_RETURN(!pPanoramiXWin, BadRequest); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin , j) { - stuff->dest = pPanoramiXWin->info[j].id; - result = ProcShapeCombine (client); + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + if(stuff->src != None) { + if(!(pmap = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->src, XRT_PIXMAP, SecurityReadAccess))) + return BadPixmap; + } else + pmap = NULL; + + FOR_NSCREENS(j) { + stuff->dest = win->info[j].id; + if(pmap) + stuff->src = pmap->info[j].id; + result = ProcShapeMask (client); BREAK_IF(result != Success); } return (result); } #endif -#ifdef PANORAMIX -int -#else + +/************ + * ProcShapeCombine + ************/ + static int -#endif ProcShapeCombine (client) register ClientPtr client; { @@ -472,8 +524,8 @@ ProcShapeCombine (client) REQUEST(xShapeCombineReq); RegionPtr srcRgn; RegionPtr *destRgn; - RegionPtr (*createDefault)(); - RegionPtr (*createSrc)(); + CreateDftPtr createDefault; + CreateDftPtr createSrc; RegionPtr tmp; int destBounding; @@ -539,40 +591,41 @@ ProcShapeCombine (client) stuff->xOff, stuff->yOff, createDefault); } -/************* - * ProcShapeOffset - *************/ + #ifdef PANORAMIX static int -ProcPanoramiXShapeOffset (client) +ProcPanoramiXShapeCombine (client) register ClientPtr client; { - WindowPtr pWin; - ScreenPtr pScreen; - REQUEST(xShapeOffsetReq); - RegionPtr srcRgn; + REQUEST(xShapeCombineReq); + PanoramiXRes *win, *win2; + int j, result = 0; + + REQUEST_AT_LEAST_SIZE (xShapeCombineReq); - register int result; - int j; - PanoramiXWindow *pPanoramiXWin = PanoramiXWinRoot; + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; - REQUEST_AT_LEAST_SIZE (xShapeOffsetReq); - PANORAMIXFIND_ID(pPanoramiXWin,stuff->dest); - IF_RETURN(!pPanoramiXWin, BadRequest); - FOR_NSCREENS_OR_ONCE(pPanoramiXWin , j) { - stuff->dest = pPanoramiXWin->info[j].id; - result = ProcShapeOffset (client); + if(!(win2 = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->src, XRT_WINDOW, SecurityReadAccess))) + return BadWindow; + + FOR_NSCREENS(j) { + stuff->dest = win->info[j].id; + stuff->src = win2->info[j].id; + result = ProcShapeCombine (client); BREAK_IF(result != Success); } return (result); } #endif -#ifdef PANORAMIX -int -#else +/************* + * ProcShapeOffset + *************/ + static int -#endif ProcShapeOffset (client) register ClientPtr client; { @@ -607,6 +660,32 @@ ProcShapeOffset (client) return Success; } + +#ifdef PANORAMIX +static int +ProcPanoramiXShapeOffset (client) + register ClientPtr client; +{ + REQUEST(xShapeOffsetReq); + PanoramiXRes *win; + int j, result = 0; + + REQUEST_AT_LEAST_SIZE (xShapeOffsetReq); + + if(!(win = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->dest, XRT_WINDOW, SecurityWriteAccess))) + return BadWindow; + + FOR_NSCREENS(j) { + stuff->dest = win->info[j].id; + result = ProcShapeOffset (client); + if(result != Success) break; + } + return (result); +} +#endif + + static int ProcShapeQueryExtents (client) register ClientPtr client; @@ -616,6 +695,7 @@ ProcShapeQueryExtents (client) xShapeQueryExtentsReply rep; BoxRec extents, *pExtents; register int n; + RegionPtr region; REQUEST_SIZE_MATCH (xShapeQueryExtentsReq); pWin = LookupWindow (stuff->window, client); @@ -626,9 +706,9 @@ ProcShapeQueryExtents (client) rep.sequenceNumber = client->sequence; rep.boundingShaped = (wBoundingShape(pWin) != 0); rep.clipShaped = (wClipShape(pWin) != 0); - if (wBoundingShape(pWin)) { + if ((region = wBoundingShape(pWin))) { /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */ - pExtents = REGION_EXTENTS(pWin->drawable.pScreen, wBoundingShape(pWin)); + pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region); extents = *pExtents; } else { extents.x1 = -wBorderWidth (pWin); @@ -640,9 +720,9 @@ ProcShapeQueryExtents (client) rep.yBoundingShape = extents.y1; rep.widthBoundingShape = extents.x2 - extents.x1; rep.heightBoundingShape = extents.y2 - extents.y1; - if (wClipShape(pWin)) { + if ((region = wClipShape(pWin))) { /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */ - pExtents = REGION_EXTENTS(pWin->drawable.pScreen, wClipShape(pWin)); + pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region); extents = *pExtents; } else { extents.x1 = 0; @@ -1001,37 +1081,29 @@ ProcShapeDispatch (client) if ( !noPanoramiXExtension ) return ProcPanoramiXShapeRectangles (client); else - return ProcShapeRectangles (client); -#else - return ProcShapeRectangles (client); #endif + return ProcShapeRectangles (client); case X_ShapeMask: #ifdef PANORAMIX if ( !noPanoramiXExtension ) return ProcPanoramiXShapeMask (client); else - return ProcShapeMask (client); -#else - return ProcShapeMask (client); #endif + return ProcShapeMask (client); case X_ShapeCombine: #ifdef PANORAMIX if ( !noPanoramiXExtension ) return ProcPanoramiXShapeCombine (client); else - return ProcShapeCombine (client); -#else - return ProcShapeCombine (client); #endif + return ProcShapeCombine (client); case X_ShapeOffset: #ifdef PANORAMIX if ( !noPanoramiXExtension ) return ProcPanoramiXShapeOffset (client); else - return ProcShapeOffset (client); -#else - return ProcShapeOffset (client); #endif + return ProcShapeOffset (client); case X_ShapeQueryExtents: return ProcShapeQueryExtents (client); case X_ShapeSelectInput: diff --git a/Xext/shm.c b/Xext/shm.c index 0a9f3af59..3ba9ad2c1 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/Xext/shm.c,v 3.36 2002/04/03 19:51:11 herrb Exp $ */ /************************************************************ Copyright 1989, 1998 The Open Group @@ -29,8 +30,15 @@ in this Software without prior written authorization from The Open Group. /* $Xorg: shm.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */ #include <sys/types.h> +#ifndef Lynx #include <sys/ipc.h> #include <sys/shm.h> +#else +#include <ipc.h> +#include <shm.h> +#endif +#include <unistd.h> +#include <sys/stat.h> #define NEED_REPLIES #define NEED_EVENTS #include "X.h" @@ -48,6 +56,14 @@ in this Software without prior written authorization from The Open Group. #define _XSHM_SERVER_ #include "shmstr.h" #include "Xfuncproto.h" +#ifdef EXTMODULE +#include "xf86_ansic.h" +#endif + +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif typedef struct _ShmDesc { struct _ShmDesc *next; @@ -58,21 +74,57 @@ typedef struct _ShmDesc { unsigned long size; } ShmDescRec, *ShmDescPtr; -static void miShmPutImage(), fbShmPutImage(); -static PixmapPtr fbShmCreatePixmap(); -static int ProcShmDispatch(), SProcShmDispatch(); -static int ShmDetachSegment(); -static void ShmResetProc(), SShmCompletionEvent(); +static void miShmPutImage(XSHM_PUT_IMAGE_ARGS); +static void fbShmPutImage(XSHM_PUT_IMAGE_ARGS); +static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS); +static int ShmDetachSegment( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* shmseg */ +#endif + ); +static void ShmResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif + ); +static void SShmCompletionEvent( +#if NeedFunctionPrototypes + xShmCompletionEvent * /* from */, + xShmCompletionEvent * /* to */ +#endif + ); + +static Bool ShmDestroyPixmap (PixmapPtr pPixmap); + +static DISPATCH_PROC(ProcShmAttach); +static DISPATCH_PROC(ProcShmCreatePixmap); +static DISPATCH_PROC(ProcShmDetach); +static DISPATCH_PROC(ProcShmDispatch); +static DISPATCH_PROC(ProcShmGetImage); +static DISPATCH_PROC(ProcShmPutImage); +static DISPATCH_PROC(ProcShmQueryVersion); +static DISPATCH_PROC(SProcShmAttach); +static DISPATCH_PROC(SProcShmCreatePixmap); +static DISPATCH_PROC(SProcShmDetach); +static DISPATCH_PROC(SProcShmDispatch); +static DISPATCH_PROC(SProcShmGetImage); +static DISPATCH_PROC(SProcShmPutImage); +static DISPATCH_PROC(SProcShmQueryVersion); static unsigned char ShmReqCode; -static int ShmCompletionCode; -static int BadShmSegCode; -static RESTYPE ShmSegType, ShmPixType; +int ShmCompletionCode; +int BadShmSegCode; +RESTYPE ShmSegType; static ShmDescPtr Shmsegs; static Bool sharedPixmaps; static int pixmapFormat; static int shmPixFormat[MAXSCREENS]; static ShmFuncsPtr shmFuncs[MAXSCREENS]; +static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS]; +#ifdef PIXPRIV +static int shmPixmapPrivate; +#endif static ShmFuncs miFuncs = {NULL, miShmPutImage}; static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage}; @@ -106,20 +158,60 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage}; } \ } + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#include <sys/signal.h> + +static Bool badSysCall = FALSE; + +static void +SigSysHandler(signo) +int signo; +{ + badSysCall = TRUE; +} + +static Bool CheckForShmSyscall() +{ + void (*oldHandler)(); + int shmid = -1; + + /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ + oldHandler = signal(SIGSYS, SigSysHandler); + + badSysCall = FALSE; + shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); + /* Clean up */ + if (shmid != -1) + { + shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL); + } + signal(SIGSYS, oldHandler); + return(!badSysCall); +} +#endif + void ShmExtensionInit() { ExtensionEntry *extEntry; int i; -#ifdef INTERNAL_VS_EXTERNAL_PADDING +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + if (!CheckForShmSyscall()) + { + ErrorF("MIT-SHM extension disabled due to lack of kernel support\n"); + return; + } +#endif + sharedPixmaps = xFalse; pixmapFormat = 0; -#else - sharedPixmaps = xTrue; - pixmapFormat = shmPixFormat[0]; - for (i = 0; i < screenInfo.numScreens; i++) { + sharedPixmaps = xTrue; + pixmapFormat = shmPixFormat[0]; + for (i = 0; i < screenInfo.numScreens; i++) + { if (!shmFuncs[i]) shmFuncs[i] = &miFuncs; if (!shmFuncs[i]->CreatePixmap) @@ -129,13 +221,29 @@ ShmExtensionInit() sharedPixmaps = xFalse; pixmapFormat = 0; } - } - if (!pixmapFormat) + } + if (!pixmapFormat) pixmapFormat = ZPixmap; + if (sharedPixmaps) + { + for (i = 0; i < screenInfo.numScreens; i++) + { + destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap; + screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; + } +#ifdef PIXPRIV + shmPixmapPrivate = AllocatePixmapPrivateIndex(); + for (i = 0; i < screenInfo.numScreens; i++) + { + if (!AllocatePixmapPrivate(screenInfo.screens[i], + shmPixmapPrivate, 0)) + return; + } #endif + } + } ShmSegType = CreateNewResourceType(ShmDetachSegment); - ShmPixType = CreateNewResourceType(ShmDetachSegment); - if (ShmSegType && ShmPixType && + if (ShmSegType && (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors, ProcShmDispatch, SProcShmDispatch, ShmResetProc, StandardMinorOpcode))) @@ -143,7 +251,7 @@ ShmExtensionInit() ShmReqCode = (unsigned char)extEntry->base; ShmCompletionCode = extEntry->eventBase; BadShmSegCode = extEntry->errorBase; - EventSwapVector[ShmCompletionCode] = SShmCompletionEvent; + EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent; } } @@ -177,6 +285,41 @@ ShmSetPixmapFormat(pScreen, format) shmPixFormat[pScreen->myNum] = format; } +static Bool +ShmDestroyPixmap (PixmapPtr pPixmap) +{ + ScreenPtr pScreen = pPixmap->drawable.pScreen; + Bool ret; + if (pPixmap->refcnt == 1) + { + ShmDescPtr shmdesc; +#ifdef PIXPRIV + shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr; +#else + char *base = (char *) pPixmap->devPrivate.ptr; + + if (base != (pointer) (pPixmap + 1)) + { + for (shmdesc = Shmsegs; shmdesc; shmdesc = shmdesc->next) + { + if (shmdesc->addr <= base && base <= shmdesc->addr + shmdesc->size) + break; + } + } + else + shmdesc = 0; +#endif + if (shmdesc) + ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id); + } + + pScreen->DestroyPixmap = destroyPixmap[pScreen->myNum]; + ret = (*pScreen->DestroyPixmap) (pPixmap); + destroyPixmap[pScreen->myNum] = pScreen->DestroyPixmap; + pScreen->DestroyPixmap = ShmDestroyPixmap; + return ret; +} + void ShmRegisterFbFuncs(pScreen) ScreenPtr pScreen; @@ -188,7 +331,6 @@ static int ProcShmQueryVersion(client) register ClientPtr client; { - REQUEST(xShmQueryVersionReq); xShmQueryVersionReply rep; register int n; @@ -214,6 +356,47 @@ ProcShmQueryVersion(client) return (client->noClientException); } +/* + * Simulate the access() system call for a shared memory segement, + * using the credentials from the client if available + */ +static int +shm_access(ClientPtr client, struct ipc_perm *perm, int readonly) +{ + int uid, gid; + mode_t mask; + + if (LocalClientCred(client, &uid, &gid) != -1) { + + /* User id 0 always gets access */ + if (uid == 0) { + return 0; + } + /* Check the owner */ + if (perm->uid == uid || perm->cuid == uid) { + mask = S_IRUSR; + if (!readonly) { + mask |= S_IWUSR; + } + return (perm->mode & mask) == mask ? 0 : -1; + } + /* Check the group */ + if (perm->gid == gid || perm->cgid == gid) { + mask = S_IRGRP; + if (!readonly) { + mask |= S_IWGRP; + } + return (perm->mode & mask) == mask ? 0 : -1; + } + } + /* Otherwise, check everyone else */ + mask = S_IROTH; + if (!readonly) { + mask |= S_IWOTH; + } + return (perm->mode & mask) == mask ? 0 : -1; +} + static int ProcShmAttach(client) register ClientPtr client; @@ -252,6 +435,17 @@ ProcShmAttach(client) xfree(shmdesc); return BadAccess; } + + /* The attach was performed with root privs. We must + * do manual checking of access rights for the credentials + * of the client */ + + if (shm_access(client, &(buf.shm_perm), stuff->readOnly) == -1) { + shmdt(shmdesc->addr); + xfree(shmdesc); + return BadAccess; + } + shmdesc->shmid = stuff->shmid; shmdesc->refcnt = 1; shmdesc->writable = !stuff->readOnly; @@ -342,7 +536,7 @@ fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) PixmapPtr pPixmap; pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth, - /*XXX*/depth, PixmapBytePad(w, depth), (pointer)data); + BitsPerPixel(depth), PixmapBytePad(w, depth), (pointer)data); if (!pPixmap) return; if (format == XYBitmap) @@ -358,6 +552,251 @@ fbShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, data) data); } + +#ifdef PANORAMIX +static int +ProcPanoramiXShmPutImage(register ClientPtr client) +{ + int j, result = 0, orig_x, orig_y; + PanoramiXRes *draw, *gc; + Bool sendEvent, isRoot; + + REQUEST(xShmPutImageReq); + REQUEST_SIZE_MATCH(xShmPutImageReq); + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if(!(gc = (PanoramiXRes *)SecurityLookupIDByType( + client, stuff->gc, XRT_GC, SecurityReadAccess))) + return BadGC; + + isRoot = (draw->type == XRT_WINDOW) && + (stuff->drawable == WindowTable[0]->drawable.id); + + orig_x = stuff->dstX; + orig_y = stuff->dstY; + sendEvent = stuff->sendEvent; + stuff->sendEvent = 0; + FOR_NSCREENS(j) { + if(!j) stuff->sendEvent = sendEvent; + stuff->drawable = draw->info[j].id; + stuff->gc = gc->info[j].id; + if (isRoot) { + stuff->dstX = orig_x - panoramiXdataPtr[j].x; + stuff->dstY = orig_y - panoramiXdataPtr[j].y; + } + result = ProcShmPutImage(client); + if(result != client->noClientException) break; + } + return(result); +} + +static int +ProcPanoramiXShmGetImage(ClientPtr client) +{ + PanoramiXRes *draw; + DrawablePtr drawables[MAXSCREENS]; + DrawablePtr pDraw; + xShmGetImageReply xgi; + ShmDescPtr shmdesc; + int i, x, y, w, h, format; + Mask plane = 0, planemask; + long lenPer = 0, length, widthBytesLine; + Bool isRoot; + + REQUEST(xShmGetImageReq); + + REQUEST_SIZE_MATCH(xShmGetImageReq); + + if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) { + client->errorValue = stuff->format; + return(BadValue); + } + + if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass( + client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess))) + return BadDrawable; + + if (draw->type == XRT_PIXMAP) + return ProcShmGetImage(client); + + VERIFY_DRAWABLE(pDraw, stuff->drawable, client); + + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); + + x = stuff->x; + y = stuff->y; + w = stuff->width; + h = stuff->height; + format = stuff->format; + planemask = stuff->planeMask; + + isRoot = (draw->type == XRT_WINDOW) && + (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); + } else { + if( /* check for being onscreen */ + panoramiXdataPtr[0].x + pDraw->x + x < 0 || + panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth || + panoramiXdataPtr[0].y + pDraw->y + y < 0 || + panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight || + /* check for being inside of border */ + x < - wBorderWidth((WindowPtr)pDraw) || + x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width || + y < -wBorderWidth((WindowPtr)pDraw) || + y + h > wBorderWidth ((WindowPtr)pDraw) + (int)pDraw->height) + return(BadMatch); + } + + drawables[0] = pDraw; + for(i = 1; i < PanoramiXNumScreens; i++) + VERIFY_DRAWABLE(drawables[i], draw->info[i].id, client); + + xgi.visual = wVisual(((WindowPtr)pDraw)); + xgi.type = X_Reply; + xgi.length = 0; + xgi.sequenceNumber = client->sequence; + xgi.depth = pDraw->depth; + + if(format == ZPixmap) { + widthBytesLine = PixmapBytePad(w, pDraw->depth); + length = widthBytesLine * h; + } else { + widthBytesLine = PixmapBytePad(w, 1); + lenPer = widthBytesLine * h; + plane = ((Mask)1) << (pDraw->depth - 1); + length = lenPer * Ones(planemask & (plane | (plane - 1))); + } + + VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); + xgi.size = length; + + if (length == 0) {/* nothing to do */ } + else if (format == ZPixmap) { + XineramaGetImageData(drawables, x, y, w, h, format, planemask, + shmdesc->addr + stuff->offset, + widthBytesLine, isRoot); + } else { + + length = stuff->offset; + for (; plane; plane >>= 1) { + if (planemask & plane) { + XineramaGetImageData(drawables, x, y, w, h, + format, plane, shmdesc->addr + length, + widthBytesLine, isRoot); + length += lenPer; + } + } + } + + if (client->swapped) { + register int n; + swaps(&xgi.sequenceNumber, n); + swapl(&xgi.length, n); + swapl(&xgi.visual, n); + swapl(&xgi.size, n); + } + WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); + + return(client->noClientException); +} + +static int +ProcPanoramiXShmCreatePixmap(client) + register ClientPtr client; +{ + ScreenPtr pScreen = NULL; + PixmapPtr pMap = NULL; + DrawablePtr pDraw; + DepthPtr pDepth; + int i, j, result; + ShmDescPtr shmdesc; + REQUEST(xShmCreatePixmapReq); + PanoramiXRes *newPix; + + REQUEST_SIZE_MATCH(xShmCreatePixmapReq); + client->errorValue = stuff->pid; + if (!sharedPixmaps) + return BadImplementation; + LEGAL_NEW_RESOURCE(stuff->pid, client); + VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); + VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); + if (!stuff->width || !stuff->height) + { + client->errorValue = 0; + return BadValue; + } + if (stuff->depth != 1) + { + pDepth = pDraw->pScreen->allowedDepths; + for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++) + if (pDepth->depth == stuff->depth) + goto CreatePmap; + client->errorValue = stuff->depth; + return BadValue; + } +CreatePmap: + VERIFY_SHMSIZE(shmdesc, stuff->offset, + PixmapBytePad(stuff->width, stuff->depth) * stuff->height, + client); + + if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) + return BadAlloc; + + newPix->type = XRT_PIXMAP; + newPix->u.pix.shared = TRUE; + newPix->info[0].id = stuff->pid; + for(j = 1; j < PanoramiXNumScreens; j++) + newPix->info[j].id = FakeClientID(client->index); + + result = (client->noClientException); + + FOR_NSCREENS(j) { + pScreen = screenInfo.screens[j]; + + pMap = (*shmFuncs[j]->CreatePixmap)(pScreen, + stuff->width, stuff->height, stuff->depth, + shmdesc->addr + stuff->offset); + + if (pMap) { +#ifdef PIXPRIV + pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc; +#endif + shmdesc->refcnt++; + pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pMap->drawable.id = newPix->info[j].id; + if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) { + (*pScreen->DestroyPixmap)(pMap); + result = BadAlloc; + break; + } + } else { + result = BadAlloc; + break; + } + } + + if(result == BadAlloc) { + while(j--) { + (*pScreen->DestroyPixmap)(pMap); + FreeResource(newPix->info[j].id, RT_NONE); + } + xfree(newPix); + } else + AddResource(stuff->pid, XRT_PIXMAP, newPix); + + return result; +} + +#endif + static int ProcShmPutImage(client) register ClientPtr client; @@ -365,11 +804,6 @@ ProcShmPutImage(client) register GCPtr pGC; register DrawablePtr pDraw; long length; -#ifdef INTERNAL_VS_EXTERNAL_PADDING - long lengthProto; - char *tmpImage; - int tmpAlloced = 0; -#endif ShmDescPtr shmdesc; REQUEST(xShmPutImageReq); @@ -383,9 +817,6 @@ ProcShmPutImage(client) if (stuff->depth != 1) return BadMatch; length = PixmapBytePad(stuff->totalWidth, 1); -#ifdef INTERNAL_VS_EXTERNAL_PADDING - lengthProto = PixmapBytePadProto(stuff->totalWidth, 1); -#endif } else if (stuff->format == XYPixmap) { @@ -393,19 +824,12 @@ ProcShmPutImage(client) return BadMatch; length = PixmapBytePad(stuff->totalWidth, 1); length *= stuff->depth; -#ifdef INTERNAL_VS_EXTERNAL_PADDING - lengthProto = PixmapBytePadProto(stuff->totalWidth, 1); - lengthProto *= stuff->depth; -#endif } else if (stuff->format == ZPixmap) { if (pDraw->depth != stuff->depth) return BadMatch; length = PixmapBytePad(stuff->totalWidth, stuff->depth); -#ifdef INTERNAL_VS_EXTERNAL_PADDING - lengthProto = PixmapBytePadProto(stuff->totalWidth, stuff->depth); -#endif } else { @@ -413,13 +837,8 @@ ProcShmPutImage(client) return BadValue; } -#ifdef INTERNAL_VS_EXTERNAL_PADDING - VERIFY_SHMSIZE(shmdesc, stuff->offset, lengthProto * stuff->totalHeight, - client); -#else VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight, client); -#endif if (stuff->srcX > stuff->totalWidth) { client->errorValue = stuff->srcX; @@ -441,63 +860,6 @@ ProcShmPutImage(client) return BadValue; } -#ifdef INTERNAL_VS_EXTERNAL_PADDING - /* handle 64 bit case where protocol may pad to 32 and we want 64 - * In this case, length is what the server wants and lengthProto is - * what the protocol thinks it is. If the the two are different, - * copy the protocol version (i.e. the memory shared between the - * server and the client) to a version with a scanline pad of 64. - */ - if (length != lengthProto) - { - register int i; - char * stuffptr, /* pointer into protocol data */ - * tmpptr; /* new location to copy to */ - - if(!(tmpImage = (char *) ALLOCATE_LOCAL(length*stuff->totalHeight))) - return (BadAlloc); - tmpAlloced = 1; - - bzero(tmpImage,length*stuff->totalHeight); - - if (stuff->format == XYPixmap) - { - int lineBytes = PixmapBytePad(stuff->totalWidth, 1); - int lineBytesProto = PixmapBytePadProto(stuff->totalWidth, 1); - int depth = stuff->depth; - - stuffptr = shmdesc->addr + stuff->offset ; - tmpptr = tmpImage; - for (i = 0; i < stuff->totalHeight*stuff->depth; - stuffptr += lineBytesProto,tmpptr += lineBytes, i++) - bcopy(stuffptr,tmpptr,lineBytesProto); - } - else - { - for (i = 0, - stuffptr = shmdesc->addr + stuff->offset, - tmpptr=tmpImage; - i < stuff->totalHeight; - stuffptr += lengthProto,tmpptr += length, i++) - bcopy(stuffptr,tmpptr,lengthProto); - } - } - /* handle 64-bit case where stuff is not 64-bit aligned - */ - else if ((unsigned long)(shmdesc->addr+stuff->offset) & - (sizeof(long)-1)) - { - if(!(tmpImage = (char *) ALLOCATE_LOCAL(length*stuff->totalHeight))) - return (BadAlloc); - tmpAlloced = 1; - bcopy((char *)(shmdesc->addr+stuff->offset), - tmpImage, - length*stuff->totalHeight); - } - else - tmpImage = (char *)(shmdesc->addr+stuff->offset); -#endif - if ((((stuff->format == ZPixmap) && (stuff->srcX == 0)) || ((stuff->format != ZPixmap) && (stuff->srcX < screenInfo.bitmapScanlinePad) && @@ -509,11 +871,7 @@ ProcShmPutImage(client) stuff->dstX, stuff->dstY, stuff->totalWidth, stuff->srcHeight, stuff->srcX, stuff->format, -#ifdef INTERNAL_VS_EXTERNAL_PADDING - tmpImage + -#else shmdesc->addr + stuff->offset + -#endif (stuff->srcY * length)); else (*shmFuncs[pDraw->pScreen->myNum]->PutImage)( @@ -522,12 +880,7 @@ ProcShmPutImage(client) stuff->srcX, stuff->srcY, stuff->srcWidth, stuff->srcHeight, stuff->dstX, stuff->dstY, -#ifdef INTERNAL_VS_EXTERNAL_PADDING - tmpImage); - -#else shmdesc->addr + stuff->offset); -#endif if (stuff->sendEvent) { @@ -543,12 +896,7 @@ ProcShmPutImage(client) WriteEventsToClient(client, 1, (xEvent *) &ev); } -#ifdef INTERNAL_VS_EXTERNAL_PADDING - if (tmpAlloced) - DEALLOCATE_LOCAL(tmpImage); -#endif - - return (client->noClientException); + return (client->noClientException); } @@ -558,17 +906,11 @@ ProcShmGetImage(client) register ClientPtr client; { register DrawablePtr pDraw; - long lenPer, length; - Mask plane; + long lenPer = 0, length; + Mask plane = 0; xShmGetImageReply xgi; ShmDescPtr shmdesc; int n; -#ifdef INTERNAL_VS_EXTERNAL_PADDING - long widthBytesLine,widthBytesLineProto; - long lenPerProto,lengthProto; - char *tmpImage; - int tmpAlloced = 0; -#endif REQUEST(xShmGetImageReq); @@ -616,43 +958,18 @@ ProcShmGetImage(client) xgi.depth = pDraw->depth; if(stuff->format == ZPixmap) { -#ifdef INTERNAL_VS_EXTERNAL_PADDING - widthBytesLine = PixmapBytePad(stuff->width, pDraw->depth); - length = widthBytesLine * stuff->height; - widthBytesLineProto = PixmapBytePadProto(stuff->width, pDraw->depth); - lengthProto = widthBytesLineProto * stuff->height; -#else length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height; -#endif } else { -#ifdef INTERNAL_VS_EXTERNAL_PADDING - widthBytesLine = PixmapBytePad(stuff->width, 1); - lenPer = widthBytesLine * stuff->height; - plane = ((Mask)1) << (pDraw->depth - 1); - /* only planes asked for */ - length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1))); - - widthBytesLineProto = PixmapBytePadProto(stuff->width, 1); - lenPerProto = widthBytesLineProto * stuff->height; - lengthProto = lenPerProto * Ones(stuff->planeMask & - (plane | (plane - 1))); -#else lenPer = PixmapBytePad(stuff->width, 1) * stuff->height; plane = ((Mask)1) << (pDraw->depth - 1); /* only planes asked for */ length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1))); -#endif } -#ifdef INTERNAL_VS_EXTERNAL_PADDING - VERIFY_SHMSIZE(shmdesc, stuff->offset, lengthProto, client); - xgi.size = lengthProto; -#else VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client); xgi.size = length; -#endif if (length == 0) { @@ -660,105 +977,25 @@ ProcShmGetImage(client) } else if (stuff->format == ZPixmap) { -#ifdef INTERNAL_VS_EXTERNAL_PADDING - /* check for protocol/server padding differences. - */ - if ((widthBytesLine != widthBytesLineProto) || - ((unsigned long)shmdesc->addr + stuff->offset & (sizeof(long)-1))) - { - /* temp stuff for 64 bit alignment stuff */ - register char * bufPtr, * protoPtr; - register int i; - - if(!(tmpImage = (char *) ALLOCATE_LOCAL(length))) - return (BadAlloc); - tmpAlloced = 1; - - (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, stuff->planeMask, - tmpImage); - - /* for 64-bit server, convert image to pad to 32 bits - */ - bzero(shmdesc->addr + stuff->offset,lengthProto); - - for (i=0,bufPtr=tmpImage,protoPtr=shmdesc->addr + stuff->offset; - i < stuff->height; - bufPtr += widthBytesLine,protoPtr += widthBytesLineProto, - i++) - bcopy(bufPtr,protoPtr,widthBytesLineProto); - } - else - { - (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, stuff->planeMask, - shmdesc->addr + stuff->offset); - } -#else (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y, stuff->width, stuff->height, stuff->format, stuff->planeMask, shmdesc->addr + stuff->offset); -#endif } else { -#ifdef INTERNAL_VS_EXTERNAL_PADDING - /* check for protocol/server padding differences. - */ - if ((widthBytesLine != widthBytesLineProto) || - ((unsigned long)shmdesc->addr + stuff->offset & - (sizeof(long)-1))) - { - if(!(tmpImage = (char *) ALLOCATE_LOCAL(length))) - return (BadAlloc); - tmpAlloced = 1; - } -#endif length = stuff->offset; for (; plane; plane >>= 1) { if (stuff->planeMask & plane) { -#ifdef INTERNAL_VS_EXTERNAL_PADDING - if ((widthBytesLine != widthBytesLineProto) || - ((unsigned long)shmdesc->addr + stuff->offset & - (sizeof(long)-1))) - { - /* get image for each plane. - */ - (*pDraw->pScreen->GetImage)(pDraw, - stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, plane, - tmpImage); - - /* for 64-bit server, convert image to pad to 32 bits */ - bzero(shmdesc->addr+length, widthBytesLine); - bcopy(tmpImage, shmdesc->addr+length, widthBytesLineProto); - /* increment length */ - length += lenPerProto; - } - else /* no diff between protocol and server */ - { - (*pDraw->pScreen->GetImage)(pDraw, - stuff->x, stuff->y, - stuff->width, stuff->height, - stuff->format, plane, - shmdesc->addr + length); - length += lenPer; - } -#else (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y, stuff->width, stuff->height, stuff->format, plane, shmdesc->addr + length); length += lenPer; -#endif } } } @@ -771,11 +1008,6 @@ ProcShmGetImage(client) } WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi); -#ifdef INTERNAL_VS_EXTERNAL_PADDING - if (tmpAlloced) - DEALLOCATE_LOCAL(tmpImage); -#endif - return(client->noClientException); } @@ -794,8 +1026,10 @@ fbShmCreatePixmap (pScreen, width, height, depth, addr) return NullPixmap; if (!(*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth, - /*XXX*/depth, PixmapBytePad(width, depth), (pointer)addr)) + BitsPerPixel(depth), PixmapBytePad(width, depth), (pointer)addr)) { + (*pScreen->DestroyPixmap)(pPixmap); return NullPixmap; + } return pPixmap; } @@ -841,14 +1075,15 @@ CreatePmap: shmdesc->addr + stuff->offset); if (pMap) { +#ifdef PIXPRIV + pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc; +#endif + shmdesc->refcnt++; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) { - shmdesc->refcnt++; - if (AddResource(stuff->pid, ShmPixType, (pointer)shmdesc)) - return(client->noClientException); - FreeResource(stuff->pid, RT_NONE); + return(client->noClientException); } } return (BadAlloc); @@ -868,11 +1103,23 @@ ProcShmDispatch (client) case X_ShmDetach: return ProcShmDetach(client); case X_ShmPutImage: +#ifdef PANORAMIX + if ( !noPanoramiXExtension ) + return ProcPanoramiXShmPutImage(client); +#endif return ProcShmPutImage(client); case X_ShmGetImage: +#ifdef PANORAMIX + if ( !noPanoramiXExtension ) + return ProcPanoramiXShmGetImage(client); +#endif return ProcShmGetImage(client); case X_ShmCreatePixmap: - return ProcShmCreatePixmap(client); +#ifdef PANORAMIX + if ( !noPanoramiXExtension ) + return ProcPanoramiXShmCreatePixmap(client); +#endif + return ProcShmCreatePixmap(client); default: return BadRequest; } diff --git a/Xext/sleepuntil.c b/Xext/sleepuntil.c index 292924ed6..eb2b96a76 100644 --- a/Xext/sleepuntil.c +++ b/Xext/sleepuntil.c @@ -25,9 +25,11 @@ in this Software without prior written authorization from The Open Group. * * Author: Keith Packard, MIT X Consortium */ +/* $XFree86: xc/programs/Xserver/Xext/sleepuntil.c,v 3.5 2001/12/14 19:58:51 dawes Exp $ */ /* dixsleep.c - implement millisecond timeouts for X clients */ +#include "sleepuntil.h" #include "X.h" #include "Xmd.h" #include "misc.h" @@ -41,7 +43,13 @@ typedef struct _Sertafied { TimeStamp revive; ClientPtr pClient; XID id; - void (*notifyFunc)(); + void (*notifyFunc)( +#if NeedNestedPrototypes + ClientPtr /* client */, + pointer /* closure */ +#endif + ); + pointer closure; } SertafiedRec, *SertafiedPtr; @@ -49,11 +57,35 @@ static SertafiedPtr pPending; static RESTYPE SertafiedResType; static Bool BlockHandlerRegistered; static int SertafiedGeneration; -static void ClientAwaken(); -static int SertafiedDelete(); -static void SertafiedBlockHandler(); -static void SertafiedWakeupHandler(); +static void ClientAwaken( +#if NeedFunctionPrototypes + ClientPtr /* client */, + pointer /* closure */ +#endif +); +static int SertafiedDelete( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif +); +static void SertafiedBlockHandler( +#if NeedFunctionPrototypes + pointer /* data */, + OSTimePtr /* wt */, + pointer /* LastSelectMask */ +#endif +); +static void SertafiedWakeupHandler( +#if NeedFunctionPrototypes + pointer /* data */, + int /* i */, + pointer /* LastSelectMask */ +#endif +); + +int ClientSleepUntil (client, revive, notifyFunc, closure) ClientPtr client; TimeStamp *revive; @@ -152,7 +184,7 @@ SertafiedBlockHandler (data, wt, LastSelectMask) pointer LastSelectMask; { SertafiedPtr pReq, pNext; - unsigned long newdelay, olddelay; + unsigned long delay; TimeStamp now; if (!pPending) @@ -177,8 +209,8 @@ SertafiedBlockHandler (data, wt, LastSelectMask) pReq = pPending; if (!pReq) return; - newdelay = pReq->revive.milliseconds - now.milliseconds; - AdjustWaitForDelay (wt, newdelay); + delay = pReq->revive.milliseconds - now.milliseconds; + AdjustWaitForDelay (wt, delay); } static void diff --git a/Xext/sync.c b/Xext/sync.c index 8274d2522..079a804e3 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -50,10 +50,10 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* $XFree86: xc/programs/Xserver/Xext/sync.c,v 3.11 2001/12/14 19:58:51 dawes Exp $ */ #define NEED_REPLIES #define NEED_EVENTS -#include <stdio.h> #include "X.h" #include "Xproto.h" #include "Xmd.h" @@ -67,6 +67,15 @@ PERFORMANCE OF THIS SOFTWARE. #include "sync.h" #include "syncstr.h" +#ifdef EXTMODULE +#include "xf86_ansic.h" +#else +#include <stdio.h> +#if !defined(WIN32) && !defined(Lynx) +#include <sys/time.h> +#endif +#endif + /* * Local Global Variables */ @@ -87,13 +96,254 @@ static SyncCounter **SysCounterList = NULL; #define XSyncCAAllTrigger \ (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType) +static int +FreeAlarm( +#if NeedFunctionPrototypes + pointer /* addr */, + XID /* id */ +#endif +); + +static int +FreeAlarmClient( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif +); + +static int +FreeAwait( +#if NeedFunctionPrototypes + pointer /* addr */, + XID /* id */ +#endif +); + +static void +ServertimeBracketValues( +#if NeedFunctionPrototypes + pointer /* pCounter */, + CARD64 * /* pbracket_less */, + CARD64 * /* pbracket_greater */ +#endif +); + +static void +ServertimeQueryValue( +#if NeedFunctionPrototypes + pointer /* pCounter */, + CARD64 * /* pValue_return */ +#endif +); + +static void +ServertimeWakeupHandler( +#if NeedFunctionPrototypes + pointer /* env */, + int /* rc */, + pointer /* LastSelectMask */ +#endif +); + +static int +SyncInitTrigger( +#if NeedFunctionPrototypes + ClientPtr /* client */, + SyncTrigger * /* pTrigger */, + XSyncCounter /* counter */, + Mask /* changes */ +#endif +); + +static void +SAlarmNotifyEvent( +#if NeedFunctionPrototypes + xSyncAlarmNotifyEvent * /* from */, + xSyncAlarmNotifyEvent * /* to */ +#endif +); + +static void +SCounterNotifyEvent( +#if NeedFunctionPrototypes + xSyncCounterNotifyEvent * /* from */, + xSyncCounterNotifyEvent * /* to */ +#endif +); + +static void +ServertimeBlockHandler( +#if NeedFunctionPrototypes + pointer /* env */, + struct timeval ** /* wt */, + pointer /* LastSelectMask */ +#endif +); + +static int +SyncAddTriggerToCounter( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +extern void +SyncAlarmCounterDestroyed( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static void +SyncAlarmTriggerFired( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static void +SyncAwaitTriggerFired( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static int +SyncChangeAlarmAttributes( +#if NeedFunctionPrototypes + ClientPtr /* client */, + SyncAlarm * /* pAlarm */, + Mask /* mask */, + CARD32 * /* values */ +#endif +); + +static Bool +SyncCheckTriggerNegativeComparison( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static Bool +SyncCheckTriggerNegativeTransition( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static Bool +SyncCheckTriggerPositiveComparison( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static Bool +SyncCheckTriggerPositiveTransition( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static SyncCounter * +SyncCreateCounter( +#if NeedFunctionPrototypes + ClientPtr /* client */, + XSyncCounter /* id */, + CARD64 /* initialvalue */ +#endif +); + static void SyncComputeBracketValues( #if NeedFunctionPrototypes - SyncCounter * /* pCounter */, - Bool /* startOver */ + SyncCounter * /* pCounter */, + Bool /* startOver */ #endif ); +static void +SyncDeleteTriggerFromCounter( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static Bool +SyncEventSelectForAlarm( +#if NeedFunctionPrototypes + SyncAlarm * /* pAlarm */, + ClientPtr /* client */, + Bool /* wantevents */ +#endif +); + +static void +SyncInitServerTime( +#if NeedFunctionPrototypes + void +#endif +); + +static void +SyncResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif +); + +static void +SyncSendAlarmNotifyEvents( +#if NeedFunctionPrototypes + SyncAlarm * /* pAlarm */ +#endif +); + +static void +SyncSendCounterNotifyEvents( +#if NeedFunctionPrototypes + ClientPtr /* client */, + SyncAwait ** /* ppAwait */, + int /* num_events */ +#endif +); + +static DISPATCH_PROC(ProcSyncAwait); +static DISPATCH_PROC(ProcSyncChangeAlarm); +static DISPATCH_PROC(ProcSyncChangeCounter); +static DISPATCH_PROC(ProcSyncCreateAlarm); +static DISPATCH_PROC(ProcSyncCreateCounter); +static DISPATCH_PROC(ProcSyncDestroyAlarm); +static DISPATCH_PROC(ProcSyncDestroyCounter); +static DISPATCH_PROC(ProcSyncDispatch); +static DISPATCH_PROC(ProcSyncGetPriority); +static DISPATCH_PROC(ProcSyncInitialize); +static DISPATCH_PROC(ProcSyncListSystemCounters); +static DISPATCH_PROC(ProcSyncQueryAlarm); +static DISPATCH_PROC(ProcSyncQueryCounter); +static DISPATCH_PROC(ProcSyncSetCounter); +static DISPATCH_PROC(ProcSyncSetPriority); +static DISPATCH_PROC(SProcSyncAwait); +static DISPATCH_PROC(SProcSyncChangeAlarm); +static DISPATCH_PROC(SProcSyncChangeCounter); +static DISPATCH_PROC(SProcSyncCreateAlarm); +static DISPATCH_PROC(SProcSyncCreateCounter); +static DISPATCH_PROC(SProcSyncDestroyAlarm); +static DISPATCH_PROC(SProcSyncDestroyCounter); +static DISPATCH_PROC(SProcSyncDispatch); +static DISPATCH_PROC(SProcSyncGetPriority); +static DISPATCH_PROC(SProcSyncInitialize); +static DISPATCH_PROC(SProcSyncListSystemCounters); +static DISPATCH_PROC(SProcSyncQueryAlarm); +static DISPATCH_PROC(SProcSyncQueryCounter); +static DISPATCH_PROC(SProcSyncSetCounter); +static DISPATCH_PROC(SProcSyncSetPriority); + /* Each counter maintains a simple linked list of triggers that are * interested in the counter. The two functions below are used to * delete and add triggers on this list. @@ -462,26 +712,26 @@ SyncAlarmTriggerFired(pTrigger) { Bool overflow; CARD64 oldvalue; - SyncTrigger *pTrigger = &pAlarm->trigger; + SyncTrigger *paTrigger = &pAlarm->trigger; /* "The alarm is updated by repeatedly adding delta to the * value of the trigger and re-initializing it until it * becomes FALSE." */ - oldvalue = pTrigger->test_value; + oldvalue = paTrigger->test_value; /* XXX really should do something smarter here */ do { - XSyncValueAdd(&pTrigger->test_value, pTrigger->test_value, + XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value, pAlarm->delta, &overflow); } while (!overflow && - (*pTrigger->CheckTrigger)(pTrigger, - pTrigger->pCounter->value)); + (*paTrigger->CheckTrigger)(paTrigger, + paTrigger->pCounter->value)); - new_test_value = pTrigger->test_value; - pTrigger->test_value = oldvalue; + new_test_value = paTrigger->test_value; + paTrigger->test_value = oldvalue; /* "If this update would cause value to fall outside the range * for an INT64...no change is made to value (test-value) and @@ -710,7 +960,6 @@ SyncChangeAlarmAttributes(client, pAlarm, mask, values) Mask mask; CARD32 *values; { - SyncAlarmClientList *pClients; int status; XSyncCounter counter; Mask origmask = mask; @@ -719,9 +968,9 @@ SyncChangeAlarmAttributes(client, pAlarm, mask, values) while (mask) { - int index = lowbit(mask); - mask &= ~index; - switch (index) + int index2 = lowbit(mask); + mask &= ~index2; + switch (index2) { case XSyncCACounter: mask &= ~XSyncCACounter; @@ -998,7 +1247,6 @@ FreeAlarm(addr, id) XID id; { SyncAlarm *pAlarm = (SyncAlarm *) addr; - SyncAlarmClientList *pClient; pAlarm->state = XSyncAlarmDestroyed; @@ -1139,7 +1387,6 @@ static int ProcSyncInitialize(client) ClientPtr client; { - REQUEST(xSyncInitializeReq); xSyncInitializeReply rep; int n; @@ -1166,10 +1413,9 @@ static int ProcSyncListSystemCounters(client) ClientPtr client; { - REQUEST(xSyncListSystemCountersReq); xSyncListSystemCountersReply rep; int i, len; - xSyncSystemCounter *list, *walklist; + xSyncSystemCounter *list = NULL, *walklist = NULL; REQUEST_SIZE_MATCH(xSyncListSystemCountersReq); @@ -1318,7 +1564,6 @@ ProcSyncCreateCounter(client) ClientPtr client; { REQUEST(xSyncCreateCounterReq); - SyncCounter *pCounter; CARD64 initial; REQUEST_SIZE_MATCH(xSyncCreateCounterReq); @@ -1440,9 +1685,8 @@ ProcSyncAwait(client) { REQUEST(xSyncAwaitReq); int len, items; - int n, i; + int i; xSyncWaitCondition *pProtocolWaitConds; - int ret; SyncAwaitUnion *pAwaitUnion; SyncAwait *pAwait; int status; @@ -1606,7 +1850,6 @@ ProcSyncCreateAlarm(client) REQUEST(xSyncCreateAlarmReq); SyncAlarm *pAlarm; int status; - int i; unsigned long len, vmask; SyncTrigger *pTrigger; @@ -2063,8 +2306,6 @@ static int SProcSyncDispatch(client) ClientPtr client; { - int n; - REQUEST(xReq); switch (stuff->data) @@ -2154,8 +2395,6 @@ SyncResetProc(extEntry) } -static void SyncInitServerTime(); - /* * ** Initialise the extension. */ @@ -2188,8 +2427,8 @@ SyncExtensionInit() SyncReqCode = extEntry->base; SyncEventBase = extEntry->eventBase; SyncErrorBase = extEntry->errorBase; - EventSwapVector[SyncEventBase + XSyncCounterNotify] = SCounterNotifyEvent; - EventSwapVector[SyncEventBase + XSyncAlarmNotify] = SAlarmNotifyEvent; + EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent; + EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent; /* * Although SERVERTIME is implemented by the OS layer, we initialise it @@ -2211,9 +2450,6 @@ SyncExtensionInit() */ -#ifndef WIN32 -#include <sys/time.h> -#endif static pointer ServertimeCounter; static XSyncValue Now; diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c index 4977fdf88..1d3b416db 100644 --- a/Xext/xcmisc.c +++ b/Xext/xcmisc.c @@ -26,28 +26,44 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/Xserver/Xext/xcmisc.c,v 3.5 2001/12/14 19:58:51 dawes Exp $ */ +#define NEED_EVENTS +#define NEED_REPLIES #include "X.h" #include "Xproto.h" #include "misc.h" #include "os.h" #include "dixstruct.h" #include "extnsionst.h" +#include "swaprep.h" #include "xcmiscstr.h" static unsigned char XCMiscCode; -static int ProcXCMiscDispatch(), SProcXCMiscDispatch(); -static void XCMiscResetProc(); -extern void Swap32Write(); /* XXX should be in header file */ + +static void XCMiscResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif +); + +static DISPATCH_PROC(ProcXCMiscDispatch); +static DISPATCH_PROC(ProcXCMiscGetVersion); +static DISPATCH_PROC(ProcXCMiscGetXIDList); +static DISPATCH_PROC(ProcXCMiscGetXIDRange); +static DISPATCH_PROC(SProcXCMiscDispatch); +static DISPATCH_PROC(SProcXCMiscGetVersion); +static DISPATCH_PROC(SProcXCMiscGetXIDList); +static DISPATCH_PROC(SProcXCMiscGetXIDRange); void XCMiscExtensionInit() { - ExtensionEntry *extEntry, *AddExtension(); + ExtensionEntry *extEntry; - if (extEntry = AddExtension(XCMiscExtensionName, 0, 0, + if ((extEntry = AddExtension(XCMiscExtensionName, 0, 0, ProcXCMiscDispatch, SProcXCMiscDispatch, - XCMiscResetProc, StandardMinorOpcode)) + XCMiscResetProc, StandardMinorOpcode)) != 0) XCMiscCode = (unsigned char)extEntry->base; DeclareExtensionSecurity(XCMiscExtensionName, TRUE); } @@ -63,7 +79,6 @@ static int ProcXCMiscGetVersion(client) register ClientPtr client; { - REQUEST(xXCMiscGetVersionReq); xXCMiscGetVersionReply rep; register int n; @@ -86,7 +101,6 @@ static int ProcXCMiscGetXIDRange(client) register ClientPtr client; { - REQUEST(xXCMiscGetXIDRangeReq); xXCMiscGetXIDRangeReply rep; register int n; XID min_id, max_id; @@ -137,7 +151,7 @@ ProcXCMiscGetXIDList(client) WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *)&rep); if (count) { - client->pSwapReplyFunc = Swap32Write; + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, count * sizeof(XID), pids); } DEALLOCATE_LOCAL(pids); diff --git a/Xext/xprint.c b/Xext/xprint.c index 6e2013140..db9a25135 100644 --- a/Xext/xprint.c +++ b/Xext/xprint.c @@ -1,4 +1,4 @@ -/* $Xorg: xprint.c,v 1.5 2001/03/05 20:42:36 pookie Exp $ */ +/* $Xorg: xprint.c,v 1.5 2001/03/05 20:42:26 pookie Exp $ */ /* (c) Copyright 1996 Hewlett-Packard Company (c) Copyright 1996 International Business Machines Corp. @@ -64,8 +64,11 @@ copyright holders. ** ********************************************************* ** ********************************************************************/ +/* $XFree86: xc/programs/Xserver/Xext/xprint.c,v 1.13 2001/11/23 19:21:31 dawes Exp $ */ +#define _XP_PRINT_SERVER_ #include "X.h" +#include "Xos.h" #define NEED_EVENTS #include "Xproto.h" #undef NEED_EVENTS @@ -76,105 +79,90 @@ copyright holders. #include "extnsionst.h" #include "dixstruct.h" #include "Xatom.h" -#define _XP_PRINT_SERVER_ #include "Print.h" #include "Printstr.h" -#undef _XP_PRINT_SERVER_ #include "../Xprint/DiPrint.h" - -extern WindowPtr *WindowTable; /* declared in dix:globals.c */ - -extern WindowPtr XpDiValidatePrinter(); -extern char *XpDiGetDriverName(); -extern char *XpGetAttributes(); -extern char *XpGetOneAttribute(); -extern int XpRehashPrinterList(); -extern void XpSetFontResFunc(); - -static void XpResetProc(); - -static int ProcXpDispatch(); -static int ProcXpSwappedDispatch(); - -static int ProcXpQueryVersion(); -static int ProcXpGetPrinterList(); -static int ProcXpCreateContext(); -static int ProcXpSetContext(); -static int ProcXpGetContext(); -static int ProcXpDestroyContext(); -static int ProcXpGetContextScreen(); -static int ProcXpStartJob(); -static int ProcXpEndJob(); -static int ProcXpStartDoc(); -static int ProcXpEndDoc(); -static int ProcXpStartPage(); -static int ProcXpEndPage(); -static int ProcXpSelectInput(); -static int ProcXpInputSelected(); -static int ProcXpPutDocumentData(); -static int ProcXpGetDocumentData(); -static int ProcXpGetAttributes(); -static int ProcXpGetOneAttribute(); -static int ProcXpSetAttributes(); -static int ProcXpRehashPrinterList(); -static int ProcXpQueryScreens(); -static int ProcXpGetPageDimensions(); -static int ProcXpSetImageResolution(); -static int ProcXpGetImageResolution(); - -static void SwapXpNotifyEvent(); -static void SwapXpAttributeEvent(); - -static int SProcXpGetPrinterList(); -static int SProcXpCreateContext(); -static int SProcXpSetContext(); -static int SProcXpGetContext(); -static int SProcXpDestroyContext(); -static int SProcXpGetContextScreen(); -static int SProcXpStartJob(); -static int SProcXpEndJob(); -static int SProcXpStartDoc(); -static int SProcXpEndDoc(); -static int SProcXpStartPage(); -static int SProcXpEndPage(); -static int SProcXpSelectInput(); -static int SProcXpInputSelected(); -static int SProcXpPutDocumentData(); -static int SProcXpGetDocumentData(); -static int SProcXpGetAttributes(); -static int SProcXpGetOneAttribute(); -static int SProcXpSetAttributes(); -static int SProcXpRehashPrinterList(); -static int SProcXpGetPageDimensions(); -static int SProcXpSetImageResolution(); -static int SProcXpGetImageResolution(); - -static void SendXpNotify(); -static void SendAttributeNotify(); -static int XpFreeClient(); -static int XpFreeContext(); -static int XpFreePage(); -static int XpFreeEvents(); -static Bool XpCloseScreen(); -static CARD32 GetAllEventMasks(); -static struct _XpEvent *AddEventRec(); -static void DeleteEventRec(); -static struct _XpEvent *FindEventRec(); -static struct _XpClient *CreateXpClient(); -static void FreeXpClient(); -static void InitContextPrivates(); -static void ResetContextPrivates(); -static struct _XpClient *FindClient(); -static struct _XpClient *AcquireClient(); +#include "../Xprint/attributes.h" + +static void XpResetProc(ExtensionEntry *); + +static int ProcXpDispatch(ClientPtr); +static int ProcXpSwappedDispatch(ClientPtr); + +static int ProcXpQueryVersion(ClientPtr); +static int ProcXpGetPrinterList(ClientPtr); +static int ProcXpCreateContext(ClientPtr); +static int ProcXpSetContext(ClientPtr); +static int ProcXpGetContext(ClientPtr); +static int ProcXpDestroyContext(ClientPtr); +static int ProcXpGetContextScreen(ClientPtr); +static int ProcXpStartJob(ClientPtr); +static int ProcXpEndJob(ClientPtr); +static int ProcXpStartDoc(ClientPtr); +static int ProcXpEndDoc(ClientPtr); +static int ProcXpStartPage(ClientPtr); +static int ProcXpEndPage(ClientPtr); +static int ProcXpSelectInput(ClientPtr); +static int ProcXpInputSelected(ClientPtr); +static int ProcXpPutDocumentData(ClientPtr); +static int ProcXpGetDocumentData(ClientPtr); +static int ProcXpGetAttributes(ClientPtr); +static int ProcXpGetOneAttribute(ClientPtr); +static int ProcXpSetAttributes(ClientPtr); +static int ProcXpRehashPrinterList(ClientPtr); +static int ProcXpQueryScreens(ClientPtr); +static int ProcXpGetPageDimensions(ClientPtr); +static int ProcXpSetImageResolution(ClientPtr); +static int ProcXpGetImageResolution(ClientPtr); + +static void SwapXpNotifyEvent(xPrintPrintEvent *, xPrintPrintEvent *); +static void SwapXpAttributeEvent(xPrintAttributeEvent *, xPrintAttributeEvent *); + +static int SProcXpGetPrinterList(ClientPtr); +static int SProcXpCreateContext(ClientPtr); +static int SProcXpSetContext(ClientPtr); +static int SProcXpGetContext(ClientPtr); +static int SProcXpDestroyContext(ClientPtr); +static int SProcXpGetContextScreen(ClientPtr); +static int SProcXpStartJob(ClientPtr); +static int SProcXpEndJob(ClientPtr); +static int SProcXpStartDoc(ClientPtr); +static int SProcXpEndDoc(ClientPtr); +static int SProcXpStartPage(ClientPtr); +static int SProcXpEndPage(ClientPtr); +static int SProcXpSelectInput(ClientPtr); +static int SProcXpInputSelected(ClientPtr); +static int SProcXpPutDocumentData(ClientPtr); +static int SProcXpGetDocumentData(ClientPtr); +static int SProcXpGetAttributes(ClientPtr); +static int SProcXpGetOneAttribute(ClientPtr); +static int SProcXpSetAttributes(ClientPtr); +static int SProcXpRehashPrinterList(ClientPtr); +static int SProcXpGetPageDimensions(ClientPtr); +static int SProcXpSetImageResolution(ClientPtr); +static int SProcXpGetImageResolution(ClientPtr); + +static void SendXpNotify(XpContextPtr, int, int); +static void SendAttributeNotify(XpContextPtr, int); +static int XpFreeClient(pointer, XID); +static int XpFreeContext(pointer, XID); +static int XpFreePage(pointer, XID); +static Bool XpCloseScreen(int, ScreenPtr); +static CARD32 GetAllEventMasks(XpContextPtr); +static struct _XpClient *CreateXpClient(ClientPtr); +static void InitContextPrivates(XpContextPtr); +static void ResetContextPrivates(void); +static struct _XpClient *FindClient(XpContextPtr, ClientPtr); +static struct _XpClient *AcquireClient(XpContextPtr, ClientPtr); typedef struct _driver { struct _driver *next; char *name; - int (* CreateContext)(); + int (* CreateContext)(XpContextPtr); } XpDriverRec, *XpDriverPtr; typedef struct _xpScreen { - Bool (* CloseScreen)(); + Bool (* CloseScreen)(int, ScreenPtr); struct _driver *drivers; } XpScreenRec, *XpScreenPtr; @@ -196,6 +184,8 @@ typedef struct _XpClient { XID contextClientID; /* unneeded sanity check? */ } XpClientRec, *XpClientPtr; +static void FreeXpClient(XpClientPtr, Bool); + /* * Each StartPage request specifies a window which forms the top level * window of the page. One of the following structs is created as a @@ -240,8 +230,7 @@ static XpScreenPtr XpScreens[MAXSCREENS]; static unsigned char XpReqCode; static int XpEventBase; static int XpErrorBase; -static int XpGeneration = 0; -static int XpWindowPrivateIndex; +static unsigned long XpGeneration = 0; static int XpClientPrivateIndex; /* Variables for the context private machinery. @@ -293,9 +282,9 @@ static CARD32 allEvents = XPPrintMask | XPAttributeMask; */ void -XpExtensionInit() +XpExtensionInit(void) { - ExtensionEntry *extEntry, *AddExtension(); + ExtensionEntry *extEntry; int i; RTclient = CreateNewResourceType(XpFreeClient); @@ -309,8 +298,8 @@ XpExtensionInit() XpReqCode = (unsigned char)extEntry->base; XpEventBase = extEntry->eventBase; XpErrorBase = extEntry->errorBase; - EventSwapVector[XpEventBase] = SwapXpNotifyEvent; - EventSwapVector[XpEventBase+1] = SwapXpAttributeEvent; + EventSwapVector[XpEventBase] = (EventSwapPtr) SwapXpNotifyEvent; + EventSwapVector[XpEventBase+1] = (EventSwapPtr) SwapXpAttributeEvent; } if(XpGeneration != serverGeneration) @@ -347,15 +336,15 @@ XpExtensionInit() } static void -XpResetProc(extEntry) - ExtensionEntry extEntry; +XpResetProc(ExtensionEntry *extEntry) { - int i; - /* * We can't free up the XpScreens recs here, because extensions are * closed before screens, and our CloseScreen function uses the XpScreens * recs. + + int i; + for(i = 0; i < MAXSCREENS; i++) { if(XpScreens[i] != (XpScreenPtr)NULL) @@ -366,11 +355,9 @@ XpResetProc(extEntry) } static Bool -XpCloseScreen(index, pScreen) - int index; - ScreenPtr pScreen; +XpCloseScreen(int index, ScreenPtr pScreen) { - Bool (* CloseScreen)(); + Bool (* CloseScreen)(int, ScreenPtr); CloseScreen = XpScreens[index]->CloseScreen; if(XpScreens[index] != (XpScreenPtr)NULL) @@ -399,9 +386,9 @@ XpCloseScreen(index, pScreen) return (*CloseScreen)(index, pScreen); } +#if 0 /* NOT USED */ static void -FreeScreenEntry(pScreenEntry) - XpScreenPtr pScreenEntry; +FreeScreenEntry(XpScreenPtr pScreenEntry) { XpDriverPtr pDriver; @@ -416,6 +403,7 @@ FreeScreenEntry(pScreenEntry) } xfree(pScreenEntry); } +#endif /* * XpRegisterInitFunc tells the print extension which screens @@ -426,24 +414,20 @@ FreeScreenEntry(pScreenEntry) * whenever a context gets created for a particular driver on this screen. */ void -XpRegisterInitFunc(pScreen, driverName, initContext) - ScreenPtr pScreen; - char *driverName; - int (*initContext)(); +XpRegisterInitFunc(ScreenPtr pScreen, char *driverName, int (*initContext)(struct _XpContext *)) { XpDriverPtr pDriver; - if(XpScreens[pScreen->myNum] == (XpScreenPtr)NULL) + if(XpScreens[pScreen->myNum] == 0) { if((XpScreens[pScreen->myNum] = - (XpScreenPtr) Xalloc(sizeof(XpScreenRec))) == (XpScreenPtr)NULL) + (XpScreenPtr) Xalloc(sizeof(XpScreenRec))) == 0) return; - XpScreens[pScreen->myNum]->CloseScreen = (Bool(*)())NULL; - XpScreens[pScreen->myNum]->drivers = (XpDriverPtr)NULL; + XpScreens[pScreen->myNum]->CloseScreen = 0; + XpScreens[pScreen->myNum]->drivers = 0; } - if((pDriver = (XpDriverPtr)Xalloc(sizeof(XpDriverRec))) == - (XpDriverPtr)NULL) + if((pDriver = (XpDriverPtr)Xalloc(sizeof(XpDriverRec))) == 0) return; pDriver->next = XpScreens[pScreen->myNum]->drivers; pDriver->name = driverName; @@ -452,8 +436,7 @@ XpRegisterInitFunc(pScreen, driverName, initContext) } static int -ProcXpDispatch(client) - ClientPtr client; +ProcXpDispatch(ClientPtr client) { REQUEST(xReq); @@ -515,8 +498,7 @@ ProcXpDispatch(client) } static int -ProcXpSwappedDispatch(client) - ClientPtr client; +ProcXpSwappedDispatch(ClientPtr client) { int temp; REQUEST(xReq); @@ -581,10 +563,9 @@ ProcXpSwappedDispatch(client) } static int -ProcXpQueryVersion(client) - ClientPtr client; +ProcXpQueryVersion(ClientPtr client) { - REQUEST(xPrintQueryVersionReq); + /* REQUEST(xPrintQueryVersionReq); */ xPrintQueryVersionReply rep; register int n; long l; @@ -614,12 +595,12 @@ ProcXpQueryVersion(client) ******************************************************************************/ static int -ProcXpGetPrinterList(client) - ClientPtr client; +ProcXpGetPrinterList(ClientPtr client) { REQUEST(xPrintGetPrinterListReq); - int totalSize, numEntries; - XpDiListEntry **pList, *pEntry; + int totalSize; + int numEntries; + XpDiListEntry **pList; xPrintGetPrinterListReply *rep; int n, i, totalBytes; long l; @@ -699,10 +680,9 @@ ProcXpGetPrinterList(client) ******************************************************************************/ static int -ProcXpQueryScreens(client) - ClientPtr client; +ProcXpQueryScreens(ClientPtr client) { - REQUEST(xPrintQueryScreensReq); + /* REQUEST(xPrintQueryScreensReq); */ int i, numPrintScreens, totalSize; WINDOW *pWinId; xPrintQueryScreensReply *rep; @@ -752,8 +732,7 @@ ProcXpQueryScreens(client) } static int -ProcXpGetPageDimensions(client) - ClientPtr client; +ProcXpGetPageDimensions(ClientPtr client) { REQUEST(xPrintGetPageDimensionsReq); CARD16 width, height; @@ -774,12 +753,12 @@ ProcXpGetPageDimensions(client) return XpErrorBase+XPBadContext; } - if(pContext->funcs.GetMediumDimensions != (int (*)())NULL) + if(pContext->funcs.GetMediumDimensions != 0) result = pContext->funcs.GetMediumDimensions(pContext, &width, &height); else return BadImplementation; - if(pContext->funcs.GetReproducibleArea != (int (*)())NULL) + if(pContext->funcs.GetReproducibleArea != 0) result = pContext->funcs.GetReproducibleArea(pContext, &rect); else return BadImplementation; @@ -814,8 +793,7 @@ ProcXpGetPageDimensions(client) } static int -ProcXpSetImageResolution(client) - ClientPtr client; +ProcXpSetImageResolution(ClientPtr client) { REQUEST(xPrintSetImageResolutionReq); xPrintSetImageResolutionReply rep; @@ -836,7 +814,7 @@ ProcXpSetImageResolution(client) } rep.prevRes = pContext->imageRes; - if(pContext->funcs.SetImageResolution != (int (*)())NULL) + if(pContext->funcs.SetImageResolution != 0) result = pContext->funcs.SetImageResolution(pContext, (int)stuff->imageRes, &status); @@ -863,14 +841,11 @@ ProcXpSetImageResolution(client) } static int -ProcXpGetImageResolution(client) - ClientPtr client; +ProcXpGetImageResolution(ClientPtr client) { REQUEST(xPrintGetImageResolutionReq); xPrintGetImageResolutionReply rep; XpContextPtr pContext; - Bool status; - int result; REQUEST_SIZE_MATCH(xPrintGetImageResolutionReq); @@ -912,10 +887,9 @@ ProcXpGetImageResolution(client) ******************************************************************************/ static int -ProcXpRehashPrinterList(client) - ClientPtr client; +ProcXpRehashPrinterList(ClientPtr client) { - REQUEST(xPrintRehashPrinterListReq); + /* REQUEST(xPrintRehashPrinterListReq); */ REQUEST_SIZE_MATCH(xPrintRehashPrinterListReq); @@ -950,15 +924,13 @@ ProcXpRehashPrinterList(client) * is then called. */ static int -ProcXpCreateContext(client) - ClientPtr client; +ProcXpCreateContext(ClientPtr client) { REQUEST(xPrintCreateContextReq); XpScreenPtr pPrintScreen; WindowPtr pRoot; - char *printerName, *driverName; + char *driverName; XpContextPtr pContext; - XpClientPtr pNewPrintClient; int result = Success; XpDriverPtr pDriver; @@ -969,7 +941,7 @@ ProcXpCreateContext(client) /* * Check to see if the printer name is valid. */ - if((pRoot = XpDiValidatePrinter(stuff + 1, stuff->printerNameLen)) == + if((pRoot = XpDiValidatePrinter((char *)(stuff + 1), stuff->printerNameLen)) == (WindowPtr)NULL) return BadMatch; @@ -998,22 +970,22 @@ ProcXpCreateContext(client) pContext->clientSlept = (ClientPtr)NULL; pContext->imageRes = 0; - pContext->funcs.DestroyContext = (int (*)())NULL; - pContext->funcs.StartJob = (int (*)())NULL; - pContext->funcs.EndJob = (int (*)())NULL; - pContext->funcs.StartDoc = (int (*)())NULL; - pContext->funcs.EndDoc = (int (*)())NULL; - pContext->funcs.StartPage = (int (*)())NULL; - pContext->funcs.EndPage = (int (*)())NULL; - pContext->funcs.PutDocumentData = (int (*)())NULL; - pContext->funcs.GetDocumentData = (int (*)())NULL; - pContext->funcs.GetAttributes = (char * (*)())NULL; - pContext->funcs.GetOneAttribute = (char * (*)())NULL; - pContext->funcs.SetAttributes = (int (*)())NULL; - pContext->funcs.AugmentAttributes = (int (*)())NULL; - pContext->funcs.GetMediumDimensions = (int (*)())NULL; - pContext->funcs.GetReproducibleArea = (int (*)())NULL; - pContext->funcs.SetImageResolution = (int (*)())NULL; + pContext->funcs.DestroyContext = 0; + pContext->funcs.StartJob = 0; + pContext->funcs.EndJob = 0; + pContext->funcs.StartDoc = 0; + pContext->funcs.EndDoc = 0; + pContext->funcs.StartPage = 0; + pContext->funcs.EndPage = 0; + pContext->funcs.PutDocumentData = 0; + pContext->funcs.GetDocumentData = 0; + pContext->funcs.GetAttributes = 0; + pContext->funcs.GetOneAttribute = 0; + pContext->funcs.SetAttributes = 0; + pContext->funcs.AugmentAttributes = 0; + pContext->funcs.GetMediumDimensions = 0; + pContext->funcs.GetReproducibleArea = 0; + pContext->funcs.SetImageResolution = 0; if((pContext->printerName = (char *)xalloc(stuff->printerNameLen + 1)) == (char *)NULL) @@ -1034,7 +1006,7 @@ ProcXpCreateContext(client) { if(!strcmp(driverName, pDriver->name)) { - if(pDriver->CreateContext != (Bool (*)())NULL) + if(pDriver->CreateContext != 0) pDriver->CreateContext(pContext); else return BadImplementation; @@ -1053,8 +1025,7 @@ ProcXpCreateContext(client) * and stashes the contextID in the client's devPrivate. */ static int -ProcXpSetContext(client) - ClientPtr client; +ProcXpSetContext(ClientPtr client) { REQUEST(xPrintSetContextReq); @@ -1111,22 +1082,18 @@ ProcXpSetContext(client) } XpContextPtr -XpGetPrintContext(client) - ClientPtr client; +XpGetPrintContext(ClientPtr client) { return (client->devPrivates[XpClientPrivateIndex].ptr); } static int -ProcXpGetContext(client) - ClientPtr client; +ProcXpGetContext(ClientPtr client) { - REQUEST(xPrintGetContextReq); + /* REQUEST(xPrintGetContextReq); */ xPrintGetContextReply rep; XpContextPtr pContext; - XpClientPtr pNewPrintClient; - int result = Success; register int n; register long l; @@ -1156,14 +1123,11 @@ ProcXpGetContext(client) * to be called. */ static int -ProcXpDestroyContext(client) - ClientPtr client; +ProcXpDestroyContext(ClientPtr client) { REQUEST(xPrintDestroyContextReq); XpContextPtr pContext; - XpClientPtr pXpClient; - ClientPtr curClient; REQUEST_SIZE_MATCH(xPrintDestroyContextReq); @@ -1185,8 +1149,7 @@ ProcXpDestroyContext(client) } static int -ProcXpGetContextScreen(client) - ClientPtr client; +ProcXpGetContextScreen(ClientPtr client) { REQUEST(xPrintGetContextScreenReq); xPrintGetContextScreenReply rep; @@ -1229,9 +1192,7 @@ ProcXpGetContextScreen(client) * itself. */ static int -XpFreeContext(data, id) - pointer data; - XID id; +XpFreeContext(pointer data, XID id) { XpContextPtr pContext = (XpContextPtr)data; @@ -1245,7 +1206,7 @@ XpFreeContext(data, id) XpPagePtr pPage = (XpPagePtr)LookupIDByType( pContext->pageWin, RTpage); - pContext->funcs.EndPage(pContext, pWin, TRUE); + pContext->funcs.EndPage(pContext, pWin); SendXpNotify(pContext, XPEndPageNotify, TRUE); pContext->state &= ~PAGE_STARTED; if(pPage) @@ -1259,7 +1220,7 @@ XpFreeContext(data, id) pContext->state &= ~DOC_RAW_STARTED; pContext->state &= ~DOC_COOKED_STARTED; } - if(pContext->funcs.EndJob != (int (*)())NULL) + if(pContext->funcs.EndJob != 0) { pContext->funcs.EndJob(pContext, TRUE); SendXpNotify(pContext, XPEndJobNotify, TRUE); @@ -1272,7 +1233,7 @@ XpFreeContext(data, id) * Tell the driver we're destroying the context * This allows the driver to free and ContextPrivate data */ - if(pContext->funcs.DestroyContext != (int (*)())NULL) + if(pContext->funcs.DestroyContext != 0) pContext->funcs.DestroyContext(pContext); /* Free up all the XpClientRecs */ @@ -1291,11 +1252,10 @@ XpFreeContext(data, id) * is freed. It simply calls the FreeXpClient routine to do the work. */ static int -XpFreeClient(data, id) - pointer data; - XID id; +XpFreeClient(pointer data, XID id) { FreeXpClient((XpClientPtr)data, TRUE); + return Success; } /* @@ -1309,9 +1269,7 @@ XpFreeClient(data, id) * XpClientRec's XID). */ static void -FreeXpClient(pXpClient, freeResource) - XpClientPtr pXpClient; - Bool freeResource; +FreeXpClient(XpClientPtr pXpClient, Bool freeResource) { XpClientPtr pCurrent, pPrev; XpContextPtr pContext = pXpClient->context; @@ -1355,8 +1313,7 @@ FreeXpClient(pXpClient, freeResource) * freeing of the Rec when the client's connection is closed. */ static XpClientPtr -CreateXpClient(client) - ClientPtr client; +CreateXpClient(ClientPtr client) { XpClientPtr pNewPrintClient; XID clientResource; @@ -1389,9 +1346,7 @@ CreateXpClient(client) * the page resource. */ static int -XpFreePage(data, id) - pointer data; - XID id; +XpFreePage(pointer data, XID id) { XpPagePtr page = (XpPagePtr)data; int result = Success; @@ -1401,9 +1356,8 @@ XpFreePage(data, id) if(page->context != (XpContextPtr)NULL && page->context->state & PAGE_STARTED) { - XpScreenPtr pPrintScreen = XpScreens[page->context->screenNum]; - if(page->context->funcs.EndPage != (int (*)())NULL) - result = page->context->funcs.EndPage(page->context, pWin, TRUE); + if(page->context->funcs.EndPage != 0) + result = page->context->funcs.EndPage(page->context, pWin); SendXpNotify(page->context, XPEndPageNotify, (int)TRUE); page->context->pageWin = 0; /* None, NULL??? XXX */ } @@ -1420,8 +1374,7 @@ XpFreePage(data, id) */ static void -InitContextPrivates(context) - XpContextPtr context; +InitContextPrivates(XpContextPtr context) { register char *ptr; DevUnion *ppriv; @@ -1450,7 +1403,7 @@ InitContextPrivates(context) } static void -ResetContextPrivates() +ResetContextPrivates(void) { contextPrivateCount = 0; contextPrivateLen = 0; @@ -1461,15 +1414,13 @@ ResetContextPrivates() } int -XpAllocateContextPrivateIndex() +XpAllocateContextPrivateIndex(void) { return contextPrivateCount++; } Bool -XpAllocateContextPrivate(index, amount) - int index; - unsigned amount; +XpAllocateContextPrivate(int index, unsigned amount) { unsigned oldamount; @@ -1497,9 +1448,7 @@ XpAllocateContextPrivate(index, amount) } static XpClientPtr -AcquireClient(pContext, client) - XpContextPtr pContext; - ClientPtr client; +AcquireClient(XpContextPtr pContext, ClientPtr client) { XpClientPtr pXpClient; @@ -1517,9 +1466,7 @@ AcquireClient(pContext, client) } static XpClientPtr -FindClient(pContext, client) - XpContextPtr pContext; - ClientPtr client; +FindClient(XpContextPtr pContext, ClientPtr client) { XpClientPtr pXpClient; @@ -1539,8 +1486,7 @@ FindClient(pContext, client) ******************************************************************************/ static int -ProcXpStartJob(client) - ClientPtr client; +ProcXpStartJob(ClientPtr client) { REQUEST(xPrintStartJobReq); XpContextPtr pContext; @@ -1564,9 +1510,10 @@ ProcXpStartJob(client) } pPrintScreen = XpScreens[pContext->screenNum]; - if(pContext->funcs.StartJob != (int (*)())NULL) + if(pContext->funcs.StartJob != 0) result = pContext->funcs.StartJob(pContext, - (stuff->saveData == XPGetData)? TRUE:FALSE); + (stuff->saveData == XPGetData)? TRUE:FALSE, + client); else return BadImplementation; @@ -1583,12 +1530,10 @@ ProcXpStartJob(client) } static int -ProcXpEndJob(client) - ClientPtr client; +ProcXpEndJob(ClientPtr client) { REQUEST(xPrintEndJobReq); XpScreenPtr pPrintScreen; - WindowPtr pWin; int result = Success; XpContextPtr pContext; @@ -1617,8 +1562,8 @@ ProcXpEndJob(client) if(stuff->cancel != TRUE) return XpErrorBase+XPBadSequence; - if(pContext->funcs.EndPage != (int (*)())NULL) - result = pContext->funcs.EndPage(pContext, pWin, TRUE); + if(pContext->funcs.EndPage != 0) + result = pContext->funcs.EndPage(pContext, pWin); else return BadImplementation; @@ -1632,7 +1577,7 @@ ProcXpEndJob(client) if(result != Success) return result; } - if(pContext->funcs.EndDoc != (int (*)())NULL) + if(pContext->funcs.EndDoc != 0) result = pContext->funcs.EndDoc(pContext, stuff->cancel); else return BadImplementation; @@ -1640,7 +1585,7 @@ ProcXpEndJob(client) SendXpNotify(pContext, XPEndDocNotify, stuff->cancel); } - if(pContext->funcs.EndJob != (int (*)())NULL) + if(pContext->funcs.EndJob != 0) result = pContext->funcs.EndJob(pContext, stuff->cancel); else return BadImplementation; @@ -1656,9 +1601,7 @@ ProcXpEndJob(client) } static Bool -DoStartDoc(client, c) - ClientPtr client; - XpStDocPtr c; +DoStartDoc(ClientPtr client, XpStDocPtr c) { XpScreenPtr pPrintScreen; int result = Success; @@ -1670,7 +1613,7 @@ DoStartDoc(client, c) if(!c->slept) { c->slept = TRUE; - ClientSleep(client, DoStartDoc, (pointer) c); + ClientSleep(client, (ClientSleepProcPtr)DoStartDoc, (pointer) c); c->pContext->clientSlept = client; } return TRUE; @@ -1678,7 +1621,7 @@ DoStartDoc(client, c) pPrintScreen = XpScreens[pContext->screenNum]; - if(pContext->funcs.StartDoc != (int (*)())NULL) + if(pContext->funcs.StartDoc != 0) result = pContext->funcs.StartDoc(pContext, c->type); else { @@ -1699,11 +1642,9 @@ DoStartDoc(client, c) } static int -ProcXpStartDoc(client) - ClientPtr client; +ProcXpStartDoc(ClientPtr client) { REQUEST(xPrintStartDocReq); - XpScreenPtr pPrintScreen; int result = Success; XpContextPtr pContext; XpStDocPtr c; @@ -1738,8 +1679,7 @@ ProcXpStartDoc(client) } static int -ProcXpEndDoc(client) - ClientPtr client; +ProcXpEndDoc(ClientPtr client) { REQUEST(xPrintEndDocReq); XpScreenPtr pPrintScreen; @@ -1767,8 +1707,8 @@ ProcXpEndDoc(client) XpPagePtr pPage = (XpPagePtr)LookupIDByType( pContext->pageWin, RTpage); - if(pContext->funcs.EndPage != (int (*)())NULL) - result = pContext->funcs.EndPage(pContext, pWin, TRUE); + if(pContext->funcs.EndPage != 0) + result = pContext->funcs.EndPage(pContext, pWin); else return BadImplementation; @@ -1783,7 +1723,7 @@ ProcXpEndDoc(client) return result; } - if(pContext->funcs.EndDoc != (int (*)())NULL) + if(pContext->funcs.EndDoc != 0) result = pContext->funcs.EndDoc(pContext, stuff->cancel); else return BadImplementation; @@ -1800,9 +1740,9 @@ ProcXpEndDoc(client) } static Bool -DoStartPage(client, c) - ClientPtr client; - XpStPagePtr c; +DoStartPage( + ClientPtr client, + XpStPagePtr c) { XpScreenPtr pPrintScreen; WindowPtr pWin = c->pWin; @@ -1816,7 +1756,7 @@ DoStartPage(client, c) if(!c->slept) { c->slept = TRUE; - ClientSleep(client, DoStartPage, (pointer) c); + ClientSleep(client, (ClientSleepProcPtr)DoStartPage, (pointer) c); c->pContext->clientSlept = client; } return TRUE; @@ -1825,7 +1765,7 @@ DoStartPage(client, c) if(!(pContext->state & DOC_COOKED_STARTED)) { /* Implied StartDoc if it was omitted */ - if(pContext->funcs.StartDoc != (int (*)())NULL) + if(pContext->funcs.StartDoc != 0) result = pContext->funcs.StartDoc(pContext, XPDocNormal); else { @@ -1878,7 +1818,7 @@ DoStartPage(client, c) pPrintScreen = XpScreens[pContext->screenNum]; - if(pContext->funcs.StartPage != (int (*)())NULL) + if(pContext->funcs.StartPage != 0) result = pContext->funcs.StartPage(pContext, pWin); else { @@ -1897,15 +1837,12 @@ DoStartPage(client, c) } static int -ProcXpStartPage(client) - ClientPtr client; +ProcXpStartPage(ClientPtr client) { REQUEST(xPrintStartPageReq); - XpScreenPtr pPrintScreen; WindowPtr pWin; int result = Success; XpContextPtr pContext; - XpPagePtr pPage; XpStPagePtr c; REQUEST_SIZE_MATCH(xPrintStartPageReq); @@ -1944,8 +1881,7 @@ ProcXpStartPage(client) } static int -ProcXpEndPage(client) - ClientPtr client; +ProcXpEndPage(ClientPtr client) { REQUEST(xPrintEndPageReq); XpScreenPtr pPrintScreen; @@ -1967,8 +1903,8 @@ ProcXpEndPage(client) pWin = (WindowPtr )LookupIDByType(pContext->pageWin, RT_WINDOW); /* Call the ddx's EndPage proc. */ - if(pContext->funcs.EndPage != (int (*)())NULL) - result = pContext->funcs.EndPage(pContext, pWin, stuff->cancel); + if(pContext->funcs.EndPage != 0) + result = pContext->funcs.EndPage(pContext, pWin); else return BadImplementation; @@ -1996,14 +1932,13 @@ ProcXpEndPage(client) ******************************************************************************/ static int -ProcXpPutDocumentData(client) - ClientPtr client; +ProcXpPutDocumentData(ClientPtr client) { REQUEST(xPrintPutDocumentDataReq); XpContextPtr pContext; DrawablePtr pDraw; int result = Success; - int len, totalSize; + unsigned totalSize; char *pData, *pDoc_fmt, *pOptions; REQUEST_AT_LEAST_SIZE(xPrintPutDocumentDataReq); @@ -2040,7 +1975,7 @@ ProcXpPutDocumentData(client) if((totalSize + (sz_xPrintPutDocumentDataReq >> 2)) != client->req_len) return BadLength; - if(pContext->funcs.PutDocumentData != (int (*)())NULL) + if(pContext->funcs.PutDocumentData != 0) { result = (*pContext->funcs.PutDocumentData)(pContext, pDraw, pData, stuff->len_data, @@ -2058,12 +1993,10 @@ ProcXpPutDocumentData(client) } static int -ProcXpGetDocumentData(client) - ClientPtr client; +ProcXpGetDocumentData(ClientPtr client) { REQUEST(xPrintGetDocumentDataReq); xPrintGetDocumentDataReply rep; - XpScreenPtr pPrintScreen; XpContextPtr pContext; int result = Success; @@ -2079,7 +2012,7 @@ ProcXpGetDocumentData(client) return XpErrorBase+XPBadContext; } - if(pContext->funcs.GetDocumentData == (int (*)())NULL) + if(pContext->funcs.GetDocumentData == 0) return BadImplementation; if(!(pContext->state & JOB_GET_DATA) || @@ -2132,8 +2065,7 @@ ProcXpGetDocumentData(client) ******************************************************************************/ static int -ProcXpGetAttributes(client) - ClientPtr client; +ProcXpGetAttributes(ClientPtr client) { REQUEST(xPrintGetAttributesReq); XpContextPtr pContext; @@ -2163,7 +2095,7 @@ ProcXpGetAttributes(client) return XpErrorBase+XPBadContext; } - if(pContext->funcs.GetAttributes == (char *(*)())NULL) + if(pContext->funcs.GetAttributes == 0) return BadImplementation; if((attrs = (*pContext->funcs.GetAttributes)(pContext, stuff->type)) == (char *)NULL) @@ -2203,8 +2135,7 @@ ProcXpGetAttributes(client) } static int -ProcXpSetAttributes(client) - ClientPtr client; +ProcXpSetAttributes(ClientPtr client) { REQUEST(xPrintSetAttributesReq); int result = Success; @@ -2236,7 +2167,7 @@ ProcXpSetAttributes(client) return XpErrorBase+XPBadContext; } - if(pContext->funcs.SetAttributes == (int (*)())NULL) + if(pContext->funcs.SetAttributes == 0) return BadImplementation; /* @@ -2275,14 +2206,14 @@ ProcXpSetAttributes(client) } static int -ProcXpGetOneAttribute(client) - ClientPtr client; +ProcXpGetOneAttribute(ClientPtr client) { REQUEST(xPrintGetOneAttributeReq); XpContextPtr pContext; char *value, *attrName; xPrintGetOneAttributeReply *pRep; - int totalSize, n; + int totalSize; + int n; unsigned long l; REQUEST_AT_LEAST_SIZE(xPrintGetOneAttributeReq); @@ -2316,7 +2247,7 @@ ProcXpGetOneAttribute(client) return XpErrorBase+XPBadContext; } - if(pContext->funcs.GetOneAttribute == (char *(*)())NULL) + if(pContext->funcs.GetOneAttribute == 0) return BadImplementation; if((value = (*pContext->funcs.GetOneAttribute)(pContext, stuff->type, attrName)) == (char *)NULL) @@ -2364,8 +2295,7 @@ ProcXpGetOneAttribute(client) static int -ProcXpSelectInput(client) - ClientPtr client; +ProcXpSelectInput(ClientPtr client) { REQUEST(xPrintSelectInputReq); int result = Success; @@ -2403,14 +2333,12 @@ ProcXpSelectInput(client) } static int -ProcXpInputSelected(client) - ClientPtr client; +ProcXpInputSelected(ClientPtr client) { REQUEST(xPrintInputSelectedReq); xPrintInputSelectedReply rep; register int n; - long l, allMask; - WindowPtr pWin; + long l; XpClientPtr pXpClient; XpContextPtr pContext; @@ -2446,9 +2374,7 @@ ProcXpInputSelected(client) } static void -SendAttributeNotify(pContext, which) - XpContextPtr pContext; - int which; +SendAttributeNotify(XpContextPtr pContext, int which) { XpClientPtr pXpClient; xPrintAttributeEvent ae; @@ -2473,11 +2399,9 @@ SendAttributeNotify(pContext, which) WriteEventsToClient (client, 1, (xEvent *) &ae); } } + static void -SendXpNotify(pContext, which, val) - XpContextPtr pContext; - int which; - int val; +SendXpNotify(XpContextPtr pContext, int which, int val) { XpClientPtr pXpClient; xPrintPrintEvent pe; @@ -2505,8 +2429,7 @@ SendXpNotify(pContext, which, val) } static CARD32 -GetAllEventMasks(pContext) - XpContextPtr pContext; +GetAllEventMasks(XpContextPtr pContext) { XpClientPtr pPrintClient; CARD32 totalMask = (CARD32)0; @@ -2526,11 +2449,8 @@ GetAllEventMasks(pContext) * does not currently have a context set. */ XpContextPtr -XpContextOfClient(client) - ClientPtr client; +XpContextOfClient(ClientPtr client) { - XpContextPtr pContext; - return (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr; } @@ -2542,8 +2462,7 @@ XpContextOfClient(client) ******************************************************************************/ static int -SProcXpCreateContext(client) - ClientPtr client; +SProcXpCreateContext(ClientPtr client) { int i; long n; @@ -2558,8 +2477,7 @@ SProcXpCreateContext(client) } static int -SProcXpGetPrinterList(client) - ClientPtr client; +SProcXpGetPrinterList(ClientPtr client) { int i; long n; @@ -2573,11 +2491,9 @@ SProcXpGetPrinterList(client) } static int -SProcXpRehashPrinterList(client) - ClientPtr client; +SProcXpRehashPrinterList(ClientPtr client) { int i; - long n; REQUEST(xPrintRehashPrinterListReq); swaps(&stuff->length, i); @@ -2585,11 +2501,9 @@ SProcXpRehashPrinterList(client) } static int -SProcXpSetContext(client) - ClientPtr client; +SProcXpSetContext(ClientPtr client) { int i; - long n; REQUEST(xPrintSetContextReq); swaps(&stuff->length, i); @@ -2598,8 +2512,7 @@ SProcXpSetContext(client) } static int -SProcXpGetContext(client) - ClientPtr client; +SProcXpGetContext(ClientPtr client) { int i; @@ -2609,8 +2522,7 @@ SProcXpGetContext(client) } static int -SProcXpDestroyContext(client) - ClientPtr client; +SProcXpDestroyContext(ClientPtr client) { int i; long n; @@ -2622,8 +2534,7 @@ SProcXpDestroyContext(client) } static int -SProcXpGetContextScreen(client) - ClientPtr client; +SProcXpGetContextScreen(ClientPtr client) { int i; long n; @@ -2635,8 +2546,7 @@ SProcXpGetContextScreen(client) } static int -SProcXpInputSelected(client) - ClientPtr client; +SProcXpInputSelected(ClientPtr client) { int i; long n; @@ -2648,8 +2558,7 @@ SProcXpInputSelected(client) } static int -SProcXpStartJob(client) - ClientPtr client; +SProcXpStartJob(ClientPtr client) { int i; @@ -2659,8 +2568,7 @@ SProcXpStartJob(client) } static int -SProcXpEndJob(client) - ClientPtr client; +SProcXpEndJob(ClientPtr client) { int i; @@ -2670,8 +2578,7 @@ SProcXpEndJob(client) } static int -SProcXpStartDoc(client) - ClientPtr client; +SProcXpStartDoc(ClientPtr client) { int i; @@ -2681,8 +2588,7 @@ SProcXpStartDoc(client) } static int -SProcXpEndDoc(client) - ClientPtr client; +SProcXpEndDoc(ClientPtr client) { int i; @@ -2692,8 +2598,7 @@ SProcXpEndDoc(client) } static int -SProcXpStartPage(client) - ClientPtr client; +SProcXpStartPage(ClientPtr client) { int i; long n; @@ -2705,8 +2610,7 @@ SProcXpStartPage(client) } static int -SProcXpEndPage(client) - ClientPtr client; +SProcXpEndPage(ClientPtr client) { int i; @@ -2716,8 +2620,7 @@ SProcXpEndPage(client) } static int -SProcXpPutDocumentData(client) - ClientPtr client; +SProcXpPutDocumentData(ClientPtr client) { long n; int i; @@ -2732,8 +2635,7 @@ SProcXpPutDocumentData(client) } static int -SProcXpGetDocumentData(client) - ClientPtr client; +SProcXpGetDocumentData(ClientPtr client) { long n; int i; @@ -2746,8 +2648,7 @@ SProcXpGetDocumentData(client) } static int -SProcXpGetAttributes(client) - ClientPtr client; +SProcXpGetAttributes(ClientPtr client) { long n; int i; @@ -2759,8 +2660,7 @@ SProcXpGetAttributes(client) } static int -SProcXpSetAttributes(client) - ClientPtr client; +SProcXpSetAttributes(ClientPtr client) { long n; int i; @@ -2773,8 +2673,7 @@ SProcXpSetAttributes(client) } static int -SProcXpGetOneAttribute(client) - ClientPtr client; +SProcXpGetOneAttribute(ClientPtr client) { long n; int i; @@ -2787,8 +2686,7 @@ SProcXpGetOneAttribute(client) } static int -SProcXpSelectInput(client) - ClientPtr client; +SProcXpSelectInput(ClientPtr client) { long n; int i; @@ -2799,9 +2697,9 @@ SProcXpSelectInput(client) swapl(&stuff->printContext, n); return ProcXpSelectInput(client); } + static int -SProcXpGetPageDimensions(client) - ClientPtr client; +SProcXpGetPageDimensions(ClientPtr client) { long n; int i; @@ -2811,9 +2709,9 @@ SProcXpGetPageDimensions(client) swapl(&stuff->printContext, n); return ProcXpGetPageDimensions(client); } + static int -SProcXpSetImageResolution(client) - ClientPtr client; +SProcXpSetImageResolution(ClientPtr client) { long n; int i; @@ -2824,9 +2722,9 @@ SProcXpSetImageResolution(client) swaps(&stuff->imageRes, i); return ProcXpSetImageResolution(client); } + static int -SProcXpGetImageResolution(client) - ClientPtr client; +SProcXpGetImageResolution(ClientPtr client) { long n; int i; @@ -2838,8 +2736,7 @@ SProcXpGetImageResolution(client) } static void -SwapXpNotifyEvent(src, dst) - xPrintPrintEvent *src, *dst; +SwapXpNotifyEvent(xPrintPrintEvent *src, xPrintPrintEvent *dst) { /* * Swap the sequence number and context fields. @@ -2856,8 +2753,7 @@ SwapXpNotifyEvent(src, dst) } static void -SwapXpAttributeEvent(src, dst) - xPrintAttributeEvent *src, *dst; +SwapXpAttributeEvent(xPrintAttributeEvent *src, xPrintAttributeEvent *dst) { /* * Swap the sequence number and context fields. diff --git a/Xext/xtest.c b/Xext/xtest.c index a07cf6186..47e7418d8 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/Xserver/Xext/xtest.c,v 3.7 2001/12/14 19:58:51 dawes Exp $ */ #include "X.h" #define NEED_EVENTS @@ -37,6 +38,8 @@ from The Open Group. #include "windowstr.h" #include "inputstr.h" #include "scrnintstr.h" +#include "dixevents.h" +#include "sleepuntil.h" #define _XTEST_SERVER_ #include "XTest.h" #include "xteststr.h" @@ -44,27 +47,49 @@ from The Open Group. #include "XI.h" #include "XIproto.h" #define EXTENSION_EVENT_BASE 64 +#include "extinit.h" /* LookupDeviceIntRec */ #endif /* XINPUT */ +#ifdef EXTMODULE +#include "xf86_ansic.h" +#endif static unsigned char XTestReqCode; -static int ProcXTestDispatch(), SProcXTestDispatch(); -static void XTestResetProc(); -static int XTestSwapFakeInput(); -CursorPtr GetSpriteCursor(); -WindowPtr GetCurrentRootWindow(); + #ifdef XINPUT extern int DeviceValuator; -DeviceIntPtr LookupDeviceIntRec(); #endif /* XINPUT */ +static void XTestResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif +); +static int XTestSwapFakeInput( +#if NeedFunctionPrototypes + ClientPtr /* client */, + xReq * /* req */ +#endif +); + +static DISPATCH_PROC(ProcXTestCompareCursor); +static DISPATCH_PROC(ProcXTestDispatch); +static DISPATCH_PROC(ProcXTestFakeInput); +static DISPATCH_PROC(ProcXTestGetVersion); +static DISPATCH_PROC(ProcXTestGrabControl); +static DISPATCH_PROC(SProcXTestCompareCursor); +static DISPATCH_PROC(SProcXTestDispatch); +static DISPATCH_PROC(SProcXTestFakeInput); +static DISPATCH_PROC(SProcXTestGetVersion); +static DISPATCH_PROC(SProcXTestGrabControl); + void XTestExtensionInit() { - ExtensionEntry *extEntry, *AddExtension(); + ExtensionEntry *extEntry; - if (extEntry = AddExtension(XTestExtensionName, 0, 0, + if ((extEntry = AddExtension(XTestExtensionName, 0, 0, ProcXTestDispatch, SProcXTestDispatch, - XTestResetProc, StandardMinorOpcode)) + XTestResetProc, StandardMinorOpcode)) != 0) XTestReqCode = (unsigned char)extEntry->base; } @@ -79,7 +104,6 @@ static int ProcXTestGetVersion(client) register ClientPtr client; { - REQUEST(xXTestGetVersionReq); xXTestGetVersionReply rep; register int n; @@ -142,12 +166,12 @@ ProcXTestFakeInput(client) int nev; int n; xEvent *ev; - DeviceIntPtr dev; + DeviceIntPtr dev = NULL; WindowPtr root; int type; #ifdef XINPUT Bool extension = FALSE; - deviceValuator *dv; + deviceValuator *dv = NULL; int base; int *values; #endif /* XINPUT */ @@ -468,7 +492,7 @@ XTestSwapFakeInput(client, req) register int nev; register xEvent *ev; xEvent sev; - void (*proc)(), NotImplemented(); + EventSwapPtr proc; nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent); for (ev = (xEvent *)&req[1]; --nev >= 0; ev++) @@ -476,7 +500,7 @@ XTestSwapFakeInput(client, req) /* Swap event */ proc = EventSwapVector[ev->u.u.type & 0177]; /* no swapping proc; invalid event type? */ - if (!proc || (int (*)()) proc == (int (*)()) NotImplemented) { + if (!proc || proc == NotImplemented) { client->errorValue = ev->u.u.type; return BadValue; } diff --git a/Xext/xtest1dd.c b/Xext/xtest1dd.c index 38c977557..8a2b779be 100644 --- a/Xext/xtest1dd.c +++ b/Xext/xtest1dd.c @@ -52,6 +52,7 @@ Telephone and Telegraph Company or of the Regents of the University of California. */ +/* $XFree86: xc/programs/Xserver/Xext/xtest1dd.c,v 3.5 2001/12/14 19:58:52 dawes Exp $ */ /*************************************************************** * include files @@ -70,6 +71,8 @@ University of California. #define XTestSERVER_SIDE #include "xtestext1.h" +#include "xtest1dd.h" + /*************************************************************** * defines ***************************************************************/ @@ -96,8 +99,6 @@ extern int XTestFakeAckType; /* * used in the WriteReplyToClient macro */ -extern void (* ReplySwapVector[256]) (); - extern int exclusive_steal; /*************************************************************** @@ -286,24 +287,62 @@ KeyCode xtest_command_key = 0; * function declarations ***************************************************************/ -void flush_input_actions(); -void XTestStealJumpData(); -void XTestGenerateEvent(); -void XTestGetPointerPos(); -void XTestJumpPointer(); - -static void parse_key_fake(); -static void parse_motion_fake(); -static void parse_jump_fake(); -static void parse_delay_fake(); -static void send_ack(); -static void start_play_clock(); -static void compute_action_time(); -static int find_residual_time(); +static void parse_key_fake( +#if NeedFunctionPrototypes + XTestKeyInfo * /* fkey */ +#endif + ); +static void parse_motion_fake( +#if NeedFunctionPrototypes + XTestMotionInfo * /* fmotion */ +#endif + ); +static void parse_jump_fake( +#if NeedFunctionPrototypes + XTestJumpInfo * /* fjump */ +#endif + ); +static void parse_delay_fake( +#if NeedFunctionPrototypes + XTestDelayInfo * /* tevent */ +#endif + ); +static void send_ack( +#if NeedFunctionPrototypes + ClientPtr /* client */ +#endif + ); +static void start_play_clock( +#if NeedFunctionPrototypes + void +#endif + ); +static void compute_action_time( +#if NeedFunctionPrototypes + struct timeval * /* rtime */ +#endif + ); +static int find_residual_time( +#if NeedFunctionPrototypes + struct timeval * /* rtime */ +#endif + ); -static CARD16 check_time_event(); -static CARD32 current_ms(); -static int there_is_room(); +static CARD16 check_time_event( +#if NeedFunctionPrototypes + void +#endif + ); +static CARD32 current_ms( +#if NeedFunctionPrototypes + struct timeval * /* otime */ +#endif + ); +static int there_is_room( +#if NeedFunctionPrototypes + int /* actsize */ +#endif + ); /****************************************************************************** * @@ -450,8 +489,8 @@ XTestStealJumpData(jx, jy, dev_type) /* * the x and y coordinates to jump to */ -short jx; -short jy; +int jx; +int jy; /* * which device caused the jump */ @@ -527,7 +566,7 @@ current_ms(otime) struct timeval *otime; { struct timeval tval; - unsigned long ctime; + unsigned long the_ms; unsigned long sec; unsigned long usec; @@ -556,8 +595,8 @@ struct timeval *otime; * compute the number of milliseconds contained in * 'sec' seconds and 'usec' microseconds */ - ctime = (sec * 1000000 + usec) / 1000; - return (ctime); + the_ms = (sec * 1000000L + usec) / 1000L; + return (the_ms); } /****************************************************************************** @@ -673,8 +712,8 @@ XTestStealMotionData(dx, dy, dev_type, mx, my) /* * the x and y delta motion of the locator */ -short dx; -short dy; +int dx; +int dy; /* * which locator did the moving */ @@ -682,8 +721,8 @@ int dev_type; /* * the x and y position of the locator before the delta motion */ -short mx; -short my; +int mx; +int my; { /* * pointer to a XTestMOTION_ACTION input action @@ -791,20 +830,20 @@ XTestStealKeyData(keycode, keystate, dev_type, locx, locy) /* * which key/button moved */ -CARD8 keycode; +unsigned keycode; /* * whether the key/button was pressed or released */ -char keystate; +int keystate; /* * which device caused the input action */ -int dev_type; +int dev_type; /* * the x and y coordinates of the locator when the action happenned */ -short locx; -short locy; +int locx; +int locy; { /* * pointer to key/button motion input action @@ -814,7 +853,7 @@ short locy; * time delta from previous event */ CARD16 tchar; - char keytrans; + char keytrans = 0; /* * update the logical position of the locator if the physical position @@ -1445,8 +1484,8 @@ struct timeval *rtime; * the current time. */ static int -find_residual_time(rtime) -struct timeval *rtime; +find_residual_time(the_residual) +struct timeval *the_residual; { /* * if > 0, there is time to wait. If < 0, then don't wait @@ -1507,8 +1546,8 @@ struct timeval *rtime; } else { - rtime->tv_usec = pusec - busec; - rtime->tv_sec = 0; + the_residual->tv_usec = pusec - busec; + the_residual->tv_sec = 0; } } else @@ -1519,14 +1558,14 @@ struct timeval *rtime; * 'borrow' a second's worth of microseconds * from the seconds left to wait */ - rtime->tv_usec = 1000000 - busec + pusec; + the_residual->tv_usec = 1000000 - busec + pusec; psec--; - rtime->tv_sec = psec - bsec; + the_residual->tv_sec = psec - bsec; } else { - rtime->tv_sec = psec - bsec; - rtime->tv_usec = pusec - busec; + the_residual->tv_sec = psec - bsec; + the_residual->tv_usec = pusec - busec; } } } @@ -1540,8 +1579,8 @@ struct timeval *rtime; /* * set the time to wait to 0 */ - rtime->tv_sec = 0; - rtime->tv_usec = 0; + the_residual->tv_sec = 0; + the_residual->tv_usec = 0; } return(wait); } diff --git a/Xext/xtest1di.c b/Xext/xtest1di.c index cd8f5e727..43c1d58d1 100644 --- a/Xext/xtest1di.c +++ b/Xext/xtest1di.c @@ -52,6 +52,7 @@ Telephone and Telegraph Company or of the Regents of the University of California. */ +/* $XFree86: xc/programs/Xserver/Xext/xtest1di.c,v 3.3 2001/12/14 19:58:52 dawes Exp $ */ /***************************************************************************** * include files @@ -72,6 +73,8 @@ University of California. #define XTestSERVER_SIDE #include "xtestext1.h" +#include "xtest1dd.h" + /***************************************************************************** * defines ****************************************************************************/ @@ -81,10 +84,6 @@ University of California. ****************************************************************************/ /* - * holds the addresses of the routines that handle byte-swapping of replys - */ -extern void (* ReplySwapVector[256]) (); -/* * id of client using XTestGetInput * * defined in xtest1dd.c @@ -137,31 +136,44 @@ static XID current_client_id; * function declarations ****************************************************************************/ -static int ProcXTestDispatch(); -static int SProcXTestDispatch(); -static void XTestResetProc(); -static int ProcTestFakeInput(); -static int SProcTestFakeInput(); -static int ProcTestGetInput(); -static int SProcTestGetInput(); -static int ProcTestStopInput(); -static int SProcTestStopInput(); -static int ProcTestReset(); -static int SProcTestReset(); -static int ProcTestQueryInputSize(); -static int SProcTestQueryInputSize(); -static void SReplyXTestDispatch(); -static void SEventXTestDispatch(); -void NotImplemented(); - -void abort_play_back(); -void return_input_array_size(); -void steal_input(); -void stop_stealing_input(); -void flush_input_actions(); -void parse_fake_input(); - -static int XTestCurrentClientGone(); +static DISPATCH_PROC(ProcXTestDispatch); +static DISPATCH_PROC(SProcXTestDispatch); +static DISPATCH_PROC(ProcTestFakeInput); +static DISPATCH_PROC(SProcTestFakeInput); +static DISPATCH_PROC(ProcTestGetInput); +static DISPATCH_PROC(SProcTestGetInput); +static DISPATCH_PROC(ProcTestStopInput); +static DISPATCH_PROC(SProcTestStopInput); +static DISPATCH_PROC(ProcTestReset); +static DISPATCH_PROC(SProcTestReset); +static DISPATCH_PROC(ProcTestQueryInputSize); +static DISPATCH_PROC(SProcTestQueryInputSize); + +static void XTestResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* unused */ +#endif + ); +static void SReplyXTestDispatch( +#if NeedFunctionPrototypes + ClientPtr /* client_ptr */, + int /* size */, + char * /* reply_ptr */ +#endif + ); +static void SEventXTestDispatch( +#if NeedFunctionPrototypes + xEvent * /* from */, + xEvent * /* to */ +#endif + ); + +static int XTestCurrentClientGone( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif + ); /***************************************************************************** * @@ -180,10 +192,6 @@ XTestExtension1Init() * holds the pointer to the extension entry structure */ ExtensionEntry *extEntry; - /* - * This routine adds the extension to the server extension table. - */ - ExtensionEntry *AddExtension(); extEntry = AddExtension(XTestEXTENSION_NAME, XTestEVENT_COUNT, @@ -213,7 +221,7 @@ XTestExtension1Init() * install the routine to handle byte-swapping the replies * for this extension in the ReplySwapVector table */ - ReplySwapVector[XTestReqCode] = SReplyXTestDispatch; + ReplySwapVector[XTestReqCode] = (ReplySwapPtr) SReplyXTestDispatch; /* * install the routine to handle byte-swapping the events * for this extension in the EventSwapVector table @@ -647,7 +655,6 @@ static int ProcTestStopInput(client) register ClientPtr client; { - REQUEST(xTestStopInputReq); REQUEST_SIZE_MATCH(xTestStopInputReq); if (on_steal_input && (current_xtest_client == client)) { @@ -686,7 +693,6 @@ static int ProcTestReset(client) register ClientPtr client; { - REQUEST(xTestResetReq); REQUEST_SIZE_MATCH(xTestResetReq); on_steal_input = FALSE; exclusive_steal = FALSE; @@ -711,7 +717,6 @@ static int ProcTestQueryInputSize(client) register ClientPtr client; { - REQUEST(xTestQueryInputSizeReq); REQUEST_SIZE_MATCH(xTestQueryInputSizeReq); /* * defined in xtest1dd.c @@ -728,14 +733,16 @@ ProcTestQueryInputSize(client) * connected to it. It must put eveything back the way it was before * this extension was installed. */ +/*ARGSUSED*/ static void -XTestResetProc() +XTestResetProc(unused) + ExtensionEntry * unused; { /* * remove the routine to handle byte-swapping the replies * for this extension in the ReplySwapVector table */ - ReplySwapVector[XTestReqCode] = NotImplemented; + ReplySwapVector[XTestReqCode] = ReplyNotSwappd; /* * remove the routine to handle byte-swapping the events * for this extension in the EventSwapVector table @@ -755,7 +762,7 @@ XTestResetProc() /***************************************************************************** * - * ProcTestQueryInputSize + * PXTestCurrentClientGone * * This routine is called when a client that has asked for input actions * to be sent to it "goes away". This routine must clean up the |