home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / X / Xserver / xlayerinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.7 KB  |  83 lines

  1. /*
  2.  * Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /* $Revision: 1.6 $ */
  18. /* compile: cc -o xlayerinfo xlayerinfo.c XLayerUtil.c -lX11 */
  19.  
  20. #include <stdio.h>
  21. #include "XLayerUtil.h"
  22.  
  23. main(argc, argv)
  24. int argc;
  25. char *argv[];
  26. {
  27.    Display *dpy;
  28.    char *display_name, *arg, *class;
  29.    XLayerVisualInfo template, *lvinfo;
  30.    int nVisuals, i;
  31.  
  32.    display_name = NULL;
  33.    for(i=1; i<argc; i++) {
  34.       arg = argv[i];
  35.       if(strcmp(arg, "-display") == 0 || strcmp(arg, "-d") == 0) {
  36.      if(++i >= argc) {
  37.         fprintf(stderr, "nmbxdemo: missing argument to -display\n");
  38.         exit(1);
  39.          }
  40.      display_name = argv[i];
  41.       }
  42.    }
  43.    dpy = XOpenDisplay(display_name);
  44.    if(dpy == NULL) {
  45.       fprintf(stderr, "xlayerinfo: cannot open display %s\n",
  46.      XDisplayName(NULL));
  47.       exit(1);
  48.    }
  49.    lvinfo = XGetLayerVisualInfo(dpy, 0L, &template, &nVisuals);
  50.    for(i=0; i<nVisuals; i++) {
  51.       printf("  Visual ID: 0x%x\n", lvinfo[i].vinfo.visualid);
  52.       printf("    screen: %d\n", lvinfo[i].vinfo.screen);
  53.       printf("    depth: %d\n", lvinfo[i].vinfo.depth);
  54.       switch(lvinfo[i].vinfo.class) {
  55.      case StaticGray:   class = "StaticGray"; break;
  56.      case GrayScale:    class = "GrayScale"; break;
  57.      case StaticColor:  class = "StaticColor"; break;
  58.      case PseudoColor:  class = "PseudoColor"; break;
  59.      case TrueColor:    class = "TrueColor"; break;
  60.      case DirectColor:  class = "DirectColor"; break;
  61.      default:           class = "Unknown"; break;
  62.       }
  63.       printf("    class: %s\n", class);
  64.       switch(lvinfo[i].type) {
  65.       case None:
  66.          printf("    transparent type: None\n");
  67.          break;
  68.       case TransparentPixel:
  69.          printf("    transparent type: TransparentPixel\n");
  70.          printf("    pixel value: %d\n", lvinfo[i].value);
  71.      break;
  72.       case TransparentMask:
  73.          printf("    transparent type: TransparentMask\n");
  74.          printf("    transparency mask: %0x%x\n", lvinfo[i].value);
  75.      break;
  76.       default:
  77.          printf("    transparent type: Unkown or invalid\n");
  78.      break;
  79.       }
  80.       printf("    layer: %d\n", lvinfo[i].layer);
  81.    }
  82. }
  83.