-/* xscreensaver, Copyright (c) 1999-2009 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1999-2011 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
Window window;
XWindowAttributes xgwa;
XFontStruct *font;
+ const char *program;
int grid_width, grid_height;
int char_width, char_height;
int saved_x, saved_y;
state->char_height = font->max_bounds.ascent + font->max_bounds.descent;
}
+ state->program = get_string_resource (dpy, "program", "Program");
+
+
+ /* Kludge for MacOS standalone mode: see OSX/SaverRunner.m. */
+ {
+ const char *s = getenv ("XSCREENSAVER_STANDALONE");
+ if (s && *s && strcmp(s, "0"))
+ {
+ state->mode = 1;
+ state->program = getenv ("SHELL");
+ }
+ }
+
+
state->grid_width = state->xgwa.width / (state->char_width * state->scale);
state->grid_height = state->xgwa.height /(state->char_height * state->scale);
state->cells = (p_cell *) calloc (sizeof(p_cell),
/* Re-query the window size and update the internal character grid if changed.
*/
-static void
+static Bool
resize_grid (p_state *state)
{
int ow = state->grid_width;
if (ow == state->grid_width &&
oh == state->grid_height)
- return;
+ return False;
state->cells = (p_cell *) calloc (sizeof(p_cell),
state->grid_width * state->grid_height);
state->cursor_y = state->grid_height-1;
free (ocells);
+ return True;
}
launch_text_generator (p_state *state)
{
XtAppContext app = XtDisplayToApplicationContext (state->dpy);
- Display *dpy = state->dpy;
char buf[255];
- char *oprogram = get_string_resource (dpy, "program", "Program");
+ const char *oprogram = state->program;
char *program = (char *) malloc (strlen (oprogram) + 50);
strcpy (program, "( ");
relaunch_generator_timer (XtPointer closure, XtIntervalId *id)
{
p_state *state = (p_state *) closure;
- if (!state->pipe_timer) abort();
+ /* if (!state->pipe_timer) abort(); */
state->pipe_timer = 0;
launch_text_generator (state);
}
{
unsigned char s[2];
int n = read (fileno (state->pipe), (void *) s, 1);
+
if (n == 1)
{
print_char (state, s[0]);
unsigned int w, unsigned int h)
{
p_state *state = (p_state *) closure;
- resize_grid (state);
+ Bool changed_p = resize_grid (state);
+
+ if (! changed_p) return;
# if defined(HAVE_FORKPTY) && defined(TIOCSWINSZ)
if (state->pid && state->pipe)
kill (state->pid, SIGWINCH);
}
# endif /* HAVE_FORKPTY && TIOCSWINSZ */
+
+
+ /* If we're running xscreensaver-text, then kill and restart it any
+ time the window is resized so that it gets an updated --cols arg
+ right away. But if we're running something else, leave it alone.
+ */
+ if (!strcmp (state->program, "xscreensaver-text"))
+ {
+ if (state->pid)
+ kill (state->pid, SIGTERM);
+ if (state->pipe)
+ pclose (state->pipe);
+ state->input_available_p = False;
+ relaunch_generator_timer (state, 0);
+ }
}
+
static Bool
phosphor_event (Display *dpy, Window window, void *closure, XEvent *event)
{