ftp://ftp.linux.ncsu.edu/mirror/ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os...
[xscreensaver] / utils / grabscreen.c
index f2abe8cb678a525b0a38a682c65dea211f4bed43..cc5b57522de05d06d31e8cee2811fc4eae033797 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992, 1993, 1994, 1997, 1998
+/* xscreensaver, Copyright (c) 1992, 1993, 1994, 1997, 1998, 2003, 2004
  *  Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -117,12 +117,12 @@ xscreensaver_window_p (Display *dpy, Window window)
   Atom type;
   int format;
   unsigned long nitems, bytesafter;
-  char *version;
+  unsigned char *version;
   if (XGetWindowProperty (dpy, window,
                          XInternAtom (dpy, "_SCREENSAVER_VERSION", False),
                          0, 1, False, XA_STRING,
                          &type, &format, &nitems, &bytesafter,
-                         (unsigned char **) &version)
+                         &version)
       == Success
       && type != None)
     return True;
@@ -133,7 +133,6 @@ xscreensaver_window_p (Display *dpy, Window window)
 
 /* Whether the given window is:
    - the real root window;
-   - the virtual root window;
    - a direct child of the root window;
    - a direct child of the window manager's decorations.
  */
@@ -142,20 +141,16 @@ top_level_window_p (Screen *screen, Window window)
 {
   Display *dpy = DisplayOfScreen (screen);
   Window root, parent, *kids;
-  Window vroot = VirtualRootWindowOfScreen(screen);
   unsigned int nkids;
 
-  if (window == vroot)
-    return True;
-
   if (!XQueryTree (dpy, window, &root, &parent, &kids, &nkids))
     return False;
 
   if (window == root)
     return True;
 
-  /* If our direct parent is the root (or *a* root), then yes. */
-  if (parent == root || parent == vroot)
+  /* If our direct parent is the real root window, then yes. */
+  if (parent == root)
     return True;
   else
     {
@@ -183,11 +178,12 @@ top_level_window_p (Screen *screen, Window window)
 }
 
 
-
+static Bool error_handler_hit_p = False;
 static XErrorHandler old_ehandler = 0;
 static int
 BadWindow_ehandler (Display *dpy, XErrorEvent *error)
 {
+  error_handler_hit_p = True;
   if (error->error_code == BadWindow || error->error_code == BadDrawable)
     return 0;
   else if (!old_ehandler)
@@ -227,17 +223,18 @@ use_subwindow_mode_p(Screen *screen, Window window)
 static void
 install_screen_colormaps (Screen *screen)
 {
-  int i;
+  unsigned int i;
   Display *dpy = DisplayOfScreen (screen);
-  Window vroot, real_root;
+  Window real_root;
   Window parent, *kids = 0;
   unsigned int nkids = 0;
 
   XSync (dpy, False);
   old_ehandler = XSetErrorHandler (BadWindow_ehandler);
+  error_handler_hit_p = False;
 
-  vroot = VirtualRootWindowOfScreen (screen);
-  if (XQueryTree (dpy, vroot, &real_root, &parent, &kids, &nkids))
+  real_root = XRootWindowOfScreen (screen);  /* not vroot */
+  if (XQueryTree (dpy, real_root, &real_root, &parent, &kids, &nkids))
     for (i = 0; i < nkids; i++)
       {
        XWindowAttributes xgwa;
@@ -263,7 +260,7 @@ install_screen_colormaps (Screen *screen)
 
 
 void
-grab_screen_image (Screen *screen, Window window)
+grab_screen_image_internal (Screen *screen, Window window)
 {
   Display *dpy = DisplayOfScreen (screen);
   XWindowAttributes xgwa;