ftp://ftp.uniovi.es/pub/X11R6/graphics/misc/lock/xscreensaver-1.22.tar.gz
[xscreensaver] / driver / windows.c
index 1e4b22df9c2cd3c2fdd323c507916f0d047fd1dc..fb459ace60c7bca9fa375a2495d9745c18866e51 100644 (file)
@@ -29,6 +29,10 @@ extern Bool lock_p, demo_mode_p;
 Atom XA_VROOT, XA_XSETROOT_ID;
 Atom XA_SCREENSAVER_VERSION, XA_SCREENSAVER_ID;
 
+#if __STDC__
+extern void describe_visual (FILE *, Display *, Visual *);
+#endif
+
 Window screensaver_window = 0;
 Cursor cursor;
 Colormap cmap, cmap2;
@@ -421,6 +425,8 @@ initialize_screensaver_window ()
   int height = HeightOfScreen (screen);
   char id [2048];
 
+  black.red = black.green = black.blue = 0;
+
   if (cmap == DefaultColormapOfScreen (screen))
     cmap = 0;
 
@@ -459,15 +465,19 @@ initialize_screensaver_window ()
        fade_p = unfade_p = 0;
     }
 
-  attrmask = CWOverrideRedirect | CWEventMask | CWBackingStore | CWColormap;
+  attrmask = (CWOverrideRedirect | CWEventMask | CWBackingStore | CWColormap |
+             CWBackPixel | CWBackingPixel | CWBorderPixel);
   attrs.override_redirect = True;
   attrs.event_mask = (KeyPressMask | KeyReleaseMask |
                      ButtonPressMask | ButtonReleaseMask |
                      PointerMotionMask);
   attrs.backing_store = NotUseful;
   attrs.colormap = cmap;
+  attrs.background_pixel = black_pixel;
+  attrs.backing_pixel = black_pixel;
+  attrs.border_pixel = black_pixel;
 
-/*  if (demo_mode_p || lock_p || locked_p) width = width / 2;  #### */
+/*  if (demo_mode_p || lock_p) width = width / 2;   #### */
 
   if (screensaver_window)
     {
@@ -484,6 +494,21 @@ initialize_screensaver_window ()
     }
   else
     {
+      if (! verbose_p)
+       ;
+      else if (visual == DefaultVisualOfScreen (screen))
+       {
+         fprintf (stderr, "%s: using default visual ", progname);
+         describe_visual (stderr, dpy, visual);
+       }
+      else
+       {
+         fprintf (stderr, "%s: using visual:   ", progname);
+         describe_visual (stderr, dpy, visual);
+         fprintf (stderr, "%s: default visual: ", progname);
+         describe_visual (stderr, dpy, DefaultVisualOfScreen (screen));
+       }
+
       screensaver_window =
        XCreateWindow (dpy, RootWindowOfScreen (screen), 0, 0, width, height,
                       0, visual_depth, InputOutput, visual, attrmask,
@@ -505,7 +530,6 @@ initialize_screensaver_window ()
   XChangeProperty (dpy, screensaver_window, XA_SCREENSAVER_ID, XA_STRING, 8,
                   PropModeReplace, (unsigned char *) id, strlen (id));
 
-  black.red = black.green = black.blue = 0;
   if (!cursor)
     {
       Pixmap bit;
@@ -545,6 +569,8 @@ raise_window (inhibit_fade, between_hacks_p)
       fade_colormap (dpy, current_map, cmap2, fade_seconds, fade_ticks, True);
       XClearWindow (dpy, screensaver_window);
       XMapRaised (dpy, screensaver_window);
+      /* Once the saver window is up, restore the colormap.
+        (The "black" pixels of the two colormaps are compatible.) */
       XInstallColormap (dpy, cmap);
       if (grabbed == GrabSuccess)
        XUngrabPointer (dpy, CurrentTime);