home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / ibm / AIX / AIXV3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  9.9 KB  |  333 lines

  1. /*
  2.  * $XConsortium: AIXV3.c,v 1.4 91/07/16 12:55:43 jap Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989,1990,1991
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * License to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND 
  18.  * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
  19.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23.  * SOFTWARE.
  24.  *
  25. */
  26.  
  27. #ifndef AIXV3
  28. #include <sys/select.h>
  29. #endif
  30. #include <ctype.h>
  31. #include "ibmTrace.h"
  32. #include "hftUtils.h"
  33.  
  34. #ifdef AIXV3
  35. #include <sys/time.h>
  36. #include "X_msg.h"
  37. extern void aixErrMsg();
  38. #endif
  39.  
  40. /*int     AIXDefaultDisplay= 0;*/
  41. int     AIXDefaultDisplay= HFT_SKYWAY_ID;
  42. #ifdef SOFTWARE_CURSOR
  43. int     AIXCurrentX= 640;
  44. int     AIXCurrentY= 512;
  45. #else
  46. int     AIXCurrentX= 0;
  47. int     AIXCurrentY= 0;
  48. #endif
  49. int     AIXMouseChordDelay=     20;
  50.  
  51. extern  int     hftPending;
  52. static  int     handleInput;
  53.  
  54. /***====================================================================***/
  55.  
  56.     /*
  57.      * BlockHandler is called just before the server goes into select
  58.      * forever (effectively),  WakeupHandler is called when select
  59.      * returns (times out or is interrupted).
  60.      *
  61.      * Normally, the hft interrupt knocks us out of select, but not
  62.      * back to Dispatch() -- only to WaitForSomething().  WaitForSomething()
  63.      * does *not* check device input -- it loops back around to the block
  64.      * handler and select.  It doesn't return to dispatch until a client
  65.      * does something.  The WakeupHandler only needs to dispatch input
  66.      * events when we're waiting for clients in WaitForSomething().
  67.      *
  68.      * We need to set a timeout if input is pending, because
  69.      * hftDispatchEvents wants to be called periodically if it has
  70.      * a pending timeout, and it won't be generating any interrupts to
  71.      * blow the select away.
  72.      *
  73.      * waittime is used to get a reasonable amount of time for timeouts
  74.      * in the hft queue.  The value of the timeout below was derived
  75.      * experimentally -- I played with the length of the timeout
  76.      * until the mouse felt "right."
  77.      */
  78.  
  79. int SelectWaitTime = 10000; /* usec */
  80.  
  81. void
  82. AIXBlockHandler(scrNdx,blockData,ppTimeout,pReadmask)
  83.     int     scrNdx;
  84.     char    *blockData;
  85.     struct timeval  **ppTimeout;
  86.     unsigned        *pReadmask;
  87. {
  88. static  struct timeval waittime = { 0, 0 };  /* {sec, usec} */
  89.  
  90.     TRACE(("AIXBlockHandler()\n"));
  91.     waittime.tv_usec = SelectWaitTime;
  92.     if (hftPending) {
  93.     *ppTimeout= &waittime;
  94.     handleInput= 1;
  95.     }
  96.     else {
  97.     hftInterruptAlways();
  98.     handleInput= 0;
  99.     }
  100.     return;
  101. }
  102.  
  103. /***====================================================================***/
  104.  
  105. void
  106. AIXWakeupHandler(scrNdx,blockData,pTimeout,pReadmask)
  107.     int     scrNdx;
  108.     char    *blockData;
  109.     struct timeval  *pTimeout;
  110.     unsigned        *pReadmask;
  111. {
  112.     TRACE(("AIXWakeupHandler()\n"));
  113.     if (handleInput) {
  114.     ProcessInputEvents();
  115.     }
  116.     hftInterruptOnFirst();
  117.     return;
  118. }
  119.  
  120. /***====================================================================***/
  121.  
  122. #ifndef NO_SECRETS
  123. static  int     aixShowSecretArgs= 0;
  124. #endif
  125.  
  126. #ifdef AIXV3
  127. void
  128. AIXUseMsg()
  129. {
  130.      aixErrMsg(M_MSG_4);
  131. }
  132. #else
  133. void
  134. AIXUseMsg()
  135. {
  136.     ErrorF("The \"X\" command accepts the following flags:\n");
  137.     ErrorF("   -a  <accel>     specify the mouse acceleration\n");
  138.     ErrorF("   -bp <color>     specify a BlackPixel color\n");
  139.     ErrorF("   -c  <volume>    specify the key click volume\n");
  140.     ErrorF("   -D  <file>      specify the color definition data base file\n");
  141.     ErrorF("   -f  <volume>    specify the beep volume\n");
  142.     ErrorF("   -fc <font>      specify the font for cursor glyphs and masks\n");
  143.     ErrorF("   -fn <font>      specify the default text font\n");
  144.     ErrorF("   -fp <path>      specify the search path for fonts\n");
  145.     ErrorF("   -n :<num>       specify the connection number\n");
  146.     ErrorF("   -p  <interval>  specify the screen saver interval\n");
  147.     ErrorF("   -r              disables auto repeat\n");
  148.     ErrorF("   -s <delay>      specify the screen saver delay\n");
  149.     ErrorF("   -t <threshold>  specify the mouse threshold\n");
  150.     ErrorF("   -to <time>      specify the time between connection checks\n");
  151.     ErrorF("   -T              disable the Ctrl-Alt-Backspace key sequence\n");
  152.     ErrorF("   -v              activate screen saver with background color\n");
  153.     ErrorF("   -wp <color>     specify a WhitePixel color\n");
  154. #ifndef NO_SECRETS
  155.     if (aixShowSecretArgs) {
  156.     ErrorF("For the moment, X also accepts some undocumented, unsupported\n");
  157.     ErrorF("flags.  These flags are *not* guaranteed to exist in future\n");
  158.     ErrorF("releases or to work all that well in this release.\n");
  159.     ErrorF("These unsupported flags are:\n");
  160.     ErrorF("   -bs             enable backing store (default)\n");
  161.     ErrorF("   -mdelay <count> set delay for middle button chord (default 10)\n");
  162.     ErrorF("   -nobs           disable backing store\n");
  163.     ErrorF("   -nohdwr         use generic functions where applicable\n");
  164.     ErrorF("   -pckeys         swap CAPS LOCK and CTRL (for touch typists)\n");
  165. #ifdef IBM_SPECIAL_MALLOC
  166.     ErrorF("   -plumber <file> dump malloc arena to named file\n");
  167. #endif
  168.     ErrorF("   -quiet          do not print information messages (default)\n");
  169.     ErrorF("   -refresh        refresh clients to restore HFT\n");
  170.     ErrorF("   -repaint        repaint to restore HFT (default)\n");
  171.     ErrorF("   -rtkeys         use CAPS LOCK and CTRL as labelled (default)\n");
  172. #ifdef TRACE_X
  173.     ErrorF("   -trace          trace execution of IBM specific functions\n");
  174. #endif /* TRACE_X */
  175.     ErrorF("   -verbose        print information messages\n");
  176.     ErrorF("   -wrap           wrap mouse in both dimensions\n");
  177.     ErrorF("   -wrapx          wrap mouse in X only\n");
  178.     ErrorF("   -wrapy          wrap mouse in Y only\n");
  179.     }
  180. #endif
  181.     ErrorF("See the X User's Guide or X server manual page for more information\n");
  182. }
  183. #endif
  184. /***====================================================================***/
  185.  
  186. extern  int     ibmRefreshOnActivate;
  187.  
  188. int
  189. AIXProcessArgument(argc,argv,i)
  190. int      argc;
  191. char    *argv[];
  192. int     i;
  193. {
  194. extern  char    *rgbPath;
  195. extern  char    *display;
  196.  
  197.     TRACE(("AIXProcessArgument(%d,0x%x,%d)\n",argc,argv,i));
  198.  
  199.     if      (( strcmp( argv[i], "-c" ) == 0) && ((i+1) < argc))
  200.     {
  201.        if ((argv[i+1][0] >= '0') && (argv[i+1][0] <= '9'))
  202.             argv[i] = "c";
  203.        return(0);
  204.     }
  205.     else if ( strcmp( argv[i], "-D" ) == 0)
  206.     {
  207.         if(++i < argc)
  208.             rgbPath = argv[i];
  209.         else
  210.             return(0);
  211.         return(2);
  212.     }
  213.     else if (strcmp(argv[i], "-mdelay") == 0 ) {
  214.     if ((++i<argc)&&(isdigit(argv[i][0]))) {
  215.         AIXMouseChordDelay= atoi(argv[i]);
  216.         return(2);
  217.     }
  218.     }
  219.     else if ( strcmp( argv[i], "-n") == 0) {
  220.     char *dpy= argv[++i];
  221.  
  222.     if (i<argc) {
  223.         if (dpy[0]==':') {
  224.             display= &dpy[1];
  225.         }
  226.         else {
  227.             ErrorF("display specification must begin with ':'\n");
  228.             UseMsg();
  229.             exit(1);
  230.         }
  231.     }
  232.     else {
  233.         ErrorF("must specify display number after -n\n");
  234.         UseMsg();
  235.         exit(1);
  236.     }
  237.     return(2);
  238.     }
  239.     else if ( strcmp( argv[i], "-refresh" ) == 0 ) {
  240.     ibmRefreshOnActivate= 1;
  241.     return(1);
  242.     }
  243.     else if ( strcmp( argv[i], "-repaint" ) == 0 ) {
  244.     ibmRefreshOnActivate= 0;
  245.     return(1);
  246.     }
  247. #ifndef NO_SECRETS
  248.     else if (strcmp(argv[i],"-secrethelp")==0) {
  249.     aixShowSecretArgs= 1;
  250.     AIXUseMsg();
  251.     exit(1);
  252.     }
  253.     else if (strcmp(argv[i],"-dwa")==0) {  /* dwa test version */
  254.     /* playground */
  255.     ibmRefreshOnActivate= 1;
  256.     ErrorF("Refresh ON \n");
  257.     return(1);
  258.     }
  259. #endif
  260.     return(0);
  261. }
  262.  
  263. /***====================================================================***/
  264.  
  265. int     (*ibmAdditionalDfltScreen)();
  266.  
  267. void
  268. osGetDefaultScreens()
  269. {
  270. unsigned        Device, hftQueryCurrentDevice();
  271. char            *devflag, **fakeArgv= &devflag;
  272. char            *devstring = "unknown device";
  273.  
  274.     TRACE(("osGetDefaultScreens()\n"));
  275.  
  276.     Device = hftQueryCurrentDevice();
  277.  
  278.     if( ! Device )
  279.     return;
  280.  
  281.     if( ibmFindProbeAndAdd(Device, -1, -1) )
  282.     return;
  283.  
  284.     switch (Device & HFT_DEVID_MASK) {
  285.  
  286.     case HFT_SKYWAY_ID:
  287.             devflag= "-skyway";
  288.             devstring = "skyway";
  289.             break;
  290.     case HFT_SKYMONO_ID:
  291.             devflag= "-skyMono";
  292.             devstring = "skymono";
  293.             break;
  294.     case HFT_SABINE_ID:
  295.             devflag= "-sabine";
  296.             devstring = "sabine";
  297.             break;
  298.     case HFT_GEMINI_ID:
  299.             devflag= "-gemini";
  300.             devstring = "gemini";
  301.             break;
  302.     case HFT_PEDER_ID:
  303.             devflag= "-peder";
  304.             devstring = "peder";
  305.             break;
  306.     default:
  307.             if (ibmAdditionalDfltScreen) {
  308. #if MERGED_AIXNEW
  309.                 if (mtxAdditionalDfltScreen(Device,&devstring,&devflag))
  310. #else
  311.                 if ((*ibmAdditionalDfltScreen)(Device,&devstring,&devflag))
  312. #endif
  313.                     break;
  314.             }
  315.             devstring= "unknown device";
  316.             devflag= "-gai";
  317.             break;
  318.     case HFT_ILLEGAL_ID:
  319.             ErrorF("Cannot determine current device for X screen.\n");
  320.             ErrorF("Possible problems: remote execution, no active\n");
  321.             ErrorF("tty, or running in background on old kernel.\n");
  322.             ErrorF("Retry by specifying a screen option on the command\n");
  323.             ErrorF("Check out the documentation if all else fails\n\n");
  324.             Error("Goodbye!\n");    /* should *NEVER* return */
  325.             _exit();        /* NOTREACHED */
  326.             break;          /* NOTREACHED */
  327.     }
  328.  
  329.     ddxProcessArgument(1,fakeArgv,0);
  330.  
  331.     return;
  332. }
  333.