home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / sun / sun.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-22  |  9.5 KB  |  285 lines

  1. /*-
  2.  * sun.h --
  3.  *    Internal declarations for the sun ddx interface
  4.  *
  5.  * Copyright (c) 1987 by the Regents of the University of California
  6.  *
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  *    "$XConsortium: sun.h,v 5.12 91/07/22 23:47:22 keith Exp $ SPRITE (Berkeley)"
  16.  */
  17. #ifndef _SUN_H_
  18. #define _SUN_H_
  19.  
  20. #include    <errno.h>
  21. extern int  errno;
  22. #include    <sys/param.h>
  23. #include    <sys/types.h>
  24. #include    <sys/time.h>
  25. #include    <sys/file.h>
  26. #include    <sys/fcntl.h>
  27. #include    <sys/signal.h>
  28. #include    <sundev/kbd.h>
  29. #include    <sundev/kbio.h>
  30. #include    <sundev/msio.h>
  31. #include    <sun/fbio.h>
  32.  
  33. /*
  34.  * SUN_WINDOWS is now defined (or not) by the Makefile
  35.  * variable $(SUNWINDOWSFLAGS) in server/Makefile.
  36.  */
  37.  
  38. #ifdef SUN_WINDOWS
  39. #include    <varargs.h>
  40. #include    <sys/ioctl.h>
  41. #include    <stdio.h>
  42. #include    <pixrect/pixrect_hs.h>
  43. #include    <sunwindow/rect.h>
  44. #include    <sunwindow/rectlist.h>
  45. #include    <sunwindow/pixwin.h>
  46. #include    <sunwindow/win_screen.h>
  47. #include    <sunwindow/win_input.h>
  48. #include    <sunwindow/cms.h>
  49. #include    <sunwindow/win_struct.h>
  50. #else 
  51. /* already included by sunwindow/win_input.h */
  52. #include    <sundev/vuid_event.h>
  53. #endif /* SUN_WINDOWS */
  54.  
  55. #include    "X.h"
  56. #include    "Xproto.h"
  57. #include    "misc.h"
  58. #include    "scrnintstr.h"
  59. #ifdef NEED_EVENTS
  60. #include    "inputstr.h"
  61. #endif /* NEED_EVENTS */
  62. #include    "input.h"
  63. #include    "colormapst.h"
  64. #include    "dix.h"
  65. #include    "cursor.h"
  66.  
  67. /*
  68.  * MAXEVENTS is the maximum number of events the mouse and keyboard functions
  69.  * will read on a given call to their GetEvents vectors.
  70.  */
  71. #define MAXEVENTS     32
  72.  
  73. /*
  74.  * Data private to any sun keyboard.
  75.  *    GetEvents reads any events which are available for the keyboard
  76.  *    ProcessEvent processes a single event and gives it to DIX
  77.  *    DoneEvents is called when done handling a string of keyboard
  78.  *        events or done handling all events.
  79.  *    devPrivate is private to the specific keyboard.
  80.  *    map_q is TRUE if the event queue for the keyboard is memory mapped.
  81.  */
  82. typedef struct kbPrivate {
  83.     int              type;               /* Type of keyboard */
  84.     int              fd;                    /* Descriptor open to device */
  85.     Firm_event      *(*GetEvents)();      /* Function to read events */
  86.     void          (*EnqueueEvent)();    /* Function to process an event */
  87.     pointer       devPrivate;            /* Private to keyboard device */
  88.     Bool      map_q;        /* TRUE if fd has a mapped event queue */
  89.     int          offset;        /* to be added to device keycodes */
  90.     KeybdCtrl      *ctrl;                /* Current control structure (for
  91.                       * keyclick, bell duration, auto-
  92.                       * repeat, etc.) */
  93.     char      lockLight;        /* Caps Lock light state */
  94. } KbPrivRec, *KbPrivPtr;
  95.  
  96. #define SUN_LOCK_LED    8    /* can't find this in an include file */
  97. #define SUN_LED_MASK    0x0f    /*  nor this */
  98. #define    MIN_KEYCODE    8    /* necessary to avoid the mouse buttons */
  99. #ifndef KB_SUN4
  100. #define KB_SUN4        0x04    /* Type 4 Sun keyboard */
  101. #endif
  102.  
  103. /*
  104.  * Data private to any sun pointer device.
  105.  *    GetEvents, ProcessEvent and DoneEvents have uses similar to the
  106.  *        keyboard fields of the same name.
  107.  *    pScreen is the screen the pointer is on (only valid if it is the
  108.  *        main pointer device).
  109.  *    dx and dy are relative coordinates on that screen (they may be negative)
  110.  */
  111. typedef struct ptrPrivate {
  112.     int              fd;                    /* Descriptor to device */
  113.     Firm_event       *(*GetEvents)();     /* Function to read events */
  114.     void          (*EnqueueEvent)();    /* Function to process an event */
  115.     pointer          devPrivate;            /* Field private to device */
  116. } PtrPrivRec, *PtrPrivPtr;
  117.  
  118. /*
  119.  * Cursor-private data
  120.  *    screenBits    saves the contents of the screen before the cursor
  121.  *                  was placed in the frame buffer.
  122.  *    source          a bitmap for placing the foreground pixels down
  123.  *    srcGC          a GC for placing the foreground pixels down.
  124.  *                  Prevalidated for the cursor's screen.
  125.  *    invSource     a bitmap for placing the background pixels down.
  126.  *    invSrcGC      a GC for placing the background pixels down.
  127.  *                  Also prevalidated for the cursor's screen Pixmap.
  128.  *    temp          a temporary pixmap for low-flicker cursor motion --
  129.  *                  exists to avoid the overhead of creating a pixmap
  130.  *                  whenever the cursor must be moved.
  131.  *    fg, bg          foreground and background pixels. For a color display,
  132.  *                  these are allocated once and the rgb values changed
  133.  *                  when the cursor is recolored.
  134.  *    scrX, scrY    the coordinate on the screen of the upper-left corner
  135.  *                  of screenBits.
  136.  *    state          one of CR_IN, CR_OUT and CR_XING to track whether the
  137.  *                  cursor is in or out of the frame buffer or is in the
  138.  *                  process of going from one state to the other.
  139.  */
  140. typedef enum {
  141.     CR_IN,        /* Cursor in frame buffer */
  142.     CR_OUT,        /* Cursor out of frame buffer */
  143.     CR_XING          /* Cursor in flux */
  144. } CrState;
  145.  
  146. typedef struct crPrivate {
  147.     PixmapPtr              screenBits; /* Screen before cursor put down */
  148.     PixmapPtr              source;     /* Cursor source (foreground bits) */
  149.     GCPtr             srcGC;        /* Foreground GC */
  150.     PixmapPtr              invSource;  /* Cursor source inverted (background) */
  151.     GCPtr             invSrcGC;   /* Background GC */
  152.     PixmapPtr              temp;        /* Temporary pixmap for merging screenBits
  153.                      * and the sources. Saves creation time */
  154.     Pixel             fg;         /* Foreground color */
  155.     Pixel             bg;         /* Background color */
  156.     int                  scrX,        /* Screen X coordinate of screenBits */
  157.             scrY;        /* Screen Y coordinate of screenBits */
  158.     CrState        state;      /* Current state of the cursor */
  159. } CrPrivRec, *CrPrivPtr;
  160.  
  161. extern int  sunScreenIndex;
  162.  
  163. typedef struct {
  164.     int            width, height;
  165.     Bool        has_cursor;
  166. } sunCursorRec, *sunCursorPtr;
  167.  
  168. typedef struct {
  169.     ColormapPtr        installedMap;
  170.     Bool        (*CloseScreen)();
  171.     void        (*UpdateColormap)();
  172.     sunCursorRec    hardwareCursor;
  173.     Bool        hasHardwareCursor;
  174. #ifdef SUN_WINDOWS
  175.     Bool        (*SetCursorPosition)();
  176. #endif
  177. } sunScreenRec, *sunScreenPtr;
  178.  
  179. #define GetScreenPrivate(s)   ((sunScreenPtr) ((s)->devPrivates[sunScreenIndex].ptr))
  180. #define SetupScreen(s)    sunScreenPtr    pPrivate = GetScreenPrivate(s)
  181.  
  182. /*
  183.  * Frame-buffer-private info.
  184.  *    fd            file opened to the frame buffer device.
  185.  *    info          description of the frame buffer -- type, height, depth,
  186.  *                  width, etc.
  187.  *    fb            pointer to the mapped image of the frame buffer. Used
  188.  *                  by the driving routines for the specific frame buffer
  189.  *                  type.
  190.  *    mapped          flag set true by the driver when the frame buffer has
  191.  *                  been mapped in.
  192.  *    parent          set true if the frame buffer is actually a SunWindows
  193.  *                  window.
  194.  *    fbPriv          Data private to the frame buffer type.
  195.  */
  196. typedef struct {
  197.     pointer           fb;         /* Frame buffer itself */
  198.     Bool              mapped;        /* TRUE if frame buffer already mapped */
  199.     Bool        parent;        /* TRUE if fd is a SunWindows window */
  200.     int                  fd;         /* Descriptor open to frame buffer */
  201.     struct fbtype     info;        /* Frame buffer characteristics */
  202.     void        (*EnterLeave)();    /* screen switch */
  203.     pointer           fbPriv;        /* Frame-buffer-dependent data */
  204. } fbFd;
  205.  
  206. extern Bool sunSupportsDepth8;
  207. extern unsigned long sunGeneration;
  208.  
  209.  
  210. typedef struct _sunFbDataRec {
  211.     Bool    (*probeProc)();    /* probe procedure for this fb */
  212.     char    *devName;        /* device filename */
  213.     Bool    (*createProc)();    /* create procedure for this fb */
  214. } sunFbDataRec;
  215.  
  216. extern sunFbDataRec sunFbData[];
  217. /*
  218.  * Cursor functions
  219.  */
  220. extern void       sunInitCursor();
  221. #ifdef SUN_WINDOWS
  222. extern Bool      sunSetCursorPosition();
  223. extern Bool      (*realSetCursorPosition)();
  224. #endif
  225.  
  226. /*
  227.  * Initialization
  228.  */
  229. extern Bool       sunScreenInit();
  230. extern int        sunOpenFrameBuffer();
  231.  
  232. extern fbFd       sunFbs[];
  233.  
  234. extern int        lastEventTime;    /* Time (in ms.) of last event */
  235. extern void       SetTimeSinceLastInputEvent();
  236.  
  237. extern int monitorResolution;
  238.  
  239. #define AUTOREPEAT_INITIATE    (200)        /* milliseconds */
  240. #define AUTOREPEAT_DELAY    (50)        /* milliseconds */
  241. /*
  242.  * We signal autorepeat events with the unique Firm_event
  243.  * id AUTOREPEAT_EVENTID.
  244.  * Because inputevent ie_code is set to Firm_event ids in
  245.  * sunKbdProcessEventSunWin, and ie_code is short whereas
  246.  * Firm_event id is u_short, we use 0x7fff.
  247.  */
  248. #define AUTOREPEAT_EVENTID      (0x7fff)        /* AutoRepeat Firm_event id */
  249.  
  250. extern int    autoRepeatKeyDown;        /* TRUE if key down */
  251. extern int    autoRepeatReady;        /* TRUE if time out */
  252. extern int    autoRepeatDebug;        /* TRUE if debugging */
  253. extern long    autoRepeatInitiate;
  254. extern long     autoRepeatDelay;
  255. extern struct timeval autoRepeatLastKeyDownTv;
  256. extern struct timeval autoRepeatDeltaTv;
  257.  
  258. #define tvminus(tv, tv1, tv2)    /* tv = tv1 - tv2 */ \
  259.         if ((tv1).tv_usec < (tv2).tv_usec) { \
  260.             (tv1).tv_usec += 1000000; \
  261.             (tv1).tv_sec -= 1; \
  262.         } \
  263.         (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
  264.         (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
  265.  
  266. #define tvplus(tv, tv1, tv2)    /* tv = tv1 + tv2 */ \
  267.         (tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
  268.         (tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
  269.         if ((tv).tv_usec > 1000000) { \
  270.             (tv).tv_usec -= 1000000; \
  271.             (tv).tv_sec += 1; \
  272.         }
  273.  
  274. /*-
  275.  * TVTOMILLI(tv)
  276.  *    Given a struct timeval, convert its time into milliseconds...
  277.  */
  278. #define TVTOMILLI(tv)    (((tv).tv_usec/1000)+((tv).tv_sec*1000))
  279.  
  280. #ifdef SUN_WINDOWS
  281. extern int windowFd;
  282. #endif /* SUN_WINDOWS */
  283.  
  284. #endif /* _SUN_H_ */
  285.