http://www.jwz.org/xscreensaver/xscreensaver-5.13.tar.gz
[xscreensaver] / driver / splash.c
index 52c21ad6c0e21881df9b1c0e0bf5a5dfed72007e..02844b58c72b94624c1127c9cb619e774003faf3 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-2006 Jamie Zawinski <jwz@netscape.com>
+/* xscreensaver, Copyright (c) 1991-2008 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
@@ -87,10 +87,7 @@ draw_shaded_rectangle (Display *dpy, Window window,
 int
 string_width (XFontStruct *font, char *s)
 {
-  int direction, ascent, descent;
-  XCharStruct overall;
-  XTextExtents (font, s, strlen(s), &direction, &ascent, &descent, &overall);
-  return overall.width;
+  return XTextWidth(font, s, strlen(s));
 }
 
 
@@ -129,6 +126,7 @@ struct splash_dialog_data {
 
   Pixel foreground;
   Pixel background;
+  Pixel border;
   Pixel button_foreground;
   Pixel button_background;
   Pixel shadow_top;
@@ -173,6 +171,10 @@ make_splash_dialog (saver_info *si)
     return;
 
   ssi = &si->screens[mouse_screen (si)];
+
+  if (!ssi || !ssi->screen)
+    return;    /* WTF?  Trying to splash while no screens connected? */
+
   cmap = DefaultColormapOfScreen (ssi->screen);
 
   sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
@@ -240,6 +242,9 @@ make_splash_dialog (saver_info *si)
   sp->background = get_pixel_resource (si->dpy, cmap, 
                                        "splash.background",
                                       "Dialog.Background");
+  sp->border = get_pixel_resource (si->dpy, cmap, 
+                                       "splash.borderColor",
+                                      "Dialog.borderColor");
 
   if (sp->foreground == sp->background)
     {
@@ -379,7 +384,7 @@ make_splash_dialog (saver_info *si)
   attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
 
   {
-    int sx, sy, w, h;
+    int sx = 0, sy = 0, w, h;
     int mouse_x = 0, mouse_y = 0;
 
     {
@@ -396,7 +401,10 @@ make_splash_dialog (saver_info *si)
         }
     }
 
-    get_screen_viewport (ssi, &sx, &sy, &w, &h, mouse_x, mouse_y, False);
+    x = ssi->x;
+    y = ssi->y;
+    w = ssi->width;
+    h = ssi->height;
     if (si->prefs.debug_p) w /= 2;
     x = sx + (((w + sp->width)  / 2) - sp->width);
     y = sy + (((h + sp->height) / 2) - sp->height);
@@ -416,8 +424,12 @@ make_splash_dialog (saver_info *si)
                   DefaultVisualOfScreen(ssi->screen),
                   attrmask, &attrs);
   XSetWindowBackground (si->dpy, si->splash_dialog, sp->background);
+  XSetWindowBorder (si->dpy, si->splash_dialog, sp->border);
+
 
-  sp->logo_pixmap = xscreensaver_logo (ssi->screen, ssi->current_visual,
+  sp->logo_pixmap = xscreensaver_logo (ssi->screen, 
+                                       /* same visual as si->splash_dialog */
+                                       DefaultVisualOfScreen (ssi->screen),
                                        si->splash_dialog, cmap,
                                        sp->background, 
                                        &sp->logo_pixels, &sp->logo_npixels,