summaryrefslogtreecommitdiffstats
path: root/driver/test-vp.c
blob: bf1a0b188c160acfa705cf97270a4a9e16e34a8e (plain) (blame)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* test-xinerama.c --- playing with XF86VidModeGetViewPort
 * xscreensaver, Copyright (c) 2004 Jamie Zawinski <jwz@jwz.org>
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation.  No representations are made about the suitability of this
 * software for any purpose.  It is provided "as is" without express or 
 * implied warranty.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif

#include <stdio.h>
#include <time.h>
#include <sys/time.h>

#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Intrinsic.h>

#include <X11/Xproto.h>
#include <X11/extensions/xf86vmode.h>
#include <X11/extensions/Xinerama.h>

char *progname = 0;
char *progclass = "XScreenSaver";

static const char *
blurb (void)
{
  static char buf[255];
  time_t now = time ((time_t *) 0);
  char *ct = (char *) ctime (&now);
  int n = strlen(progname);
  if (n > 100) n = 99;
  strncpy(buf, progname, n);
  buf[n++] = ':';
  buf[n++] = ' ';
  strncpy(buf+n, ct+11, 8);
  strcpy(buf+n+9, ": ");
  return buf;
}


static Bool error_handler_hit_p = False;

static int
ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error)
{
  error_handler_hit_p = True;
  return 0;
}


static int
screen_count (Display *dpy)
{
  int n = ScreenCount(dpy);
  int xn = 0;
  int event_number, error_number;

  if (!XineramaQueryExtension (dpy, &event_number, &error_number))
    {
      fprintf(stderr, "%s: XineramaQueryExtension(dpy, ...)    ==> False\n",
              blurb());
      goto DONE;
    }
  else
    fprintf(stderr,   "%s: XineramaQueryExtension(dpy, ...)    ==> %d, %d\n",
            blurb(), event_number, error_number);

  if (!XineramaIsActive(dpy))
    {
      fprintf(stderr, "%s: XineramaIsActive(dpy)               ==> False\n",
              blurb());
      goto DONE;
    }
  else
    {
      int major, minor;
      XineramaScreenInfo *xsi;
      fprintf(stderr, "%s: XineramaIsActive(dpy)               ==> True\n",
              blurb());
      if (!XineramaQueryVersion(dpy, &major, &minor))
        {
          fprintf(stderr,
                  "%s: XineramaQueryVersion(dpy, ...)      ==> False\n",
                  blurb());
          goto DONE;
        }
      else
        fprintf(stderr,
                "%s: XineramaQueryVersion(dpy, ...)      ==> %d, %d\n",
                blurb(), major, minor);

      xsi = XineramaQueryScreens (dpy, &xn);
      if (xsi) XFree (xsi);
    }

 DONE:
  fprintf (stderr, "\n");
  fprintf (stderr, "%s: X client screens: %d\n", blurb(), n);
  fprintf (stderr, "%s: Xinerama screens: %d\n", blurb(), xn);
  fprintf (stderr, "\n");

  if (xn > n) return xn;
  else return n;
}


int
main (int argc, char **argv)
{
  int event_number, error_number;
  int major, minor;
  int nscreens = 0;
  int i;

  XtAppContext app;
  Widget toplevel_shell = XtAppInitialize (&app, progclass, 0, 0,
					   &argc, argv, 0, 0, 0);
  Display *dpy = XtDisplay (toplevel_shell);
  XtGetApplicationNameAndClass (dpy, &progname, &progclass);

  if (!XF86VidModeQueryExtension(dpy, &event_number, &error_number))
    {
      fprintf(stderr, "%s: XF86VidModeQueryExtension(dpy, ...) ==> False\n",
	      blurb());
      fprintf(stderr,
              "%s: server does not support the XF86VidMode extension.\n",
	      blurb());
      exit(1);
    }
  else
    fprintf(stderr, "%s: XF86VidModeQueryExtension(dpy, ...) ==> %d, %d\n",
            blurb(), event_number, error_number);

  if (!XF86VidModeQueryVersion(dpy, &major, &minor))
    {
      fprintf(stderr, "%s: XF86VidModeQueryVersion(dpy, ...) ==> False\n",
              blurb());
      fprintf(stderr,
              "%s: server didn't report XF86VidMode version numbers?\n",
	      blurb());
    }
  else
    fprintf(stderr, "%s: XF86VidModeQueryVersion(dpy, ...)   ==> %d, %d\n",
            blurb(), major, minor);

  nscreens = screen_count (dpy);

  for (i = 0; i < nscreens; i++)
    {
      int result = 0;
      int x = 0, y = 0, dot = 0;
      XF86VidModeModeLine ml = { 0, };
      XErrorHandler old_handler;

      XSync (dpy, False);
      error_handler_hit_p = False;
      old_handler = XSetErrorHandler (ignore_all_errors_ehandler);

      result = XF86VidModeGetViewPort (dpy, i, &x, &y);

      XSync (dpy, False);
      XSetErrorHandler (old_handler);
      XSync (dpy, False);

      if (error_handler_hit_p)
        {
          fprintf(stderr,
                  "%s: XF86VidModeGetViewPort(dpy, %d, ...) ==> X error\n",
                  blurb(), i);
          continue;
        }

      if (! result)
        fprintf(stderr, "%s: XF86VidModeGetViewPort(dpy, %d, ...) ==> %d\n",
                blurb(), i, result);

      result = XF86VidModeGetModeLine (dpy, i, &dot, &ml);
      if (! result)
        fprintf(stderr, "%s: XF86VidModeGetModeLine(dpy, %d, ...) ==> %d\n",
                blurb(), i, result);

      fprintf (stderr, "%s:   screen %d: %dx%d; viewport: %dx%d+%d+%d\n",
               blurb(), i,
               DisplayWidth (dpy, i), DisplayHeight (dpy, i),
               ml.hdisplay, ml.vdisplay, x, y
               );

      fprintf (stderr,
               "%s:       hsync start %d; end %d; total %d; skew  %d;\n",
               blurb(),
               ml.hsyncstart, ml.hsyncend, ml.htotal, ml.hskew);
      fprintf (stderr,
               "%s:       vsync start %d; end %d; total %d; flags 0x%04x;\n",
               blurb(),
               ml.vsyncstart, ml.vsyncend, ml.vtotal, ml.flags);
      fprintf (stderr, "\n");
    }
  XSync (dpy, False);
  exit (0);
}
9c838f93a55ea6'>644570b83026 ^
1da177e4c3f4
67543e508d74 ^
8b58be884a9f ^


ce00f85c45d7 ^
27a2a5ff41e3 ^
8a6e25357d51 ^
eeba444a5d56 ^
ce00f85c45d7 ^
679655daffdd ^

2315cb14010c ^




67543e508d74 ^
91952bc0b48a ^









e2d1d6c0a5d3 ^
8b58be884a9f ^
e2d1d6c0a5d3 ^

1da177e4c3f4
679655daffdd ^

1da177e4c3f4
ea8f8fc8631d ^






249e3c85afb9 ^
93d0cc588345 ^
f2b84bbcebfd ^

679655daffdd ^
f2b84bbcebfd ^
249e3c85afb9 ^
8b58be884a9f ^
249e3c85afb9 ^

679655daffdd ^
249e3c85afb9 ^
1da177e4c3f4
8b58be884a9f ^
1da177e4c3f4

531c4f896ca3 ^
1da177e4c3f4
e86435eb91b2 ^
8b58be884a9f ^
d094485323a1 ^
4fc26e36acce ^


e86435eb91b2 ^
745a5d212692 ^
182ae55c1285 ^
d094485323a1 ^
745a5d212692 ^
679655daffdd ^
745a5d212692 ^
1da177e4c3f4
49db19038fe5 ^
7fb060820acb ^
6968e50c2b53 ^
360818b83f86 ^


8b59a454c421 ^
679655daffdd ^


43368e74d126 ^
994b942fb4eb ^
89ca78a060a1 ^
15fd830dd310 ^


2754c447b7a7 ^
8b59a454c421 ^
3774929d2ac6 ^












2754c447b7a7 ^
3774929d2ac6 ^
8b59a454c421 ^
8b58be884a9f ^
8b59a454c421 ^
5ca92bd96a4d ^
8b59a454c421 ^
679655daffdd ^
1da177e4c3f4
8b59a454c421 ^
8b58be884a9f ^
8b59a454c421 ^
5ca92bd96a4d ^
8b59a454c421 ^
679655daffdd ^
998be20fdff1 ^
359acec8cd78 ^
8b58be884a9f ^
8b59a454c421 ^
5ca92bd96a4d ^
8b59a454c421 ^
679655daffdd ^
998be20fdff1 ^
bff431e49ff5 ^
d094485323a1 ^
5b9272594b51 ^
679655daffdd ^
bff431e49ff5 ^
2f39d51981e2 ^
8b58be884a9f ^
795fb7e74dff ^


679655daffdd ^
2f39d51981e2 ^
527a1a83cc1b ^

a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^




a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^




a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^




a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^




a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^


1330b0dcf876 ^



1da177e4c3f4
7c81c60f3789 ^
cc0b07ed479f ^
1da177e4c3f4
679655daffdd ^

1da177e4c3f4
cae2caae7825 ^
fce8ffa35408 ^
cae2caae7825 ^

679655daffdd ^
cae2caae7825 ^
cc0b88cf5ecf ^
cc0b88cf5ecf ^
491b26b40222 ^
e71bcbd0a149 ^
679655daffdd ^
cc0b88cf5ecf ^
e8e31622a17e ^






527a1a83cc1b ^

a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^


45b4e0d54bdb ^
77278d50e04b ^
527a1a83cc1b ^



a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^

77278d50e04b ^
527a1a83cc1b ^


a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^


8c22a8f57516 ^







1da177e4c3f4
8b58be884a9f ^
1da177e4c3f4
679655daffdd ^
1da177e4c3f4
b058b8596136 ^
7c81c60f3789 ^
b058b8596136 ^




527a1a83cc1b ^

a3f531ac556d ^
a4edbc101151 ^
527a1a83cc1b ^


8c6af9e174ab ^
8b58be884a9f ^
8c6af9e174ab ^

679655daffdd ^

8c6af9e174ab ^
1da177e4c3f4
8b58be884a9f ^
1da177e4c3f4
679655daffdd ^
1da177e4c3f4
91952bc0b48a ^



















1da177e4c3f4
6cf515e113fc ^

679655daffdd ^

1da177e4c3f4
e2d1d6c0a5d3 ^
8b58be884a9f ^
e2d1d6c0a5d3 ^

679655daffdd ^


e2d1d6c0a5d3 ^
1da177e4c3f4
8b58be884a9f ^
878eaf61be20 ^
1da177e4c3f4
679655daffdd ^

c117ab842001 ^
1da177e4c3f4

8b58be884a9f ^
1da177e4c3f4

679655daffdd ^

1da177e4c3f4
64624d4f46d5 ^
8b58be884a9f ^
64624d4f46d5 ^
1da177e4c3f4
679655daffdd ^
1da177e4c3f4
450500ad1d58 ^







e2d1d6c0a5d3 ^
8b58be884a9f ^
e2d1d6c0a5d3 ^

679655daffdd ^

e2d1d6c0a5d3 ^
1da177e4c3f4
8b58be884a9f ^
6372594ac177 ^
1da177e4c3f4

679655daffdd ^

1da177e4c3f4
272f133afb20 ^
8b58be884a9f ^
08fcb7208c4a ^
679655daffdd ^
272f133afb20 ^
4a4e5787e0b7 ^
8b58be884a9f ^
846557d3ceb6 ^
4a4e5787e0b7 ^
679655daffdd ^

4a4e5787e0b7 ^
1da177e4c3f4
8b58be884a9f ^
8b58be884a9f ^
abd4d609057d ^
c89f4f9a611a ^
a94066992b30 ^
679655daffdd ^
1da177e4c3f4
16b8b9220486 ^
0d9327ab7003 ^
16b8b9220486 ^




adf9251fe9b8 ^


61bd0943bc41 ^
adf9251fe9b8 ^





f4875e12f3dd ^






512d1027a6c5 ^
d034fbf08b6f ^
512d1027a6c5 ^




167a675a8caa ^
8b58be884a9f ^
67d7671036e6 ^
167a675a8caa ^
679655daffdd ^
167a675a8caa ^
f90b8116032f ^
6900609612d2 ^
67d7671036e6 ^
f90b8116032f ^

679655daffdd ^



f90b8116032f ^
919ee7dd9a66 ^
e41105687b90 ^
919ee7dd9a66 ^
525b233c7188 ^
e41105687b90 ^
b2c1639135c0 ^

919ee7dd9a66 ^
e7f5b309c9bd ^
943482d07e92 ^
7d2c86b5a048 ^
943482d07e92 ^
679655daffdd ^
e7f5b309c9bd ^
45198c7b35c0 ^






284f42b627c0 ^
8b58be884a9f ^
284f42b627c0 ^
bd5f47ec9615 ^
284f42b627c0 ^
f94b533d091a ^
8b58be884a9f ^

e6cc0fd1e31c ^
f94b533d091a ^
679655daffdd ^
f94b533d091a ^
531fca1649da ^





c40ddfa34add ^





531fca1649da ^





c40ddfa34add ^





527a1a83cc1b ^
535bd16f4190 ^
4bdef3bd7e59 ^
a3f531ac556d ^
a4edbc101151 ^
4bdef3bd7e59 ^
39c9d199ce67 ^
cc52688a0888 ^
4bdef3bd7e59 ^
ae48f5efb8b3 ^
4bdef3bd7e59 ^
40216ce7aa88 ^
4bdef3bd7e59 ^
527a1a83cc1b ^
b3fe92b03dd6 ^
527a1a83cc1b ^




422690636117 ^
8b58be884a9f ^
a4724ed6f084 ^
93711660086d ^
422690636117 ^
679655daffdd ^
422690636117 ^
1da177e4c3f4
81024fc41a93 ^

679655daffdd ^

c117ab842001 ^
81024fc41a93 ^
1da177e4c3f4
bd7aa4b2dafd ^
8b58be884a9f ^
bd7aa4b2dafd ^

679655daffdd ^
bd7aa4b2dafd ^
6f2fad748ccc ^
d618540fb3e5 ^

6f2fad748ccc ^
679655daffdd ^
6f2fad748ccc ^
1da177e4c3f4
8b58be884a9f ^
1da177e4c3f4
679655daffdd ^

1da177e4c3f4
62a37dc7a273 ^





a480167b23ef ^
2d8a3b3d926e ^
a480167b23ef ^




1154ea7dcd8e ^
8b58be884a9f ^
1154ea7dcd8e ^
679655daffdd ^

1154ea7dcd8e ^
1da177e4c3f4
8b58be884a9f ^
1da177e4c3f4
679655daffdd ^

1da177e4c3f4
6f96521fab97 ^




6f96521fab97 ^



d4275354993e ^
8b58be884a9f ^
efc03ecb9d67 ^
d4275354993e ^



d323c243d9e6 ^

56ca9d98772c ^
d323c243d9e6 ^



cefbf4ea6294 ^















2761f5c2ea80 ^
08a5c9a2bb5d ^

679655daffdd ^
2f748aaad7f4 ^
2761f5c2ea80 ^
1b4304e5ca4e ^




2761f5c2ea80 ^
cefbf4ea6294 ^





2b7a52a459cb ^
8b58be884a9f ^
efc03ecb9d67 ^
2b7a52a459cb ^

9c784f958d01 ^
8b58be884a9f ^
efc03ecb9d67 ^
9c784f958d01 ^

2b7a52a459cb ^
8b58be884a9f ^
efc03ecb9d67 ^
2b7a52a459cb ^

1b106699647b ^



60b0f380beed ^





1b106699647b ^
c1fc8675c9e3 ^
8b58be884a9f ^
c1fc8675c9e3 ^

efc03ecb9d67 ^
795fb7e74dff ^
c1fc8675c9e3 ^


70e389cc7fed ^



d4a89c7d2788 ^
6e05dd4e1ccb ^




986cf2e91968 ^
5d3ad8a63844 ^
986cf2e91968 ^



d94f944e108d ^
9d5e2a023eee ^
d94f944e108d ^



386ab5168bbf ^



b8ba3874b4cf ^
386ab5168bbf ^
2b7a52a459cb ^
ddd559b13f6d ^
1c5454eed85a ^
efc03ecb9d67 ^
2b7a52a459cb ^
d19d36672ee3 ^

2b7a52a459cb ^

8b58be884a9f ^
efc03ecb9d67 ^
2b7a52a459cb ^

d4275354993e ^
8b58be884a9f ^
efc03ecb9d67 ^
37417046b903 ^
d4275354993e ^
4fa2651db463 ^
d4275354993e ^
d48134e709d5 ^
8b58be884a9f ^
efc03ecb9d67 ^
a9da4f7ed6a7 ^

941500954470 ^




1da177e4c3f4
8b58be884a9f ^
1da177e4c3f4

881a95f976e6 ^
162500b3a3ff ^
efc03ecb9d67 ^
162500b3a3ff ^

f49afbb572d5 ^
881a95f976e6 ^
a990cbd88758 ^
5abf58bf4cd0