http://packetstormsecurity.org/UNIX/admin/xscreensaver-3.28.tar.gz
[xscreensaver] / driver / splash.c
index 8f6fb011249ad9fd72dee71aeaf4b896ac051cd9..b4dcf20c6efe0c9ad57319eb9f2d438f7231bbdb 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1998 Jamie Zawinski <jwz@netscape.com>
+/* xscreensaver, Copyright (c) 1991-2001 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -157,7 +157,8 @@ make_splash_dialog (saver_info *si)
 
   if (si->sp_data)
     return;
-  if (si->prefs.splash_duration <= 0)
+  if (!si->prefs.splash_p ||
+      si->prefs.splash_duration <= 0)
     return;
 
   sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
@@ -343,13 +344,13 @@ make_splash_dialog (saver_info *si)
   attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
 
   {
-    Dimension w = WidthOfScreen(screen);
-    Dimension h = HeightOfScreen(screen);
+    int sx, sy, w, h;
+    get_screen_viewport (si->default_screen, &sx, &sy, &w, &h, False);
     if (si->prefs.debug_p) w /= 2;
-    x = ((w + sp->width) / 2) - sp->width;
-    y = ((h + sp->height) / 2) - sp->height;
-    if (x < 0) x = 0;
-    if (y < 0) y = 0;
+    x = sx + (((w + sp->width)  / 2) - sp->width);
+    y = sy + (((h + sp->height) / 2) - sp->height);
+    if (x < sx) x = sx;
+    if (y < sy) y = sy;
   }
 
   bw = get_integer_resource ("splash.borderWidth", "Dialog.BorderWidth");
@@ -375,6 +376,22 @@ make_splash_dialog (saver_info *si)
   XSync (si->dpy, False);
 }
 
+void
+draw_logo (saver_info *si, Window win, int x, int y, int w, int h,
+           Bool first_time_p)
+{
+  Colormap cmap = DefaultColormapOfScreen (si->default_screen->screen);
+  Pixmap logo_map = XCreatePixmap (si->dpy, win, w, h, 
+                                   si->default_screen->current_depth);
+  XGCValues gcv;
+  GC gc = XCreateGC (si->dpy, win, 0, &gcv);
+  xscreensaver_logo (si->dpy, logo_map, cmap, !first_time_p);
+  XCopyArea (si->dpy, logo_map, win, gc, 0, 0, w, h, x, y);
+  XFreeGC (si->dpy, gc);
+  XFreePixmap (si->dpy, logo_map);
+}
+
+
 static void
 draw_splash_window (saver_info *si)
 {
@@ -488,10 +505,7 @@ draw_splash_window (saver_info *si)
   x2 = sp->logo_width - (sp->shadow_width * 6);
   y2 = sp->logo_height - (sp->shadow_width * 6);
 
-  XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1, x2, y2);
-  skull (si->dpy, si->splash_dialog, gc1, gc2,
-        x1 + sp->shadow_width, y1 + sp->shadow_width,
-        x2 - (sp->shadow_width * 2), y2 - (sp->shadow_width * 2));
+  draw_logo (si, si->splash_dialog, x1, y1, x2, y2, True);
 
 
   /* The shadow around the logo