1 /* xscreensaver, Copyright (c) 1991-2002 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 int direction, ascent, descent;
92 XTextExtents (font, s, strlen(s), &direction, &ascent, &descent, &overall);
97 static void update_splash_window (saver_info *si);
98 static void draw_splash_window (saver_info *si);
99 static void destroy_splash_window (saver_info *si);
100 static void unsplash_timer (XtPointer closure, XtIntervalId *id);
102 static void do_demo (saver_info *si);
104 static void do_prefs (saver_info *si);
105 #endif /* PREFS_BUTTON */
106 static void do_help (saver_info *si);
109 struct splash_dialog_data {
111 saver_screen_info *prompt_screen;
123 #endif /* PREFS_BUTTON */
126 XFontStruct *heading_font;
127 XFontStruct *body_font;
128 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;
151 unsigned long *logo_pixels;
158 make_splash_dialog (saver_info *si)
161 XSetWindowAttributes attrs;
162 unsigned long attrmask = 0;
163 splash_dialog_data *sp;
164 saver_screen_info *ssi;
170 if (!si->prefs.splash_p ||
171 si->prefs.splash_duration <= 0)
174 ssi = &si->screens[mouse_screen (si)];
175 cmap = DefaultColormapOfScreen (ssi->screen);
177 sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
178 sp->prompt_screen = ssi;
180 sp->heading_label = get_string_resource ("splash.heading.label",
181 "Dialog.Label.Label");
182 sp->body_label = get_string_resource ("splash.body.label",
183 "Dialog.Label.Label");
184 sp->body2_label = get_string_resource ("splash.body2.label",
185 "Dialog.Label.Label");
186 sp->demo_label = get_string_resource ("splash.demo.label",
187 "Dialog.Button.Label");
189 sp->prefs_label = get_string_resource ("splash.prefs.label",
190 "Dialog.Button.Label");
191 #endif /* PREFS_BUTTON */
192 sp->help_label = get_string_resource ("splash.help.label",
193 "Dialog.Button.Label");
195 if (!sp->heading_label)
196 sp->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
198 sp->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
199 if (!sp->body2_label)
200 sp->body2_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
201 if (!sp->demo_label) sp->demo_label = strdup("ERROR");
203 if (!sp->prefs_label) sp->prefs_label = strdup("ERROR");
204 #endif /* PREFS_BUTTON */
205 if (!sp->help_label) sp->help_label = strdup("ERROR");
207 /* Put the version number in the label. */
209 char *s = (char *) malloc (strlen(sp->heading_label) + 20);
210 sprintf(s, sp->heading_label, si->version);
211 free (sp->heading_label);
212 sp->heading_label = s;
215 f = get_string_resource ("splash.headingFont", "Dialog.Font");
216 sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
217 if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed");
220 f = get_string_resource("splash.bodyFont", "Dialog.Font");
221 sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
222 if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed");
225 f = get_string_resource("splash.buttonFont", "Dialog.Font");
226 sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
227 if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed");
230 sp->foreground = get_pixel_resource ("splash.foreground",
233 sp->background = get_pixel_resource ("splash.background",
237 if (sp->foreground == sp->background)
239 /* Make sure the error messages show up. */
240 sp->foreground = BlackPixelOfScreen (ssi->screen);
241 sp->background = WhitePixelOfScreen (ssi->screen);
244 sp->button_foreground = get_pixel_resource ("splash.Button.foreground",
245 "Dialog.Button.Foreground",
247 sp->button_background = get_pixel_resource ("splash.Button.background",
248 "Dialog.Button.Background",
250 sp->shadow_top = get_pixel_resource ("splash.topShadowColor",
253 sp->shadow_bottom = get_pixel_resource ("splash.bottomShadowColor",
257 sp->logo_width = get_integer_resource ("splash.logo.width",
258 "Dialog.Logo.Width");
259 sp->logo_height = get_integer_resource ("splash.logo.height",
260 "Dialog.Logo.Height");
261 sp->internal_border = get_integer_resource ("splash.internalBorderWidth",
262 "Dialog.InternalBorderWidth");
263 sp->shadow_width = get_integer_resource ("splash.shadowThickness",
264 "Dialog.ShadowThickness");
266 if (sp->logo_width == 0) sp->logo_width = 150;
267 if (sp->logo_height == 0) sp->logo_height = 150;
268 if (sp->internal_border == 0) sp->internal_border = 15;
269 if (sp->shadow_width == 0) sp->shadow_width = 4;
272 int direction, ascent, descent;
278 /* Measure the heading_label. */
279 XTextExtents (sp->heading_font,
280 sp->heading_label, strlen(sp->heading_label),
281 &direction, &ascent, &descent, &overall);
282 if (overall.width > sp->width) sp->width = overall.width;
283 sp->height += ascent + descent;
285 /* Measure the body_label. */
286 XTextExtents (sp->body_font,
287 sp->body_label, strlen(sp->body_label),
288 &direction, &ascent, &descent, &overall);
289 if (overall.width > sp->width) sp->width = overall.width;
290 sp->height += ascent + descent;
292 /* Measure the body2_label. */
293 XTextExtents (sp->body_font,
294 sp->body2_label, strlen(sp->body2_label),
295 &direction, &ascent, &descent, &overall);
296 if (overall.width > sp->width) sp->width = overall.width;
297 sp->height += ascent + descent;
300 Dimension w2 = 0, w3 = 0, w4 = 0;
301 Dimension h2 = 0, h3 = 0, h4 = 0;
303 /* Measure the Demo button. */
304 XTextExtents (sp->button_font,
305 sp->demo_label, strlen(sp->demo_label),
306 &direction, &ascent, &descent, &overall);
308 h2 = ascent + descent;
311 /* Measure the Prefs button. */
312 XTextExtents (sp->button_font,
313 sp->prefs_label, strlen(sp->prefs_label),
314 &direction, &ascent, &descent, &overall);
316 h3 = ascent + descent;
317 #else /* !PREFS_BUTTON */
320 #endif /* !PREFS_BUTTON */
322 /* Measure the Help button. */
323 XTextExtents (sp->button_font,
324 sp->help_label, strlen(sp->help_label),
325 &direction, &ascent, &descent, &overall);
327 h4 = ascent + descent;
329 w2 = MAX(w2, w3); w2 = MAX(w2, w4);
330 h2 = MAX(h2, h3); h2 = MAX(h2, h4);
332 /* Add some horizontal padding inside the buttons. */
335 w2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
336 h2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
338 sp->button_width = w2;
339 sp->button_height = h2;
343 #else /* !PREFS_BUTTON */
345 #endif /* !PREFS_BUTTON */
347 w2 += ((ascent + descent) * 2); /* for space between buttons */
349 if (w2 > sp->width) sp->width = w2;
353 sp->width += (sp->internal_border * 2);
354 sp->height += (sp->internal_border * 3);
356 if (sp->logo_height > sp->height)
357 sp->height = sp->logo_height;
358 else if (sp->height > sp->logo_height)
359 sp->logo_height = sp->height;
361 sp->logo_width = sp->logo_height;
363 sp->width += sp->logo_width;
366 attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
367 attrmask |= CWEventMask;
368 attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
372 int mouse_x = 0, mouse_y = 0;
375 Window pointer_root, pointer_child;
376 int root_x, root_y, win_x, win_y;
378 if (XQueryPointer (si->dpy,
379 RootWindowOfScreen (ssi->screen),
380 &pointer_root, &pointer_child,
381 &root_x, &root_y, &win_x, &win_y, &mask))
388 get_screen_viewport (ssi, &sx, &sy, &w, &h, mouse_x, mouse_y, False);
389 if (si->prefs.debug_p) w /= 2;
390 x = sx + (((w + sp->width) / 2) - sp->width);
391 y = sy + (((h + sp->height) / 2) - sp->height);
396 bw = get_integer_resource ("splash.borderWidth", "Dialog.BorderWidth");
399 XCreateWindow (si->dpy,
400 RootWindowOfScreen(ssi->screen),
401 x, y, sp->width, sp->height, bw,
402 DefaultDepthOfScreen (ssi->screen), InputOutput,
403 DefaultVisualOfScreen(ssi->screen),
405 XSetWindowBackground (si->dpy, si->splash_dialog, sp->background);
407 sp->logo_pixmap = xscreensaver_logo (si->dpy, si->splash_dialog, cmap,
409 &sp->logo_pixels, &sp->logo_npixels,
412 XMapRaised (si->dpy, si->splash_dialog);
413 XSync (si->dpy, False);
417 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
418 unsplash_timer, (XtPointer) si);
420 draw_splash_window (si);
421 XSync (si->dpy, False);
426 draw_splash_window (saver_info *si)
428 splash_dialog_data *sp = si->sp_data;
431 int hspacing, vspacing, height;
432 int x1, x2, x3, y1, y2;
437 #else /* !PREFS_BUTTON */
439 #endif /* !PREFS_BUTTON */
441 height = (sp->heading_font->ascent + sp->heading_font->descent +
442 sp->body_font->ascent + sp->body_font->descent +
443 sp->body_font->ascent + sp->body_font->descent +
444 sp->button_font->ascent + sp->button_font->descent);
445 vspacing = ((sp->height
446 - (4 * sp->shadow_width)
447 - (2 * sp->internal_border)
449 if (vspacing < 0) vspacing = 0;
450 if (vspacing > (sp->heading_font->ascent * 2))
451 vspacing = (sp->heading_font->ascent * 2);
453 gcv.foreground = sp->foreground;
454 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
455 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
457 x3 = sp->width - (sp->shadow_width * 2);
458 y1 = sp->internal_border;
462 XSetFont (si->dpy, gc1, sp->heading_font->fid);
463 sw = string_width (sp->heading_font, sp->heading_label);
464 x2 = (x1 + ((x3 - x1 - sw) / 2));
465 y1 += sp->heading_font->ascent;
466 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
467 sp->heading_label, strlen(sp->heading_label));
468 y1 += sp->heading_font->descent;
470 /* text below top heading
472 XSetFont (si->dpy, gc1, sp->body_font->fid);
473 y1 += vspacing + sp->body_font->ascent;
474 sw = string_width (sp->body_font, sp->body_label);
475 x2 = (x1 + ((x3 - x1 - sw) / 2));
476 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
477 sp->body_label, strlen(sp->body_label));
478 y1 += sp->body_font->descent;
480 y1 += sp->body_font->ascent;
481 sw = string_width (sp->body_font, sp->body2_label);
482 x2 = (x1 + ((x3 - x1 - sw) / 2));
483 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
484 sp->body2_label, strlen(sp->body2_label));
485 y1 += sp->body_font->descent;
489 XSetForeground (si->dpy, gc1, sp->button_foreground);
490 XSetForeground (si->dpy, gc2, sp->button_background);
492 /* y1 += (vspacing * 2);*/
493 y1 = sp->height - sp->internal_border - sp->button_height;
495 x1 += sp->internal_border;
496 y2 = (y1 + ((sp->button_height -
497 (sp->button_font->ascent + sp->button_font->descent))
499 + sp->button_font->ascent);
500 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
501 sp->internal_border - (sp->button_width * nbuttons))
504 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_label))
506 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
507 sp->button_width, sp->button_height);
508 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
509 sp->demo_label, strlen(sp->demo_label));
510 sp->demo_button_x = x1;
511 sp->demo_button_y = y1;
514 x1 += hspacing + sp->button_width;
515 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
517 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
518 sp->button_width, sp->button_height);
519 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
520 sp->prefs_label, strlen(sp->prefs_label));
521 sp->prefs_button_x = x1;
522 sp->prefs_button_y = y1;
523 #endif /* PREFS_BUTTON */
526 x1 += hspacing + sp->button_width;
527 #else /* !PREFS_BUTTON */
528 x1 = (sp->width - sp->button_width -
529 sp->internal_border - (sp->shadow_width * 2));
530 #endif /* !PREFS_BUTTON */
532 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
534 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
535 sp->button_width, sp->button_height);
536 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
537 sp->help_label, strlen(sp->help_label));
538 sp->help_button_x = x1;
539 sp->help_button_y = y1;
544 x1 = sp->shadow_width * 6;
545 y1 = sp->shadow_width * 6;
546 x2 = sp->logo_width - (sp->shadow_width * 12);
547 y2 = sp->logo_height - (sp->shadow_width * 12);
553 unsigned int w, h, bw, d;
554 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
555 XSetForeground (si->dpy, gc1, sp->foreground);
556 XSetBackground (si->dpy, gc1, sp->background);
558 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
560 x1 + ((x2 - (int)w) / 2),
561 y1 + ((y2 - (int)h) / 2),
564 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
566 x1 + ((x2 - (int)w) / 2),
567 y1 + ((y2 - (int)h) / 2));
570 /* Solid border inside the logo box. */
572 XSetForeground (si->dpy, gc1, sp->foreground);
573 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
576 /* The shadow around the logo
578 draw_shaded_rectangle (si->dpy, si->splash_dialog,
579 sp->shadow_width * 4,
580 sp->shadow_width * 4,
581 sp->logo_width - (sp->shadow_width * 8),
582 sp->logo_height - (sp->shadow_width * 8),
584 sp->shadow_bottom, sp->shadow_top);
586 /* The shadow around the whole window
588 draw_shaded_rectangle (si->dpy, si->splash_dialog,
589 0, 0, sp->width, sp->height, sp->shadow_width,
590 sp->shadow_top, sp->shadow_bottom);
592 XFreeGC (si->dpy, gc1);
593 XFreeGC (si->dpy, gc2);
595 update_splash_window (si);
600 update_splash_window (saver_info *si)
602 splash_dialog_data *sp = si->sp_data;
605 pressed = sp->pressed;
607 /* The shadows around the buttons
609 draw_shaded_rectangle (si->dpy, si->splash_dialog,
610 sp->demo_button_x, sp->demo_button_y,
611 sp->button_width, sp->button_height, sp->shadow_width,
612 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
613 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
615 draw_shaded_rectangle (si->dpy, si->splash_dialog,
616 sp->prefs_button_x, sp->prefs_button_y,
617 sp->button_width, sp->button_height, sp->shadow_width,
618 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
619 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
620 #endif /* PREFS_BUTTON */
621 draw_shaded_rectangle (si->dpy, si->splash_dialog,
622 sp->help_button_x, sp->help_button_y,
623 sp->button_width, sp->button_height, sp->shadow_width,
624 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
625 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
629 destroy_splash_window (saver_info *si)
631 splash_dialog_data *sp = si->sp_data;
632 saver_screen_info *ssi = sp->prompt_screen;
633 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
634 Pixel black = BlackPixelOfScreen (ssi->screen);
635 Pixel white = WhitePixelOfScreen (ssi->screen);
638 XtRemoveTimeOut (sp->timer);
640 if (si->splash_dialog)
642 XDestroyWindow (si->dpy, si->splash_dialog);
643 si->splash_dialog = 0;
646 if (sp->heading_label) free (sp->heading_label);
647 if (sp->body_label) free (sp->body_label);
648 if (sp->body2_label) free (sp->body2_label);
649 if (sp->demo_label) free (sp->demo_label);
651 if (sp->prefs_label) free (sp->prefs_label);
652 #endif /* PREFS_BUTTON */
653 if (sp->help_label) free (sp->help_label);
655 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
656 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
657 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
659 if (sp->foreground != black && sp->foreground != white)
660 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
661 if (sp->background != black && sp->background != white)
662 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
663 if (sp->button_foreground != black && sp->button_foreground != white)
664 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
665 if (sp->button_background != black && sp->button_background != white)
666 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
667 if (sp->shadow_top != black && sp->shadow_top != white)
668 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
669 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
670 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
673 XFreePixmap (si->dpy, sp->logo_pixmap);
676 if (sp->logo_npixels)
677 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
678 free (sp->logo_pixels);
680 sp->logo_npixels = 0;
683 memset (sp, 0, sizeof(*sp));
689 handle_splash_event (saver_info *si, XEvent *event)
691 splash_dialog_data *sp = si->sp_data;
695 switch (event->xany.type)
698 draw_splash_window (si);
701 case ButtonPress: case ButtonRelease:
703 if (event->xbutton.x >= sp->demo_button_x &&
704 event->xbutton.x < sp->demo_button_x + sp->button_width &&
705 event->xbutton.y >= sp->demo_button_y &&
706 event->xbutton.y < sp->demo_button_y + sp->button_height)
710 else if (event->xbutton.x >= sp->prefs_button_x &&
711 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
712 event->xbutton.y >= sp->prefs_button_y &&
713 event->xbutton.y < sp->prefs_button_y + sp->button_height)
715 #endif /* PREFS_BUTTON */
717 else if (event->xbutton.x >= sp->help_button_x &&
718 event->xbutton.x < sp->help_button_x + sp->button_width &&
719 event->xbutton.y >= sp->help_button_y &&
720 event->xbutton.y < sp->help_button_y + sp->button_height)
723 if (event->xany.type == ButtonPress)
726 update_splash_window (si);
728 XBell (si->dpy, False);
730 else if (event->xany.type == ButtonRelease)
732 if (which && sp->pressed == which)
734 destroy_splash_window (si);
737 case 1: do_demo (si); break;
739 case 2: do_prefs (si); break;
740 #endif /* PREFS_BUTTON */
741 case 3: do_help (si); break;
745 else if (which == 0 && sp->pressed == 0)
747 /* click and release on the window but not in a button:
748 treat that as "dismiss the splash dialog." */
749 destroy_splash_window (si);
752 update_splash_window (si);
762 unsplash_timer (XtPointer closure, XtIntervalId *id)
764 saver_info *si = (saver_info *) closure;
765 if (si && si->sp_data)
766 destroy_splash_window (si);
770 /* Button callbacks */
778 fork_and_exec (saver_info *si, const char *command, const char *desc)
780 saver_preferences *p = &si->prefs;
786 if (!command || !*command)
788 fprintf (stderr, "%s: no %s command has been specified.\n",
793 switch ((int) (forked = fork ()))
796 sprintf (buf, "%s: couldn't fork", blurb());
801 close (ConnectionNumber (si->dpy)); /* close display fd */
802 hack_subproc_environment (si->default_screen); /* set $DISPLAY */
804 av [ac++] = (char *) p->shell;
805 av [ac++] = (char *) "-c";
806 av [ac++] = (char *) command;
808 execvp (av[0], av); /* shouldn't return. */
810 sprintf (buf, "%s: execvp(\"%s\", \"%s\", \"%s\") failed",
811 blurb(), av[0], av[1], av[2]);
815 exit (1); /* Note that this only exits a child fork. */
826 do_demo (saver_info *si)
828 saver_preferences *p = &si->prefs;
829 fork_and_exec (si, p->demo_command, "demo-mode");
834 do_prefs (saver_info *si)
836 saver_preferences *p = &si->prefs;
837 fork_and_exec (si, p->prefs_command, "preferences");
839 #endif /* PREFS_BUTTON */
842 do_help (saver_info *si)
844 saver_preferences *p = &si->prefs;
847 if (!p->help_url || !*p->help_url)
849 fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
853 help_command = (char *) malloc (strlen (p->load_url_command) +
854 (strlen (p->help_url) * 2) + 10);
855 sprintf (help_command, p->load_url_command, p->help_url, p->help_url);
856 fork_and_exec (si, help_command, "URL-loading");