Release 5 XTEST Public Patch MIT X Consortium This patch contains changes necessary to build the XTEST extension. You do not need to apply this patch unless you want to build the XTEST extension (usually to run the X Test Suite). Before applying this patch, you must have R5 public patches 1 through 17 already applied. To apply this patch: cd to the top of the source tree (to the directory containing the "mit" and "contrib" subdirectories) and do: patch -p -s < ThisFile Patch will work silently unless an error occurs. You will likely get the following warning messages, which can be ignored: mkdir: mit: File exists mkdir: mit/extensions: File exists mkdir: mit/extensions/include: File exists mkdir: mit: File exists mkdir: mit/extensions: File exists mkdir: mit/extensions/include: File exists mkdir: mit: File exists mkdir: mit/extensions: File exists mkdir: mit/extensions/lib: File exists mkdir: mit: File exists mkdir: mit/extensions: File exists mkdir: mit/extensions/lib: File exists mkdir: mit/extensions/lib/xtest: File exists mkdir: mit: File exists mkdir: mit/extensions: File exists mkdir: mit/extensions/server: File exists mkdir: mit: File exists mkdir: mit/extensions: File exists mkdir: mit/extensions/server: File exists If you want to watch patch do its thing, leave out the "-s" argument to patch. This patch creates the following new files: mit/extensions/include/XTest.h mit/extensions/include/xteststr.h mit/extensions/lib/xtest/Imakefile mit/extensions/lib/xtest/XTest.c mit/extensions/server/sleepuntil.c mit/extensions/server/xtest.c If you are using a symbolic link tree, you will need to create new links. To build a server with the XTEST extension enabled, you will need to edit your vendor.cf or site.def file in mit/config/. For most servers, you can insert the following line into the "AfterVendorCF" part of your site.def: #define ExtensionOSDefines -DXTEST If your vendor.cf already contains a #define for ExtensionOSDefines (e.g., x386.cf does), then you can edit the .cf file and add -DXTEST to ExtensionOSDefines there. Finally, to rebuild after applying this patch, cd to the "mit" subdirectory and do: make Everything >& every.log Note: this will *not* "clean" your tree. *** /tmp/,RCSt1016565 Wed Sep 9 15:41:50 1992 --- mit/extensions/include/Imakefile Wed Sep 9 15:41:51 1992 *************** *** 1,4 **** ! XCOMM $XConsortium: Imakefile,v 1.24 91/07/16 23:08:47 gildea Exp $ #if BuildPexClients || BuildPexExt #define IHaveSubdirs #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' --- 1,4 ---- ! XCOMM $XConsortium: Imakefile,v 1.24.1.1 92/09/09 15:25:53 rws Exp $ #if BuildPexClients || BuildPexExt #define IHaveSubdirs #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' *************** *** 6,12 **** #endif HEADERS = Xext.h multibuf.h shape.h XShm.h MITMisc.h XI.h XInput.h XIproto.h \ ! xtestext1.h INSTALLFLAGS = $(INSTINCFLAGS) all:: --- 6,12 ---- #endif HEADERS = Xext.h multibuf.h shape.h XShm.h MITMisc.h XI.h XInput.h XIproto.h \ ! XTest.h xtestext1.h INSTALLFLAGS = $(INSTINCFLAGS) all:: *** /dev/null Wed Sep 9 15:40:33 1992 --- mit/extensions/include/XTest.h Mon Apr 20 13:15:18 1992 *************** *** 0 **** --- 1,126 ---- + /* $XConsortium: XTest.h,v 1.4 92/04/20 13:13:54 rws Exp $ */ + /* + + Copyright 1992 by the Massachusetts Institute of Technology + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation, and that the name of M.I.T. not be used in advertising or + publicity pertaining to distribution of the software without specific, + written prior permission. M.I.T. makes no representations about the + suitability of this software for any purpose. It is provided "as is" + without express or implied warranty. + + */ + + #ifndef _XTEST_H_ + #define _XTEST_H_ + + #include + + #define X_XTestGetVersion 0 + #define X_XTestCompareCursor 1 + #define X_XTestFakeInput 2 + + #define XTestNumberEvents 0 + + #define XTestNumberErrors 0 + + #define XTestMajorVersion 2 + #define XTestMinorVersion 1 + + #define XTestExtensionName "XTEST" + + #ifndef _XTEST_SERVER_ + + _XFUNCPROTOBEGIN + + Bool XTestQueryExtension( + #if NeedFunctionPrototypes + Display* /* dpy */, + int* /* event_basep */, + int* /* error_basep */, + int* /* majorp */, + int* /* minorp */ + #endif + ); + + Bool XTestCompareCursorWithWindow( + #if NeedFunctionPrototypes + Display* /* dpy */, + Window /* window */, + Cursor /* cursor */ + #endif + ); + + Bool XTestCompareCurrentCursorWithWindow( + #if NeedFunctionPrototypes + Display* /* dpy */, + Window /* window */ + #endif + ); + + extern XTestFakeKeyEvent( + #if NeedFunctionPrototypes + Display* /* dpy */, + unsigned int /* keycode */, + Bool /* is_press */, + unsigned long /* delay */ + #endif + ); + + extern XTestFakeButtonEvent( + #if NeedFunctionPrototypes + Display* /* dpy */, + unsigned int /* button */, + Bool /* is_press */, + unsigned long /* delay */ + #endif + ); + + extern XTestFakeMotionEvent( + #if NeedFunctionPrototypes + Display* /* dpy */, + int /* screen */, + int /* x */, + int /* y */, + unsigned long /* delay */ + #endif + ); + + extern XTestFakeRelativeMotionEvent( + #if NeedFunctionPrototypes + Display* /* dpy */, + int /* x */, + int /* y */, + unsigned long /* delay */ + #endif + ); + + void XTestSetGContextOfGC( + #if NeedFunctionPrototypes + GC /* gc */, + GContext /* gid */ + #endif + ); + + void XTestSetVisualIDOfVisual( + #if NeedFunctionPrototypes + Visual* /* visual */, + VisualID /* visualid */ + #endif + ); + + Status XTestDiscard( + #if NeedFunctionPrototypes + Display* /* dpy */ + #endif + ); + + _XFUNCPROTOEND + + #endif /* _XTEST_SERVER_ */ + + #endif *** /dev/null Wed Sep 9 15:40:33 1992 --- mit/extensions/include/xteststr.h Mon Apr 20 13:15:45 1992 *************** *** 0 **** --- 1,84 ---- + /* $XConsortium: xteststr.h,v 1.5 92/04/20 13:14:15 rws Exp $ */ + /* + + Copyright 1992 by the Massachusetts Institute of Technology + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation, and that the name of M.I.T. not be used in advertising or + publicity pertaining to distribution of the software without specific, + written prior permission. M.I.T. makes no representations about the + suitability of this software for any purpose. It is provided "as is" + without express or implied warranty. + + */ + + #define XTestCurrentCursor ((Cursor)1) + + typedef struct { + CARD8 reqType; /* always XTestReqCode */ + CARD8 xtReqType; /* always X_XTestGetVersion */ + CARD16 length B16; + CARD8 majorVersion; + CARD8 pad; + CARD16 minorVersion B16; + } xXTestGetVersionReq; + #define sz_xXTestGetVersionReq 8 + + typedef struct { + BYTE type; /* X_Reply */ + CARD8 majorVersion; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD16 minorVersion B16; + CARD16 pad0 B16; + CARD32 pad1 B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + } xXTestGetVersionReply; + #define sz_xXTestGetVersionReply 32 + + typedef struct { + CARD8 reqType; /* always XTestReqCode */ + CARD8 xtReqType; /* always X_XTestCompareCursor */ + CARD16 length B16; + Window window B32; + Cursor cursor B32; + } xXTestCompareCursorReq; + #define sz_xXTestCompareCursorReq 12 + + typedef struct { + BYTE type; /* X_Reply */ + BOOL same; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 pad0 B32; + CARD32 pad1 B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + } xXTestCompareCursorReply; + #define sz_xXTestCompareCursorReply 32 + + /* used only on the client side */ + typedef struct { + CARD8 reqType; /* always XTestReqCode */ + CARD8 xtReqType; /* always X_XTestFakeInput */ + CARD16 length B16; + BYTE type; + BYTE detail; + CARD16 pad0 B16; + Time time B32; + Window root B32; + CARD32 pad1 B32; + CARD32 pad2 B32; + INT16 rootX B16, rootY B16; + CARD32 pad3 B32; + CARD32 pad4 B32; + } xXTestFakeInputReq; + #define sz_xXTestFakeInputReq 36 *** /tmp/,RCSt1016576 Wed Sep 9 15:43:55 1992 --- mit/extensions/lib/Imakefile Wed Sep 9 15:43:56 1992 *************** *** 1,4 **** ! XCOMM $XConsortium: Imakefile,v 1.33 91/07/22 22:56:37 rws Exp $ #define DoNormalLib NormalLibXext #define DoSharedLib SharedLibXext #define DoDebugLib DebugLibXext --- 1,4 ---- ! XCOMM $XConsortium: Imakefile,v 1.33.1.1 92/09/09 15:29:32 rws Exp $ #define DoNormalLib NormalLibXext #define DoSharedLib SharedLibXext #define DoDebugLib DebugLibXext *************** *** 9,15 **** REQUIREDLIBS = $(XLIBSRC)/libX11.a #endif - #if BuildXInputLib || BuildPexClients #define IHaveSubdirs #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' #if BuildXInputLib --- 9,14 ---- *************** *** 18,25 **** #if BuildPexClients PEXDIRS = PEX #endif ! SUBDIRS = $(XINPUTDIRS) $(PEXDIRS) ! #endif #if HasShm SHMSRCS = XShm.c --- 17,23 ---- #if BuildPexClients PEXDIRS = PEX #endif ! SUBDIRS = $(XINPUTDIRS) $(PEXDIRS) xtest #if HasShm SHMSRCS = XShm.c *** /dev/null Wed Sep 9 15:40:33 1992 --- mit/extensions/lib/xtest/Imakefile Wed Sep 9 15:44:55 1992 *************** *** 0 **** --- 1,49 ---- + XCOMM $XConsortium: Imakefile,v 1.2.1.1 92/09/09 15:38:45 rws Exp $ + #ifndef NormalLibXTest + #define NormalLibXTest YES + #endif + #define DoNormalLib NormalLibXTest + #define DoSharedLib SharedLibXTest + #define DoDebugLib DebugLibXTest + #define DoProfileLib ProfileLibXTest + #include + + #ifdef RsArchitecture + REQUIREDLIBS = $(EXTENSIONSRC)/lib/libXext.a $(XLIBSRC)/libX11.a + #endif + + INCLUDES = -I$(TOP) -I$(XLIBSRC) -I../../include + + SRCS = XTest.c + OBJS = XTest.o + + LINTLIBS = $(LINTXLIB) + + LibraryObjectRule() + + #if DoSharedLib + #if DoNormalLib + SharedLibraryTarget(Xtst,$(SOXTESTREV),$(OBJS),shared,..) + #else + SharedLibraryTarget(Xtst,$(SOXTESTREV),$(OBJS),.,.) + #endif + InstallSharedLibrary(Xtst,$(SOXTESTREV),$(USRLIBDIR)) + #endif + #if DoNormalLib + NormalLibraryTarget(Xtst,$(OBJS)) + InstallLibrary(Xtst,$(USRLIBDIR)) + #endif + #if DoProfileLib + ProfiledLibraryTarget(Xtst,$(OBJS)) + InstallLibrary(Xtst_p,$(USRLIBDIR)) + #endif + #if DoDebugLib + DebuggedLibraryTarget(Xtst,$(OBJS)) + #endif + + LintLibraryTarget(Xtst,$(SRCS)) + InstallLintLibrary(Xtst,$(LINTLIBDIR)) + + DependTarget() + + NormalLintTarget($(SRCS)) *** /dev/null Wed Sep 9 15:40:33 1992 --- mit/extensions/lib/xtest/XTest.c Mon Apr 20 13:16:12 1992 *************** *** 0 **** --- 1,272 ---- + /* $XConsortium: XTest.c,v 1.7 92/04/20 13:14:52 rws Exp $ */ + /* + + Copyright 1990, 1991 by UniSoft Group Limited + Copyright 1992 by the Massachusetts Institute of Technology + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation, and that the name of M.I.T. not be used in advertising or + publicity pertaining to distribution of the software without specific, + written prior permission. M.I.T. makes no representations about the + suitability of this software for any purpose. It is provided "as is" + without express or implied warranty. + + */ + + #define NEED_REPLIES + #include "Xlibint.h" + #include "XTest.h" + #include "xteststr.h" + #include "Xext.h" + #include "extutil.h" + + static XExtensionInfo _xtest_info_data; + static XExtensionInfo *xtest_info = &_xtest_info_data; + static /* const */ char *xtest_extension_name = XTestExtensionName; + + #define XTestCheckExtension(dpy,i,val) \ + XextCheckExtension (dpy, i, xtest_extension_name, val) + + /***************************************************************************** + * * + * private utility routines * + * * + *****************************************************************************/ + + static int close_display(); + static /* const */ XExtensionHooks xtest_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + close_display, /* close_display */ + NULL, /* wire_to_event */ + NULL, /* event_to_wire */ + NULL, /* error */ + NULL /* error_string */ + }; + + static XEXT_GENERATE_FIND_DISPLAY (find_display, xtest_info, + xtest_extension_name, + &xtest_extension_hooks, XTestNumberEvents, + NULL) + + static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xtest_info) + + /***************************************************************************** + * * + * public routines * + * * + *****************************************************************************/ + + Bool + XTestQueryExtension (dpy, event_basep, error_basep, majorp, minorp) + Display *dpy; + int *event_basep, *error_basep; + int *majorp, *minorp; + { + XExtDisplayInfo *info = find_display (dpy); + register xXTestGetVersionReq *req; + xXTestGetVersionReply rep; + + if (XextHasExtension(info)) { + LockDisplay(dpy); + GetReq(XTestGetVersion, req); + req->reqType = info->codes->major_opcode; + req->xtReqType = X_XTestGetVersion; + req->majorVersion = XTestMajorVersion; + req->minorVersion = XTestMinorVersion; + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + UnlockDisplay(dpy); + SyncHandle(); + *event_basep = info->codes->first_event; + *error_basep = info->codes->first_error; + *majorp = rep.majorVersion; + *minorp = rep.minorVersion; + return True; + } else { + return False; + } + } + + Bool + XTestCompareCursorWithWindow(dpy, window, cursor) + Display *dpy; + Window window; + Cursor cursor; + { + XExtDisplayInfo *info = find_display (dpy); + register xXTestCompareCursorReq *req; + xXTestCompareCursorReply rep; + + XTestCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq(XTestCompareCursor, req); + req->reqType = info->codes->major_opcode; + req->xtReqType = X_XTestCompareCursor; + req->window = window; + req->cursor = cursor; + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } + UnlockDisplay(dpy); + SyncHandle(); + return rep.same; + } + + Bool + XTestCompareCurrentCursorWithWindow(dpy, window) + Display *dpy; + Window window; + { + return XTestCompareCursorWithWindow(dpy, window, XTestCurrentCursor); + } + + XTestFakeKeyEvent(dpy, keycode, is_press, delay) + Display *dpy; + unsigned int keycode; + Bool is_press; + unsigned long delay; + { + XExtDisplayInfo *info = find_display (dpy); + register xXTestFakeInputReq *req; + + XTestCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq(XTestFakeInput, req); + req->reqType = info->codes->major_opcode; + req->xtReqType = X_XTestFakeInput; + req->type = is_press ? KeyPress : KeyRelease; + req->detail = keycode; + req->time = delay; + UnlockDisplay(dpy); + SyncHandle(); + } + + XTestFakeButtonEvent(dpy, button, is_press, delay) + Display *dpy; + unsigned int button; + Bool is_press; + unsigned long delay; + { + XExtDisplayInfo *info = find_display (dpy); + register xXTestFakeInputReq *req; + + XTestCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq(XTestFakeInput, req); + req->reqType = info->codes->major_opcode; + req->xtReqType = X_XTestFakeInput; + req->type = is_press ? ButtonPress : ButtonRelease; + req->detail = button; + req->time = delay; + UnlockDisplay(dpy); + SyncHandle(); + } + + XTestFakeMotionEvent(dpy, screen, x, y, delay) + Display *dpy; + int screen; + int x, y; + unsigned long delay; + { + XExtDisplayInfo *info = find_display (dpy); + register xXTestFakeInputReq *req; + + XTestCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq(XTestFakeInput, req); + req->reqType = info->codes->major_opcode; + req->xtReqType = X_XTestFakeInput; + req->type = MotionNotify; + req->detail = False; + if (screen == -1) + req->root = None; + else + req->root = RootWindow(dpy, screen); + req->rootX = x; + req->rootY = y; + req->time = delay; + UnlockDisplay(dpy); + SyncHandle(); + } + + XTestFakeRelativeMotionEvent(dpy, dx, dy, delay) + Display *dpy; + int dx, dy; + unsigned long delay; + { + XExtDisplayInfo *info = find_display (dpy); + register xXTestFakeInputReq *req; + + XTestCheckExtension (dpy, info, 0); + + LockDisplay(dpy); + GetReq(XTestFakeInput, req); + req->reqType = info->codes->major_opcode; + req->xtReqType = X_XTestFakeInput; + req->type = MotionNotify; + req->detail = True; + req->root = None; + req->rootX = dx; + req->rootY = dy; + req->time = delay; + UnlockDisplay(dpy); + SyncHandle(); + } + + void + XTestSetGContextOfGC(gc, gid) + GC gc; + GContext gid; + { + gc->gid = gid; + } + + void + XTestSetVisualIDOfVisual(visual, visualid) + Visual *visual; + VisualID visualid; + { + visual->visualid = visualid; + } + + static xReq _dummy_request = { + 0, 0, 0 + }; + + Status + XTestDiscard(dpy) + Display *dpy; + { + Bool something; + register char *ptr; + + LockDisplay(dpy); + if (something = (dpy->bufptr != dpy->buffer)) { + for (ptr = dpy->buffer; + ptr < dpy->bufptr; + ptr += (((xReq *)ptr)->length << 2)) + dpy->request--; + dpy->bufptr = dpy->buffer; + dpy->last_req = (char *)&_dummy_request; + } + UnlockDisplay(dpy); + SyncHandle(); + return something; + } *** /tmp/,RCSt1016593 Wed Sep 9 15:46:33 1992 --- mit/extensions/server/Imakefile Wed Sep 9 15:46:35 1992 *************** *** 1,4 **** ! XCOMM $XConsortium: Imakefile,v 5.15 91/07/16 23:09:51 gildea Exp $ #include #if BuildXInputExt || BuildPexExt || BuildPexClients --- 1,4 ---- ! XCOMM $XConsortium: Imakefile,v 5.15.1.1 92/09/09 15:32:22 rws Exp $ #include #if BuildXInputExt || BuildPexExt || BuildPexClients *************** *** 19,26 **** SHMSRCS = shm.c SHMOBJS = shm.o #endif ! SRCS = shape.c $(SHMSRCS) multibuf.c mitmisc.c xtest1di.c xtest1dd.c ! OBJS = shape.o $(SHMOBJS) multibuf.o mitmisc.o xtest1di.o xtest1dd.o INCLUDES = -I../include -I$(INCLUDESRC) -I$(SERVERSRC)/include LINTLIBS = ../../server/dix/llib-ldix.ln ../../server/os/4.2bsd/llib-los.ln SUBDIRS = $(XINPUTDIRS) $(PEXDIRS) --- 19,26 ---- SHMSRCS = shm.c SHMOBJS = shm.o #endif ! SRCS = shape.c $(SHMSRCS) multibuf.c mitmisc.c sleepuntil.c xtest.c xtest1di.c xtest1dd.c ! OBJS = shape.o $(SHMOBJS) multibuf.o mitmisc.o sleepuntil.o xtest.o xtest1di.o xtest1dd.o INCLUDES = -I../include -I$(INCLUDESRC) -I$(SERVERSRC)/include LINTLIBS = ../../server/dix/llib-ldix.ln ../../server/os/4.2bsd/llib-los.ln SUBDIRS = $(XINPUTDIRS) $(PEXDIRS) *** /dev/null Wed Sep 9 15:40:33 1992 --- mit/extensions/server/sleepuntil.c Mon Feb 24 19:02:47 1992 *************** *** 0 **** --- 1,199 ---- + /* + * $XConsortium: sleepuntil.c,v 1.1 92/02/24 19:02:27 keith Exp $ + * + * Copyright 1992 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. M.I.T. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, MIT X Consortium + */ + + /* dixsleep.c - implement millisecond timeouts for X clients */ + + #include "X.h" + #include "Xmd.h" + #include "misc.h" + #include "windowstr.h" + #include "dixstruct.h" + #include "pixmapstr.h" + #include "scrnintstr.h" + + typedef struct _Sertafied { + struct _Sertafied *next; + TimeStamp revive; + ClientPtr pClient; + XID id; + void (*notifyFunc)(); + pointer closure; + } SertafiedRec, *SertafiedPtr; + + static SertafiedPtr pPending; + static RESTYPE SertafiedResType; + static Bool BlockHandlerRegistered; + static int SertafiedGeneration; + static void WachetAuf(); + static void SertafiedDelete(); + static void SertafiedBlockHandler(); + static void SertafiedWakeupHandler(); + + ClientSleepUntil (client, revive, notifyFunc, closure) + ClientPtr client; + TimeStamp *revive; + void (*notifyFunc)(); + pointer closure; + { + SertafiedPtr pRequest, pReq, pPrev; + + if (SertafiedGeneration != serverGeneration) + { + SertafiedResType = CreateNewResourceType (SertafiedDelete); + if (!SertafiedResType) + return FALSE; + SertafiedGeneration = serverGeneration; + BlockHandlerRegistered = FALSE; + } + pRequest = (SertafiedPtr) xalloc (sizeof (SertafiedRec)); + if (!pRequest) + return FALSE; + pRequest->pClient = client; + pRequest->revive = *revive; + pRequest->id = FakeClientID (client->index); + pRequest->closure = closure; + if (!BlockHandlerRegistered) + { + if (!RegisterBlockAndWakeupHandlers (SertafiedBlockHandler, + SertafiedWakeupHandler, + (pointer) 0)) + { + xfree (pRequest); + return FALSE; + } + BlockHandlerRegistered = TRUE; + } + pRequest->notifyFunc = 0; + if (!AddResource (pRequest->id, SertafiedResType, (pointer) pRequest)) + return FALSE; + if (!notifyFunc) + notifyFunc = WachetAuf; + pRequest->notifyFunc = notifyFunc; + /* Insert into time-ordered queue, with earliest activation time coming first. */ + pPrev = 0; + for (pReq = pPending; pReq; pReq = pReq->next) + { + if (CompareTimeStamps (pReq->revive, *revive) == LATER) + break; + pPrev = pReq; + } + if (pPrev) + pPrev->next = pRequest; + else + pPending = pRequest; + pRequest->next = pReq; + IgnoreClient (client); + return TRUE; + } + + static void + WachetAuf (client, closure) + ClientPtr client; + pointer closure; + { + if (!client->clientGone) + AttendClient (client); + } + + + static void + SertafiedDelete (pRequest) + SertafiedPtr pRequest; + { + SertafiedPtr pReq, pPrev; + + pPrev = 0; + for (pReq = pPending; pReq; pReq = pReq->next) + if (pReq == pRequest) + { + if (pPrev) + pPrev->next = pReq->next; + else + pPending = pReq->next; + break; + } + if (pRequest->notifyFunc) + (*pRequest->notifyFunc) (pRequest->pClient, pRequest->closure); + xfree (pRequest); + } + + static void + SertafiedBlockHandler (data, wt, LastSelectMask) + pointer data; /* unused */ + pointer wt; /* wait time */ + long *LastSelectMask; + { + SertafiedPtr pReq, pNext; + unsigned long newdelay, olddelay; + TimeStamp now; + + if (!pPending) + return; + now.milliseconds = GetTimeInMillis (); + now.months = currentTime.months; + if ((int) (now.milliseconds - currentTime.milliseconds) < 0) + now.months++; + for (pReq = pPending; pReq; pReq = pNext) + { + pNext = pReq->next; + if (CompareTimeStamps (pReq->revive, now) == LATER) + break; + FreeResource (pReq->id, RT_NONE); + } + pReq = pPending; + if (!pReq) + return; + newdelay = pReq->revive.milliseconds - now.milliseconds; + AdjustWaitForDelay (wt, newdelay); + } + + static void + SertafiedWakeupHandler (data, i, LastSelectMask) + pointer data; + int i; + long *LastSelectMask; + { + SertafiedPtr pReq, pNext; + TimeStamp now; + + now.milliseconds = GetTimeInMillis (); + now.months = currentTime.months; + if ((int) (now.milliseconds - currentTime.milliseconds) < 0) + now.months++; + for (pReq = pPending; pReq; pReq = pNext) + { + pNext = pReq->next; + if (CompareTimeStamps (pReq->revive, now) == LATER) + break; + FreeResource (pReq->id, RT_NONE); + } + if (!pPending) + { + RemoveBlockAndWakeupHandlers (SertafiedBlockHandler, + SertafiedWakeupHandler, + (pointer) 0); + BlockHandlerRegistered = FALSE; + } + } *** /dev/null Wed Sep 9 17:02:52 1992 --- mit/extensions/server/xtest.c Wed Sep 9 17:09:49 1992 *************** *** 0 **** --- 1,358 ---- + /* $XConsortium: xtest.c,v 1.12.1.1 92/09/09 17:08:16 rws Exp $ */ + /* + + Copyright 1992 by the Massachusetts Institute of Technology + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation, and that the name of M.I.T. not be used in advertising or + publicity pertaining to distribution of the software without specific, + written prior permission. M.I.T. makes no representations about the + suitability of this software for any purpose. It is provided "as is" + without express or implied warranty. + + */ + + #include "X.h" + #define NEED_EVENTS + #include "Xproto.h" + #include "misc.h" + #include "os.h" + #include "dixstruct.h" + #include "extnsionst.h" + #include "windowstr.h" + #include "inputstr.h" + #include "scrnintstr.h" + #define _XTEST_SERVER_ + #include "XTest.h" + #include "xteststr.h" + + static unsigned char XTestReqCode; + static int ProcXTestDispatch(), SProcXTestDispatch(); + static void XTestResetProc(); + static int XTestSwapFakeInput(); + CursorPtr GetSpriteCursor(); + WindowPtr GetCurrentRootWindow(); + extern int screenIsSaved; + + void + XTestExtensionInit() + { + ExtensionEntry *extEntry, *AddExtension(); + + if (extEntry = AddExtension(XTestExtensionName, 0, 0, + ProcXTestDispatch, SProcXTestDispatch, + XTestResetProc, StandardMinorOpcode)) + XTestReqCode = (unsigned char)extEntry->base; + } + + /*ARGSUSED*/ + static void + XTestResetProc (extEntry) + ExtensionEntry *extEntry; + { + } + + static int + ProcXTestGetVersion(client) + register ClientPtr client; + { + REQUEST(xXTestGetVersionReq); + xXTestGetVersionReply rep; + register int n; + + REQUEST_SIZE_MATCH(xXTestGetVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XTestMajorVersion; + rep.minorVersion = XTestMinorVersion; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xXTestGetVersionReply), (char *)&rep); + return(client->noClientException); + } + + static int + ProcXTestCompareCursor(client) + register ClientPtr client; + { + REQUEST(xXTestCompareCursorReq); + xXTestCompareCursorReply rep; + WindowPtr pWin; + CursorPtr pCursor; + register int n; + + REQUEST_SIZE_MATCH(xXTestCompareCursorReq); + pWin = (WindowPtr)LookupWindow(stuff->window, client); + if (!pWin) + return(BadWindow); + if (stuff->cursor == None) + pCursor = NullCursor; + else if (stuff->cursor == XTestCurrentCursor) + pCursor = GetSpriteCursor(); + else { + pCursor = (CursorPtr)LookupIDByType(stuff->cursor, RT_CURSOR); + if (!pCursor) + { + client->errorValue = stuff->cursor; + return (BadCursor); + } + } + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.same = (wCursor(pWin) == pCursor); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + } + WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *)&rep); + return(client->noClientException); + } + + static int + ProcXTestFakeInput(client) + register ClientPtr client; + { + REQUEST(xReq); + int nev; + int n; + xEvent *ev; + DeviceIntPtr dev; + WindowPtr root; + + nev = (stuff->length << 2) - sizeof(xReq); + if (nev % sizeof(xEvent)) + return BadLength; + nev /= sizeof(xEvent); + if (nev != 1) + return BadLength; /* for now */ + UpdateCurrentTime(); + ev = (xEvent *)&stuff[1]; + switch (ev->u.u.type & 0177) + { + case KeyPress: + case KeyRelease: + case MotionNotify: + case ButtonPress: + case ButtonRelease: + break; + default: + client->errorValue = ev->u.u.type; + return BadValue; + } + if (ev->u.keyButtonPointer.time) + { + TimeStamp activateTime; + CARD32 ms; + + activateTime = currentTime; + ms = activateTime.milliseconds + ev->u.keyButtonPointer.time; + if (ms < activateTime.milliseconds) + activateTime.months++; + activateTime.milliseconds = ms; + ev->u.keyButtonPointer.time = 0; + /* swap the request back so we can simply re-execute it */ + if (client->swapped) + { + (void) XTestSwapFakeInput(client, stuff); + swaps(&stuff->length, n); + } + ResetCurrentRequest (client); + client->sequence--; + if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) + { + /* + * flush this request - must be in this order because + * ResetCurrentRequest adds the client back to + * clientsWithInput which will cause the client to + * keep going, instead of waiting for the timeout. + */ + (void) ReadRequestFromClient (client); + client->sequence++; + return BadAlloc; + } + return Success; + } + switch (ev->u.u.type & 0177) + { + case KeyPress: + case KeyRelease: + dev = (DeviceIntPtr)LookupKeyboardDevice(); + if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || + ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) + { + client->errorValue = ev->u.u.detail; + return BadValue; + } + break; + case MotionNotify: + dev = (DeviceIntPtr)LookupPointerDevice(); + if (ev->u.keyButtonPointer.root == None) + root = GetCurrentRootWindow(); + else + { + root = LookupWindow(ev->u.keyButtonPointer.root, client); + if (!root) + return BadWindow; + if (root->parent) + { + client->errorValue = ev->u.keyButtonPointer.root; + return BadValue; + } + } + if (ev->u.u.detail == xTrue) + { + int x, y; + GetSpritePosition(&x, &y); + ev->u.keyButtonPointer.rootX += x; + ev->u.keyButtonPointer.rootY += y; + } + else if (ev->u.u.detail != xFalse) + { + client->errorValue = ev->u.u.detail; + return BadValue; + } + if (ev->u.keyButtonPointer.rootX < 0) + ev->u.keyButtonPointer.rootX = 0; + else if (ev->u.keyButtonPointer.rootX >= root->drawable.width) + ev->u.keyButtonPointer.rootX = root->drawable.width - 1; + if (ev->u.keyButtonPointer.rootY < 0) + ev->u.keyButtonPointer.rootY = 0; + else if (ev->u.keyButtonPointer.rootY >= root->drawable.height) + ev->u.keyButtonPointer.rootY = root->drawable.height - 1; + if (root != GetCurrentRootWindow()) + { + NewCurrentScreen(root->drawable.pScreen, + ev->u.keyButtonPointer.rootX, + ev->u.keyButtonPointer.rootY); + return client->noClientException; + } + (*root->drawable.pScreen->SetCursorPosition) + (root->drawable.pScreen, + ev->u.keyButtonPointer.rootX, + ev->u.keyButtonPointer.rootY, FALSE); + break; + case ButtonPress: + case ButtonRelease: + dev = (DeviceIntPtr)LookupPointerDevice(); + if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) + { + client->errorValue = ev->u.u.detail; + return BadValue; + } + break; + } + if (screenIsSaved == SCREEN_SAVER_ON) + SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset); + ev->u.keyButtonPointer.time = currentTime.milliseconds; + (*dev->public.processInputProc)(ev, (DevicePtr)dev, 1); + return client->noClientException; + } + + static int + ProcXTestDispatch (client) + register ClientPtr client; + { + REQUEST(xReq); + switch (stuff->data) + { + case X_XTestGetVersion: + return ProcXTestGetVersion(client); + case X_XTestCompareCursor: + return ProcXTestCompareCursor(client); + case X_XTestFakeInput: + return ProcXTestFakeInput(client); + default: + return BadRequest; + } + } + + static int + SProcXTestGetVersion(client) + register ClientPtr client; + { + register int n; + REQUEST(xXTestGetVersionReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXTestGetVersionReq); + swaps(&stuff->minorVersion, n); + return ProcXTestGetVersion(client); + } + + static int + SProcXTestCompareCursor(client) + register ClientPtr client; + { + register int n; + REQUEST(xXTestCompareCursorReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXTestCompareCursorReq); + swapl(&stuff->window, n); + swapl(&stuff->cursor, n); + return ProcXTestCompareCursor(client); + } + + static int + XTestSwapFakeInput(client, req) + register ClientPtr client; + xReq *req; + { + register int nev; + register xEvent *ev; + xEvent sev; + void (*proc)(), NotImplemented(); + + nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent); + for (ev = (xEvent *)&req[1]; --nev >= 0; ev++) + { + /* Swap event */ + proc = EventSwapVector[ev->u.u.type & 0177]; + /* no swapping proc; invalid event type? */ + if (!proc || (int (*)()) proc == (int (*)()) NotImplemented) { + client->errorValue = ev->u.u.type; + return BadValue; + } + (*proc)(ev, &sev); + *ev = sev; + } + return Success; + } + + static int + SProcXTestFakeInput(client) + register ClientPtr client; + { + register int n; + REQUEST(xReq); + + swaps(&stuff->length, n); + n = XTestSwapFakeInput(client, stuff); + if (n != Success) + return n; + return ProcXTestFakeInput(client); + } + + static int + SProcXTestDispatch (client) + register ClientPtr client; + { + REQUEST(xReq); + switch (stuff->data) + { + case X_XTestGetVersion: + return SProcXTestGetVersion(client); + case X_XTestCompareCursor: + return SProcXTestCompareCursor(client); + case X_XTestFakeInput: + return SProcXTestFakeInput(client); + default: + return BadRequest; + } + } *** /tmp/,RCSt1016604 Wed Sep 9 15:47:54 1992 --- mit/server/ddx/mi/miinitext.c Wed Sep 9 15:47:56 1992 *************** *** 21,27 **** SOFTWARE. ******************************************************************/ ! /* $XConsortium: miinitext.c,v 1.15 90/08/15 08:42:23 rws Exp $ */ #ifdef BEZIER extern void BezierExtensionInit(); --- 21,27 ---- SOFTWARE. ******************************************************************/ ! /* $XConsortium: miinitext.c,v 1.15.1.1 92/09/09 15:34:45 rws Exp $ */ #ifdef BEZIER extern void BezierExtensionInit(); *************** *** 44,49 **** --- 44,52 ---- #ifdef XINPUT extern void XInputExtensionInit(); #endif + #ifdef XTEST + extern void XTestExtensionInit(); + #endif #ifdef MITMISC extern void MITMiscExtensionInit(); #endif *************** *** 77,82 **** --- 80,88 ---- #endif #ifdef XINPUT XInputExtensionInit(); + #endif + #ifdef XTEST + XTestExtensionInit(); #endif #ifdef MITMISC MITMiscExtensionInit();