1 /* xscreensaver, Copyright (c) 1998, 1999, 2006
2 * by 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
13 /* The XDBE (Double Buffering) extension is pretty tricky to use, since you
14 can get X errors at inconvenient times during initialization. This file
15 contains a utility routine to make it easier to deal with.
20 #include "resources.h" /* for get_string_resource() */
25 # include <X11/Xmu/Error.h>
28 extern char *progname;
30 #ifdef HAVE_DOUBLE_BUFFER_EXTENSION /* whole file */
32 static Bool xdbe_got_x_error = False;
34 xdbe_ehandler (Display *dpy, XErrorEvent *error)
36 xdbe_got_x_error = True;
39 fprintf (stderr, "\n%s: ignoring X error from DOUBLE-BUFFER:\n", progname);
40 XmuPrintDefaultErrorMessage (dpy, error, stderr);
41 fprintf (stderr, "\n");
49 xdbe_get_backbuffer (Display *dpy, Window window,
50 XdbeSwapAction action)
53 XErrorHandler old_handler;
56 if (!get_boolean_resource(dpy, "useDBE", "Boolean"))
59 if (!XdbeQueryExtension (dpy, &maj, &min))
63 xdbe_got_x_error = False;
64 old_handler = XSetErrorHandler (xdbe_ehandler);
65 b = XdbeAllocateBackBufferName(dpy, window, XdbeUndefined);
67 XSetErrorHandler (old_handler);
75 #endif /* HAVE_DOUBLE_BUFFER_EXTENSION */