X11R4 patch for SCO XENIX (part05)

Chain Lee chain at paul.rutgers.edu
Mon Jan 7 13:24:43 AEST 1991


*** X11R4.ORIG/mit/server/ddx/xenix/trident/xenixMouse.c	Sun Jan  6 01:03:40 1991
--- X11R4/mit/server/ddx/xenix/trident/xenixMouse.c	Sun Dec  9 18:53:08 1990
***************
*** 0 ****
--- 1,367 ----
+ /*
+  * xenixMouse.c			Modified for Xenix by Chain Lee 08/90
+  */
+ 
+ /*-
+  * sunMouse.c --
+  *	Functions for playing cat and mouse... sorry.
+  *
+  * Copyright (c) 1987 by the Regents of the University of California
+  *
+  * Permission to use, copy, modify, and distribute this
+  * software and its documentation for any purpose and without
+  * fee is hereby granted, provided that the above copyright
+  * notice appear in all copies.  The University of California
+  * makes no representations about the suitability of this
+  * software for any purpose.  It is provided "as is" without
+  * express or implied warranty.
+  *
+  *
+  */
+ 
+ /************************************************************
+ Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+ 
+                     All Rights Reserved
+ 
+ Permission  to  use,  copy,  modify,  and  distribute   this
+ software  and  its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright no-
+ tice  appear  in all copies and that both that copyright no-
+ tice and this permission notice appear in  supporting  docu-
+ mentation,  and  that the names of Sun or MIT not be used in
+ advertising or publicity pertaining to distribution  of  the
+ software  without specific prior written permission. Sun and
+ M.I.T. make no representations about the suitability of this
+ software for any purpose. It is provided "as is" without any
+ express or implied warranty.
+ 
+ SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+ NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ ABLE  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.
+ 
+ ********************************************************/
+ 
+ #define	NEED_EVENTS
+ 
+ #include    "xenix.h"
+ #include    "mipointer.h"
+ #include    "misprite.h"
+ 
+ #define	ABS(a)	(((a)>0)?(a):-(a))
+ 
+ Bool ActiveZaphod = TRUE;
+ 
+ extern void xenixSuspendX();
+ 
+ static long xenixEventTime();
+ static Bool xenixCursorOffScreen();
+ static void xenixCrossScreen();
+ extern void miPointerQueueEvent();
+ 
+ miPointerCursorFuncRec xenixPointerCursorFuncs = {
+     xenixEventTime,
+     xenixCursorOffScreen,
+     xenixCrossScreen,
+     miPointerQueueEvent,
+ };
+ 
+ typedef struct {
+     int	    bmask;	    /* Current button state */
+     Bool    mouseMoved;	    /* Mouse has moved */
+ } XenixMsPrivRec, *XenixMsPrivPtr;
+ 
+ static void 	  	xenixMouseCtrl();
+ static int 	  	xenixMouseGetMotionEvents();
+ void	 	  	xenixMouseProcessEvent();
+ static void 	  	xenixMouseDoneEvents();
+ 
+ static XenixMsPrivRec	xenixMousePriv;
+ static PtrPrivRec	sysMousePriv = {
+     xenixMouseProcessEvent,	/* Function to process an event	*/
+     xenixMouseDoneEvents,		/* When	all the	events have been */
+ 				/* handled, this function will be */
+ 				/* called. */
+     0,				/* Current X coordinate	of pointer */
+     0,				/* Current Y coordinate	*/
+     (pointer)&xenixMousePriv,	/* Field private to device */
+ };
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixMouseProc --
+  *	Handle the initialization, etc. of a mouse
+  *
+  * Results:
+  *	none.
+  *
+  * Side Effects:
+  *
+  * Note:
+  *	When using xenixwindows, all input comes off a single fd, stored in the
+  *	global windowFd.  Therefore, only one device should be enabled and
+  *	disabled, even though the application still sees both mouse and
+  *	keyboard.  We have arbitrarily chosen to enable and disable windowFd
+  *	in the keyboard routine xenixKbdProc rather than in xenixMouseProc.
+  *
+  *-----------------------------------------------------------------------
+  */
+ int
+ xenixMouseProc (pMouse, what)
+     DevicePtr	  pMouse;   	/* Mouse to play with */
+     int	    	  what;	    	/* What to do with it */
+ {
+     register int  fd;
+     int	    	  format;
+     static int	  oformat;
+     BYTE    	  map[4];
+ 
+     switch (what) {
+ 	case DEVICE_INIT:
+ 	    if (pMouse != LookupPointerDevice()) {
+ 		ErrorF ("Cannot open non-system mouse");	
+ 		return (!Success);
+ 	    }
+ 
+ 	    sysMousePriv.x = 0;
+ 	    sysMousePriv.y = 0;
+ 
+ 	    xenixMousePriv.mouseMoved =	FALSE;
+ 	    pMouse->devicePrivate = (pointer) &sysMousePriv;
+ 
+ 	    pMouse->on = FALSE;
+ 	    map[1] = 1;
+ 	    map[2] = 2;
+ 	    map[3] = 3;
+ 	    InitPointerDeviceStruct(
+ 		pMouse, map, 3, xenixMouseGetMotionEvents, xenixMouseCtrl, 0);
+ 	    break;
+ 
+ 	case DEVICE_ON:
+ 
+ /*	    AddEnabledDevice (((PtrPrivPtr)pMouse->devicePrivate)->fd);
+ */
+ 	    pMouse->on = TRUE;
+ 	    break;
+ 
+ 	case DEVICE_CLOSE:
+ 	    break;
+ 
+ 	case DEVICE_OFF:
+ /*	    RemoveEnabledDevice (((PtrPrivPtr)pMouse->devicePrivate)->fd);
+ */	    pMouse->on = FALSE;
+ 	    break;
+     }
+     return (Success);
+ }
+ 	    
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixMouseCtrl --
+  *	Alter the control parameters for the mouse. Since acceleration
+  *	etc. is done from the PtrCtrl record in the mouse's device record,
+  *	there's nothing to do here.
+  *
+  * Results:
+  *	None.
+  *
+  * Side Effects:
+  *	None.
+  *
+  *-----------------------------------------------------------------------
+  */
+ /*ARGSUSED*/
+ static void
+ xenixMouseCtrl (pMouse)
+     DevicePtr	  pMouse;
+ {
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixMouseGetMotionEvents --
+  *	Return the (number of) motion events in the "motion history
+  *	buffer" (snicker) between the given times.
+  *
+  * Results:
+  *	The number of events stuffed.
+  *
+  * Side Effects:
+  *	The relevant xTimecoord's are stuffed in the passed memory.
+  *
+  *-----------------------------------------------------------------------
+  */
+ /*ARGSUSED*/
+ static int
+ xenixMouseGetMotionEvents (buff, start, stop, pScreen)
+     CARD32 start, stop;
+     xTimecoord *buff;
+     ScreenPtr pScreen;
+ {
+     return 0;
+ }
+ 
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixMouseProcessEvent --
+  *	Given a Firm_event for a mouse, pass it off the the dix layer
+  *	properly converted...
+  *
+  * Results:
+  *	None.
+  *
+  * Side Effects:
+  *	The cursor may be redrawn...? devPrivate/x/y will be altered.
+  *
+  *-----------------------------------------------------------------------
+  */
+ void
+ xenixMouseProcessEvent (pMouse, evp)
+     DevicePtr	  pMouse;   	/* Mouse from which the event came */
+     EVENT	  *evp;	    	/* Event to process */
+ {
+     xEvent	xE;
+     register XenixMsPrivPtr pXenixPriv; /* Private data for mouse */
+     static	int	button = 0;	/* previous button state */
+     int		b;			/* current button state */
+     int		bKey;			/* button value expected by X */
+     static	int	mouseMoved = 0;
+ 
+ 
+     xE.u.keyButtonPointer.time = EV_TIME(*evp);
+ 
+     if (EV_TAG(*evp) & T_BUTTON) {
+     	b = EV_BUTTONS(*evp);
+ 
+ 	if (b == 7) {
+  	    xenixSuspendX();
+  	    return;
+         }
+ 	switch (ABS(b - button)) {
+ 	    case LT_BUTTON:	bKey = 1;	break;
+ 	    case MD_BUTTON:	bKey = 2;	break;
+ 	    case RT_BUTTON:	bKey = 3;	break;
+ 	    default:		return;
+ 	}
+ 	/*
+ 	 * A button changed state. Sometimes we will get two events
+ 	 * for a single state change. Should we get a button event which
+ 	 * reflects the current state of affairs, that event is discarded.
+ 	 *
+ 	 * Mouse buttons start at 1.
+ 	 */
+ 	xE.u.u.detail = bKey;
+ 	if (button - b > 0)
+ 		xE.u.u.type = ButtonRelease;
+ 	else
+ 		xE.u.u.type = ButtonPress;
+ 	button = b;
+ 
+ 	/*
+ 	 * If the mouse has moved, we must update any interested client
+ 	 * as well as DIX before sending a button event along.
+ 	 */
+ 	if (mouseMoved) {
+ 	    xenixMouseDoneEvents (pMouse, FALSE);
+ 	}
+     
+ 	miPointerPosition (screenInfo.screens[0],
+ 			   &xE.u.keyButtonPointer.rootX,
+ 			   &xE.u.keyButtonPointer.rootY);
+     
+ 	(* pMouse->processInputProc) (&xE, pMouse, 1);
+     } 
+     if (EV_TAG(*evp) & T_REL_LOCATOR) { 
+ 	miPointerDeltaCursor (screenInfo.screens[0], 
+ 			      EV_DX(*evp),
+ 			      -EV_DY(*evp), 
+ 			      TRUE);
+     }
+ }
+ 
+ /*ARGSUSED*/
+ static Bool
+ xenixCursorOffScreen (pScreen, x, y)
+     ScreenPtr	*pScreen;
+     int		*x, *y;
+ {
+     int	    index;
+ 
+     /*
+      * Active Zaphod implementation:
+      *    increment or decrement the current screen
+      *    if the x is to the right or the left of
+      *    the current screen.
+      */
+     if (ActiveZaphod &&
+ 	screenInfo.numScreens > 1 && (*x >= (*pScreen)->width || *x < 0))
+     {
+ 	index = (*pScreen)->myNum;
+ 	if (*x < 0)
+ 	{
+ 	    index = (index ? index : screenInfo.numScreens) - 1;
+ 	    *pScreen = screenInfo.screens[index];
+ 	    *x += (*pScreen)->width;
+ 	}
+ 	else
+ 	{
+ 	    *x -= (*pScreen)->width;
+ 	    index = (index + 1) % screenInfo.numScreens;
+ 	    *pScreen = screenInfo.screens[index];
+ 	}
+ 	return TRUE;
+     }
+     return FALSE;
+ }
+ 
+ /*ARGSUSED*/
+ static long
+ xenixEventTime (pScreen)
+     ScreenPtr	pScreen;
+ {
+     return lastEventTime;
+ }
+ 
+ static void
+ xenixCrossScreen (pScreen, entering)
+     ScreenPtr	pScreen;
+     Bool	entering;
+ {
+     uchar_t  select;
+ 
+     select = 1;
+     if (entering)
+ 	select = 0;
+     if (xenixFbs[pScreen->myNum].EnterLeave)
+ 	(*xenixFbs[pScreen->myNum].EnterLeave) (pScreen, select);
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixMouseDoneEvents --
+  *	Finish off any mouse motions we haven't done yet. (At the moment
+  *	this code is unused since we never save mouse motions as I'm
+  *	unsure of the effect of getting a keystroke at a given [x,y] w/o
+  *	having gotten a motion event to that [x,y])
+  *
+  * Results:
+  *	None.
+  *
+  * Side Effects:
+  *	A MotionNotify event may be generated.
+  *
+  *-----------------------------------------------------------------------
+  */
+ /*ARGSUSED*/
+ static void
+ xenixMouseDoneEvents (pMouse,final)
+     DevicePtr	  pMouse;
+     Bool	  final;
+ {
+ }
*** X11R4.ORIG/mit/server/ddx/xenix/trident/xenixTty.c	Sun Jan  6 01:03:43 1991
--- X11R4/mit/server/ddx/xenix/trident/xenixTty.c	Thu Dec 13 20:51:26 1990
***************
*** 0 ****
--- 1,41 ----
+ /*
+  * xenixTty.c
+  */
+ 
+ #include <sys/types.h>
+ #include <sys/vtkd.h>
+ #include <sgtty.h>
+ 
+ int
+ set_tty(file)
+ int	file;
+ {
+     set_mode(file,RAW,ECHO,0);
+     ioctl(file, KDSKBMODE, K_RAW);
+ }
+ 
+ int
+ reset_tty(file)
+ int	file;
+ {
+     ioctl(file, KDSKBMODE, K_XLATE);
+     set_mode(file,ECHO,RAW,0);
+ }
+ 
+ static int
+ set_mode(file,on,off,speed)
+ int	file;
+ int	on;
+ int	off;
+ {
+     struct sgttyb buff;
+ 
+     gtty(file,&buff);
+     buff.sg_flags |= on;
+     buff.sg_flags &= ~off;
+     if (speed)
+ 	buff.sg_ispeed = buff.sg_ospeed = speed;
+     stty(file,&buff);
+     return(0);
+ }
+ 
*** X11R4.ORIG/mit/server/ddx/xenix/trident/xenixInit.c	Sun Jan  6 01:03:45 1991
--- X11R4/mit/server/ddx/xenix/trident/xenixInit.c	Fri Dec 14 00:09:36 1990
***************
*** 0 ****
--- 1,427 ----
+ /*
+  * xenixInit.c			Modified for Xenix by Chain Lee 08/90
+  */
+ 
+ /*-
+  *
+  * Copyright (c) 1987 by the Regents of the University of California
+  *
+  * Permission to use, copy, modify, and distribute this
+  * software and its documentation for any purpose and without
+  * fee is hereby granted, provided that the above copyright
+  * notice appear in all copies.  The University of California
+  * makes no representations about the suitability of this
+  * software for any purpose.  It is provided "as is" without
+  * express or implied warranty.
+  *
+  *
+  */
+ 
+ /************************************************************
+ Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+ 
+                     All Rights Reserved
+ 
+ Permission  to  use,  copy,  modify,  and  distribute   this
+ software  and  its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright no-
+ tice  appear  in all copies and that both that copyright no-
+ tice and this permission notice appear in  supporting  docu-
+ mentation,  and  that the names of Sun or MIT not be used in
+ advertising or publicity pertaining to distribution  of  the
+ software  without specific prior written permission. Sun and
+ M.I.T. make no representations about the suitability of this
+ software for any purpose. It is provided "as is" without any
+ express or implied warranty.
+ 
+ SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+ NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ ABLE  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.
+ 
+ ********************************************************/
+ 
+ #include    "xenix.h"
+ #include    <servermd.h>
+ #include    "dixstruct.h"
+ #include    "dix.h"
+ #include    "opaque.h"
+ #include    "mipointer.h"
+ 
+ extern int xenixMouseProc(), xenixKbdProc();
+ extern Bool xenixVGAProbe(), xenixVGACreate();
+ 
+ extern void ProcessInputEvents();
+ extern void SetInputCheck();
+ 
+ extern char *strncpy();
+ extern GCPtr CreateScratchGC();
+ 
+ #define	XDEVICE	"XDEVICE"
+ 
+ int xenixEventPending = 0;	 /* For use with SetInputCheck */
+ static int autoRepeatHandlersInstalled;	/* FALSE each time InitOutput called */
+ 
+ static Bool xenixDevsProbed = FALSE;
+ Bool xenixSupportsDepth8 = FALSE;
+ unsigned long xenixGeneration = 0;
+ 
+ extern int xenixCheckEvent();
+ 
+ static void
+ xenixBlock(blockData, pptv, pReadmask)
+ int	*blockData;
+ int	*pptv;
+ int	*pReadmask;
+ {
+ 	if (xenixCheckEvent())
+ 		xenixEventPending = 1;
+ }
+ static void
+ xenixWakeup(blockData, pptv, pReadmask)
+ int	*blockData;
+ int	*pptv;
+ int	*pReadmask;
+ {
+ 	/* nothing */
+ }
+ 
+ xenixFbDataRec xenixFbData[] = {
+     xenixVGAProbe,  	"/dev/fb",	    xenixVGACreate,
+     xenixVGAProbe,  	"/dev/fb",	    xenixVGACreate,
+ };
+ 
+ #define NUMSCREENS (sizeof(xenixFbData)/sizeof(xenixFbData[0]))
+ #define NUMDEVICES  2
+ 
+ fbFd xenixFbs[NUMDEVICES];
+ 
+ static PixmapFormatRec	formats[] = {
+     1, 1, BITMAP_SCANLINE_PAD,	/* 1-bit deep */
+     8, 8, BITMAP_SCANLINE_PAD,	/* 8-bit deep */
+ };
+ #define NUMFORMATS	(sizeof formats)/(sizeof formats[0])
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * InitOutput --
+  *	Initialize screenInfo for all actually accessible framebuffers.
+  *	The
+  *
+  * Results:
+  *	screenInfo init proc field set
+  *
+  * Side Effects:
+  *	None
+  *
+  *-----------------------------------------------------------------------
+  */
+ 
+ InitOutput(pScreenInfo, argc, argv)
+     ScreenInfo 	  *pScreenInfo;
+     int     	  argc;
+     char    	  **argv;
+ {
+     int     	  i, n, dev;
+     int		  nonBlockConsole = 1;
+     static int	  setup_on_exit = 0;
+     int		  devStart = 1;
+ 
+     if (!monitorResolution)
+ 	monitorResolution = 90;
+     for (i = 1; i < argc; i++) {
+ 	if (!strcmp(argv[i],"-debug"))
+ 	    nonBlockConsole = 0;
+ 	else if (!strcmp(argv[i],"-mono"))
+ 	    devStart = 0;
+     }
+ 
+     pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+     pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+     pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+     pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+ 
+     pScreenInfo->numPixmapFormats = NUMFORMATS;
+     for (i=0; i< NUMFORMATS; i++)
+         pScreenInfo->formats[i] = formats[i];
+ 
+     autoRepeatHandlersInstalled = FALSE;
+ 
+     if (!xenixDevsProbed)
+     {
+ 	n = 0;
+ 	for (i = NUMSCREENS, dev = devStart; --i > 0; dev++) {
+ 	    if ((*xenixFbData[dev].probeProc)(pScreenInfo, n, dev, argc, argv))
+ 		n++;
+ 	    else
+ 		xenixFbData[dev].createProc = (Bool(*)()) NULL;
+ 	}
+         xenixDevsProbed = TRUE;
+ 	if (n == 0)
+ 	    return;
+     }
+     if (!xenixSupportsDepth8)
+ 	pScreenInfo->numPixmapFormats--;
+     for (i = NUMSCREENS, dev = devStart; --i > 0; dev++) {
+ 	if (xenixFbData[dev].createProc)
+ 	    (*xenixFbData[dev].createProc)(pScreenInfo, argc, argv);
+     }
+     xenixGeneration = serverGeneration;
+     xenixInitCursor();
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * InitInput --
+  *	Initialize all supported input devices...what else is there
+  *	besides pointer and keyboard?
+  *
+  * Results:
+  *	None.
+  *
+  * Side Effects:
+  *	Two DeviceRec's are allocated and registered as the system pointer
+  *	and keyboard devices.
+  *
+  *-----------------------------------------------------------------------
+  */
+ /*ARGSUSED*/
+ InitInput(argc, argv)
+     int     	  argc;
+     char    	  **argv;
+ {
+     DevicePtr p, k;
+     static int  zero = 0;
+     
+     p = AddInputDevice(xenixMouseProc, TRUE);
+     k = AddInputDevice(xenixKbdProc, TRUE);
+     if (!p || !k)
+ 	FatalError("failed to create input devices in InitInput");
+ 
+     RegisterPointerDevice(p);
+     RegisterKeyboardDevice(k);
+     miRegisterPointerDevice(screenInfo.screens[0], p);
+ 
+     if (RegisterBlockAndWakeupHandlers(xenixBlock, xenixWakeup, 0) == FALSE)
+     	ErrorF("InitInput: RegisterBlockAndWakeupHandlers() failed\n");
+ 
+     SetInputCheck (&zero, &xenixEventPending);
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixScreenInit --
+  *	Things which must be done for all types of frame buffers...
+  *	Should be called last of all.
+  *
+  * Results:
+  *	TRUE if successful, else FALSE
+  *
+  * Side Effects:
+  *	Both a BlockHandler and a WakeupHandler are installed for the
+  *	first screen.  Together, these handlers implement autorepeat
+  *	keystrokes on the Xenix.
+  *
+  *-----------------------------------------------------------------------
+  */
+ Bool
+ xenixScreenInit (pScreen)
+     ScreenPtr	  pScreen;
+ {
+     extern void   xenixBlockHandler();
+     extern void   xenixWakeupHandler();
+     static ScreenPtr autoRepeatScreen;
+ 
+     extern miPointerCursorFuncRec   xenixPointerCursorFuncs;
+ 
+     /*
+      *	Block/Unblock handlers
+      */
+ 
+     if (autoRepeatHandlersInstalled == FALSE) {
+ 	autoRepeatScreen = pScreen;
+ 	autoRepeatHandlersInstalled = TRUE;
+     }
+ 
+     if (pScreen == autoRepeatScreen) {
+         pScreen->BlockHandler = xenixBlockHandler;
+         pScreen->WakeupHandler = xenixWakeupHandler;
+     }
+ 
+     miDCInitialize (pScreen, &xenixPointerCursorFuncs);
+ 
+     return TRUE;
+ }
+ 
+ 
+ extern char *getenv();
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * nthdev --
+  *	Return the nth device in a colon-separated list of devices.
+  *	n is 0-origin.
+  *
+  * Results:
+  *	A pointer to a STATIC string which is the device name.
+  *
+  * Side Effects:
+  *	None.
+  *
+  *-----------------------------------------------------------------------
+  */
+ static char *
+ nthdev (dList, n)
+     register char    *dList;	    /* Colon-separated device names */
+     int	    n;	  	    /* Device number wanted */
+ {
+     char *result;
+     static char returnstring[100];
+ 
+     while (n--) {
+ 	while (*dList && *dList != ':') {
+ 	    dList++;
+ 	}
+     }
+     if (*dList) {
+ 	register char *cp = dList;
+ 
+ 	while (*cp && *cp != ':') {
+ 	    cp++;
+ 	}
+ 	result = returnstring;
+ 	strncpy (result, dList, cp - dList);
+ 	result[cp - dList] = '\0';
+     } else {
+ 	result = (char *)0;
+     }
+     return (result);
+ }
+ 
+ /*-
+  *-----------------------------------------------------------------------
+  * xenixOpenFrameBuffer --
+  *	Open a frame buffer according to several rules. If running under
+  *	overview and we're set up for it, use the device given in the
+  *	PARENT envariable and note that the screen is under overview.
+  *	Else find the device to use by looking in the xenixFbData table,
+  *	an XDEVICE envariable, a -dev switch or using /dev/fb if trying
+  *	to open screen 0 and all else has failed.
+  *
+  * Results:
+  *	The fd of the framebuffer.
+  *
+  * Side Effects:
+  *
+  *-----------------------------------------------------------------------
+  */
+ int
+ xenixOpenFrameBuffer(expect, index, fbNum, argc, argv)
+     int	    	  expect;   	/* The expected type of framebuffer */
+     int	    	  fbNum;    	/* Index into the xenixFbData array */
+     int	    	  index;    	/* Screen index */
+     int	    	  argc;	    	/* Command-line arguments... */
+     char	  **argv;   	/* ... */
+ {
+     char       	  *name=(char *)0;
+     int           i;	    	/* Index into argument list */
+     int           fd = -1;	    	/* Descriptor to device */
+     static int	  devFbUsed=FALSE;  /* true if /dev/fb has been used for a */
+     	    	  	    	    /* screen already */
+     static Bool	  inited = FALSE;
+     static char	  *xdevice; 	/* string of devices to use from environ */
+     static char	  *devsw;   	/* string of devices from args */
+     int		  type;
+ 
+     if (!inited) {
+ 	xdevice = devsw = (char *)NULL;
+ 
+ 	xdevice = getenv (XDEVICE);
+ 	/*
+ 	 * Look for an argument of the form -dev <device-string>
+ 	 * If such a one is found place the <device-string> in devsw.
+ 	 */
+ 	for (i = 1; i < argc; i++) {
+ 	    if ((strcmp(argv[i], "-dev") == 0) && (i + 1 < argc)) {
+ 		devsw = argv[i+1];
+ 		break;
+ 	    }
+ 	}
+ 	inited = TRUE;
+     }
+ 
+     /*
+      * Attempt to find a file name for the frame buffer 
+      */
+ 
+     /*
+      * First see if any device was given on the command line.
+      * If one was and the device is both readable and writeable,
+      * set 'name' to it, else set it to NULL.
+      */
+     if (devsw == (char *)NULL ||
+ 	(name = nthdev (devsw, index)) == (char *)NULL ||
+ 	(access (name, R_OK | W_OK) != 0) ||
+ 	(strcmp(name, xenixFbData[fbNum].devName) != 0)) {
+ 	    name = (char *)NULL;
+     }
+ 	    
+     /*
+      * If we still don't have a device for this screen, check the
+      * environment variable for one. If one was given, stick its
+      * path in name and check its accessibility. If it's not
+      * properly accessible, then reset the name to NULL to force the
+      * checking of the xenixFbData array.
+      */
+     if (devsw == (char *)NULL && name == (char *)NULL &&
+ 	xdevice != (char *)NULL &&
+ 	(name = nthdev(xdevice, index)) != (char *)NULL &&
+ 	(access (name, R_OK | W_OK) != 0)) {
+ 	    name = (char *)NULL;
+     }
+ 
+     /*
+      * Take the device given in the frame buffer description
+      * and see if it exists and is accessible. If it does/is,
+      * we will use it, as long as no other device was given.
+      */
+     if (devsw == (char *)NULL && name == (char *)NULL &&
+ 	access(xenixFbData[fbNum].devName, (R_OK | W_OK)) == 0) {
+ 	    name = xenixFbData[fbNum].devName;
+     }
+ 
+     /*
+      * If we still have nothing and have yet to use "/dev/vga" for
+      * a screen, default the name to be "/dev/vga"
+      */
+     if (devsw == (char *)NULL && name == (char *)NULL && !devFbUsed) {
+ 	name = "/dev/vga";
+     }
+ 
+     if (name) {
+ 	fd = open(name, O_RDWR, 0);
+         if (fd < 0) {
+ 	    return (-1);
+ 	} 
+ 	/* init screen here */
+     }
+ 
+     if (name && strcmp (name, "/dev/vga") == 0) {
+ 	devFbUsed = TRUE;
+     }
+ 
+     return (fd);
+ }
+ 
+ /*****************************************************************************/
+ 
+ void
+ xenixInitCursor()
+ {
+ }
+ 
+ 
*** X11R4.ORIG/mit/server/ddx/xenix/trident/xenix.h	Sun Jan  6 01:03:48 1991
--- X11R4/mit/server/ddx/xenix/trident/xenix.h	Sun Dec  9 18:52:38 1990
***************
*** 0 ****
--- 1,241 ----
+ /*
+  * xenix.h			Modified for Xenix by Chain Lee 08/90
+  */
+ 
+ /*-
+  * sun.h --
+  *	Internal declarations for the sun ddx interface
+  *
+  * Copyright (c) 1987 by the Regents of the University of California
+  *
+  * Permission to use, copy, modify, and distribute this
+  * software and its documentation for any purpose and without
+  * fee is hereby granted, provided that the above copyright
+  * notice appear in all copies.  The University of California
+  * makes no representations about the suitability of this
+  * software for any purpose.  It is provided "as is" without
+  * express or implied warranty.
+  *
+  *	"$XConsortium: sun.h,v 5.7 89/12/06 09:37:35 rws Exp $ SPRITE (Berkeley)"
+  */
+ 
+ #ifndef _XENIX_H_
+ #define _XENIX_H_
+ 
+ #include    <errno.h>
+ extern int  errno;
+ #include    <sys/param.h>
+ #include    <sys/types.h>
+ #include    <sys/select.h>
+ #include    <sys/file.h>
+ #include    <sys/fcntl.h>
+ #include    <sys/signal.h>
+ #include    <unistd.h>
+ 
+ #include    <sys/termio.h>
+ #include    <sys/machdep.h>
+ #include    <sys/sysmacros.h>
+ 
+ #define	    PGSIZE	ctob(1)
+ 
+ #include    <sys/event.h>
+ #include    <mouse.h>
+ #include    <sys/vtkd.h>
+ 
+ #include    "xenixDevInfo.h"
+ 
+ #include    "X.h"
+ #include    "Xproto.h"
+ #include    "scrnintstr.h"
+ #include    "screenint.h"
+ #ifdef NEED_EVENTS
+ #include    "inputstr.h"
+ #endif NEED_EVENTS
+ #include    "input.h"
+ #include    "cursorstr.h"
+ #include    "cursor.h"
+ #include    "pixmapstr.h"
+ #include    "pixmap.h"
+ #include    "windowstr.h"
+ #include    "gc.h"
+ #include    "gcstruct.h"
+ #include    "regionstr.h"
+ #include    "colormap.h"
+ #include    "miscstruct.h"
+ #include    "dix.h"
+ #include    "mfb.h"
+ #include    "mi.h"
+ 
+ /*
+  * MAXEVENTS is the maximum number of events the mouse and keyboard functions
+  * will read on a given call to their GetEvents vectors.
+  */
+ #define MAXEVENTS 	32
+ 
+ KeybdCtrl	  *ctrl;    	    	/* Current control structure (for
+  					 * keyclick, bell duration, auto-
+  					 * repeat, etc.) */
+ 
+ typedef	struct kbPrivate {
+     int		  type;			/* Type	of keyboard */
+     void	  (*ProcessEvent)();	/* Function to process an event	*/
+     void	  (*DoneEvents)();	/* Function called when	all events */
+ 					/* have	been handled. */
+     pointer	  devPrivate;		/* Private to keyboard device */
+     int		  offset;		/* to be added to device keycodes */
+     KeybdCtrl	  *ctrl;		/* Current control structure (for
+ 					 * keyclick, bell duration, auto-
+ 					 * repeat, etc.) */
+ } KbPrivRec, *KbPrivPtr;
+ 
+ #define	MIN_KEYCODE	8	/* necessary to avoid the mouse buttons */
+ 
+ typedef	struct ptrPrivate {
+     void	  (*ProcessEvent)();	/* Function to process an event	*/
+     void	  (*DoneEvents)();	/* When	all the	events have been */
+ 					/* handled, this function will be */
+ 					/* called. */
+     short	  x,			/* Current X coordinate	of pointer */
+ 		  y;			/* Current Y coordinate	*/
+     pointer	  devPrivate;		/* Field private to device */
+ } PtrPrivRec, *PtrPrivPtr;
+ 
+ 
+ /*
+  * Cursor-private data
+  *	screenBits	saves the contents of the screen before the cursor
+  *	    	  	was placed in the frame buffer.
+  *	source	  	a bitmap for placing the foreground pixels down
+  *	srcGC	  	a GC for placing the foreground pixels down.
+  *	    	  	Prevalidated for the cursor's screen.
+  *	invSource 	a bitmap for placing the background pixels down.
+  *	invSrcGC  	a GC for placing the background pixels down.
+  *	    	  	Also prevalidated for the cursor's screen Pixmap.
+  *	temp	  	a temporary pixmap for low-flicker cursor motion --
+  *	    	  	exists to avoid the overhead of creating a pixmap
+  *	    	  	whenever the cursor must be moved.
+  *	fg, bg	  	foreground and background pixels. For a color display,
+  *	    	  	these are allocated once and the rgb values changed
+  *	    	  	when the cursor is recolored.
+  *	scrX, scrY	the coordinate on the screen of the upper-left corner
+  *	    	  	of screenBits.
+  *	state	  	one of CR_IN, CR_OUT and CR_XING to track whether the
+  *	    	  	cursor is in or out of the frame buffer or is in the
+  *	    	  	process of going from one state to the other.
+  */
+ typedef enum {
+     CR_IN,		/* Cursor in frame buffer */
+     CR_OUT,		/* Cursor out of frame buffer */
+     CR_XING	  	/* Cursor in flux */
+ } CrState;
+ 
+ typedef struct crPrivate {
+     PixmapPtr  	        screenBits; /* Screen before cursor put down */
+     PixmapPtr  	        source;     /* Cursor source (foreground bits) */
+     GCPtr   	  	srcGC;	    /* Foreground GC */
+     PixmapPtr  	        invSource;  /* Cursor source inverted (background) */
+     GCPtr   	  	invSrcGC;   /* Background GC */
+     PixmapPtr  	        temp;	    /* Temporary pixmap for merging screenBits
+ 				     * and the sources. Saves creation time */
+     Pixel   	  	fg; 	    /* Foreground color */
+     Pixel   	  	bg; 	    /* Background color */
+     int	    	  	scrX,	    /* Screen X coordinate of screenBits */
+ 			scrY;	    /* Screen Y coordinate of screenBits */
+     CrState		state;      /* Current state of the cursor */
+ } CrPrivRec, *CrPrivPtr;
+ 
+ /*
+  * Frame-buffer-private info.
+  *	fd  	  	file opened to the frame buffer device.
+  *	info	  	description of the frame buffer -- type, height, depth,
+  *	    	  	width, etc.
+  *	fb  	  	pointer to the mapped image of the frame buffer. Used
+  *	    	  	by the driving routines for the specific frame buffer
+  *	    	  	type.
+  *	mapped	  	flag set true by the driver when the frame buffer has
+  *	    	  	been mapped in.
+  *	parent	  	set true if the frame buffer is actually a SunWindows
+  *	    	  	window.
+  *	fbPriv	  	Data private to the frame buffer type.
+  */
+ typedef struct {
+     pointer 	  	fb; 	    /* Frame buffer itself */
+     Bool    	  	mapped;	    /* TRUE if frame buffer already mapped */
+     int	    	  	fd; 	    /* Descriptor open to frame buffer */
+     int			fb_width;
+     int			fb_height;
+     int			fb_size;
+     void		(*EnterLeave)();    /* screen switch */
+     pointer 	  	fbPriv;	    /* Frame-buffer-dependent data */
+ } fbFd;
+ 
+ extern Bool xenixSupportsDepth8;
+ extern unsigned long xenixGeneration;
+ 
+ typedef struct _xenixFbDataRec {
+     Bool    (*probeProc)();	/* probe procedure for this fb */
+     char    *devName;		/* device filename */
+     Bool    (*createProc)();	/* create procedure for this fb */
+ } xenixFbDataRec;
+ 
+ extern xenixFbDataRec xenixFbData[];
+ /*
+  * Cursor functions
+  */
+ extern void 	  xenixInitCursor();
+ 
+ /*
+  * Initialization
+  */
+ extern Bool 	  xenixScreenInit();
+ extern int  	  xenixOpenFrameBuffer();
+ 
+ extern fbFd 	  xenixFbs[];
+ 
+ extern int  	  lastEventTime;    /* Time (in ms.) of last event */
+ extern void 	  SetTimeSinceLastInputEvent();
+ 
+ extern int monitorResolution;
+ 
+ #define AUTOREPEAT_INITIATE	(200)		/* milliseconds */
+ #define AUTOREPEAT_DELAY	(50)		/* milliseconds */
+ /*
+  * We signal autorepeat events with the unique Firm_event
+  * id AUTOREPEAT_EVENTID.
+  * Because inputevent ie_code is set to Firm_event ids in
+  * sunKbdProcessEventSunWin, and ie_code is short whereas
+  * Firm_event id is u_short, we use 0x7fff.
+  */
+ #define AUTOREPEAT_EVENTID      (0x7fff)        /* AutoRepeat Firm_event id */
+ 
+ extern int	autoRepeatKeyDown;		/* TRUE if key down */
+ extern int	autoRepeatReady;		/* TRUE if time out */
+ extern int	autoRepeatDebug;		/* TRUE if debugging */
+ extern long	autoRepeatInitiate;
+ extern long 	autoRepeatDelay;
+ extern struct timeval autoRepeatLastKeyDownTv;
+ extern struct timeval autoRepeatDeltaTv;
+ 
+ #define tvminus(tv, tv1, tv2)	/* tv = tv1 - tv2 */ \
+ 		if ((tv1).tv_usec < (tv2).tv_usec) { \
+ 			(tv1).tv_usec += 1000000; \
+ 			(tv1).tv_sec -= 1; \
+ 		} \
+ 		(tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
+ 		(tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
+ 
+ #define tvplus(tv, tv1, tv2)	/* tv = tv1 + tv2 */ \
+ 		(tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
+ 		(tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
+ 		if ((tv).tv_usec > 1000000) { \
+ 			(tv).tv_usec -= 1000000; \
+ 			(tv).tv_sec += 1; \
+ 		}
+ 
+ /*-
+  * TVTOMILLI(tv)
+  *	Given a struct timeval, convert its time into milliseconds...
+  */
+ #define TVTOMILLI(tv)	(((tv).tv_usec/1000)+((tv).tv_sec*1000))
+ 
+ #endif _XENIX_H_



More information about the Alt.sources mailing list