home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Enlightenment / enl14.tgz / enl14.tar / enl14 / setup.c < prev    next >
C/C++ Source or Header  |  1997-11-17  |  4KB  |  109 lines

  1. #include "enl.h"
  2.  
  3. void SetupVars()
  4. {
  5.    lists.next=NULL;
  6.    mode.mode=MODE_NONE;
  7. }
  8.  
  9. void SetupSignals()
  10. {
  11.    struct sigaction sa;
  12.    
  13.    sa.sa_handler = HandleSigChild;
  14.    sa.sa_flags = 0;
  15.    sigemptyset (&sa.sa_mask);
  16.    sigaction(SIGCHLD, &sa, (struct sigaction *)0);
  17. }
  18.  
  19. void SetupX()
  20. {
  21.    int test_event_base,test_error_base,test_v1,test_v2;
  22.    int shape_event_base,shape_error_base;
  23.    Root *root;
  24.    
  25.    /* Open a connection to the diplay nominted by the DISPLAY variable */
  26.    disp=XOpenDisplay(NULL);
  27.    /* if cannot connect to display */
  28.    if (!disp)
  29.      {
  30.     Alert("Enlightenment cannot connect to the display nominated by\n"
  31.           "your shell's DISPLAY environment variable. You may set this\n"
  32.           "variable to indicate which display name Enlightenment is to\n"
  33.           "connect to. It may be that you do not have an Xserver already\n"
  34.           "running to serve that Display connection, or that you do not\n"
  35.           "have permission to connect to that display. Please make sure\n"
  36.           "all is correct before trying again. Run an Xserver by running\n"
  37.           "xdm or startx first, or contact your local system\n"
  38.           "administrator, or Xserver vendor, or read the X, xdm and\n"
  39.           "startx manual pages before proceeding.\n");
  40.     EExit(1);
  41.      }
  42.    /* set up an error handler for then E would normally have fatal X errors */
  43.    XSetErrorHandler((XErrorHandler)HandleXError);
  44.    /* set up a handler for when the X Connection goes down */
  45.    XSetIOErrorHandler((XIOErrorHandler)HandleXIOError);
  46.    /* Check for the Shape Extension */
  47.    if (!XShapeQueryExtension(disp,&shape_event_base,&shape_error_base))
  48.      {
  49.     Alert("FATAL ERROR:\n"
  50.           "This Xserver does not support the Shape extension.\n"
  51.           "This is required for Enlightenment to run.\n"
  52.           "Exiting.\n");
  53.     EExit(1);
  54.      }
  55.    /* check for the XTEST extension */
  56.    if (XTestQueryExtension(disp,&test_event_base,&test_error_base,&test_v1,&test_v2))
  57.      {
  58.     /* make Enlightenment immune to other clients using XGrabServer */
  59.     XTestGrabControl(disp,True);
  60.      }   
  61.    /* record the event base for shape change events */
  62.    event_base_shape=shape_event_base;
  63.    /* initialise imlib */
  64.    imd=ImlibInit(disp);
  65.    /* get info about the root window */
  66.    root=SetupRoot();
  67.    AddItem((void *)root,"ROOT",LIST_TYPE_ROOT);
  68.    /* warn, if necessary about visual problems */
  69.    if (root->visual!=imd->x.visual)
  70.      {
  71.     Alert("WARNING:\n"
  72.           "The Visual used for the Root Window (Desktop Background) does\n"
  73.           "not match the visual that Imlib has chosen to use (which\n"
  74.           "will the the visual with the greatest bit depth / greatest\n"
  75.           "number of colours). This may result in backgrounds set by\n"
  76.           "Enlightenment either not working, or looking strange.\n"
  77.           "You can fix this by running your Xserver with its default\n"
  78.           "Visual being the one with the highest bit-depth. Please\n"
  79.           "refer to your Xserver manuals, or contact your system\n"
  80.           "administrator or Xserver vendor.\n");
  81.      }
  82.    /* warn, if necessary about lack fo multi-head support */
  83.    if (ScreenCount(disp)>1)
  84.      {
  85.     Alert("WARNING:\n"
  86.           "Your Xserver supports a multi-headed configuration with\n"
  87.           "multiple screens attached to the one display. Enlightenment\n"
  88.           "does not currently support multi-headed setups, and as a\n"
  89.           "result will only manage the first screen (this one).\n");
  90.      }
  91.    /* warn, if necessary about X version problems */
  92.    if (ProtocolVersion(disp)!=11)
  93.      {
  94.     Alert("WARNING:\n"
  95.           "This is not an X11 Xserver. It infact talks the X%i protocol.\n"
  96.           "This may mean Enlightenment will either not function, or\n"
  97.           "function incorrectly. If it is later than X11, then your\n"
  98.           "server is one the author(s) of Enlightenment neither have\n"
  99.           "access to, nor have heard of.\n",ProtocolVersion(disp));
  100.      }
  101.    /* sleect all the root window events to start managing */
  102. /*   XSelectInput(disp,root->win,
  103.  *        SubstructureNotifyMask|ButtonPressMask|ButtonReleaseMask|
  104.  *        EnterWindowMask|LeaveWindowMask|ButtonMotionMask|
  105.  *        PropertyChangeMask|SubstructureRedirectMask|KeyPressMask|
  106.  *        KeyReleaseMask|PointerMotionMask);
  107.  */
  108. }
  109.