1 /* xscreensaver, Copyright (c) 1991-2017 Jamie Zawinski <jwz@netscape.com>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
16 #include <X11/Intrinsic.h>
18 #include "xscreensaver.h"
19 #include "resources.h"
22 #define MAX(a,b) ((a)>(b)?(a):(b))
25 draw_shaded_rectangle (Display *dpy, Window window,
27 int width, int height,
29 unsigned long top_color,
30 unsigned long bottom_color)
35 if (thickness == 0) return;
37 gcv.foreground = top_color;
38 gc1 = XCreateGC (dpy, window, GCForeground, &gcv);
39 gcv.foreground = bottom_color;
40 gc2 = XCreateGC (dpy, window, GCForeground, &gcv);
44 points [1].x = x + width;
46 points [2].x = x + width - thickness;
47 points [2].y = y + thickness;
49 points [3].y = y + thickness;
50 XFillPolygon (dpy, window, gc1, points, 4, Convex, CoordModeOrigin);
53 points [0].y = y + thickness;
55 points [1].y = y + height;
56 points [2].x = x + thickness;
57 points [2].y = y + height - thickness;
58 points [3].x = x + thickness;
59 points [3].y = y + thickness;
60 XFillPolygon (dpy, window, gc1, points, 4, Convex, CoordModeOrigin);
62 points [0].x = x + width;
64 points [1].x = x + width - thickness;
65 points [1].y = y + thickness;
66 points [2].x = x + width - thickness;
67 points [2].y = y + height - thickness;
68 points [3].x = x + width;
69 points [3].y = y + height - thickness;
70 XFillPolygon (dpy, window, gc2, points, 4, Convex, CoordModeOrigin);
73 points [0].y = y + height;
74 points [1].x = x + width;
75 points [1].y = y + height;
76 points [2].x = x + width;
77 points [2].y = y + height - thickness;
78 points [3].x = x + thickness;
79 points [3].y = y + height - thickness;
80 XFillPolygon (dpy, window, gc2, points, 4, Convex, CoordModeOrigin);
88 string_width (XFontStruct *font, char *s)
90 return XTextWidth(font, s, strlen(s));
94 static void update_splash_window (saver_info *si);
95 static void draw_splash_window (saver_info *si);
96 static void destroy_splash_window (saver_info *si);
97 static void unsplash_timer (XtPointer closure, XtIntervalId *id);
99 static void do_demo (saver_screen_info *ssi);
101 static void do_prefs (saver_screen_info *ssi);
102 #endif /* PREFS_BUTTON */
103 static void do_help (saver_screen_info *ssi);
106 struct splash_dialog_data {
108 saver_screen_info *prompt_screen;
122 #endif /* PREFS_BUTTON */
125 XFontStruct *heading_font;
126 XFontStruct *body_font;
127 XFontStruct *button_font;
132 Pixel button_foreground;
133 Pixel button_background;
137 Dimension logo_width;
138 Dimension logo_height;
139 Dimension internal_border;
140 Dimension shadow_width;
142 Dimension button_width, button_height;
143 Dimension demo_button_x, demo_button_y;
145 Dimension prefs_button_x, prefs_button_y;
146 #endif /* PREFS_BUTTON */
147 Dimension help_button_x, help_button_y;
150 Pixmap logo_clipmask;
152 unsigned long *logo_pixels;
159 make_splash_dialog (saver_info *si)
161 saver_preferences *p = &si->prefs;
163 XSetWindowAttributes attrs;
164 unsigned long attrmask = 0;
165 splash_dialog_data *sp;
166 saver_screen_info *ssi;
170 Bool whine = decrepit_p ();
174 /* If locking is not enabled, make sure they see the message. */
177 si->prefs.splash_p = True;
178 if (si->prefs.splash_duration < 5000)
179 si->prefs.splash_duration = 5000;
181 si->prefs.splash_duration += 3000;
186 if (!si->prefs.splash_p ||
187 si->prefs.splash_duration <= 0)
190 ssi = &si->screens[mouse_screen (si)];
192 if (!ssi || !ssi->screen)
193 return; /* WTF? Trying to splash while no screens connected? */
195 cmap = DefaultColormapOfScreen (ssi->screen);
197 sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
198 sp->prompt_screen = ssi;
200 sp->heading_label = get_string_resource (si->dpy,
201 "splash.heading.label",
202 "Dialog.Label.Label");
203 sp->body_label = get_string_resource (si->dpy,
205 "Dialog.Label.Label");
206 sp->body2_label = get_string_resource (si->dpy,
207 "splash.body2.label",
208 "Dialog.Label.Label");
209 sp->demo_label = get_string_resource (si->dpy,
211 "Dialog.Button.Label");
213 sp->prefs_label = get_string_resource (si->dpy,
214 "splash.prefs.label",
215 "Dialog.Button.Label");
216 #endif /* PREFS_BUTTON */
217 sp->help_label = get_string_resource (si->dpy,
219 "Dialog.Button.Label");
225 sp->body3_label = strdup("WARNING: This version is very old!");
226 sp->body4_label = strdup("Please upgrade!");
229 if (!sp->heading_label)
230 sp->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
232 sp->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
233 if (!sp->body2_label)
234 sp->body2_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
235 if (!sp->demo_label) sp->demo_label = strdup("ERROR");
237 if (!sp->prefs_label) sp->prefs_label = strdup("ERROR");
238 #endif /* PREFS_BUTTON */
239 if (!sp->help_label) sp->help_label = strdup("ERROR");
241 /* Put the version number in the label. */
243 char *s = (char *) malloc (strlen(sp->heading_label) + 20);
244 sprintf(s, sp->heading_label, si->version);
245 free (sp->heading_label);
246 sp->heading_label = s;
249 f = get_string_resource (si->dpy, "splash.headingFont", "Dialog.Font");
250 sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
251 if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed");
254 f = get_string_resource(si->dpy, "splash.bodyFont", "Dialog.Font");
255 sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
256 if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed");
259 f = get_string_resource(si->dpy, "splash.buttonFont", "Dialog.Font");
260 sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
261 if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed");
264 sp->foreground = get_pixel_resource (si->dpy, cmap,
266 "Dialog.Foreground");
267 sp->background = get_pixel_resource (si->dpy, cmap,
269 "Dialog.Background");
270 sp->border = get_pixel_resource (si->dpy, cmap,
271 "splash.borderColor",
272 "Dialog.borderColor");
274 if (sp->foreground == sp->background)
276 /* Make sure the error messages show up. */
277 sp->foreground = BlackPixelOfScreen (ssi->screen);
278 sp->background = WhitePixelOfScreen (ssi->screen);
281 sp->button_foreground = get_pixel_resource (si->dpy, cmap,
282 "splash.Button.foreground",
283 "Dialog.Button.Foreground");
284 sp->button_background = get_pixel_resource (si->dpy, cmap,
285 "splash.Button.background",
286 "Dialog.Button.Background");
287 sp->shadow_top = get_pixel_resource (si->dpy, cmap,
288 "splash.topShadowColor",
289 "Dialog.Foreground");
290 sp->shadow_bottom = get_pixel_resource (si->dpy, cmap,
291 "splash.bottomShadowColor",
292 "Dialog.Background");
294 sp->logo_width = get_integer_resource (si->dpy,
296 "Dialog.Logo.Width");
297 sp->logo_height = get_integer_resource (si->dpy,
298 "splash.logo.height",
299 "Dialog.Logo.Height");
300 sp->internal_border = get_integer_resource (si->dpy,
301 "splash.internalBorderWidth",
302 "Dialog.InternalBorderWidth");
303 sp->shadow_width = get_integer_resource (si->dpy,
304 "splash.shadowThickness",
305 "Dialog.ShadowThickness");
307 if (sp->logo_width == 0) sp->logo_width = 150;
308 if (sp->logo_height == 0) sp->logo_height = 150;
309 if (sp->internal_border == 0) sp->internal_border = 15;
310 if (sp->shadow_width == 0) sp->shadow_width = 4;
313 int direction, ascent, descent;
319 /* Measure the heading_label. */
320 XTextExtents (sp->heading_font,
321 sp->heading_label, strlen(sp->heading_label),
322 &direction, &ascent, &descent, &overall);
323 if (overall.width > sp->width) sp->width = overall.width;
324 sp->height += ascent + descent;
326 /* Measure the body_label. */
327 XTextExtents (sp->body_font,
328 sp->body_label, strlen(sp->body_label),
329 &direction, &ascent, &descent, &overall);
330 if (overall.width > sp->width) sp->width = overall.width;
331 sp->height += ascent + descent;
333 /* Measure the body2_label. */
334 XTextExtents (sp->body_font,
335 sp->body2_label, strlen(sp->body2_label),
336 &direction, &ascent, &descent, &overall);
337 if (overall.width > sp->width) sp->width = overall.width;
338 sp->height += ascent + descent;
340 /* Measure the optional body3_label. */
343 XTextExtents (sp->heading_font,
344 sp->body3_label, strlen(sp->body3_label),
345 &direction, &ascent, &descent, &overall);
346 if (overall.width > sp->width) sp->width = overall.width;
347 XTextExtents (sp->heading_font,
348 sp->body4_label, strlen(sp->body4_label),
349 &direction, &ascent, &descent, &overall);
350 if (overall.width > sp->width) sp->width = overall.width;
351 sp->height += (ascent + descent) * 5;
355 Dimension w2 = 0, w3 = 0, w4 = 0;
356 Dimension h2 = 0, h3 = 0, h4 = 0;
358 /* Measure the Demo button. */
359 XTextExtents (sp->button_font,
360 sp->demo_label, strlen(sp->demo_label),
361 &direction, &ascent, &descent, &overall);
363 h2 = ascent + descent;
366 /* Measure the Prefs button. */
367 XTextExtents (sp->button_font,
368 sp->prefs_label, strlen(sp->prefs_label),
369 &direction, &ascent, &descent, &overall);
371 h3 = ascent + descent;
372 #else /* !PREFS_BUTTON */
375 #endif /* !PREFS_BUTTON */
377 /* Measure the Help button. */
378 XTextExtents (sp->button_font,
379 sp->help_label, strlen(sp->help_label),
380 &direction, &ascent, &descent, &overall);
382 h4 = ascent + descent;
384 w2 = MAX(w2, w3); w2 = MAX(w2, w4);
385 h2 = MAX(h2, h3); h2 = MAX(h2, h4);
387 /* Add some horizontal padding inside the buttons. */
390 w2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
391 h2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
393 sp->button_width = w2;
394 sp->button_height = h2;
398 #else /* !PREFS_BUTTON */
400 #endif /* !PREFS_BUTTON */
402 w2 += ((ascent + descent) * 2); /* for space between buttons */
404 if (w2 > sp->width) sp->width = w2;
408 sp->width += (sp->internal_border * 2);
409 sp->height += (sp->internal_border * 3);
411 if (sp->logo_height > sp->height)
412 sp->height = sp->logo_height;
413 else if (sp->height > sp->logo_height)
414 sp->logo_height = sp->height;
416 sp->logo_width = sp->logo_height;
418 sp->width += sp->logo_width;
421 attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
422 attrmask |= CWEventMask;
423 attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
426 int sx = 0, sy = 0, w, h;
432 if (si->prefs.debug_p) w /= 2;
433 x = sx + (((w + sp->width) / 2) - sp->width);
434 y = sy + (((h + sp->height) / 2) - sp->height);
439 bw = get_integer_resource (si->dpy,
440 "splash.borderWidth",
441 "Dialog.BorderWidth");
444 XCreateWindow (si->dpy,
445 RootWindowOfScreen(ssi->screen),
446 x, y, sp->width, sp->height, bw,
447 DefaultDepthOfScreen (ssi->screen), InputOutput,
448 DefaultVisualOfScreen(ssi->screen),
450 XSetWindowBackground (si->dpy, si->splash_dialog, sp->background);
451 XSetWindowBorder (si->dpy, si->splash_dialog, sp->border);
454 sp->logo_pixmap = xscreensaver_logo (ssi->screen,
455 /* same visual as si->splash_dialog */
456 DefaultVisualOfScreen (ssi->screen),
457 si->splash_dialog, cmap,
459 &sp->logo_pixels, &sp->logo_npixels,
460 &sp->logo_clipmask, True);
462 XMapRaised (si->dpy, si->splash_dialog);
463 XSync (si->dpy, False);
467 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
468 unsplash_timer, (XtPointer) si);
470 draw_splash_window (si);
471 XSync (si->dpy, False);
476 draw_splash_window (saver_info *si)
478 splash_dialog_data *sp = si->sp_data;
481 int vspacing, height;
482 int x1, x2, x3, y1, y2;
488 #endif /* !PREFS_BUTTON */
490 height = (sp->heading_font->ascent + sp->heading_font->descent +
491 sp->body_font->ascent + sp->body_font->descent +
492 sp->body_font->ascent + sp->body_font->descent +
493 sp->button_font->ascent + sp->button_font->descent);
494 vspacing = ((sp->height
495 - (4 * sp->shadow_width)
496 - (2 * sp->internal_border)
498 if (vspacing < 0) vspacing = 0;
499 if (vspacing > (sp->heading_font->ascent * 2))
500 vspacing = (sp->heading_font->ascent * 2);
502 gcv.foreground = sp->foreground;
503 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
504 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
506 x3 = sp->width - (sp->shadow_width * 2);
507 y1 = sp->internal_border;
511 XSetFont (si->dpy, gc1, sp->heading_font->fid);
512 sw = string_width (sp->heading_font, sp->heading_label);
513 x2 = (x1 + ((x3 - x1 - sw) / 2));
514 y1 += sp->heading_font->ascent;
515 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
516 sp->heading_label, strlen(sp->heading_label));
517 y1 += sp->heading_font->descent;
519 /* text below top heading
521 XSetFont (si->dpy, gc1, sp->body_font->fid);
522 y1 += vspacing + sp->body_font->ascent;
523 sw = string_width (sp->body_font, sp->body_label);
524 x2 = (x1 + ((x3 - x1 - sw) / 2));
525 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
526 sp->body_label, strlen(sp->body_label));
527 y1 += sp->body_font->descent;
529 y1 += sp->body_font->ascent;
530 sw = string_width (sp->body_font, sp->body2_label);
531 x2 = (x1 + ((x3 - x1 - sw) / 2));
532 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
533 sp->body2_label, strlen(sp->body2_label));
534 y1 += sp->body_font->descent;
538 XSetFont (si->dpy, gc1, sp->heading_font->fid);
539 y1 += sp->heading_font->ascent + sp->heading_font->descent;
540 y1 += sp->heading_font->ascent;
541 sw = string_width (sp->heading_font, sp->body3_label);
542 x2 = (x1 + ((x3 - x1 - sw) / 2));
543 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
544 sp->body3_label, strlen(sp->body3_label));
545 y1 += sp->heading_font->descent + sp->heading_font->ascent;
546 sw = string_width (sp->heading_font, sp->body4_label);
547 x2 = (x1 + ((x3 - x1 - sw) / 2));
548 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
549 sp->body4_label, strlen(sp->body4_label));
550 y1 += sp->heading_font->descent;
551 XSetFont (si->dpy, gc1, sp->body_font->fid);
556 XSetForeground (si->dpy, gc1, sp->button_foreground);
557 XSetForeground (si->dpy, gc2, sp->button_background);
559 /* y1 += (vspacing * 2);*/
560 y1 = sp->height - sp->internal_border - sp->button_height;
562 x1 += sp->internal_border;
563 y2 = (y1 + ((sp->button_height -
564 (sp->button_font->ascent + sp->button_font->descent))
566 + sp->button_font->ascent);
568 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
569 sp->internal_border - (sp->button_width * nbuttons))
573 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_label))
575 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
576 sp->button_width, sp->button_height);
577 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
578 sp->demo_label, strlen(sp->demo_label));
579 sp->demo_button_x = x1;
580 sp->demo_button_y = y1;
583 x1 += hspacing + sp->button_width;
584 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
586 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
587 sp->button_width, sp->button_height);
588 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
589 sp->prefs_label, strlen(sp->prefs_label));
590 sp->prefs_button_x = x1;
591 sp->prefs_button_y = y1;
592 #endif /* PREFS_BUTTON */
595 x1 += hspacing + sp->button_width;
596 #else /* !PREFS_BUTTON */
597 x1 = (sp->width - sp->button_width -
598 sp->internal_border - (sp->shadow_width * 2));
599 #endif /* !PREFS_BUTTON */
601 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
603 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
604 sp->button_width, sp->button_height);
605 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
606 sp->help_label, strlen(sp->help_label));
607 sp->help_button_x = x1;
608 sp->help_button_y = y1;
613 x1 = sp->shadow_width * 6;
614 y1 = sp->shadow_width * 6;
615 x2 = sp->logo_width - (sp->shadow_width * 12);
616 y2 = sp->logo_height - (sp->shadow_width * 12);
622 unsigned int w, h, bw, d;
623 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
624 XSetForeground (si->dpy, gc1, sp->foreground);
625 XSetBackground (si->dpy, gc1, sp->background);
626 XSetClipMask (si->dpy, gc1, sp->logo_clipmask);
627 XSetClipOrigin (si->dpy, gc1, x1 + ((x2 - (int)w) /2), y1 + ((y2 - (int)h) / 2));
629 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
631 x1 + ((x2 - (int)w) / 2),
632 y1 + ((y2 - (int)h) / 2),
635 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
637 x1 + ((x2 - (int)w) / 2),
638 y1 + ((y2 - (int)h) / 2));
641 /* Solid border inside the logo box. */
643 XSetForeground (si->dpy, gc1, sp->foreground);
644 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
647 /* The shadow around the logo
649 draw_shaded_rectangle (si->dpy, si->splash_dialog,
650 sp->shadow_width * 4,
651 sp->shadow_width * 4,
652 sp->logo_width - (sp->shadow_width * 8),
653 sp->logo_height - (sp->shadow_width * 8),
655 sp->shadow_bottom, sp->shadow_top);
657 /* The shadow around the whole window
659 draw_shaded_rectangle (si->dpy, si->splash_dialog,
660 0, 0, sp->width, sp->height, sp->shadow_width,
661 sp->shadow_top, sp->shadow_bottom);
663 XFreeGC (si->dpy, gc1);
664 XFreeGC (si->dpy, gc2);
666 update_splash_window (si);
671 update_splash_window (saver_info *si)
673 splash_dialog_data *sp = si->sp_data;
676 pressed = sp->pressed;
678 /* The shadows around the buttons
680 draw_shaded_rectangle (si->dpy, si->splash_dialog,
681 sp->demo_button_x, sp->demo_button_y,
682 sp->button_width, sp->button_height, sp->shadow_width,
683 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
684 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
686 draw_shaded_rectangle (si->dpy, si->splash_dialog,
687 sp->prefs_button_x, sp->prefs_button_y,
688 sp->button_width, sp->button_height, sp->shadow_width,
689 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
690 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
691 #endif /* PREFS_BUTTON */
692 draw_shaded_rectangle (si->dpy, si->splash_dialog,
693 sp->help_button_x, sp->help_button_y,
694 sp->button_width, sp->button_height, sp->shadow_width,
695 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
696 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
700 destroy_splash_window (saver_info *si)
702 splash_dialog_data *sp = si->sp_data;
703 saver_screen_info *ssi = sp->prompt_screen;
704 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
705 Pixel black = BlackPixelOfScreen (ssi->screen);
706 Pixel white = WhitePixelOfScreen (ssi->screen);
709 XtRemoveTimeOut (sp->timer);
711 if (si->splash_dialog)
713 XDestroyWindow (si->dpy, si->splash_dialog);
714 si->splash_dialog = 0;
717 if (sp->heading_label) free (sp->heading_label);
718 if (sp->body_label) free (sp->body_label);
719 if (sp->body2_label) free (sp->body2_label);
720 if (sp->body3_label) free (sp->body3_label);
721 if (sp->body4_label) free (sp->body4_label);
722 if (sp->demo_label) free (sp->demo_label);
724 if (sp->prefs_label) free (sp->prefs_label);
725 #endif /* PREFS_BUTTON */
726 if (sp->help_label) free (sp->help_label);
728 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
729 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
730 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
732 if (sp->foreground != black && sp->foreground != white)
733 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
734 if (sp->background != black && sp->background != white)
735 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
736 if (sp->button_foreground != black && sp->button_foreground != white)
737 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
738 if (sp->button_background != black && sp->button_background != white)
739 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
740 if (sp->shadow_top != black && sp->shadow_top != white)
741 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
742 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
743 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
746 XFreePixmap (si->dpy, sp->logo_pixmap);
747 if (sp->logo_clipmask)
748 XFreePixmap (si->dpy, sp->logo_clipmask);
751 if (sp->logo_npixels)
752 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
753 free (sp->logo_pixels);
755 sp->logo_npixels = 0;
758 memset (sp, 0, sizeof(*sp));
764 handle_splash_event (saver_info *si, XEvent *event)
766 splash_dialog_data *sp = si->sp_data;
767 saver_screen_info *ssi;
770 ssi = sp->prompt_screen;
772 switch (event->xany.type)
775 draw_splash_window (si);
778 case ButtonPress: case ButtonRelease:
780 if (event->xbutton.x >= sp->demo_button_x &&
781 event->xbutton.x < sp->demo_button_x + sp->button_width &&
782 event->xbutton.y >= sp->demo_button_y &&
783 event->xbutton.y < sp->demo_button_y + sp->button_height)
787 else if (event->xbutton.x >= sp->prefs_button_x &&
788 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
789 event->xbutton.y >= sp->prefs_button_y &&
790 event->xbutton.y < sp->prefs_button_y + sp->button_height)
792 #endif /* PREFS_BUTTON */
794 else if (event->xbutton.x >= sp->help_button_x &&
795 event->xbutton.x < sp->help_button_x + sp->button_width &&
796 event->xbutton.y >= sp->help_button_y &&
797 event->xbutton.y < sp->help_button_y + sp->button_height)
800 if (event->xany.type == ButtonPress)
803 update_splash_window (si);
805 XBell (si->dpy, False);
807 else if (event->xany.type == ButtonRelease)
809 if (which && sp->pressed == which)
811 destroy_splash_window (si);
815 case 1: do_demo (ssi); break;
817 case 2: do_prefs (ssi); break;
818 #endif /* PREFS_BUTTON */
819 case 3: do_help (ssi); break;
823 else if (which == 0 && sp->pressed == 0)
825 /* click and release on the window but not in a button:
826 treat that as "dismiss the splash dialog." */
827 destroy_splash_window (si);
830 if (sp) sp->pressed = 0;
831 update_splash_window (si);
841 unsplash_timer (XtPointer closure, XtIntervalId *id)
843 saver_info *si = (saver_info *) closure;
844 if (si && si->sp_data)
845 destroy_splash_window (si);
849 /* Button callbacks */
858 do_demo (saver_screen_info *ssi)
860 saver_info *si = ssi->global;
861 saver_preferences *p = &si->prefs;
862 const char *cmd = p->demo_command;
865 fork_and_exec (ssi, cmd);
867 fprintf (stderr, "%s: no demo-mode command has been specified.\n",
873 do_prefs (saver_screen_info *ssi)
875 saver_info *si = ssi->global;
876 saver_preferences *p = &si->prefs;
877 const char *cmd = p->prefs_command;
879 if (command && *command)
880 fork_and_exec (ssi, cmd);
882 fprintf (stderr, "%s: no preferences command has been specified.\n",
885 #endif /* PREFS_BUTTON */
888 do_help (saver_screen_info *ssi)
890 saver_info *si = ssi->global;
891 saver_preferences *p = &si->prefs;
892 char *help_command = 0;
894 if (!p->load_url_command || !*p->load_url_command)
896 fprintf (stderr, "%s: no URL command has been specified.\n", blurb());
899 if (!p->help_url || !*p->help_url)
901 fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
905 help_command = (char *) malloc (strlen (p->load_url_command) +
906 (strlen (p->help_url) * 4) + 10);
907 sprintf (help_command, p->load_url_command,
908 p->help_url, p->help_url, p->help_url, p->help_url);
910 fork_and_exec (ssi, help_command);