1 /* xscreensaver, Copyright (c) 1998, 1999 by Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 /* The XDBE (Double Buffering) extension is pretty tricky to use, since you
13 can get X errors at inconvenient times during initialization. This file
14 contains a utility routine to make it easier to deal with.
19 #include "resources.h" /* for get_string_resource() */
24 # include <X11/Xmu/Error.h>
27 extern char *progname;
29 #ifdef HAVE_DOUBLE_BUFFER_EXTENSION /* whole file */
31 static Bool xdbe_got_x_error = False;
33 xdbe_ehandler (Display *dpy, XErrorEvent *error)
35 xdbe_got_x_error = True;
38 fprintf (stderr, "\n%s: ignoring X error from DOUBLE-BUFFER:\n", progname);
39 XmuPrintDefaultErrorMessage (dpy, error, stderr);
40 fprintf (stderr, "\n");
48 xdbe_get_backbuffer (Display *dpy, Window window,
49 XdbeSwapAction action)
52 XErrorHandler old_handler;
55 if (!get_boolean_resource("useDBE", "Boolean"))
58 if (!XdbeQueryExtension (dpy, &maj, &min))
62 xdbe_got_x_error = False;
63 old_handler = XSetErrorHandler (xdbe_ehandler);
64 b = XdbeAllocateBackBufferName(dpy, window, XdbeUndefined);
66 XSetErrorHandler (old_handler);
74 #endif /* HAVE_DOUBLE_BUFFER_EXTENSION */