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;
130 Pixel button_foreground;
131 Pixel button_background;
135 Dimension logo_width;
136 Dimension logo_height;
137 Dimension internal_border;
138 Dimension shadow_width;
140 Dimension button_width, button_height;
141 Dimension demo_button_x, demo_button_y;
143 Dimension prefs_button_x, prefs_button_y;
144 #endif /* PREFS_BUTTON */
145 Dimension help_button_x, help_button_y;
148 Pixmap logo_clipmask;
150 unsigned long *logo_pixels;
157 make_splash_dialog (saver_info *si)
160 XSetWindowAttributes attrs;
161 unsigned long attrmask = 0;
162 splash_dialog_data *sp;
163 saver_screen_info *ssi;
169 if (!si->prefs.splash_p ||
170 si->prefs.splash_duration <= 0)
173 ssi = &si->screens[mouse_screen (si)];
175 if (!ssi || !ssi->screen)
176 return; /* WTF? Trying to splash while no screens connected? */
178 cmap = DefaultColormapOfScreen (ssi->screen);
180 sp = (splash_dialog_data *) calloc (1, sizeof(*sp));
181 sp->prompt_screen = ssi;
183 sp->heading_label = get_string_resource (si->dpy,
184 "splash.heading.label",
185 "Dialog.Label.Label");
186 sp->body_label = get_string_resource (si->dpy,
188 "Dialog.Label.Label");
189 sp->body2_label = get_string_resource (si->dpy,
190 "splash.body2.label",
191 "Dialog.Label.Label");
192 sp->demo_label = get_string_resource (si->dpy,
194 "Dialog.Button.Label");
196 sp->prefs_label = get_string_resource (si->dpy,
197 "splash.prefs.label",
198 "Dialog.Button.Label");
199 #endif /* PREFS_BUTTON */
200 sp->help_label = get_string_resource (si->dpy,
202 "Dialog.Button.Label");
204 if (!sp->heading_label)
205 sp->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
207 sp->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
208 if (!sp->body2_label)
209 sp->body2_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
210 if (!sp->demo_label) sp->demo_label = strdup("ERROR");
212 if (!sp->prefs_label) sp->prefs_label = strdup("ERROR");
213 #endif /* PREFS_BUTTON */
214 if (!sp->help_label) sp->help_label = strdup("ERROR");
216 /* Put the version number in the label. */
218 char *s = (char *) malloc (strlen(sp->heading_label) + 20);
219 sprintf(s, sp->heading_label, si->version);
220 free (sp->heading_label);
221 sp->heading_label = s;
224 f = get_string_resource (si->dpy, "splash.headingFont", "Dialog.Font");
225 sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
226 if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed");
229 f = get_string_resource(si->dpy, "splash.bodyFont", "Dialog.Font");
230 sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
231 if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed");
234 f = get_string_resource(si->dpy, "splash.buttonFont", "Dialog.Font");
235 sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
236 if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed");
239 sp->foreground = get_pixel_resource (si->dpy, cmap,
241 "Dialog.Foreground");
242 sp->background = get_pixel_resource (si->dpy, cmap,
244 "Dialog.Background");
245 sp->border = get_pixel_resource (si->dpy, cmap,
246 "splash.borderColor",
247 "Dialog.borderColor");
249 if (sp->foreground == sp->background)
251 /* Make sure the error messages show up. */
252 sp->foreground = BlackPixelOfScreen (ssi->screen);
253 sp->background = WhitePixelOfScreen (ssi->screen);
256 sp->button_foreground = get_pixel_resource (si->dpy, cmap,
257 "splash.Button.foreground",
258 "Dialog.Button.Foreground");
259 sp->button_background = get_pixel_resource (si->dpy, cmap,
260 "splash.Button.background",
261 "Dialog.Button.Background");
262 sp->shadow_top = get_pixel_resource (si->dpy, cmap,
263 "splash.topShadowColor",
264 "Dialog.Foreground");
265 sp->shadow_bottom = get_pixel_resource (si->dpy, cmap,
266 "splash.bottomShadowColor",
267 "Dialog.Background");
269 sp->logo_width = get_integer_resource (si->dpy,
271 "Dialog.Logo.Width");
272 sp->logo_height = get_integer_resource (si->dpy,
273 "splash.logo.height",
274 "Dialog.Logo.Height");
275 sp->internal_border = get_integer_resource (si->dpy,
276 "splash.internalBorderWidth",
277 "Dialog.InternalBorderWidth");
278 sp->shadow_width = get_integer_resource (si->dpy,
279 "splash.shadowThickness",
280 "Dialog.ShadowThickness");
282 if (sp->logo_width == 0) sp->logo_width = 150;
283 if (sp->logo_height == 0) sp->logo_height = 150;
284 if (sp->internal_border == 0) sp->internal_border = 15;
285 if (sp->shadow_width == 0) sp->shadow_width = 4;
288 int direction, ascent, descent;
294 /* Measure the heading_label. */
295 XTextExtents (sp->heading_font,
296 sp->heading_label, strlen(sp->heading_label),
297 &direction, &ascent, &descent, &overall);
298 if (overall.width > sp->width) sp->width = overall.width;
299 sp->height += ascent + descent;
301 /* Measure the body_label. */
302 XTextExtents (sp->body_font,
303 sp->body_label, strlen(sp->body_label),
304 &direction, &ascent, &descent, &overall);
305 if (overall.width > sp->width) sp->width = overall.width;
306 sp->height += ascent + descent;
308 /* Measure the body2_label. */
309 XTextExtents (sp->body_font,
310 sp->body2_label, strlen(sp->body2_label),
311 &direction, &ascent, &descent, &overall);
312 if (overall.width > sp->width) sp->width = overall.width;
313 sp->height += ascent + descent;
316 Dimension w2 = 0, w3 = 0, w4 = 0;
317 Dimension h2 = 0, h3 = 0, h4 = 0;
319 /* Measure the Demo button. */
320 XTextExtents (sp->button_font,
321 sp->demo_label, strlen(sp->demo_label),
322 &direction, &ascent, &descent, &overall);
324 h2 = ascent + descent;
327 /* Measure the Prefs button. */
328 XTextExtents (sp->button_font,
329 sp->prefs_label, strlen(sp->prefs_label),
330 &direction, &ascent, &descent, &overall);
332 h3 = ascent + descent;
333 #else /* !PREFS_BUTTON */
336 #endif /* !PREFS_BUTTON */
338 /* Measure the Help button. */
339 XTextExtents (sp->button_font,
340 sp->help_label, strlen(sp->help_label),
341 &direction, &ascent, &descent, &overall);
343 h4 = ascent + descent;
345 w2 = MAX(w2, w3); w2 = MAX(w2, w4);
346 h2 = MAX(h2, h3); h2 = MAX(h2, h4);
348 /* Add some horizontal padding inside the buttons. */
351 w2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
352 h2 += ((ascent + descent) / 2) + (sp->shadow_width * 2);
354 sp->button_width = w2;
355 sp->button_height = h2;
359 #else /* !PREFS_BUTTON */
361 #endif /* !PREFS_BUTTON */
363 w2 += ((ascent + descent) * 2); /* for space between buttons */
365 if (w2 > sp->width) sp->width = w2;
369 sp->width += (sp->internal_border * 2);
370 sp->height += (sp->internal_border * 3);
372 if (sp->logo_height > sp->height)
373 sp->height = sp->logo_height;
374 else if (sp->height > sp->logo_height)
375 sp->logo_height = sp->height;
377 sp->logo_width = sp->logo_height;
379 sp->width += sp->logo_width;
382 attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
383 attrmask |= CWEventMask;
384 attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
387 int sx = 0, sy = 0, w, h;
388 int mouse_x = 0, mouse_y = 0;
391 Window pointer_root, pointer_child;
392 int root_x, root_y, win_x, win_y;
394 if (XQueryPointer (si->dpy,
395 RootWindowOfScreen (ssi->screen),
396 &pointer_root, &pointer_child,
397 &root_x, &root_y, &win_x, &win_y, &mask))
408 if (si->prefs.debug_p) w /= 2;
409 x = sx + (((w + sp->width) / 2) - sp->width);
410 y = sy + (((h + sp->height) / 2) - sp->height);
415 bw = get_integer_resource (si->dpy,
416 "splash.borderWidth",
417 "Dialog.BorderWidth");
420 XCreateWindow (si->dpy,
421 RootWindowOfScreen(ssi->screen),
422 x, y, sp->width, sp->height, bw,
423 DefaultDepthOfScreen (ssi->screen), InputOutput,
424 DefaultVisualOfScreen(ssi->screen),
426 XSetWindowBackground (si->dpy, si->splash_dialog, sp->background);
427 XSetWindowBorder (si->dpy, si->splash_dialog, sp->border);
430 sp->logo_pixmap = xscreensaver_logo (ssi->screen,
431 /* same visual as si->splash_dialog */
432 DefaultVisualOfScreen (ssi->screen),
433 si->splash_dialog, cmap,
435 &sp->logo_pixels, &sp->logo_npixels,
436 &sp->logo_clipmask, True);
438 XMapRaised (si->dpy, si->splash_dialog);
439 XSync (si->dpy, False);
443 sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration,
444 unsplash_timer, (XtPointer) si);
446 draw_splash_window (si);
447 XSync (si->dpy, False);
452 draw_splash_window (saver_info *si)
454 splash_dialog_data *sp = si->sp_data;
457 int hspacing, vspacing, height;
458 int x1, x2, x3, y1, y2;
463 #else /* !PREFS_BUTTON */
465 #endif /* !PREFS_BUTTON */
467 height = (sp->heading_font->ascent + sp->heading_font->descent +
468 sp->body_font->ascent + sp->body_font->descent +
469 sp->body_font->ascent + sp->body_font->descent +
470 sp->button_font->ascent + sp->button_font->descent);
471 vspacing = ((sp->height
472 - (4 * sp->shadow_width)
473 - (2 * sp->internal_border)
475 if (vspacing < 0) vspacing = 0;
476 if (vspacing > (sp->heading_font->ascent * 2))
477 vspacing = (sp->heading_font->ascent * 2);
479 gcv.foreground = sp->foreground;
480 gc1 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
481 gc2 = XCreateGC (si->dpy, si->splash_dialog, GCForeground, &gcv);
483 x3 = sp->width - (sp->shadow_width * 2);
484 y1 = sp->internal_border;
488 XSetFont (si->dpy, gc1, sp->heading_font->fid);
489 sw = string_width (sp->heading_font, sp->heading_label);
490 x2 = (x1 + ((x3 - x1 - sw) / 2));
491 y1 += sp->heading_font->ascent;
492 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
493 sp->heading_label, strlen(sp->heading_label));
494 y1 += sp->heading_font->descent;
496 /* text below top heading
498 XSetFont (si->dpy, gc1, sp->body_font->fid);
499 y1 += vspacing + sp->body_font->ascent;
500 sw = string_width (sp->body_font, sp->body_label);
501 x2 = (x1 + ((x3 - x1 - sw) / 2));
502 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
503 sp->body_label, strlen(sp->body_label));
504 y1 += sp->body_font->descent;
506 y1 += sp->body_font->ascent;
507 sw = string_width (sp->body_font, sp->body2_label);
508 x2 = (x1 + ((x3 - x1 - sw) / 2));
509 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y1,
510 sp->body2_label, strlen(sp->body2_label));
511 y1 += sp->body_font->descent;
515 XSetForeground (si->dpy, gc1, sp->button_foreground);
516 XSetForeground (si->dpy, gc2, sp->button_background);
518 /* y1 += (vspacing * 2);*/
519 y1 = sp->height - sp->internal_border - sp->button_height;
521 x1 += sp->internal_border;
522 y2 = (y1 + ((sp->button_height -
523 (sp->button_font->ascent + sp->button_font->descent))
525 + sp->button_font->ascent);
526 hspacing = ((sp->width - x1 - (sp->shadow_width * 2) -
527 sp->internal_border - (sp->button_width * nbuttons))
530 x2 = x1 + ((sp->button_width - string_width(sp->button_font, sp->demo_label))
532 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
533 sp->button_width, sp->button_height);
534 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
535 sp->demo_label, strlen(sp->demo_label));
536 sp->demo_button_x = x1;
537 sp->demo_button_y = y1;
540 x1 += hspacing + sp->button_width;
541 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->prefs_label))
543 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
544 sp->button_width, sp->button_height);
545 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
546 sp->prefs_label, strlen(sp->prefs_label));
547 sp->prefs_button_x = x1;
548 sp->prefs_button_y = y1;
549 #endif /* PREFS_BUTTON */
552 x1 += hspacing + sp->button_width;
553 #else /* !PREFS_BUTTON */
554 x1 = (sp->width - sp->button_width -
555 sp->internal_border - (sp->shadow_width * 2));
556 #endif /* !PREFS_BUTTON */
558 x2 = x1 + ((sp->button_width - string_width(sp->button_font,sp->help_label))
560 XFillRectangle (si->dpy, si->splash_dialog, gc2, x1, y1,
561 sp->button_width, sp->button_height);
562 XDrawString (si->dpy, si->splash_dialog, gc1, x2, y2,
563 sp->help_label, strlen(sp->help_label));
564 sp->help_button_x = x1;
565 sp->help_button_y = y1;
570 x1 = sp->shadow_width * 6;
571 y1 = sp->shadow_width * 6;
572 x2 = sp->logo_width - (sp->shadow_width * 12);
573 y2 = sp->logo_height - (sp->shadow_width * 12);
579 unsigned int w, h, bw, d;
580 XGetGeometry (si->dpy, sp->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
581 XSetForeground (si->dpy, gc1, sp->foreground);
582 XSetBackground (si->dpy, gc1, sp->background);
583 XSetClipMask (si->dpy, gc1, sp->logo_clipmask);
584 XSetClipOrigin (si->dpy, gc1, x1 + ((x2 - (int)w) /2), y1 + ((y2 - (int)h) / 2));
586 XCopyPlane (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
588 x1 + ((x2 - (int)w) / 2),
589 y1 + ((y2 - (int)h) / 2),
592 XCopyArea (si->dpy, sp->logo_pixmap, si->splash_dialog, gc1,
594 x1 + ((x2 - (int)w) / 2),
595 y1 + ((y2 - (int)h) / 2));
598 /* Solid border inside the logo box. */
600 XSetForeground (si->dpy, gc1, sp->foreground);
601 XDrawRectangle (si->dpy, si->splash_dialog, gc1, x1, y1, x2-1, y2-1);
604 /* The shadow around the logo
606 draw_shaded_rectangle (si->dpy, si->splash_dialog,
607 sp->shadow_width * 4,
608 sp->shadow_width * 4,
609 sp->logo_width - (sp->shadow_width * 8),
610 sp->logo_height - (sp->shadow_width * 8),
612 sp->shadow_bottom, sp->shadow_top);
614 /* The shadow around the whole window
616 draw_shaded_rectangle (si->dpy, si->splash_dialog,
617 0, 0, sp->width, sp->height, sp->shadow_width,
618 sp->shadow_top, sp->shadow_bottom);
620 XFreeGC (si->dpy, gc1);
621 XFreeGC (si->dpy, gc2);
623 update_splash_window (si);
628 update_splash_window (saver_info *si)
630 splash_dialog_data *sp = si->sp_data;
633 pressed = sp->pressed;
635 /* The shadows around the buttons
637 draw_shaded_rectangle (si->dpy, si->splash_dialog,
638 sp->demo_button_x, sp->demo_button_y,
639 sp->button_width, sp->button_height, sp->shadow_width,
640 (pressed == 1 ? sp->shadow_bottom : sp->shadow_top),
641 (pressed == 1 ? sp->shadow_top : sp->shadow_bottom));
643 draw_shaded_rectangle (si->dpy, si->splash_dialog,
644 sp->prefs_button_x, sp->prefs_button_y,
645 sp->button_width, sp->button_height, sp->shadow_width,
646 (pressed == 2 ? sp->shadow_bottom : sp->shadow_top),
647 (pressed == 2 ? sp->shadow_top : sp->shadow_bottom));
648 #endif /* PREFS_BUTTON */
649 draw_shaded_rectangle (si->dpy, si->splash_dialog,
650 sp->help_button_x, sp->help_button_y,
651 sp->button_width, sp->button_height, sp->shadow_width,
652 (pressed == 3 ? sp->shadow_bottom : sp->shadow_top),
653 (pressed == 3 ? sp->shadow_top : sp->shadow_bottom));
657 destroy_splash_window (saver_info *si)
659 splash_dialog_data *sp = si->sp_data;
660 saver_screen_info *ssi = sp->prompt_screen;
661 Colormap cmap = DefaultColormapOfScreen (ssi->screen);
662 Pixel black = BlackPixelOfScreen (ssi->screen);
663 Pixel white = WhitePixelOfScreen (ssi->screen);
666 XtRemoveTimeOut (sp->timer);
668 if (si->splash_dialog)
670 XDestroyWindow (si->dpy, si->splash_dialog);
671 si->splash_dialog = 0;
674 if (sp->heading_label) free (sp->heading_label);
675 if (sp->body_label) free (sp->body_label);
676 if (sp->body2_label) free (sp->body2_label);
677 if (sp->demo_label) free (sp->demo_label);
679 if (sp->prefs_label) free (sp->prefs_label);
680 #endif /* PREFS_BUTTON */
681 if (sp->help_label) free (sp->help_label);
683 if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font);
684 if (sp->body_font) XFreeFont (si->dpy, sp->body_font);
685 if (sp->button_font) XFreeFont (si->dpy, sp->button_font);
687 if (sp->foreground != black && sp->foreground != white)
688 XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L);
689 if (sp->background != black && sp->background != white)
690 XFreeColors (si->dpy, cmap, &sp->background, 1, 0L);
691 if (sp->button_foreground != black && sp->button_foreground != white)
692 XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L);
693 if (sp->button_background != black && sp->button_background != white)
694 XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L);
695 if (sp->shadow_top != black && sp->shadow_top != white)
696 XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L);
697 if (sp->shadow_bottom != black && sp->shadow_bottom != white)
698 XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L);
701 XFreePixmap (si->dpy, sp->logo_pixmap);
702 if (sp->logo_clipmask)
703 XFreePixmap (si->dpy, sp->logo_clipmask);
706 if (sp->logo_npixels)
707 XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L);
708 free (sp->logo_pixels);
710 sp->logo_npixels = 0;
713 memset (sp, 0, sizeof(*sp));
719 handle_splash_event (saver_info *si, XEvent *event)
721 splash_dialog_data *sp = si->sp_data;
722 saver_screen_info *ssi = sp->prompt_screen;
726 switch (event->xany.type)
729 draw_splash_window (si);
732 case ButtonPress: case ButtonRelease:
734 if (event->xbutton.x >= sp->demo_button_x &&
735 event->xbutton.x < sp->demo_button_x + sp->button_width &&
736 event->xbutton.y >= sp->demo_button_y &&
737 event->xbutton.y < sp->demo_button_y + sp->button_height)
741 else if (event->xbutton.x >= sp->prefs_button_x &&
742 event->xbutton.x < sp->prefs_button_x + sp->button_width &&
743 event->xbutton.y >= sp->prefs_button_y &&
744 event->xbutton.y < sp->prefs_button_y + sp->button_height)
746 #endif /* PREFS_BUTTON */
748 else if (event->xbutton.x >= sp->help_button_x &&
749 event->xbutton.x < sp->help_button_x + sp->button_width &&
750 event->xbutton.y >= sp->help_button_y &&
751 event->xbutton.y < sp->help_button_y + sp->button_height)
754 if (event->xany.type == ButtonPress)
757 update_splash_window (si);
759 XBell (si->dpy, False);
761 else if (event->xany.type == ButtonRelease)
763 if (which && sp->pressed == which)
765 destroy_splash_window (si);
769 case 1: do_demo (ssi); break;
771 case 2: do_prefs (ssi); break;
772 #endif /* PREFS_BUTTON */
773 case 3: do_help (ssi); break;
777 else if (which == 0 && sp->pressed == 0)
779 /* click and release on the window but not in a button:
780 treat that as "dismiss the splash dialog." */
781 destroy_splash_window (si);
784 if (sp) sp->pressed = 0;
785 update_splash_window (si);
795 unsplash_timer (XtPointer closure, XtIntervalId *id)
797 saver_info *si = (saver_info *) closure;
798 if (si && si->sp_data)
799 destroy_splash_window (si);
803 /* Button callbacks */
812 do_demo (saver_screen_info *ssi)
814 saver_info *si = ssi->global;
815 saver_preferences *p = &si->prefs;
816 const char *cmd = p->demo_command;
819 fork_and_exec (ssi, cmd);
821 fprintf (stderr, "%s: no demo-mode command has been specified.\n",
827 do_prefs (saver_screen_info *ssi)
829 saver_info *si = ssi->global;
830 saver_preferences *p = &si->prefs;
831 const char *cmd = p->prefs_command;
833 if (command && *command)
834 fork_and_exec (ssi, cmd);
836 fprintf (stderr, "%s: no preferences command has been specified.\n",
839 #endif /* PREFS_BUTTON */
842 do_help (saver_screen_info *ssi)
844 saver_info *si = ssi->global;
845 saver_preferences *p = &si->prefs;
846 char *help_command = 0;
848 if (!p->load_url_command || !*p->load_url_command)
850 fprintf (stderr, "%s: no URL command has been specified.\n", blurb());
853 if (!p->help_url || !*p->help_url)
855 fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
859 help_command = (char *) malloc (strlen (p->load_url_command) +
860 (strlen (p->help_url) * 4) + 10);
861 sprintf (help_command, p->load_url_command,
862 p->help_url, p->help_url, p->help_url, p->help_url);
864 fork_and_exec (ssi, help_command);