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, ssi->current_visual,
418 si->splash_dialog, cmap,
420 &sp->logo_pixels, &sp->logo_npixels,
421 &sp->logo_clipmask, True);
423 XMapRaised (si->dpy, si->splash_dialog);
424 XSync (si->dpy, False);
428 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
429 unsplash_timer, (XtPointer) si);
431 draw_splash_window (si);
432 XSync (si->dpy, False);
437 draw_splash_window (saver_info *si)
439 splash_dialog_data *sp = si->sp_data;
442 int hspacing, vspacing, height;
443 int x1, x2, x3, y1, y2;
448 #else /* !PREFS_BUTTON */
450 #endif /* !PREFS_BUTTON */
452 height = (sp->heading_font->ascent + sp->heading_font->descent +
453 sp->body_font->ascent + sp->body_font->descent +
454 sp->body_font->ascent + sp->body_font->descent +
455 sp->button_font->ascent + sp->button_font->descent);
456 vspacing = ((sp->height
457 - (4 * sp->shadow_width)
458 - (2 * sp->internal_border)
460 if (vspacing < 0) vspacing = 0;
461 if (vspacing > (sp->heading_font->ascent * 2))
462 vspacing = (sp->heading_font->ascent * 2);
464 gcv.foreground = sp->foreground;
465 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
466 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
468 x3 = sp->width - (sp->shadow_width * 2);
469 y1 = sp->internal_border;
473 XSetFont (si->dpy, gc1, sp->heading_font->fid);
474 sw = string_width (sp->heading_font, sp->heading_label);
475 x2 = (x1 + ((x3 - x1 - sw) / 2));
476 y1 += sp->heading_font->ascent;
477 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
478 sp->heading_label, strlen(sp->heading_label));
479 y1 += sp->heading_font->descent;
481 /* text below top heading
483 XSetFont (si->dpy, gc1, sp->body_font->fid);
484 y1 += vspacing + sp->body_font->ascent;
485 sw = string_width (sp->body_font, sp->body_label);
486 x2 = (x1 + ((x3 - x1 - sw) / 2));
487 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
488 sp->body_label, strlen(sp->body_label));
489 y1 += sp->body_font->descent;
491 y1 += sp->body_font->ascent;
492 sw = string_width (sp->body_font, sp->body2_label);
493 x2 = (x1 + ((x3 - x1 - sw) / 2));
494 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
495 sp->body2_label, strlen(sp->body2_label));
496 y1 += sp->body_font->descent;
500 XSetForeground (si->dpy, gc1, sp->button_foreground);
501 XSetForeground (si->dpy, gc2, sp->button_background);
503 /* y1 += (vspacing * 2);*/
504 y1 = sp->height - sp->internal_border - sp->button_height;
506 x1 += sp->internal_border;
507 y2 = (y1 + ((sp->button_height -
508 (sp->button_font->ascent + sp->button_font->descent))
510 + sp->button_font->ascent);
511 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
512 sp->internal_border - (sp->button_width * nbuttons))
515 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_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->demo_label, strlen(sp->demo_label));
521 sp->demo_button_x = x1;
522 sp->demo_button_y = y1;
525 x1 += hspacing + sp->button_width;
526 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
528 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
529 sp->button_width, sp->button_height);
530 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
531 sp->prefs_label, strlen(sp->prefs_label));
532 sp->prefs_button_x = x1;
533 sp->prefs_button_y = y1;
534 #endif /* PREFS_BUTTON */
537 x1 += hspacing + sp->button_width;
538 #else /* !PREFS_BUTTON */
539 x1 = (sp->width - sp->button_width -
540 sp->internal_border - (sp->shadow_width * 2));
541 #endif /* !PREFS_BUTTON */
543 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
545 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
546 sp->button_width, sp->button_height);
547 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
548 sp->help_label, strlen(sp->help_label));
549 sp->help_button_x = x1;
550 sp->help_button_y = y1;
555 x1 = sp->shadow_width * 6;
556 y1 = sp->shadow_width * 6;
557 x2 = sp->logo_width - (sp->shadow_width * 12);
558 y2 = sp->logo_height - (sp->shadow_width * 12);
564 unsigned int w, h, bw, d;
565 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
566 XSetForeground (si->dpy, gc1, sp->foreground);
567 XSetBackground (si->dpy, gc1, sp->background);
568 XSetClipMask (si->dpy, gc1, sp->logo_clipmask);
569 XSetClipOrigin (si->dpy, gc1, x1 + ((x2 - (int)w) /2), y1 + ((y2 - (int)h) / 2));
571 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
573 x1 + ((x2 - (int)w) / 2),
574 y1 + ((y2 - (int)h) / 2),
577 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
579 x1 + ((x2 - (int)w) / 2),
580 y1 + ((y2 - (int)h) / 2));
583 /* Solid border inside the logo box. */
585 XSetForeground (si->dpy, gc1, sp->foreground);
586 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
589 /* The shadow around the logo
591 draw_shaded_rectangle (si->dpy, si->splash_dialog,
592 sp->shadow_width * 4,
593 sp->shadow_width * 4,
594 sp->logo_width - (sp->shadow_width * 8),
595 sp->logo_height - (sp->shadow_width * 8),
597 sp->shadow_bottom, sp->shadow_top);
599 /* The shadow around the whole window
601 draw_shaded_rectangle (si->dpy, si->splash_dialog,
602 0, 0, sp->width, sp->height, sp->shadow_width,
603 sp->shadow_top, sp->shadow_bottom);
605 XFreeGC (si->dpy, gc1);
606 XFreeGC (si->dpy, gc2);
608 update_splash_window (si);
613 update_splash_window (saver_info *si)
615 splash_dialog_data *sp = si->sp_data;
618 pressed = sp->pressed;
620 /* The shadows around the buttons
622 draw_shaded_rectangle (si->dpy, si->splash_dialog,
623 sp->demo_button_x, sp->demo_button_y,
624 sp->button_width, sp->button_height, sp->shadow_width,
625 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
626 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
628 draw_shaded_rectangle (si->dpy, si->splash_dialog,
629 sp->prefs_button_x, sp->prefs_button_y,
630 sp->button_width, sp->button_height, sp->shadow_width,
631 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
632 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
633 #endif /* PREFS_BUTTON */
634 draw_shaded_rectangle (si->dpy, si->splash_dialog,
635 sp->help_button_x, sp->help_button_y,
636 sp->button_width, sp->button_height, sp->shadow_width,
637 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
638 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
642 destroy_splash_window (saver_info *si)
644 splash_dialog_data *sp = si->sp_data;
645 saver_screen_info *ssi = sp->prompt_screen;
646 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
647 Pixel black = BlackPixelOfScreen (ssi->screen);
648 Pixel white = WhitePixelOfScreen (ssi->screen);
651 XtRemoveTimeOut (sp->timer);
653 if (si->splash_dialog)
655 XDestroyWindow (si->dpy, si->splash_dialog);
656 si->splash_dialog = 0;
659 if (sp->heading_label) free (sp->heading_label);
660 if (sp->body_label) free (sp->body_label);
661 if (sp->body2_label) free (sp->body2_label);
662 if (sp->demo_label) free (sp->demo_label);
664 if (sp->prefs_label) free (sp->prefs_label);
665 #endif /* PREFS_BUTTON */
666 if (sp->help_label) free (sp->help_label);
668 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
669 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
670 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
672 if (sp->foreground != black && sp->foreground != white)
673 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
674 if (sp->background != black && sp->background != white)
675 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
676 if (sp->button_foreground != black && sp->button_foreground != white)
677 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
678 if (sp->button_background != black && sp->button_background != white)
679 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
680 if (sp->shadow_top != black && sp->shadow_top != white)
681 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
682 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
683 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
686 XFreePixmap (si->dpy, sp->logo_pixmap);
687 if (sp->logo_clipmask)
688 XFreePixmap (si->dpy, sp->logo_clipmask);
691 if (sp->logo_npixels)
692 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
693 free (sp->logo_pixels);
695 sp->logo_npixels = 0;
698 memset (sp, 0, sizeof(*sp));
704 handle_splash_event (saver_info *si, XEvent *event)
706 splash_dialog_data *sp = si->sp_data;
707 saver_screen_info *ssi = sp->prompt_screen;
711 switch (event->xany.type)
714 draw_splash_window (si);
717 case ButtonPress: case ButtonRelease:
719 if (event->xbutton.x >= sp->demo_button_x &&
720 event->xbutton.x < sp->demo_button_x + sp->button_width &&
721 event->xbutton.y >= sp->demo_button_y &&
722 event->xbutton.y < sp->demo_button_y + sp->button_height)
726 else if (event->xbutton.x >= sp->prefs_button_x &&
727 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
728 event->xbutton.y >= sp->prefs_button_y &&
729 event->xbutton.y < sp->prefs_button_y + sp->button_height)
731 #endif /* PREFS_BUTTON */
733 else if (event->xbutton.x >= sp->help_button_x &&
734 event->xbutton.x < sp->help_button_x + sp->button_width &&
735 event->xbutton.y >= sp->help_button_y &&
736 event->xbutton.y < sp->help_button_y + sp->button_height)
739 if (event->xany.type == ButtonPress)
742 update_splash_window (si);
744 XBell (si->dpy, False);
746 else if (event->xany.type == ButtonRelease)
748 if (which && sp->pressed == which)
750 destroy_splash_window (si);
754 case 1: do_demo (ssi); break;
756 case 2: do_prefs (ssi); break;
757 #endif /* PREFS_BUTTON */
758 case 3: do_help (ssi); break;
762 else if (which == 0 && sp->pressed == 0)
764 /* click and release on the window but not in a button:
765 treat that as "dismiss the splash dialog." */
766 destroy_splash_window (si);
769 if (sp) sp->pressed = 0;
770 update_splash_window (si);
780 unsplash_timer (XtPointer closure, XtIntervalId *id)
782 saver_info *si = (saver_info *) closure;
783 if (si && si->sp_data)
784 destroy_splash_window (si);
788 /* Button callbacks */
797 do_demo (saver_screen_info *ssi)
799 saver_info *si = ssi->global;
800 saver_preferences *p = &si->prefs;
801 const char *cmd = p->demo_command;
804 fork_and_exec (ssi, cmd);
806 fprintf (stderr, "%s: no demo-mode command has been specified.\n",
812 do_prefs (saver_screen_info *ssi)
814 saver_info *si = ssi->global;
815 saver_preferences *p = &si->prefs;
816 const char *cmd = p->prefs_command;
818 if (command && *command)
819 fork_and_exec (ssi, cmd);
821 fprintf (stderr, "%s: no preferences command has been specified.\n",
824 #endif /* PREFS_BUTTON */
827 do_help (saver_screen_info *ssi)
829 saver_info *si = ssi->global;
830 saver_preferences *p = &si->prefs;
831 char *help_command = 0;
833 if (!p->load_url_command || !*p->load_url_command)
835 fprintf (stderr, "%s: no URL command has been specified.\n", blurb());
838 if (!p->help_url || !*p->help_url)
840 fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
844 help_command = (char *) malloc (strlen (p->load_url_command) +
845 (strlen (p->help_url) * 4) + 10);
846 sprintf (help_command, p->load_url_command,
847 p->help_url, p->help_url, p->help_url, p->help_url);
849 fork_and_exec (ssi, help_command);