home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / macII / macII.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-14  |  9.2 KB  |  317 lines

  1. /************************************************************ 
  2. Copyright 1988 by Apple Computer, Inc, Cupertino, California
  3.             All Rights Reserved
  4.  
  5. Permission to use, copy, modify, and distribute this software
  6. for any purpose and without fee is hereby granted, provided
  7. that the above copyright notice appear in all copies.
  8.  
  9. APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS,
  10. OR IMPLIED, WITH RESPECT TO THIS SOFTWARE, ITS QUALITY,
  11. PERFORMANCE, MERCHANABILITY, OR FITNESS FOR A PARTICULAR
  12. PURPOSE. AS A RESULT, THIS SOFTWARE IS PROVIDED "AS IS,"
  13. AND YOU THE USER ARE ASSUMING THE ENTIRE RISK AS TO ITS
  14. QUALITY AND PERFORMANCE. IN NO EVENT WILL APPLE BE LIABLE 
  15. FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  16. DAMAGES RESULTING FROM ANY DEFECT IN THE SOFTWARE.
  17.  
  18. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE
  19. AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR
  20. IMPLIED.
  21.  
  22. ************************************************************/
  23. /*-
  24.  * macII.h --
  25.  *    Internal declarations for the macII ddx interface
  26.  *
  27.  * Copyright (c) 1987 by the Regents of the University of California
  28.  *
  29.  * Permission to use, copy, modify, and distribute this
  30.  * software and its documentation for any purpose and without
  31.  * fee is hereby granted, provided that the above copyright
  32.  * notice appear in all copies.  The University of California
  33.  * makes no representations about the suitability of this
  34.  * software for any purpose.  It is provided "as is" without
  35.  * express or implied warranty.
  36.  *
  37.  * $XConsortium: macII.h,v 1.17 91/05/14 16:25:08 rws Exp $
  38.  */
  39. #ifndef _MACII_H_
  40. #define _MACII_H_
  41.  
  42. #include    <errno.h>
  43. #include    <sys/param.h>
  44. #include    <sys/types.h>
  45. #include    <sys/time.h>
  46. #include    <sys/file.h>
  47. #include    <sys/signal.h>
  48. #include    <sys/stropts.h>
  49.  
  50. /*
  51.  * Under A/UX 2.0 struct video has been "Macintized" and now incorporates
  52.  * a structure called AuxDCE which is defined once and for all in
  53.  * /usr/include/mac. Alas the definition for AuxDCE requires wheeling in
  54.  * lots of Mac stuff including QuickDraw. This is a headache as there are
  55.  * a variety of clashes between X and QuickDraw (they both do windows after
  56.  * all). So we define just what we need here and avoid pulling in the Mac
  57.  * includes. Of course if this ever changes ...
  58.  */
  59.  
  60. #ifndef __OSUTILS__
  61. struct QElem {
  62.     struct QElem *qLink;
  63.     short qType;
  64.     short qData[1];
  65. };
  66.  
  67. typedef struct QElem QElem;
  68.  
  69. typedef QElem *QElemPtr;
  70.  
  71. struct QHdr {
  72.     short qFlags;
  73.     QElemPtr qHead;
  74.     QElemPtr qTail;
  75. };
  76. #define __OSUTILS__
  77. #endif
  78.  
  79. #ifndef __DEVICES__
  80. struct CntrlParam {
  81.         struct QElem *qLink;
  82.         short qType;
  83.         short ioTrap;
  84.         char *ioCmdAddr;
  85.         int (*ioCompletion)();
  86.         short ioResult;
  87.         char *ioNamePtr;
  88.         short ioVRefNum;
  89.         short ioCRefNum;
  90.         short csCode;
  91.         short csParam[11];
  92. };
  93.  
  94. struct DCtlEntry {
  95.         char **dCtlDriver;
  96.         short dCtlFlags;
  97.         struct QHdr dCtlQHdr;
  98.         long dCtlPosition;
  99.         char **dCtlStorage;
  100.         short dCtlRefNum;
  101.         long dCtlCurTicks;
  102.         char *dCtlWindow;
  103.         short dCtlDelay;
  104.         short dCtlEMask;
  105.         short dCtlMenu;
  106.         char dCtlSlot;
  107.         char dCtlSlotId;
  108.         long dCtlDevBase;
  109.         long reserved;
  110.         char dCtlExtDev;
  111.         char fillByte;
  112. };
  113.  
  114. struct AuxDCE {
  115.         char **dCtlDriver;
  116.         short dCtlFlags;
  117.         struct QHdr dCtlQHdr;
  118.         long dCtlPosition;
  119.         char **dCtlStorage;
  120.         short dCtlRefNum;
  121.         long dCtlCurTicks;
  122.         char *dCtlWindow;
  123.         short dCtlDelay;
  124.         short dCtlEMask;
  125.         short dCtlMenu;
  126.         char dCtlSlot;
  127.         char dCtlSlotId;
  128.         long dCtlDevBase;
  129.         long reserved;
  130.         char dCtlExtDev;
  131.         char fillByte;
  132. };
  133.  
  134. #define __DEVICES__
  135. #endif
  136.  
  137. #include    <sys/video.h>
  138.  
  139. #include    "X.h"
  140. #include    "Xproto.h"
  141. #include    "scrnintstr.h"
  142. #include    "screenint.h"
  143. #ifdef NEED_EVENTS
  144. #include    "inputstr.h"
  145. #endif /* NEED_EVENTS */
  146. #include    "input.h"
  147. #include    "cursorstr.h"
  148. #include    "cursor.h"
  149. #include    "pixmapstr.h"
  150. #include    "pixmap.h"
  151. #include    "windowstr.h"
  152. #include    "gc.h"
  153. #include    "gcstruct.h"
  154. #include    "regionstr.h"
  155. #include    "colormap.h"
  156. #include    "miscstruct.h"
  157. #include    "dix.h"
  158. #include    "mfb.h"
  159. #include    "mi.h"
  160.  
  161. /*
  162.  * MAXEVENTS is the maximum number of events the mouse and keyboard functions
  163.  * will read on a given call to their GetEvents vectors.
  164.  */
  165. #define MAXEVENTS     32
  166.  
  167. /*
  168.  * Data private to any macII keyboard.
  169.  *    ProcessEvent processes a single event and gives it to DIX
  170.  *    DoneEvents is called when done handling a string of keyboard
  171.  *        events or done handling all events.
  172.  *    devPrivate is private to the specific keyboard.
  173.  */
  174. #define KEY_DETAIL(e)     ((e) & 0x7f)
  175. #define KEY_UP(e)         ((e) & 0x80)
  176.  
  177. #define MS_LEFT     1
  178. #define MS_MIDDLE     2
  179. #define MS_RIGHT     3
  180.  
  181. #define MOUSE_ESCAPE     0x7e            /* from <sys/video.h> */
  182. #define PSEUDO_MIDDLE_1 0x3b             /* Left Arrow Key */
  183. #define PSEUDO_RIGHT_1     0x3c             /* Right Arrow Key */
  184. #define PSEUDO_MIDDLE_2 PSEUDO_MIDDLE_1        /* extra defs just in case */
  185. #define PSEUDO_RIGHT_2     PSEUDO_RIGHT_1
  186.  
  187. #define IS_MIDDLE_KEY(c)             \
  188.     ((KEY_DETAIL(c) == PSEUDO_MIDDLE_1) ||     \
  189.      (KEY_DETAIL(c) == PSEUDO_MIDDLE_2))
  190.  
  191. #define IS_RIGHT_KEY(c)             \
  192.           ((KEY_DETAIL(c) == PSEUDO_RIGHT_1) ||     \
  193.      (KEY_DETAIL(c) == PSEUDO_RIGHT_2))
  194.  
  195. #define IS_MOUSE_KEY(c)                 \
  196.     (IS_MIDDLE_KEY(c) || IS_RIGHT_KEY(c))
  197.  
  198.  
  199. #define KBTYPE_MACII     0
  200.  
  201. typedef struct kbPrivate {
  202.     int              type;               /* Type of keyboard */
  203.     void          (*EnqueueEvent)();    /* Function to process an event */
  204.     int          offset;        /* to be added to device keycodes */
  205.     KeybdCtrl     *ctrl;                /* Current control structure (for
  206.                                          * keyclick, bell duration, auto-
  207.                                          * repeat, etc.) */
  208. } KbPrivRec, *KbPrivPtr;
  209.  
  210. #define    MIN_KEYCODE    8    /* necessary to avoid the mouse buttons */
  211.  
  212. /*
  213.  * Data private to any macII pointer device.
  214.  *    ProcessEvent and DoneEvents have uses similar to the
  215.  *        keyboard fields of the same name.
  216.  *    pScreen is the screen the pointer is on (only valid if it is the
  217.  *        main pointer device).
  218.  *    x and y are absolute coordinates on that screen (they may be negative)
  219.  */
  220. typedef struct ptrPrivate {
  221.     void          (*EnqueueEvent)();    /* Function to process an event */
  222.     ScreenPtr      pScreen;              /* Screen pointer is on */
  223. } PtrPrivRec, *PtrPrivPtr;
  224.  
  225. /*
  226.  * Frame-buffer-private info.
  227.  *    fb            pointer to the mapped image of the frame buffer. Used
  228.  *                  by the driving routines for the specific frame buffer
  229.  *                  type.
  230.  *    slot
  231.  *    default_depth
  232.  *    installedMap
  233.  *    info          description of the frame buffer -- type, height, depth,
  234.  *                  width, etc.
  235.  *    fbPriv          Data private to the frame buffer type.
  236.  */
  237.  
  238. #define FBTYPE_MACII 0
  239.  
  240. typedef struct video_data fbtype;
  241.  
  242. typedef struct {
  243.     pointer           fb;         /* Frame buffer itself */
  244.     int            slot;
  245.     int            default_depth;
  246.     ColormapPtr        installedMap;
  247.     fbtype         info;        /* Frame buffer characteristics */
  248.     pointer           fbPriv;        /* Frame-buffer-dependent data */
  249. } fbFd;
  250.  
  251. extern fbFd       macIIFbs[];
  252.  
  253. /*
  254.  * Data describing each type of frame buffer. The probeProc is called to
  255.  * see if such a device exists and to do what needs doing if it does. devName
  256.  * is the expected name of the device in the file system. 
  257.  */
  258. typedef enum {
  259.     neverProbed, probedAndSucceeded, probedAndFailed
  260. } macIIProbeStatus;
  261.  
  262. typedef struct _macIIFbDataRec {
  263.     Bool    (*probeProc)();    /* probe procedure for this fb */
  264.     char    *devName;        /* device filename */
  265.     macIIProbeStatus probeStatus;    /* TRUE if fb has been probed successfully */
  266. } macIIFbDataRec;
  267.  
  268. extern macIIFbDataRec macIIFbData[];
  269.  
  270. /*
  271.  * Initialization
  272.  */
  273. extern Bool       macIIScreenInit();
  274. extern int        macIIOpenFrameBuffer();
  275.  
  276. extern int        macIICheckInput;    /* Non-zero if input is available */
  277.  
  278. extern int        lastEventTime;    /* Time (in ms.) of last event */
  279. extern void       SetTimeSinceLastInputEvent();
  280.  
  281. #define AUTOREPEAT_INITIATE     (400)           /* milliseconds */
  282. #define AUTOREPEAT_DELAY        (50)           /* milliseconds */
  283. /*
  284.  * We signal autorepeat events with the unique id AUTOREPEAT_EVENTID.
  285.  */
  286. #define AUTOREPEAT_EVENTID      (0x7d)          /* AutoRepeat id */
  287.  
  288. /*-
  289.  * TVTOMILLI(tv)
  290.  *    Given a struct timeval, convert its time into milliseconds...
  291.  */
  292. #define TVTOMILLI(tv)    (((tv).tv_usec/1000)+((tv).tv_sec*1000))
  293.  
  294. #define tvminus(tv, tv1, tv2) /* tv = tv1 - tv2 */ \
  295.               if ((tv1).tv_usec < (tv2).tv_usec) { \
  296.                       (tv1).tv_usec += 1000000; \
  297.                       (tv1).tv_sec -= 1; \
  298.               } \
  299.               (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
  300.               (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
  301.  
  302. #define tvplus(tv, tv1, tv2)  /* tv = tv1 + tv2 */ \
  303.               (tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
  304.               (tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
  305.               if ((tv).tv_usec > 1000000) { \
  306.                       (tv).tv_usec -= 1000000; \
  307.                       (tv).tv_sec += 1; \
  308.               }
  309.  
  310. #define gettimeofday(time, timezone) _gettimeofday(time)
  311.  
  312. #define LookupPointerDevice()    pPointerDevice
  313. #define LookupKeyboardDevice()    pKeyboardDevice
  314. extern DevicePtr pPointerDevice, pKeyboardDevice;
  315.  
  316. #endif /* _MACII_H_ */
  317.