1 /* test-fade.c --- playing with colormap and/or gamma fading.
2 * xscreensaver, Copyright (c) 2001, 2004 Jamie Zawinski <jwz@jwz.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
24 #include <X11/Intrinsic.h>
25 #include "xscreensaver.h"
28 #ifdef HAVE_SGI_VC_EXTENSION
29 # include <X11/extensions/XSGIvc.h>
31 #ifdef HAVE_XF86VMODE_GAMMA
32 # include <X11/extensions/xf86vmode.h>
37 char *progclass = "XScreenSaver";
39 #define SGI_VC_NAME "SGI-VIDEO-CONTROL"
40 #define XF86_VIDMODE_NAME "XFree86-VidModeExtension"
43 main (int argc, char **argv)
49 int op, event, error, major, minor;
52 Widget toplevel_shell = XtAppInitialize (&app, progclass, 0, 0,
53 &argc, argv, 0, 0, 0);
54 Display *dpy = XtDisplay (toplevel_shell);
55 Colormap *current_maps;
58 XtGetApplicationNameAndClass (dpy, &progname, &progclass);
59 db = XtDatabase (dpy);
61 current_maps = (Colormap *) calloc(sizeof(Colormap), ScreenCount(dpy));
62 for (i = 0; i < ScreenCount(dpy); i++)
63 current_maps[i] = DefaultColormap (dpy, i);
65 if (!XQueryExtension (dpy, SGI_VC_NAME, &op, &event, &error))
66 fprintf(stderr, "%s: no " SGI_VC_NAME " extension\n", progname);
69 # ifdef HAVE_SGI_VC_EXTENSION
70 if (!XSGIvcQueryVersion (dpy, &major, &minor))
71 fprintf(stderr, "%s: unable to get " SGI_VC_NAME " version\n",
74 fprintf(stderr, "%s: " SGI_VC_NAME " version %d.%d\n",
75 progname, major, minor);
76 # else /* !HAVE_SGI_VC_EXTENSION */
77 fprintf(stderr, "%s: no support for display's " SGI_VC_NAME
78 " extension\n", progname);
79 # endif /* !HAVE_SGI_VC_EXTENSION */
83 if (!XQueryExtension (dpy, XF86_VIDMODE_NAME, &op, &event, &error))
84 fprintf(stderr, "%s: no " XF86_VIDMODE_NAME " extension\n", progname);
87 # ifdef HAVE_XF86VMODE_GAMMA
88 if (!XF86VidModeQueryVersion (dpy, &major, &minor))
89 fprintf(stderr, "%s: unable to get " XF86_VIDMODE_NAME " version\n",
92 fprintf(stderr, "%s: " XF86_VIDMODE_NAME " version %d.%d\n",
93 progname, major, minor);
94 # else /* !HAVE_XF86VMODE_GAMMA */
95 fprintf(stderr, "%s: no support for display's " XF86_VIDMODE_NAME
96 " extension\n", progname);
97 # endif /* !HAVE_XF86VMODE_GAMMA */
100 fprintf (stderr, "%s: fading %d screen%s\n",
101 progname, ScreenCount(dpy), ScreenCount(dpy) == 1 ? "" : "s");
107 fprintf(stderr, "%s: out...", progname);
109 fade_screens (dpy, current_maps, 0, 0, seconds, ticks, True, False);
110 fprintf(stderr, "done.\n");
113 if (delay) sleep (delay);
115 fprintf(stderr,"%s: in...", progname);
117 fade_screens (dpy, current_maps, 0, 0, seconds, ticks, False, False);
118 fprintf(stderr, "done.\n");
121 if (delay) sleep (delay);