X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fstarwars.c;h=55c6198226a309bc1b2d0b77571b4d5b7cb4b05e;hb=e4fa2ac140f7bc56571373a7b7eb585fa4500e38;hp=fb58e4c525d90596f820f2f7a285352bb3381fe7;hpb=a1d41b2aa6e18bf9a49b914a99dda8232c5d7762;p=xscreensaver diff --git a/hacks/glx/starwars.c b/hacks/glx/starwars.c index fb58e4c5..55c61982 100644 --- a/hacks/glx/starwars.c +++ b/hacks/glx/starwars.c @@ -1,5 +1,5 @@ /* - * starwars, Copyright (c) 1998-2001 Jamie Zawinski and + * starwars, Copyright (c) 1998-2001, 2004 Jamie Zawinski and * Claudio Matsuoka * * Permission to use, copy, modify, distribute, and sell this software and its @@ -87,12 +87,17 @@ extern XtAppContext app; #ifdef USE_GL /* whole file */ +#include #include #include #include "glutstroke.h" #include "glut_roman.h" #define GLUT_FONT (&glutStrokeRoman) +#ifdef HAVE_UNAME +# include +#endif /* HAVE_UNAME */ + typedef struct { GLXContext *glx_context; @@ -157,17 +162,17 @@ static XrmOptionDescRec opts[] = { }; static argtype vars[] = { - {(caddr_t *) &program, "program", "Program", DEF_PROGRAM, t_String}, - {(caddr_t *) &max_lines, "lines", "Integer", DEF_LINES, t_Int}, - {(caddr_t *) &scroll_steps, "steps", "Integer", DEF_STEPS, t_Int}, - {(caddr_t *) &star_spin, "spin", "Float", DEF_SPIN, t_Float}, - {(caddr_t *) &font_size, "fontSize","Float", DEF_STEPS, t_Float}, - {(caddr_t *) &target_columns, "columns", "Integer", DEF_COLUMNS, t_Int}, - {(caddr_t *) &wrap_p, "lineWrap","Boolean", DEF_COLUMNS, t_Bool}, - {(caddr_t *) &alignment_str, "alignment","Alignment",DEF_ALIGN, t_String}, - {(caddr_t *) &smooth_p, "smooth", "Boolean", DEF_SMOOTH, t_Bool}, - {(caddr_t *) &thick_p, "thick", "Boolean", DEF_THICK, t_Bool}, - {(caddr_t *) &fade_p, "fade", "Boolean", DEF_FADE, t_Bool}, + {&program, "program", "Program", DEF_PROGRAM, t_String}, + {&max_lines, "lines", "Integer", DEF_LINES, t_Int}, + {&scroll_steps, "steps", "Integer", DEF_STEPS, t_Int}, + {&star_spin, "spin", "Float", DEF_SPIN, t_Float}, + {&font_size, "fontSize", "Float", DEF_STEPS, t_Float}, + {&target_columns, "columns", "Integer", DEF_COLUMNS, t_Int}, + {&wrap_p, "lineWrap", "Boolean", DEF_COLUMNS, t_Bool}, + {&alignment_str, "alignment", "Alignment", DEF_ALIGN, t_String}, + {&smooth_p, "smooth", "Boolean", DEF_SMOOTH, t_Bool}, + {&thick_p, "thick", "Boolean", DEF_THICK, t_Bool}, + {&fade_p, "fade", "Boolean", DEF_FADE, t_Bool}, }; ModeSpecOpt sws_opts = {countof(opts), opts, countof(vars), vars, NULL}; @@ -258,18 +263,55 @@ launch_text_generator (sws_configuration *sc) if (!strcasecmp(oprogram, "(default)")) { -#ifdef __linux__ - static int done_once = 0; - struct stat st; - char *cmd = "cat /usr/src/linux/README"; - if (!(done_once++) && !stat (cmd+4, &st)) - oprogram = cmd; - else -#endif - oprogram = ZIPPY_PROGRAM; + oprogram = FORTUNE_PROGRAM; + +#if defined(__linux__) && defined(HAVE_UNAME) + { + static int done_once = 0; + if (!done_once) + { + struct utsname uts; + struct stat st; + done_once = 1; + if (uname (&uts) == 0) + { + static char cmd[200]; + char *s; + /* strip version at the first non-digit-dash-dot, to + lose any "SMP" crap at the end. */ + for (s = uts.release; *s; s++) + if (!isdigit(*s) && *s != '.' && *s != '-') + *s = 0; + sprintf (cmd, "cat /usr/src/linux-%s/README", uts.release); + if (!stat (cmd+4, &st)) + oprogram = cmd; + else + { + /* kernel source not installed? try X... */ + strcpy (cmd, "cat /usr/X11R6/lib/X11/doc/README"); + if (!stat (cmd+4, &st)) + oprogram = cmd; + } + } + } + } +#endif /* __linux__ && HAVE_UNAME */ + +#ifdef __APPLE__ /* MacOS X + XDarwin */ + { + static int done_once = 0; + if (!done_once) + { + struct stat st; + static char *cmd = "cat /usr/X11R6/README"; + if (!stat (cmd+4, &st)) + oprogram = cmd; + } + } +#endif /* __APPLE__ */ } - program = (char *) malloc (strlen (oprogram) + 10); + program = (char *) malloc (strlen (oprogram) + 10); strcpy (program, "( "); strcat (program, oprogram); strcat (program, " ) 2>&1"); @@ -401,7 +443,7 @@ get_more_lines (sws_configuration *sc) if (sc->buf_tail > (s - sc->buf)) { int i = sc->buf_tail - (s - sc->buf); - memcpy (sc->buf, s, i); + memmove (sc->buf, s, i); sc->buf_tail = i; sc->buf[sc->buf_tail] = 0; } @@ -721,6 +763,9 @@ init_sws (ModeInfo *mi) } launch_text_generator (sc); + + /* one more reshape, after line_height has been computed */ + reshape_sws (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } @@ -860,7 +905,9 @@ draw_sws (ModeInfo *mi) } if (alignment >= 0) - xoff = 1.0 - (glutStrokeLength(GLUT_FONT, line) * sc->font_scale); + xoff = 1.0 - (glutStrokeLength(GLUT_FONT, + (unsigned char *) line) + * sc->font_scale); if (alignment == 0) xoff /= 2;