1 /* xscreensaver, Copyright (c) 1991-2003 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 (ssi->screen, ssi->current_visual,
408 si->splash_dialog, cmap,
410 &sp->logo_pixels, &sp->logo_npixels,
413 XMapRaised (si->dpy, si->splash_dialog);
414 XSync (si->dpy, False);
418 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
419 unsplash_timer, (XtPointer) si);
421 draw_splash_window (si);
422 XSync (si->dpy, False);
427 draw_splash_window (saver_info *si)
429 splash_dialog_data *sp = si->sp_data;
432 int hspacing, vspacing, height;
433 int x1, x2, x3, y1, y2;
438 #else /* !PREFS_BUTTON */
440 #endif /* !PREFS_BUTTON */
442 height = (sp->heading_font->ascent + sp->heading_font->descent +
443 sp->body_font->ascent + sp->body_font->descent +
444 sp->body_font->ascent + sp->body_font->descent +
445 sp->button_font->ascent + sp->button_font->descent);
446 vspacing = ((sp->height
447 - (4 * sp->shadow_width)
448 - (2 * sp->internal_border)
450 if (vspacing < 0) vspacing = 0;
451 if (vspacing > (sp->heading_font->ascent * 2))
452 vspacing = (sp->heading_font->ascent * 2);
454 gcv.foreground = sp->foreground;
455 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
456 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
458 x3 = sp->width - (sp->shadow_width * 2);
459 y1 = sp->internal_border;
463 XSetFont (si->dpy, gc1, sp->heading_font->fid);
464 sw = string_width (sp->heading_font, sp->heading_label);
465 x2 = (x1 + ((x3 - x1 - sw) / 2));
466 y1 += sp->heading_font->ascent;
467 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
468 sp->heading_label, strlen(sp->heading_label));
469 y1 += sp->heading_font->descent;
471 /* text below top heading
473 XSetFont (si->dpy, gc1, sp->body_font->fid);
474 y1 += vspacing + sp->body_font->ascent;
475 sw = string_width (sp->body_font, sp->body_label);
476 x2 = (x1 + ((x3 - x1 - sw) / 2));
477 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
478 sp->body_label, strlen(sp->body_label));
479 y1 += sp->body_font->descent;
481 y1 += sp->body_font->ascent;
482 sw = string_width (sp->body_font, sp->body2_label);
483 x2 = (x1 + ((x3 - x1 - sw) / 2));
484 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
485 sp->body2_label, strlen(sp->body2_label));
486 y1 += sp->body_font->descent;
490 XSetForeground (si->dpy, gc1, sp->button_foreground);
491 XSetForeground (si->dpy, gc2, sp->button_background);
493 /* y1 += (vspacing * 2);*/
494 y1 = sp->height - sp->internal_border - sp->button_height;
496 x1 += sp->internal_border;
497 y2 = (y1 + ((sp->button_height -
498 (sp->button_font->ascent + sp->button_font->descent))
500 + sp->button_font->ascent);
501 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
502 sp->internal_border - (sp->button_width * nbuttons))
505 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_label))
507 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
508 sp->button_width, sp->button_height);
509 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
510 sp->demo_label, strlen(sp->demo_label));
511 sp->demo_button_x = x1;
512 sp->demo_button_y = y1;
515 x1 += hspacing + sp->button_width;
516 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
518 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
519 sp->button_width, sp->button_height);
520 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
521 sp->prefs_label, strlen(sp->prefs_label));
522 sp->prefs_button_x = x1;
523 sp->prefs_button_y = y1;
524 #endif /* PREFS_BUTTON */
527 x1 += hspacing + sp->button_width;
528 #else /* !PREFS_BUTTON */
529 x1 = (sp->width - sp->button_width -
530 sp->internal_border - (sp->shadow_width * 2));
531 #endif /* !PREFS_BUTTON */
533 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
535 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
536 sp->button_width, sp->button_height);
537 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
538 sp->help_label, strlen(sp->help_label));
539 sp->help_button_x = x1;
540 sp->help_button_y = y1;
545 x1 = sp->shadow_width * 6;
546 y1 = sp->shadow_width * 6;
547 x2 = sp->logo_width - (sp->shadow_width * 12);
548 y2 = sp->logo_height - (sp->shadow_width * 12);
554 unsigned int w, h, bw, d;
555 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
556 XSetForeground (si->dpy, gc1, sp->foreground);
557 XSetBackground (si->dpy, gc1, sp->background);
559 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
561 x1 + ((x2 - (int)w) / 2),
562 y1 + ((y2 - (int)h) / 2),
565 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
567 x1 + ((x2 - (int)w) / 2),
568 y1 + ((y2 - (int)h) / 2));
571 /* Solid border inside the logo box. */
573 XSetForeground (si->dpy, gc1, sp->foreground);
574 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
577 /* The shadow around the logo
579 draw_shaded_rectangle (si->dpy, si->splash_dialog,
580 sp->shadow_width * 4,
581 sp->shadow_width * 4,
582 sp->logo_width - (sp->shadow_width * 8),
583 sp->logo_height - (sp->shadow_width * 8),
585 sp->shadow_bottom, sp->shadow_top);
587 /* The shadow around the whole window
589 draw_shaded_rectangle (si->dpy, si->splash_dialog,
590 0, 0, sp->width, sp->height, sp->shadow_width,
591 sp->shadow_top, sp->shadow_bottom);
593 XFreeGC (si->dpy, gc1);
594 XFreeGC (si->dpy, gc2);
596 update_splash_window (si);
601 update_splash_window (saver_info *si)
603 splash_dialog_data *sp = si->sp_data;
606 pressed = sp->pressed;
608 /* The shadows around the buttons
610 draw_shaded_rectangle (si->dpy, si->splash_dialog,
611 sp->demo_button_x, sp->demo_button_y,
612 sp->button_width, sp->button_height, sp->shadow_width,
613 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
614 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
616 draw_shaded_rectangle (si->dpy, si->splash_dialog,
617 sp->prefs_button_x, sp->prefs_button_y,
618 sp->button_width, sp->button_height, sp->shadow_width,
619 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
620 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
621 #endif /* PREFS_BUTTON */
622 draw_shaded_rectangle (si->dpy, si->splash_dialog,
623 sp->help_button_x, sp->help_button_y,
624 sp->button_width, sp->button_height, sp->shadow_width,
625 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
626 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
630 destroy_splash_window (saver_info *si)
632 splash_dialog_data *sp = si->sp_data;
633 saver_screen_info *ssi = sp->prompt_screen;
634 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
635 Pixel black = BlackPixelOfScreen (ssi->screen);
636 Pixel white = WhitePixelOfScreen (ssi->screen);
639 XtRemoveTimeOut (sp->timer);
641 if (si->splash_dialog)
643 XDestroyWindow (si->dpy, si->splash_dialog);
644 si->splash_dialog = 0;
647 if (sp->heading_label) free (sp->heading_label);
648 if (sp->body_label) free (sp->body_label);
649 if (sp->body2_label) free (sp->body2_label);
650 if (sp->demo_label) free (sp->demo_label);
652 if (sp->prefs_label) free (sp->prefs_label);
653 #endif /* PREFS_BUTTON */
654 if (sp->help_label) free (sp->help_label);
656 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
657 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
658 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
660 if (sp->foreground != black && sp->foreground != white)
661 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
662 if (sp->background != black && sp->background != white)
663 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
664 if (sp->button_foreground != black && sp->button_foreground != white)
665 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
666 if (sp->button_background != black && sp->button_background != white)
667 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
668 if (sp->shadow_top != black && sp->shadow_top != white)
669 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
670 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
671 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
674 XFreePixmap (si->dpy, sp->logo_pixmap);
677 if (sp->logo_npixels)
678 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
679 free (sp->logo_pixels);
681 sp->logo_npixels = 0;
684 memset (sp, 0, sizeof(*sp));
690 handle_splash_event (saver_info *si, XEvent *event)
692 splash_dialog_data *sp = si->sp_data;
696 switch (event->xany.type)
699 draw_splash_window (si);
702 case ButtonPress: case ButtonRelease:
704 if (event->xbutton.x >= sp->demo_button_x &&
705 event->xbutton.x < sp->demo_button_x + sp->button_width &&
706 event->xbutton.y >= sp->demo_button_y &&
707 event->xbutton.y < sp->demo_button_y + sp->button_height)
711 else if (event->xbutton.x >= sp->prefs_button_x &&
712 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
713 event->xbutton.y >= sp->prefs_button_y &&
714 event->xbutton.y < sp->prefs_button_y + sp->button_height)
716 #endif /* PREFS_BUTTON */
718 else if (event->xbutton.x >= sp->help_button_x &&
719 event->xbutton.x < sp->help_button_x + sp->button_width &&
720 event->xbutton.y >= sp->help_button_y &&
721 event->xbutton.y < sp->help_button_y + sp->button_height)
724 if (event->xany.type == ButtonPress)
727 update_splash_window (si);
729 XBell (si->dpy, False);
731 else if (event->xany.type == ButtonRelease)
733 if (which && sp->pressed == which)
735 destroy_splash_window (si);
739 case 1: do_demo (si); break;
741 case 2: do_prefs (si); break;
742 #endif /* PREFS_BUTTON */
743 case 3: do_help (si); break;
747 else if (which == 0 && sp->pressed == 0)
749 /* click and release on the window but not in a button:
750 treat that as "dismiss the splash dialog." */
751 destroy_splash_window (si);
754 if (sp) sp->pressed = 0;
755 update_splash_window (si);
765 unsplash_timer (XtPointer closure, XtIntervalId *id)
767 saver_info *si = (saver_info *) closure;
768 if (si && si->sp_data)
769 destroy_splash_window (si);
773 /* Button callbacks */
781 fork_and_exec (saver_info *si, const char *command, const char *desc)
783 saver_preferences *p = &si->prefs;
789 if (!command || !*command)
791 fprintf (stderr, "%s: no %s command has been specified.\n",
796 switch ((int) (forked = fork ()))
799 sprintf (buf, "%s: couldn't fork", blurb());
804 close (ConnectionNumber (si->dpy)); /* close display fd */
805 hack_subproc_environment (si->default_screen); /* set $DISPLAY */
807 av [ac++] = (char *) p->shell;
808 av [ac++] = (char *) "-c";
809 av [ac++] = (char *) command;
811 execvp (av[0], av); /* shouldn't return. */
813 sprintf (buf, "%s: execvp(\"%s\", \"%s\", \"%s\") failed",
814 blurb(), av[0], av[1], av[2]);
818 exit (1); /* Note that this only exits a child fork. */
829 do_demo (saver_info *si)
831 saver_preferences *p = &si->prefs;
832 fork_and_exec (si, p->demo_command, "demo-mode");
837 do_prefs (saver_info *si)
839 saver_preferences *p = &si->prefs;
840 fork_and_exec (si, p->prefs_command, "preferences");
842 #endif /* PREFS_BUTTON */
845 do_help (saver_info *si)
847 saver_preferences *p = &si->prefs;
850 if (!p->help_url || !*p->help_url)
852 fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
856 help_command = (char *) malloc (strlen (p->load_url_command) +
857 (strlen (p->help_url) * 2) + 10);
858 sprintf (help_command, p->load_url_command, p->help_url, p->help_url);
859 fork_and_exec (si, help_command, "URL-loading");