1 /* xscreensaver, Copyright (c) 1991-2008 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)];
174 if (!ssi || !ssi->screen)
175 return; /* WTF? Trying to splash while no screens connected? */
177 cmap = DefaultColormapOfScreen (ssi->screen);
179 sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
180 sp->prompt_screen = ssi;
182 sp->heading_label = get_string_resource (si->dpy,
183 "splash.heading.label",
184 "Dialog.Label.Label");
185 sp->body_label = get_string_resource (si->dpy,
187 "Dialog.Label.Label");
188 sp->body2_label = get_string_resource (si->dpy,
189 "splash.body2.label",
190 "Dialog.Label.Label");
191 sp->demo_label = get_string_resource (si->dpy,
193 "Dialog.Button.Label");
195 sp->prefs_label = get_string_resource (si->dpy,
196 "splash.prefs.label",
197 "Dialog.Button.Label");
198 #endif /* PREFS_BUTTON */
199 sp->help_label = get_string_resource (si->dpy,
201 "Dialog.Button.Label");
203 if (!sp->heading_label)
204 sp->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
206 sp->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
207 if (!sp->body2_label)
208 sp->body2_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
209 if (!sp->demo_label) sp->demo_label = strdup("ERROR");
211 if (!sp->prefs_label) sp->prefs_label = strdup("ERROR");
212 #endif /* PREFS_BUTTON */
213 if (!sp->help_label) sp->help_label = strdup("ERROR");
215 /* Put the version number in the label. */
217 char *s = (char *) malloc (strlen(sp->heading_label) + 20);
218 sprintf(s, sp->heading_label, si->version);
219 free (sp->heading_label);
220 sp->heading_label = s;
223 f = get_string_resource (si->dpy, "splash.headingFont", "Dialog.Font");
224 sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
225 if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed");
228 f = get_string_resource(si->dpy, "splash.bodyFont", "Dialog.Font");
229 sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
230 if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed");
233 f = get_string_resource(si->dpy, "splash.buttonFont", "Dialog.Font");
234 sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
235 if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed");
238 sp->foreground = get_pixel_resource (si->dpy, cmap,
240 "Dialog.Foreground");
241 sp->background = get_pixel_resource (si->dpy, cmap,
243 "Dialog.Background");
245 if (sp->foreground == sp->background)
247 /* Make sure the error messages show up. */
248 sp->foreground = BlackPixelOfScreen (ssi->screen);
249 sp->background = WhitePixelOfScreen (ssi->screen);
252 sp->button_foreground = get_pixel_resource (si->dpy, cmap,
253 "splash.Button.foreground",
254 "Dialog.Button.Foreground");
255 sp->button_background = get_pixel_resource (si->dpy, cmap,
256 "splash.Button.background",
257 "Dialog.Button.Background");
258 sp->shadow_top = get_pixel_resource (si->dpy, cmap,
259 "splash.topShadowColor",
260 "Dialog.Foreground");
261 sp->shadow_bottom = get_pixel_resource (si->dpy, cmap,
262 "splash.bottomShadowColor",
263 "Dialog.Background");
265 sp->logo_width = get_integer_resource (si->dpy,
267 "Dialog.Logo.Width");
268 sp->logo_height = get_integer_resource (si->dpy,
269 "splash.logo.height",
270 "Dialog.Logo.Height");
271 sp->internal_border = get_integer_resource (si->dpy,
272 "splash.internalBorderWidth",
273 "Dialog.InternalBorderWidth");
274 sp->shadow_width = get_integer_resource (si->dpy,
275 "splash.shadowThickness",
276 "Dialog.ShadowThickness");
278 if (sp->logo_width == 0) sp->logo_width = 150;
279 if (sp->logo_height == 0) sp->logo_height = 150;
280 if (sp->internal_border == 0) sp->internal_border = 15;
281 if (sp->shadow_width == 0) sp->shadow_width = 4;
284 int direction, ascent, descent;
290 /* Measure the heading_label. */
291 XTextExtents (sp->heading_font,
292 sp->heading_label, strlen(sp->heading_label),
293 &direction, &ascent, &descent, &overall);
294 if (overall.width > sp->width) sp->width = overall.width;
295 sp->height += ascent + descent;
297 /* Measure the body_label. */
298 XTextExtents (sp->body_font,
299 sp->body_label, strlen(sp->body_label),
300 &direction, &ascent, &descent, &overall);
301 if (overall.width > sp->width) sp->width = overall.width;
302 sp->height += ascent + descent;
304 /* Measure the body2_label. */
305 XTextExtents (sp->body_font,
306 sp->body2_label, strlen(sp->body2_label),
307 &direction, &ascent, &descent, &overall);
308 if (overall.width > sp->width) sp->width = overall.width;
309 sp->height += ascent + descent;
312 Dimension w2 = 0, w3 = 0, w4 = 0;
313 Dimension h2 = 0, h3 = 0, h4 = 0;
315 /* Measure the Demo button. */
316 XTextExtents (sp->button_font,
317 sp->demo_label, strlen(sp->demo_label),
318 &direction, &ascent, &descent, &overall);
320 h2 = ascent + descent;
323 /* Measure the Prefs button. */
324 XTextExtents (sp->button_font,
325 sp->prefs_label, strlen(sp->prefs_label),
326 &direction, &ascent, &descent, &overall);
328 h3 = ascent + descent;
329 #else /* !PREFS_BUTTON */
332 #endif /* !PREFS_BUTTON */
334 /* Measure the Help button. */
335 XTextExtents (sp->button_font,
336 sp->help_label, strlen(sp->help_label),
337 &direction, &ascent, &descent, &overall);
339 h4 = ascent + descent;
341 w2 = MAX(w2, w3); w2 = MAX(w2, w4);
342 h2 = MAX(h2, h3); h2 = MAX(h2, h4);
344 /* Add some horizontal padding inside the buttons. */
347 w2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
348 h2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
350 sp->button_width = w2;
351 sp->button_height = h2;
355 #else /* !PREFS_BUTTON */
357 #endif /* !PREFS_BUTTON */
359 w2 += ((ascent + descent) * 2); /* for space between buttons */
361 if (w2 > sp->width) sp->width = w2;
365 sp->width += (sp->internal_border * 2);
366 sp->height += (sp->internal_border * 3);
368 if (sp->logo_height > sp->height)
369 sp->height = sp->logo_height;
370 else if (sp->height > sp->logo_height)
371 sp->logo_height = sp->height;
373 sp->logo_width = sp->logo_height;
375 sp->width += sp->logo_width;
378 attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
379 attrmask |= CWEventMask;
380 attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
383 int sx = 0, sy = 0, w, h;
384 int mouse_x = 0, mouse_y = 0;
387 Window pointer_root, pointer_child;
388 int root_x, root_y, win_x, win_y;
390 if (XQueryPointer (si->dpy,
391 RootWindowOfScreen (ssi->screen),
392 &pointer_root, &pointer_child,
393 &root_x, &root_y, &win_x, &win_y, &mask))
404 if (si->prefs.debug_p) w /= 2;
405 x = sx + (((w + sp->width) / 2) - sp->width);
406 y = sy + (((h + sp->height) / 2) - sp->height);
411 bw = get_integer_resource (si->dpy,
412 "splash.borderWidth",
413 "Dialog.BorderWidth");
416 XCreateWindow (si->dpy,
417 RootWindowOfScreen(ssi->screen),
418 x, y, sp->width, sp->height, bw,
419 DefaultDepthOfScreen (ssi->screen), InputOutput,
420 DefaultVisualOfScreen(ssi->screen),
422 XSetWindowBackground (si->dpy, si->splash_dialog, sp->background);
424 sp->logo_pixmap = xscreensaver_logo (ssi->screen,
425 /* same visual as si->splash_dialog */
426 DefaultVisualOfScreen (ssi->screen),
427 si->splash_dialog, cmap,
429 &sp->logo_pixels, &sp->logo_npixels,
430 &sp->logo_clipmask, True);
432 XMapRaised (si->dpy, si->splash_dialog);
433 XSync (si->dpy, False);
437 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
438 unsplash_timer, (XtPointer) si);
440 draw_splash_window (si);
441 XSync (si->dpy, False);
446 draw_splash_window (saver_info *si)
448 splash_dialog_data *sp = si->sp_data;
451 int hspacing, vspacing, height;
452 int x1, x2, x3, y1, y2;
457 #else /* !PREFS_BUTTON */
459 #endif /* !PREFS_BUTTON */
461 height = (sp->heading_font->ascent + sp->heading_font->descent +
462 sp->body_font->ascent + sp->body_font->descent +
463 sp->body_font->ascent + sp->body_font->descent +
464 sp->button_font->ascent + sp->button_font->descent);
465 vspacing = ((sp->height
466 - (4 * sp->shadow_width)
467 - (2 * sp->internal_border)
469 if (vspacing < 0) vspacing = 0;
470 if (vspacing > (sp->heading_font->ascent * 2))
471 vspacing = (sp->heading_font->ascent * 2);
473 gcv.foreground = sp->foreground;
474 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
475 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
477 x3 = sp->width - (sp->shadow_width * 2);
478 y1 = sp->internal_border;
482 XSetFont (si->dpy, gc1, sp->heading_font->fid);
483 sw = string_width (sp->heading_font, sp->heading_label);
484 x2 = (x1 + ((x3 - x1 - sw) / 2));
485 y1 += sp->heading_font->ascent;
486 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
487 sp->heading_label, strlen(sp->heading_label));
488 y1 += sp->heading_font->descent;
490 /* text below top heading
492 XSetFont (si->dpy, gc1, sp->body_font->fid);
493 y1 += vspacing + sp->body_font->ascent;
494 sw = string_width (sp->body_font, sp->body_label);
495 x2 = (x1 + ((x3 - x1 - sw) / 2));
496 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
497 sp->body_label, strlen(sp->body_label));
498 y1 += sp->body_font->descent;
500 y1 += sp->body_font->ascent;
501 sw = string_width (sp->body_font, sp->body2_label);
502 x2 = (x1 + ((x3 - x1 - sw) / 2));
503 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
504 sp->body2_label, strlen(sp->body2_label));
505 y1 += sp->body_font->descent;
509 XSetForeground (si->dpy, gc1, sp->button_foreground);
510 XSetForeground (si->dpy, gc2, sp->button_background);
512 /* y1 += (vspacing * 2);*/
513 y1 = sp->height - sp->internal_border - sp->button_height;
515 x1 += sp->internal_border;
516 y2 = (y1 + ((sp->button_height -
517 (sp->button_font->ascent + sp->button_font->descent))
519 + sp->button_font->ascent);
520 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
521 sp->internal_border - (sp->button_width * nbuttons))
524 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_label))
526 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
527 sp->button_width, sp->button_height);
528 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
529 sp->demo_label, strlen(sp->demo_label));
530 sp->demo_button_x = x1;
531 sp->demo_button_y = y1;
534 x1 += hspacing + sp->button_width;
535 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
537 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
538 sp->button_width, sp->button_height);
539 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
540 sp->prefs_label, strlen(sp->prefs_label));
541 sp->prefs_button_x = x1;
542 sp->prefs_button_y = y1;
543 #endif /* PREFS_BUTTON */
546 x1 += hspacing + sp->button_width;
547 #else /* !PREFS_BUTTON */
548 x1 = (sp->width - sp->button_width -
549 sp->internal_border - (sp->shadow_width * 2));
550 #endif /* !PREFS_BUTTON */
552 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
554 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
555 sp->button_width, sp->button_height);
556 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
557 sp->help_label, strlen(sp->help_label));
558 sp->help_button_x = x1;
559 sp->help_button_y = y1;
564 x1 = sp->shadow_width * 6;
565 y1 = sp->shadow_width * 6;
566 x2 = sp->logo_width - (sp->shadow_width * 12);
567 y2 = sp->logo_height - (sp->shadow_width * 12);
573 unsigned int w, h, bw, d;
574 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
575 XSetForeground (si->dpy, gc1, sp->foreground);
576 XSetBackground (si->dpy, gc1, sp->background);
577 XSetClipMask (si->dpy, gc1, sp->logo_clipmask);
578 XSetClipOrigin (si->dpy, gc1, x1 + ((x2 - (int)w) /2), y1 + ((y2 - (int)h) / 2));
580 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
582 x1 + ((x2 - (int)w) / 2),
583 y1 + ((y2 - (int)h) / 2),
586 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
588 x1 + ((x2 - (int)w) / 2),
589 y1 + ((y2 - (int)h) / 2));
592 /* Solid border inside the logo box. */
594 XSetForeground (si->dpy, gc1, sp->foreground);
595 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
598 /* The shadow around the logo
600 draw_shaded_rectangle (si->dpy, si->splash_dialog,
601 sp->shadow_width * 4,
602 sp->shadow_width * 4,
603 sp->logo_width - (sp->shadow_width * 8),
604 sp->logo_height - (sp->shadow_width * 8),
606 sp->shadow_bottom, sp->shadow_top);
608 /* The shadow around the whole window
610 draw_shaded_rectangle (si->dpy, si->splash_dialog,
611 0, 0, sp->width, sp->height, sp->shadow_width,
612 sp->shadow_top, sp->shadow_bottom);
614 XFreeGC (si->dpy, gc1);
615 XFreeGC (si->dpy, gc2);
617 update_splash_window (si);
622 update_splash_window (saver_info *si)
624 splash_dialog_data *sp = si->sp_data;
627 pressed = sp->pressed;
629 /* The shadows around the buttons
631 draw_shaded_rectangle (si->dpy, si->splash_dialog,
632 sp->demo_button_x, sp->demo_button_y,
633 sp->button_width, sp->button_height, sp->shadow_width,
634 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
635 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
637 draw_shaded_rectangle (si->dpy, si->splash_dialog,
638 sp->prefs_button_x, sp->prefs_button_y,
639 sp->button_width, sp->button_height, sp->shadow_width,
640 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
641 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
642 #endif /* PREFS_BUTTON */
643 draw_shaded_rectangle (si->dpy, si->splash_dialog,
644 sp->help_button_x, sp->help_button_y,
645 sp->button_width, sp->button_height, sp->shadow_width,
646 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
647 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
651 destroy_splash_window (saver_info *si)
653 splash_dialog_data *sp = si->sp_data;
654 saver_screen_info *ssi = sp->prompt_screen;
655 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
656 Pixel black = BlackPixelOfScreen (ssi->screen);
657 Pixel white = WhitePixelOfScreen (ssi->screen);
660 XtRemoveTimeOut (sp->timer);
662 if (si->splash_dialog)
664 XDestroyWindow (si->dpy, si->splash_dialog);
665 si->splash_dialog = 0;
668 if (sp->heading_label) free (sp->heading_label);
669 if (sp->body_label) free (sp->body_label);
670 if (sp->body2_label) free (sp->body2_label);
671 if (sp->demo_label) free (sp->demo_label);
673 if (sp->prefs_label) free (sp->prefs_label);
674 #endif /* PREFS_BUTTON */
675 if (sp->help_label) free (sp->help_label);
677 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
678 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
679 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
681 if (sp->foreground != black && sp->foreground != white)
682 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
683 if (sp->background != black && sp->background != white)
684 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
685 if (sp->button_foreground != black && sp->button_foreground != white)
686 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
687 if (sp->button_background != black && sp->button_background != white)
688 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
689 if (sp->shadow_top != black && sp->shadow_top != white)
690 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
691 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
692 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
695 XFreePixmap (si->dpy, sp->logo_pixmap);
696 if (sp->logo_clipmask)
697 XFreePixmap (si->dpy, sp->logo_clipmask);
700 if (sp->logo_npixels)
701 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
702 free (sp->logo_pixels);
704 sp->logo_npixels = 0;
707 memset (sp, 0, sizeof(*sp));
713 handle_splash_event (saver_info *si, XEvent *event)
715 splash_dialog_data *sp = si->sp_data;
716 saver_screen_info *ssi = sp->prompt_screen;
720 switch (event->xany.type)
723 draw_splash_window (si);
726 case ButtonPress: case ButtonRelease:
728 if (event->xbutton.x >= sp->demo_button_x &&
729 event->xbutton.x < sp->demo_button_x + sp->button_width &&
730 event->xbutton.y >= sp->demo_button_y &&
731 event->xbutton.y < sp->demo_button_y + sp->button_height)
735 else if (event->xbutton.x >= sp->prefs_button_x &&
736 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
737 event->xbutton.y >= sp->prefs_button_y &&
738 event->xbutton.y < sp->prefs_button_y + sp->button_height)
740 #endif /* PREFS_BUTTON */
742 else if (event->xbutton.x >= sp->help_button_x &&
743 event->xbutton.x < sp->help_button_x + sp->button_width &&
744 event->xbutton.y >= sp->help_button_y &&
745 event->xbutton.y < sp->help_button_y + sp->button_height)
748 if (event->xany.type == ButtonPress)
751 update_splash_window (si);
753 XBell (si->dpy, False);
755 else if (event->xany.type == ButtonRelease)
757 if (which && sp->pressed == which)
759 destroy_splash_window (si);
763 case 1: do_demo (ssi); break;
765 case 2: do_prefs (ssi); break;
766 #endif /* PREFS_BUTTON */
767 case 3: do_help (ssi); break;
771 else if (which == 0 && sp->pressed == 0)
773 /* click and release on the window but not in a button:
774 treat that as "dismiss the splash dialog." */
775 destroy_splash_window (si);
778 if (sp) sp->pressed = 0;
779 update_splash_window (si);
789 unsplash_timer (XtPointer closure, XtIntervalId *id)
791 saver_info *si = (saver_info *) closure;
792 if (si && si->sp_data)
793 destroy_splash_window (si);
797 /* Button callbacks */
806 do_demo (saver_screen_info *ssi)
808 saver_info *si = ssi->global;
809 saver_preferences *p = &si->prefs;
810 const char *cmd = p->demo_command;
813 fork_and_exec (ssi, cmd);
815 fprintf (stderr, "%s: no demo-mode command has been specified.\n",
821 do_prefs (saver_screen_info *ssi)
823 saver_info *si = ssi->global;
824 saver_preferences *p = &si->prefs;
825 const char *cmd = p->prefs_command;
827 if (command && *command)
828 fork_and_exec (ssi, cmd);
830 fprintf (stderr, "%s: no preferences command has been specified.\n",
833 #endif /* PREFS_BUTTON */
836 do_help (saver_screen_info *ssi)
838 saver_info *si = ssi->global;
839 saver_preferences *p = &si->prefs;
840 char *help_command = 0;
842 if (!p->load_url_command || !*p->load_url_command)
844 fprintf (stderr, "%s: no URL command has been specified.\n", blurb());
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) * 4) + 10);
855 sprintf (help_command, p->load_url_command,
856 p->help_url, p->help_url, p->help_url, p->help_url);
858 fork_and_exec (ssi, help_command);