summaryrefslogtreecommitdiffstats
path: root/examples/opengl/overlay_x11/utilities/sovinfo/sovinfo.c
blob: 059050c2fd901391bec514c9f7987b9839214c5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

/* Copyright (c) Mark J. Kilgard, 1996. */

/* This program is freely distributable without licensing fees 
   and is provided without guarantee or warrantee expressed or 
   implied. This program is -not- in the public domain. */

/* compile: cc -o sovinfo sovinfo.c sovLayerUtil.c -lX11 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sovLayerUtil.h"

int
main(int argc, char *argv[])
{
  Display *dpy;
  char *display_name, *arg, *class;
  sovVisualInfo template, *lvinfo;
  int nVisuals, i, overlaysOnly = 0;

  display_name = NULL;
  for (i = 1; i < argc; i++) {
    arg = argv[i];
    if (!strcmp(arg, "-display")) {
      if (++i >= argc) {
        fprintf(stderr, "sovinfo: missing argument to -display\n");
        exit(1);
      }
      display_name = argv[i];
    } else if (!strcmp(arg, "-overlays_only")) {
      overlaysOnly = 1;
    } else {
      fprintf(stderr,
        "usage: sovinfo [-display dpy] [-overlays_only]\n");
      exit(1);
    }
  }
  dpy = XOpenDisplay(display_name);
  if (dpy == NULL) {
    fprintf(stderr, "sovinfo: cannot open display %s\n",
      XDisplayName(NULL));
    exit(1);
  }
  lvinfo = sovGetVisualInfo(dpy, 0L, &template, &nVisuals);
  for (i = 0; i < nVisuals; i++) {
    if (!overlaysOnly || lvinfo[i].layer > 0) {
      printf("  Visual ID: 0x%x\n", lvinfo[i].vinfo.visualid);
      printf("    screen: %d\n", lvinfo[i].vinfo.screen);
      printf("    depth: %d\n", lvinfo[i].vinfo.depth);
      switch (lvinfo[i].vinfo.class) {
      case StaticGray:
        class = "StaticGray";
        break;
      case GrayScale:
        class = "GrayScale";
        break;
      case StaticColor:
        class = "StaticColor";
        break;
      case PseudoColor:
        class = "PseudoColor";
        break;
      case TrueColor:
        class = "TrueColor";
        break;
      case DirectColor:
        class = "DirectColor";
        break;
      default:
        class = "Unknown";
        break;
      }
      printf("    class: %s\n", class);
      switch (lvinfo[i].type) {
      case None:
        printf("    transparent type: None\n");
        break;
      case TransparentPixel:
        printf("    transparent type: TransparentPixel\n");
        printf("    pixel value: %d\n", lvinfo[i].value);
        break;
      case TransparentMask:
        printf("    transparent type: TransparentMask\n");
        printf("    transparency mask: %0x%x\n", lvinfo[i].value);
        break;
      default:
        printf("    transparent type: Unknown or invalid\n");
        break;
      }
      printf("    layer: %d\n", lvinfo[i].layer);
    }
  }
  return 0;
}