http://se.aminet.net/pub/X11/ftp.x.org/contrib/vms/xscreensaver-124.zip
[xscreensaver] / driver / windows.c
old mode 100644 (file)
new mode 100755 (executable)
index 1e4b22d..763a941
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@lucid.com>
+/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@mcom.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
  */
 
 #include <stdio.h>
+
+#ifdef VMS
+typedef char * caddr_t;
+#endif
+
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
 #include <X11/Xos.h>
+#ifndef VMS
 #include <X11/Xmu/SysUtil.h>
+#else
+#include "sys$common:[decw$include.xmu]SysUtil.h"
+#endif
 
 #include <signal.h>            /* for the signal names */
 
 #include "xscreensaver.h"
 
 #if __STDC__
+#ifndef __DECC
 extern int kill (pid_t, int);          /* signal() is in sys/signal.h... */
+#else
+extern int kill (int, int);
+#endif
 #endif /* __STDC__ */
 
 extern Bool lock_p, demo_mode_p;
@@ -29,6 +42,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;
@@ -53,7 +70,7 @@ static Window real_vroot, real_vroot_value;
                GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime)
 
 void
-grab_keyboard_and_mouse ()
+grab_keyboard_and_mouse P((void))
 {
   Status status;
   XSync (dpy, False);
@@ -81,7 +98,7 @@ grab_keyboard_and_mouse ()
 }
 
 void
-ungrab_keyboard_and_mouse ()
+ungrab_keyboard_and_mouse P((void))
 {
   XUngrabPointer (dpy, CurrentTime);
   XUngrabKeyboard (dpy, CurrentTime);
@@ -163,8 +180,12 @@ ERROR!  You must not include vroot.h in this file.
 #endif
 
 static void
+#if __STDC__
+store_vroot_property (Window win, Window value)
+#else
 store_vroot_property (win, value)
      Window win, value;
+#endif
 {
 #if 0
   printf ("%s: storing XA_VROOT = 0x%x (%s) = 0x%x (%s)\n", progname, 
@@ -182,8 +203,12 @@ store_vroot_property (win, value)
 }
 
 static void
+#if __STDC__
+remove_vroot_property (Window win)
+#else
 remove_vroot_property (win)
      Window win;
+#endif
 {
 #if 0
   printf ("%s: removing XA_VROOT from 0x%x (%s)\n", progname, win, 
@@ -196,7 +221,7 @@ remove_vroot_property (win)
 
 
 static void
-kill_xsetroot_data ()
+kill_xsetroot_data P((void))
 {
   Atom type;
   int format;
@@ -242,7 +267,7 @@ kill_xsetroot_data ()
 static void handle_signals P((Bool on_p));
 
 static void
-save_real_vroot ()
+save_real_vroot P((void))
 {
   int i;
   Window root = RootWindowOfScreen (screen);
@@ -295,7 +320,7 @@ save_real_vroot ()
 }
 
 static Bool
-restore_real_vroot_1 ()
+restore_real_vroot_1 P((void))
 {
   if (verbose_p && real_vroot)
     printf ("%s: restoring __SWM_VROOT property on the real vroot (0x%x).\n",
@@ -345,10 +370,14 @@ restore_real_vroot_handler (sig)
 
 
 static void
+#if __STDC__
+catch_signal (int sig, char *signame, Bool on_p)
+#else
 catch_signal (sig, signame, on_p)
      int sig;
      char *signame;
      Bool on_p;
+#endif
 {
   if (! on_p)
     signal (sig, SIG_DFL);
@@ -382,14 +411,18 @@ handle_signals (on_p)
   catch_signal (SIGILL,  "SIGILL",  on_p);
   catch_signal (SIGTRAP, "SIGTRAP", on_p);
   catch_signal (SIGIOT,  "SIGIOT",  on_p);
+#ifndef VMS
   catch_signal (SIGABRT, "SIGABRT", on_p);
+#endif
 #ifdef SIGEMT
   catch_signal (SIGEMT,  "SIGEMT",  on_p);
 #endif
   catch_signal (SIGFPE,  "SIGFPE",  on_p);
   catch_signal (SIGBUS,  "SIGBUS",  on_p);
   catch_signal (SIGSEGV, "SIGSEGV", on_p);
+#ifdef SIGSYS
   catch_signal (SIGSYS,  "SIGSYS",  on_p);
+#endif
   catch_signal (SIGTERM, "SIGTERM", on_p);
 #ifdef SIGXCPU
   catch_signal (SIGXCPU, "SIGXCPU", on_p);
@@ -406,7 +439,7 @@ handle_signals (on_p)
 /* Managing the actual screensaver window */
 
 void
-initialize_screensaver_window ()
+initialize_screensaver_window P((void))
 {
   /* This resets the screensaver window as fully as possible, since there's
      no way of knowing what some random client may have done to us in the
@@ -421,6 +454,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 +494,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 +523,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 +559,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 +598,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);