1 /* xscreensaver, Copyright (c) 1991-2006 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;
120 #endif /* PREFS_BUTTON */
123 XFontStruct *heading_font;
124 XFontStruct *body_font;
125 XFontStruct *button_font;
129 Pixel button_foreground;
130 Pixel button_background;
134 Dimension logo_width;
135 Dimension logo_height;
136 Dimension internal_border;
137 Dimension shadow_width;
139 Dimension button_width, button_height;
140 Dimension demo_button_x, demo_button_y;
142 Dimension prefs_button_x, prefs_button_y;
143 #endif /* PREFS_BUTTON */
144 Dimension help_button_x, help_button_y;
147 Pixmap logo_clipmask;
149 unsigned long *logo_pixels;
156 make_splash_dialog (saver_info *si)
159 XSetWindowAttributes attrs;
160 unsigned long attrmask = 0;
161 splash_dialog_data *sp;
162 saver_screen_info *ssi;
168 if (!si->prefs.splash_p ||
169 si->prefs.splash_duration <= 0)
172 ssi = &si->screens[mouse_screen (si)];
173 cmap = DefaultColormapOfScreen (ssi->screen);
175 sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
176 sp->prompt_screen = ssi;
178 sp->heading_label = get_string_resource (si->dpy,
179 "splash.heading.label",
180 "Dialog.Label.Label");
181 sp->body_label = get_string_resource (si->dpy,
183 "Dialog.Label.Label");
184 sp->body2_label = get_string_resource (si->dpy,
185 "splash.body2.label",
186 "Dialog.Label.Label");
187 sp->demo_label = get_string_resource (si->dpy,
189 "Dialog.Button.Label");
191 sp->prefs_label = get_string_resource (si->dpy,
192 "splash.prefs.label",
193 "Dialog.Button.Label");
194 #endif /* PREFS_BUTTON */
195 sp->help_label = get_string_resource (si->dpy,
197 "Dialog.Button.Label");
199 if (!sp->heading_label)
200 sp->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
202 sp->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
203 if (!sp->body2_label)
204 sp->body2_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
205 if (!sp->demo_label) sp->demo_label = strdup("ERROR");
207 if (!sp->prefs_label) sp->prefs_label = strdup("ERROR");
208 #endif /* PREFS_BUTTON */
209 if (!sp->help_label) sp->help_label = strdup("ERROR");
211 /* Put the version number in the label. */
213 char *s = (char *) malloc (strlen(sp->heading_label) + 20);
214 sprintf(s, sp->heading_label, si->version);
215 free (sp->heading_label);
216 sp->heading_label = s;
219 f = get_string_resource (si->dpy, "splash.headingFont", "Dialog.Font");
220 sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
221 if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed");
224 f = get_string_resource(si->dpy, "splash.bodyFont", "Dialog.Font");
225 sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
226 if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed");
229 f = get_string_resource(si->dpy, "splash.buttonFont", "Dialog.Font");
230 sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
231 if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed");
234 sp->foreground = get_pixel_resource (si->dpy, cmap,
236 "Dialog.Foreground");
237 sp->background = get_pixel_resource (si->dpy, cmap,
239 "Dialog.Background");
241 if (sp->foreground == sp->background)
243 /* Make sure the error messages show up. */
244 sp->foreground = BlackPixelOfScreen (ssi->screen);
245 sp->background = WhitePixelOfScreen (ssi->screen);
248 sp->button_foreground = get_pixel_resource (si->dpy, cmap,
249 "splash.Button.foreground",
250 "Dialog.Button.Foreground");
251 sp->button_background = get_pixel_resource (si->dpy, cmap,
252 "splash.Button.background",
253 "Dialog.Button.Background");
254 sp->shadow_top = get_pixel_resource (si->dpy, cmap,
255 "splash.topShadowColor",
256 "Dialog.Foreground");
257 sp->shadow_bottom = get_pixel_resource (si->dpy, cmap,
258 "splash.bottomShadowColor",
259 "Dialog.Background");
261 sp->logo_width = get_integer_resource (si->dpy,
263 "Dialog.Logo.Width");
264 sp->logo_height = get_integer_resource (si->dpy,
265 "splash.logo.height",
266 "Dialog.Logo.Height");
267 sp->internal_border = get_integer_resource (si->dpy,
268 "splash.internalBorderWidth",
269 "Dialog.InternalBorderWidth");
270 sp->shadow_width = get_integer_resource (si->dpy,
271 "splash.shadowThickness",
272 "Dialog.ShadowThickness");
274 if (sp->logo_width == 0) sp->logo_width = 150;
275 if (sp->logo_height == 0) sp->logo_height = 150;
276 if (sp->internal_border == 0) sp->internal_border = 15;
277 if (sp->shadow_width == 0) sp->shadow_width = 4;
280 int direction, ascent, descent;
286 /* Measure the heading_label. */
287 XTextExtents (sp->heading_font,
288 sp->heading_label, strlen(sp->heading_label),
289 &direction, &ascent, &descent, &overall);
290 if (overall.width > sp->width) sp->width = overall.width;
291 sp->height += ascent + descent;
293 /* Measure the body_label. */
294 XTextExtents (sp->body_font,
295 sp->body_label, strlen(sp->body_label),
296 &direction, &ascent, &descent, &overall);
297 if (overall.width > sp->width) sp->width = overall.width;
298 sp->height += ascent + descent;
300 /* Measure the body2_label. */
301 XTextExtents (sp->body_font,
302 sp->body2_label, strlen(sp->body2_label),
303 &direction, &ascent, &descent, &overall);
304 if (overall.width > sp->width) sp->width = overall.width;
305 sp->height += ascent + descent;
308 Dimension w2 = 0, w3 = 0, w4 = 0;
309 Dimension h2 = 0, h3 = 0, h4 = 0;
311 /* Measure the Demo button. */
312 XTextExtents (sp->button_font,
313 sp->demo_label, strlen(sp->demo_label),
314 &direction, &ascent, &descent, &overall);
316 h2 = ascent + descent;
319 /* Measure the Prefs button. */
320 XTextExtents (sp->button_font,
321 sp->prefs_label, strlen(sp->prefs_label),
322 &direction, &ascent, &descent, &overall);
324 h3 = ascent + descent;
325 #else /* !PREFS_BUTTON */
328 #endif /* !PREFS_BUTTON */
330 /* Measure the Help button. */
331 XTextExtents (sp->button_font,
332 sp->help_label, strlen(sp->help_label),
333 &direction, &ascent, &descent, &overall);
335 h4 = ascent + descent;
337 w2 = MAX(w2, w3); w2 = MAX(w2, w4);
338 h2 = MAX(h2, h3); h2 = MAX(h2, h4);
340 /* Add some horizontal padding inside the buttons. */
343 w2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
344 h2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
346 sp->button_width = w2;
347 sp->button_height = h2;
351 #else /* !PREFS_BUTTON */
353 #endif /* !PREFS_BUTTON */
355 w2 += ((ascent + descent) * 2); /* for space between buttons */
357 if (w2 > sp->width) sp->width = w2;
361 sp->width += (sp->internal_border * 2);
362 sp->height += (sp->internal_border * 3);
364 if (sp->logo_height > sp->height)
365 sp->height = sp->logo_height;
366 else if (sp->height > sp->logo_height)
367 sp->logo_height = sp->height;
369 sp->logo_width = sp->logo_height;
371 sp->width += sp->logo_width;
374 attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
375 attrmask |= CWEventMask;
376 attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
380 int mouse_x = 0, mouse_y = 0;
383 Window pointer_root, pointer_child;
384 int root_x, root_y, win_x, win_y;
386 if (XQueryPointer (si->dpy,
387 RootWindowOfScreen (ssi->screen),
388 &pointer_root, &pointer_child,
389 &root_x, &root_y, &win_x, &win_y, &mask))
396 get_screen_viewport (ssi, &sx, &sy, &w, &h, mouse_x, mouse_y, False);
397 if (si->prefs.debug_p) w /= 2;
398 x = sx + (((w + sp->width) / 2) - sp->width);
399 y = sy + (((h + sp->height) / 2) - sp->height);
404 bw = get_integer_resource (si->dpy,
405 "splash.borderWidth",
406 "Dialog.BorderWidth");
409 XCreateWindow (si->dpy,
410 RootWindowOfScreen(ssi->screen),
411 x, y, sp->width, sp->height, bw,
412 DefaultDepthOfScreen (ssi->screen), InputOutput,
413 DefaultVisualOfScreen(ssi->screen),
415 XSetWindowBackground (si->dpy, si->splash_dialog, sp->background);
417 sp->logo_pixmap = xscreensaver_logo (ssi->screen,
418 /* same visual as si->splash_dialog */
419 DefaultVisualOfScreen (ssi->screen),
420 si->splash_dialog, cmap,
422 &sp->logo_pixels, &sp->logo_npixels,
423 &sp->logo_clipmask, True);
425 XMapRaised (si->dpy, si->splash_dialog);
426 XSync (si->dpy, False);
430 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
431 unsplash_timer, (XtPointer) si);
433 draw_splash_window (si);
434 XSync (si->dpy, False);
439 draw_splash_window (saver_info *si)
441 splash_dialog_data *sp = si->sp_data;
444 int hspacing, vspacing, height;
445 int x1, x2, x3, y1, y2;
450 #else /* !PREFS_BUTTON */
452 #endif /* !PREFS_BUTTON */
454 height = (sp->heading_font->ascent + sp->heading_font->descent +
455 sp->body_font->ascent + sp->body_font->descent +
456 sp->body_font->ascent + sp->body_font->descent +
457 sp->button_font->ascent + sp->button_font->descent);
458 vspacing = ((sp->height
459 - (4 * sp->shadow_width)
460 - (2 * sp->internal_border)
462 if (vspacing < 0) vspacing = 0;
463 if (vspacing > (sp->heading_font->ascent * 2))
464 vspacing = (sp->heading_font->ascent * 2);
466 gcv.foreground = sp->foreground;
467 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
468 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
470 x3 = sp->width - (sp->shadow_width * 2);
471 y1 = sp->internal_border;
475 XSetFont (si->dpy, gc1, sp->heading_font->fid);
476 sw = string_width (sp->heading_font, sp->heading_label);
477 x2 = (x1 + ((x3 - x1 - sw) / 2));
478 y1 += sp->heading_font->ascent;
479 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
480 sp->heading_label, strlen(sp->heading_label));
481 y1 += sp->heading_font->descent;
483 /* text below top heading
485 XSetFont (si->dpy, gc1, sp->body_font->fid);
486 y1 += vspacing + sp->body_font->ascent;
487 sw = string_width (sp->body_font, sp->body_label);
488 x2 = (x1 + ((x3 - x1 - sw) / 2));
489 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
490 sp->body_label, strlen(sp->body_label));
491 y1 += sp->body_font->descent;
493 y1 += sp->body_font->ascent;
494 sw = string_width (sp->body_font, sp->body2_label);
495 x2 = (x1 + ((x3 - x1 - sw) / 2));
496 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
497 sp->body2_label, strlen(sp->body2_label));
498 y1 += sp->body_font->descent;
502 XSetForeground (si->dpy, gc1, sp->button_foreground);
503 XSetForeground (si->dpy, gc2, sp->button_background);
505 /* y1 += (vspacing * 2);*/
506 y1 = sp->height - sp->internal_border - sp->button_height;
508 x1 += sp->internal_border;
509 y2 = (y1 + ((sp->button_height -
510 (sp->button_font->ascent + sp->button_font->descent))
512 + sp->button_font->ascent);
513 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
514 sp->internal_border - (sp->button_width * nbuttons))
517 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_label))
519 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
520 sp->button_width, sp->button_height);
521 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
522 sp->demo_label, strlen(sp->demo_label));
523 sp->demo_button_x = x1;
524 sp->demo_button_y = y1;
527 x1 += hspacing + sp->button_width;
528 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
530 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
531 sp->button_width, sp->button_height);
532 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
533 sp->prefs_label, strlen(sp->prefs_label));
534 sp->prefs_button_x = x1;
535 sp->prefs_button_y = y1;
536 #endif /* PREFS_BUTTON */
539 x1 += hspacing + sp->button_width;
540 #else /* !PREFS_BUTTON */
541 x1 = (sp->width - sp->button_width -
542 sp->internal_border - (sp->shadow_width * 2));
543 #endif /* !PREFS_BUTTON */
545 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
547 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
548 sp->button_width, sp->button_height);
549 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
550 sp->help_label, strlen(sp->help_label));
551 sp->help_button_x = x1;
552 sp->help_button_y = y1;
557 x1 = sp->shadow_width * 6;
558 y1 = sp->shadow_width * 6;
559 x2 = sp->logo_width - (sp->shadow_width * 12);
560 y2 = sp->logo_height - (sp->shadow_width * 12);
566 unsigned int w, h, bw, d;
567 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
568 XSetForeground (si->dpy, gc1, sp->foreground);
569 XSetBackground (si->dpy, gc1, sp->background);
570 XSetClipMask (si->dpy, gc1, sp->logo_clipmask);
571 XSetClipOrigin (si->dpy, gc1, x1 + ((x2 - (int)w) /2), y1 + ((y2 - (int)h) / 2));
573 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
575 x1 + ((x2 - (int)w) / 2),
576 y1 + ((y2 - (int)h) / 2),
579 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
581 x1 + ((x2 - (int)w) / 2),
582 y1 + ((y2 - (int)h) / 2));
585 /* Solid border inside the logo box. */
587 XSetForeground (si->dpy, gc1, sp->foreground);
588 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
591 /* The shadow around the logo
593 draw_shaded_rectangle (si->dpy, si->splash_dialog,
594 sp->shadow_width * 4,
595 sp->shadow_width * 4,
596 sp->logo_width - (sp->shadow_width * 8),
597 sp->logo_height - (sp->shadow_width * 8),
599 sp->shadow_bottom, sp->shadow_top);
601 /* The shadow around the whole window
603 draw_shaded_rectangle (si->dpy, si->splash_dialog,
604 0, 0, sp->width, sp->height, sp->shadow_width,
605 sp->shadow_top, sp->shadow_bottom);
607 XFreeGC (si->dpy, gc1);
608 XFreeGC (si->dpy, gc2);
610 update_splash_window (si);
615 update_splash_window (saver_info *si)
617 splash_dialog_data *sp = si->sp_data;
620 pressed = sp->pressed;
622 /* The shadows around the buttons
624 draw_shaded_rectangle (si->dpy, si->splash_dialog,
625 sp->demo_button_x, sp->demo_button_y,
626 sp->button_width, sp->button_height, sp->shadow_width,
627 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
628 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
630 draw_shaded_rectangle (si->dpy, si->splash_dialog,
631 sp->prefs_button_x, sp->prefs_button_y,
632 sp->button_width, sp->button_height, sp->shadow_width,
633 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
634 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
635 #endif /* PREFS_BUTTON */
636 draw_shaded_rectangle (si->dpy, si->splash_dialog,
637 sp->help_button_x, sp->help_button_y,
638 sp->button_width, sp->button_height, sp->shadow_width,
639 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
640 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
644 destroy_splash_window (saver_info *si)
646 splash_dialog_data *sp = si->sp_data;
647 saver_screen_info *ssi = sp->prompt_screen;
648 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
649 Pixel black = BlackPixelOfScreen (ssi->screen);
650 Pixel white = WhitePixelOfScreen (ssi->screen);
653 XtRemoveTimeOut (sp->timer);
655 if (si->splash_dialog)
657 XDestroyWindow (si->dpy, si->splash_dialog);
658 si->splash_dialog = 0;
661 if (sp->heading_label) free (sp->heading_label);
662 if (sp->body_label) free (sp->body_label);
663 if (sp->body2_label) free (sp->body2_label);
664 if (sp->demo_label) free (sp->demo_label);
666 if (sp->prefs_label) free (sp->prefs_label);
667 #endif /* PREFS_BUTTON */
668 if (sp->help_label) free (sp->help_label);
670 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
671 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
672 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
674 if (sp->foreground != black && sp->foreground != white)
675 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
676 if (sp->background != black && sp->background != white)
677 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
678 if (sp->button_foreground != black && sp->button_foreground != white)
679 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
680 if (sp->button_background != black && sp->button_background != white)
681 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
682 if (sp->shadow_top != black && sp->shadow_top != white)
683 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
684 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
685 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
688 XFreePixmap (si->dpy, sp->logo_pixmap);
689 if (sp->logo_clipmask)
690 XFreePixmap (si->dpy, sp->logo_clipmask);
693 if (sp->logo_npixels)
694 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
695 free (sp->logo_pixels);
697 sp->logo_npixels = 0;
700 memset (sp, 0, sizeof(*sp));
706 handle_splash_event (saver_info *si, XEvent *event)
708 splash_dialog_data *sp = si->sp_data;
709 saver_screen_info *ssi = sp->prompt_screen;
713 switch (event->xany.type)
716 draw_splash_window (si);
719 case ButtonPress: case ButtonRelease:
721 if (event->xbutton.x >= sp->demo_button_x &&
722 event->xbutton.x < sp->demo_button_x + sp->button_width &&
723 event->xbutton.y >= sp->demo_button_y &&
724 event->xbutton.y < sp->demo_button_y + sp->button_height)
728 else if (event->xbutton.x >= sp->prefs_button_x &&
729 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
730 event->xbutton.y >= sp->prefs_button_y &&
731 event->xbutton.y < sp->prefs_button_y + sp->button_height)
733 #endif /* PREFS_BUTTON */
735 else if (event->xbutton.x >= sp->help_button_x &&
736 event->xbutton.x < sp->help_button_x + sp->button_width &&
737 event->xbutton.y >= sp->help_button_y &&
738 event->xbutton.y < sp->help_button_y + sp->button_height)
741 if (event->xany.type == ButtonPress)
744 update_splash_window (si);
746 XBell (si->dpy, False);
748 else if (event->xany.type == ButtonRelease)
750 if (which && sp->pressed == which)
752 destroy_splash_window (si);
756 case 1: do_demo (ssi); break;
758 case 2: do_prefs (ssi); break;
759 #endif /* PREFS_BUTTON */
760 case 3: do_help (ssi); break;
764 else if (which == 0 && sp->pressed == 0)
766 /* click and release on the window but not in a button:
767 treat that as "dismiss the splash dialog." */
768 destroy_splash_window (si);
771 if (sp) sp->pressed = 0;
772 update_splash_window (si);
782 unsplash_timer (XtPointer closure, XtIntervalId *id)
784 saver_info *si = (saver_info *) closure;
785 if (si && si->sp_data)
786 destroy_splash_window (si);
790 /* Button callbacks */
799 do_demo (saver_screen_info *ssi)
801 saver_info *si = ssi->global;
802 saver_preferences *p = &si->prefs;
803 const char *cmd = p->demo_command;
806 fork_and_exec (ssi, cmd);
808 fprintf (stderr, "%s: no demo-mode command has been specified.\n",
814 do_prefs (saver_screen_info *ssi)
816 saver_info *si = ssi->global;
817 saver_preferences *p = &si->prefs;
818 const char *cmd = p->prefs_command;
820 if (command && *command)
821 fork_and_exec (ssi, cmd);
823 fprintf (stderr, "%s: no preferences command has been specified.\n",
826 #endif /* PREFS_BUTTON */
829 do_help (saver_screen_info *ssi)
831 saver_info *si = ssi->global;
832 saver_preferences *p = &si->prefs;
833 char *help_command = 0;
835 if (!p->load_url_command || !*p->load_url_command)
837 fprintf (stderr, "%s: no URL command has been specified.\n", blurb());
840 if (!p->help_url || !*p->help_url)
842 fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
846 help_command = (char *) malloc (strlen (p->load_url_command) +
847 (strlen (p->help_url) * 4) + 10);
848 sprintf (help_command, p->load_url_command,
849 p->help_url, p->help_url, p->help_url, p->help_url);
851 fork_and_exec (ssi, help_command);