X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Ftest-randr.c;h=da86e04d79d78779064c1102ceb9d079496141a2;hb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;hp=63887efa670744f774768d9204bd7af903c77a9e;hpb=9c9d475ff889ed8be02e8ce8c17da28b93278fca;p=xscreensaver diff --git a/driver/test-randr.c b/driver/test-randr.c index 63887efa..da86e04d 100644 --- a/driver/test-randr.c +++ b/driver/test-randr.c @@ -1,5 +1,5 @@ /* test-randr.c --- playing with the Resize And Rotate extension. - * xscreensaver, Copyright (c) 2004 Jamie Zawinski + * xscreensaver, Copyright (c) 2004, 2005 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -50,11 +50,21 @@ blurb (void) } +static Bool error_handler_hit_p = False; + +static int +ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error) +{ + error_handler_hit_p = True; + return 0; +} + + int main (int argc, char **argv) { - int event_number, error_number; - int major, minor; + int event_number = -1, error_number = -1; + int major = -1, minor = -1; int nscreens = 0; int i; @@ -93,10 +103,27 @@ main (int argc, char **argv) for (i = 0; i < nscreens; i++) { - XRRScreenConfiguration *rrc = - (major >= 0 ? XRRGetScreenInfo (dpy, RootWindow (dpy, i)) : 0); + XRRScreenConfiguration *rrc; + XErrorHandler old_handler; + + XSync (dpy, False); + error_handler_hit_p = False; + old_handler = XSetErrorHandler (ignore_all_errors_ehandler); - if (rrc) + rrc = (major >= 0 ? XRRGetScreenInfo (dpy, RootWindow (dpy, i)) : 0); + + XSync (dpy, False); + XSetErrorHandler (old_handler); + XSync (dpy, False); + + if (error_handler_hit_p) + { + fprintf(stderr, "%s: XRRGetScreenInfo(dpy, %d) ==> X error:\n", + blurb(), i); + /* do it again without the error handler to print the error */ + rrc = XRRGetScreenInfo (dpy, RootWindow (dpy, i)); + } + else if (rrc) { SizeID current_size = -1; Rotation current_rotation = ~0; @@ -107,6 +134,9 @@ main (int argc, char **argv) XRRConfigCurrentConfiguration (rrc, ¤t_rotation); /* Times */ +# if 0 /* #### This is wrong -- I don't understand what these two + timestamp numbers represent, or how they correlate + to the wall clock or to each other. */ { Time server_time, config_time; server_time = XRRConfigTimes (rrc, &config_time); @@ -117,6 +147,7 @@ main (int argc, char **argv) fprintf (stderr, "%s: config changed %lu seconds ago\n", blurb(), (unsigned long) (server_time - config_time)); } +# endif /* Rotations */ {