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 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_screen_info *ssi);
104 static void do_prefs (saver_screen_info *ssi);
105 #endif /* PREFS_BUTTON */
106 static void do_help (saver_screen_info *ssi);
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;
150 Pixmap logo_clipmask;
152 unsigned long *logo_pixels;
159 make_splash_dialog (saver_info *si)
162 XSetWindowAttributes attrs;
163 unsigned long attrmask = 0;
164 splash_dialog_data *sp;
165 saver_screen_info *ssi;
171 if (!si->prefs.splash_p ||
172 si->prefs.splash_duration <= 0)
175 ssi = &si->screens[mouse_screen (si)];
176 cmap = DefaultColormapOfScreen (ssi->screen);
178 sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
179 sp->prompt_screen = ssi;
181 sp->heading_label = get_string_resource (si->dpy,
182 "splash.heading.label",
183 "Dialog.Label.Label");
184 sp->body_label = get_string_resource (si->dpy,
186 "Dialog.Label.Label");
187 sp->body2_label = get_string_resource (si->dpy,
188 "splash.body2.label",
189 "Dialog.Label.Label");
190 sp->demo_label = get_string_resource (si->dpy,
192 "Dialog.Button.Label");
194 sp->prefs_label = get_string_resource (si->dpy,
195 "splash.prefs.label",
196 "Dialog.Button.Label");
197 #endif /* PREFS_BUTTON */
198 sp->help_label = get_string_resource (si->dpy,
200 "Dialog.Button.Label");
202 if (!sp->heading_label)
203 sp->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
205 sp->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
206 if (!sp->body2_label)
207 sp->body2_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
208 if (!sp->demo_label) sp->demo_label = strdup("ERROR");
210 if (!sp->prefs_label) sp->prefs_label = strdup("ERROR");
211 #endif /* PREFS_BUTTON */
212 if (!sp->help_label) sp->help_label = strdup("ERROR");
214 /* Put the version number in the label. */
216 char *s = (char *) malloc (strlen(sp->heading_label) + 20);
217 sprintf(s, sp->heading_label, si->version);
218 free (sp->heading_label);
219 sp->heading_label = s;
222 f = get_string_resource (si->dpy, "splash.headingFont", "Dialog.Font");
223 sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
224 if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed");
227 f = get_string_resource(si->dpy, "splash.bodyFont", "Dialog.Font");
228 sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
229 if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed");
232 f = get_string_resource(si->dpy, "splash.buttonFont", "Dialog.Font");
233 sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
234 if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed");
237 sp->foreground = get_pixel_resource (si->dpy, cmap,
239 "Dialog.Foreground");
240 sp->background = get_pixel_resource (si->dpy, cmap,
242 "Dialog.Background");
244 if (sp->foreground == sp->background)
246 /* Make sure the error messages show up. */
247 sp->foreground = BlackPixelOfScreen (ssi->screen);
248 sp->background = WhitePixelOfScreen (ssi->screen);
251 sp->button_foreground = get_pixel_resource (si->dpy, cmap,
252 "splash.Button.foreground",
253 "Dialog.Button.Foreground");
254 sp->button_background = get_pixel_resource (si->dpy, cmap,
255 "splash.Button.background",
256 "Dialog.Button.Background");
257 sp->shadow_top = get_pixel_resource (si->dpy, cmap,
258 "splash.topShadowColor",
259 "Dialog.Foreground");
260 sp->shadow_bottom = get_pixel_resource (si->dpy, cmap,
261 "splash.bottomShadowColor",
262 "Dialog.Background");
264 sp->logo_width = get_integer_resource (si->dpy,
266 "Dialog.Logo.Width");
267 sp->logo_height = get_integer_resource (si->dpy,
268 "splash.logo.height",
269 "Dialog.Logo.Height");
270 sp->internal_border = get_integer_resource (si->dpy,
271 "splash.internalBorderWidth",
272 "Dialog.InternalBorderWidth");
273 sp->shadow_width = get_integer_resource (si->dpy,
274 "splash.shadowThickness",
275 "Dialog.ShadowThickness");
277 if (sp->logo_width == 0) sp->logo_width = 150;
278 if (sp->logo_height == 0) sp->logo_height = 150;
279 if (sp->internal_border == 0) sp->internal_border = 15;
280 if (sp->shadow_width == 0) sp->shadow_width = 4;
283 int direction, ascent, descent;
289 /* Measure the heading_label. */
290 XTextExtents (sp->heading_font,
291 sp->heading_label, strlen(sp->heading_label),
292 &direction, &ascent, &descent, &overall);
293 if (overall.width > sp->width) sp->width = overall.width;
294 sp->height += ascent + descent;
296 /* Measure the body_label. */
297 XTextExtents (sp->body_font,
298 sp->body_label, strlen(sp->body_label),
299 &direction, &ascent, &descent, &overall);
300 if (overall.width > sp->width) sp->width = overall.width;
301 sp->height += ascent + descent;
303 /* Measure the body2_label. */
304 XTextExtents (sp->body_font,
305 sp->body2_label, strlen(sp->body2_label),
306 &direction, &ascent, &descent, &overall);
307 if (overall.width > sp->width) sp->width = overall.width;
308 sp->height += ascent + descent;
311 Dimension w2 = 0, w3 = 0, w4 = 0;
312 Dimension h2 = 0, h3 = 0, h4 = 0;
314 /* Measure the Demo button. */
315 XTextExtents (sp->button_font,
316 sp->demo_label, strlen(sp->demo_label),
317 &direction, &ascent, &descent, &overall);
319 h2 = ascent + descent;
322 /* Measure the Prefs button. */
323 XTextExtents (sp->button_font,
324 sp->prefs_label, strlen(sp->prefs_label),
325 &direction, &ascent, &descent, &overall);
327 h3 = ascent + descent;
328 #else /* !PREFS_BUTTON */
331 #endif /* !PREFS_BUTTON */
333 /* Measure the Help button. */
334 XTextExtents (sp->button_font,
335 sp->help_label, strlen(sp->help_label),
336 &direction, &ascent, &descent, &overall);
338 h4 = ascent + descent;
340 w2 = MAX(w2, w3); w2 = MAX(w2, w4);
341 h2 = MAX(h2, h3); h2 = MAX(h2, h4);
343 /* Add some horizontal padding inside the buttons. */
346 w2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
347 h2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
349 sp->button_width = w2;
350 sp->button_height = h2;
354 #else /* !PREFS_BUTTON */
356 #endif /* !PREFS_BUTTON */
358 w2 += ((ascent + descent) * 2); /* for space between buttons */
360 if (w2 > sp->width) sp->width = w2;
364 sp->width += (sp->internal_border * 2);
365 sp->height += (sp->internal_border * 3);
367 if (sp->logo_height > sp->height)
368 sp->height = sp->logo_height;
369 else if (sp->height > sp->logo_height)
370 sp->logo_height = sp->height;
372 sp->logo_width = sp->logo_height;
374 sp->width += sp->logo_width;
377 attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
378 attrmask |= CWEventMask;
379 attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
383 int mouse_x = 0, mouse_y = 0;
386 Window pointer_root, pointer_child;
387 int root_x, root_y, win_x, win_y;
389 if (XQueryPointer (si->dpy,
390 RootWindowOfScreen (ssi->screen),
391 &pointer_root, &pointer_child,
392 &root_x, &root_y, &win_x, &win_y, &mask))
399 get_screen_viewport (ssi, &sx, &sy, &w, &h, mouse_x, mouse_y, False);
400 if (si->prefs.debug_p) w /= 2;
401 x = sx + (((w + sp->width) / 2) - sp->width);
402 y = sy + (((h + sp->height) / 2) - sp->height);
407 bw = get_integer_resource (si->dpy,
408 "splash.borderWidth",
409 "Dialog.BorderWidth");
412 XCreateWindow (si->dpy,
413 RootWindowOfScreen(ssi->screen),
414 x, y, sp->width, sp->height, bw,
415 DefaultDepthOfScreen (ssi->screen), InputOutput,
416 DefaultVisualOfScreen(ssi->screen),
418 XSetWindowBackground (si->dpy, si->splash_dialog, sp->background);
420 sp->logo_pixmap = xscreensaver_logo (ssi->screen, ssi->current_visual,
421 si->splash_dialog, cmap,
423 &sp->logo_pixels, &sp->logo_npixels,
424 &sp->logo_clipmask, True);
426 XMapRaised (si->dpy, si->splash_dialog);
427 XSync (si->dpy, False);
431 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
432 unsplash_timer, (XtPointer) si);
434 draw_splash_window (si);
435 XSync (si->dpy, False);
440 draw_splash_window (saver_info *si)
442 splash_dialog_data *sp = si->sp_data;
445 int hspacing, vspacing, height;
446 int x1, x2, x3, y1, y2;
451 #else /* !PREFS_BUTTON */
453 #endif /* !PREFS_BUTTON */
455 height = (sp->heading_font->ascent + sp->heading_font->descent +
456 sp->body_font->ascent + sp->body_font->descent +
457 sp->body_font->ascent + sp->body_font->descent +
458 sp->button_font->ascent + sp->button_font->descent);
459 vspacing = ((sp->height
460 - (4 * sp->shadow_width)
461 - (2 * sp->internal_border)
463 if (vspacing < 0) vspacing = 0;
464 if (vspacing > (sp->heading_font->ascent * 2))
465 vspacing = (sp->heading_font->ascent * 2);
467 gcv.foreground = sp->foreground;
468 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
469 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
471 x3 = sp->width - (sp->shadow_width * 2);
472 y1 = sp->internal_border;
476 XSetFont (si->dpy, gc1, sp->heading_font->fid);
477 sw = string_width (sp->heading_font, sp->heading_label);
478 x2 = (x1 + ((x3 - x1 - sw) / 2));
479 y1 += sp->heading_font->ascent;
480 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
481 sp->heading_label, strlen(sp->heading_label));
482 y1 += sp->heading_font->descent;
484 /* text below top heading
486 XSetFont (si->dpy, gc1, sp->body_font->fid);
487 y1 += vspacing + sp->body_font->ascent;
488 sw = string_width (sp->body_font, sp->body_label);
489 x2 = (x1 + ((x3 - x1 - sw) / 2));
490 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
491 sp->body_label, strlen(sp->body_label));
492 y1 += sp->body_font->descent;
494 y1 += sp->body_font->ascent;
495 sw = string_width (sp->body_font, sp->body2_label);
496 x2 = (x1 + ((x3 - x1 - sw) / 2));
497 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
498 sp->body2_label, strlen(sp->body2_label));
499 y1 += sp->body_font->descent;
503 XSetForeground (si->dpy, gc1, sp->button_foreground);
504 XSetForeground (si->dpy, gc2, sp->button_background);
506 /* y1 += (vspacing * 2);*/
507 y1 = sp->height - sp->internal_border - sp->button_height;
509 x1 += sp->internal_border;
510 y2 = (y1 + ((sp->button_height -
511 (sp->button_font->ascent + sp->button_font->descent))
513 + sp->button_font->ascent);
514 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
515 sp->internal_border - (sp->button_width * nbuttons))
518 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_label))
520 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
521 sp->button_width, sp->button_height);
522 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
523 sp->demo_label, strlen(sp->demo_label));
524 sp->demo_button_x = x1;
525 sp->demo_button_y = y1;
528 x1 += hspacing + sp->button_width;
529 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
531 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
532 sp->button_width, sp->button_height);
533 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
534 sp->prefs_label, strlen(sp->prefs_label));
535 sp->prefs_button_x = x1;
536 sp->prefs_button_y = y1;
537 #endif /* PREFS_BUTTON */
540 x1 += hspacing + sp->button_width;
541 #else /* !PREFS_BUTTON */
542 x1 = (sp->width - sp->button_width -
543 sp->internal_border - (sp->shadow_width * 2));
544 #endif /* !PREFS_BUTTON */
546 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
548 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
549 sp->button_width, sp->button_height);
550 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
551 sp->help_label, strlen(sp->help_label));
552 sp->help_button_x = x1;
553 sp->help_button_y = y1;
558 x1 = sp->shadow_width * 6;
559 y1 = sp->shadow_width * 6;
560 x2 = sp->logo_width - (sp->shadow_width * 12);
561 y2 = sp->logo_height - (sp->shadow_width * 12);
567 unsigned int w, h, bw, d;
568 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
569 XSetForeground (si->dpy, gc1, sp->foreground);
570 XSetBackground (si->dpy, gc1, sp->background);
571 XSetClipMask (si->dpy, gc1, sp->logo_clipmask);
572 XSetClipOrigin (si->dpy, gc1, x1 + ((x2 - (int)w) /2), y1 + ((y2 - (int)h) / 2));
574 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
576 x1 + ((x2 - (int)w) / 2),
577 y1 + ((y2 - (int)h) / 2),
580 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
582 x1 + ((x2 - (int)w) / 2),
583 y1 + ((y2 - (int)h) / 2));
586 /* Solid border inside the logo box. */
588 XSetForeground (si->dpy, gc1, sp->foreground);
589 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
592 /* The shadow around the logo
594 draw_shaded_rectangle (si->dpy, si->splash_dialog,
595 sp->shadow_width * 4,
596 sp->shadow_width * 4,
597 sp->logo_width - (sp->shadow_width * 8),
598 sp->logo_height - (sp->shadow_width * 8),
600 sp->shadow_bottom, sp->shadow_top);
602 /* The shadow around the whole window
604 draw_shaded_rectangle (si->dpy, si->splash_dialog,
605 0, 0, sp->width, sp->height, sp->shadow_width,
606 sp->shadow_top, sp->shadow_bottom);
608 XFreeGC (si->dpy, gc1);
609 XFreeGC (si->dpy, gc2);
611 update_splash_window (si);
616 update_splash_window (saver_info *si)
618 splash_dialog_data *sp = si->sp_data;
621 pressed = sp->pressed;
623 /* The shadows around the buttons
625 draw_shaded_rectangle (si->dpy, si->splash_dialog,
626 sp->demo_button_x, sp->demo_button_y,
627 sp->button_width, sp->button_height, sp->shadow_width,
628 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
629 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
631 draw_shaded_rectangle (si->dpy, si->splash_dialog,
632 sp->prefs_button_x, sp->prefs_button_y,
633 sp->button_width, sp->button_height, sp->shadow_width,
634 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
635 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
636 #endif /* PREFS_BUTTON */
637 draw_shaded_rectangle (si->dpy, si->splash_dialog,
638 sp->help_button_x, sp->help_button_y,
639 sp->button_width, sp->button_height, sp->shadow_width,
640 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
641 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
645 destroy_splash_window (saver_info *si)
647 splash_dialog_data *sp = si->sp_data;
648 saver_screen_info *ssi = sp->prompt_screen;
649 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
650 Pixel black = BlackPixelOfScreen (ssi->screen);
651 Pixel white = WhitePixelOfScreen (ssi->screen);
654 XtRemoveTimeOut (sp->timer);
656 if (si->splash_dialog)
658 XDestroyWindow (si->dpy, si->splash_dialog);
659 si->splash_dialog = 0;
662 if (sp->heading_label) free (sp->heading_label);
663 if (sp->body_label) free (sp->body_label);
664 if (sp->body2_label) free (sp->body2_label);
665 if (sp->demo_label) free (sp->demo_label);
667 if (sp->prefs_label) free (sp->prefs_label);
668 #endif /* PREFS_BUTTON */
669 if (sp->help_label) free (sp->help_label);
671 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
672 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
673 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
675 if (sp->foreground != black && sp->foreground != white)
676 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
677 if (sp->background != black && sp->background != white)
678 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
679 if (sp->button_foreground != black && sp->button_foreground != white)
680 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
681 if (sp->button_background != black && sp->button_background != white)
682 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
683 if (sp->shadow_top != black && sp->shadow_top != white)
684 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
685 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
686 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
689 XFreePixmap (si->dpy, sp->logo_pixmap);
690 if (sp->logo_clipmask)
691 XFreePixmap (si->dpy, sp->logo_clipmask);
694 if (sp->logo_npixels)
695 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
696 free (sp->logo_pixels);
698 sp->logo_npixels = 0;
701 memset (sp, 0, sizeof(*sp));
707 handle_splash_event (saver_info *si, XEvent *event)
709 splash_dialog_data *sp = si->sp_data;
710 saver_screen_info *ssi = sp->prompt_screen;
714 switch (event->xany.type)
717 draw_splash_window (si);
720 case ButtonPress: case ButtonRelease:
722 if (event->xbutton.x >= sp->demo_button_x &&
723 event->xbutton.x < sp->demo_button_x + sp->button_width &&
724 event->xbutton.y >= sp->demo_button_y &&
725 event->xbutton.y < sp->demo_button_y + sp->button_height)
729 else if (event->xbutton.x >= sp->prefs_button_x &&
730 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
731 event->xbutton.y >= sp->prefs_button_y &&
732 event->xbutton.y < sp->prefs_button_y + sp->button_height)
734 #endif /* PREFS_BUTTON */
736 else if (event->xbutton.x >= sp->help_button_x &&
737 event->xbutton.x < sp->help_button_x + sp->button_width &&
738 event->xbutton.y >= sp->help_button_y &&
739 event->xbutton.y < sp->help_button_y + sp->button_height)
742 if (event->xany.type == ButtonPress)
745 update_splash_window (si);
747 XBell (si->dpy, False);
749 else if (event->xany.type == ButtonRelease)
751 if (which && sp->pressed == which)
753 destroy_splash_window (si);
757 case 1: do_demo (ssi); break;
759 case 2: do_prefs (ssi); break;
760 #endif /* PREFS_BUTTON */
761 case 3: do_help (ssi); break;
765 else if (which == 0 && sp->pressed == 0)
767 /* click and release on the window but not in a button:
768 treat that as "dismiss the splash dialog." */
769 destroy_splash_window (si);
772 if (sp) sp->pressed = 0;
773 update_splash_window (si);
783 unsplash_timer (XtPointer closure, XtIntervalId *id)
785 saver_info *si = (saver_info *) closure;
786 if (si && si->sp_data)
787 destroy_splash_window (si);
791 /* Button callbacks */
800 do_demo (saver_screen_info *ssi)
802 saver_info *si = ssi->global;
803 saver_preferences *p = &si->prefs;
804 const char *cmd = p->demo_command;
807 fork_and_exec (ssi, cmd);
809 fprintf (stderr, "%s: no demo-mode command has been specified.\n",
815 do_prefs (saver_screen_info *ssi)
817 saver_info *si = ssi->global;
818 saver_preferences *p = &si->prefs;
819 const char *cmd = p->prefs_command;
821 if (command && *command)
822 fork_and_exec (ssi, cmd);
824 fprintf (stderr, "%s: no preferences command has been specified.\n",
827 #endif /* PREFS_BUTTON */
830 do_help (saver_screen_info *ssi)
832 saver_info *si = ssi->global;
833 saver_preferences *p = &si->prefs;
834 char *help_command = 0;
836 if (!p->load_url_command || !*p->load_url_command)
838 fprintf (stderr, "%s: no URL command has been specified.\n", blurb());
841 if (!p->help_url || !*p->help_url)
843 fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
847 help_command = (char *) malloc (strlen (p->load_url_command) +
848 (strlen (p->help_url) * 4) + 10);
849 sprintf (help_command, p->load_url_command,
850 p->help_url, p->help_url, p->help_url, p->help_url);
852 fork_and_exec (ssi, help_command);