- Define a convenience macro ISTTYOPEN().

- Slightly refine screen saver logic.

No functional change.
MFC after:	2 weeks
This commit is contained in:
yokota 2001-07-12 11:43:29 +00:00
parent 5b4d2518a8
commit 116d68b2a9
2 changed files with 29 additions and 21 deletions

View File

@ -99,7 +99,7 @@ static char init_done = COLD;
static char shutdown_in_progress = FALSE;
static char sc_malloc = FALSE;
static int saver_mode = CONS_LKM_SAVER; /* LKM/user saver */
static int saver_mode = CONS_NO_SAVER; /* LKM/user saver */
static int run_scrn_saver = FALSE; /* should run the saver? */
static long scrn_blank_time = 0; /* screen saver timeout value */
#if NSPLASH > 0
@ -126,6 +126,7 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key,
#define VIRTUAL_TTY(sc, x) (SC_DEV((sc), (x)) != NULL ? \
SC_DEV((sc), (x))->si_tty : NULL)
#define ISTTYOPEN(tp) ((tp) && ((tp)->t_state & TS_ISOPEN))
static int debugger;
@ -459,7 +460,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
tp->t_param = scparam;
tp->t_stop = nottystop;
tp->t_dev = dev;
if (!(tp->t_state & TS_ISOPEN)) {
if (!ISTTYOPEN(tp)) {
ttychars(tp);
/* Use the current setting of the <-- key as default VERASE. */
/* If the Delete key is preferable, an stty is necessary */
@ -591,11 +592,11 @@ sckbdevent(keyboard_t *thiskbd, int event, void *arg)
while ((c = scgetc(sc, SCGETC_NONBLOCK)) != NOKEY) {
cur_tty = VIRTUAL_TTY(sc, sc->cur_scp->index);
/* XXX */
if (!(cur_tty->t_state & TS_ISOPEN))
if (((cur_tty = sc_console_tty) == NULL)
|| !(cur_tty->t_state & TS_ISOPEN))
if (!ISTTYOPEN(cur_tty)) {
cur_tty = sc_console_tty;
if (!ISTTYOPEN(cur_tty))
continue;
}
if ((*sc->cur_scp->tsw->te_input)(sc->cur_scp, c, cur_tty))
continue;
@ -785,6 +786,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
case CONS_SAVERMODE: /* set saver mode */
switch(*(int *)data) {
case CONS_NO_SAVER:
case CONS_USR_SAVER:
/* if a LKM screen saver is running, stop it first. */
scsplash_stick(FALSE);
@ -797,7 +799,10 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
}
#endif /* NSPLASH */
run_scrn_saver = TRUE;
scp->status |= SAVER_RUNNING;
if (saver_mode == CONS_USR_SAVER)
scp->status |= SAVER_RUNNING;
else
scp->status &= ~SAVER_RUNNING;
scsplash_stick(TRUE);
splx(s);
break;
@ -958,7 +963,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
case VT_OPENQRY: /* return free virtual console */
for (i = sc->first_vty; i < sc->first_vty + sc->vtys; i++) {
tp = VIRTUAL_TTY(sc, i);
if ((tp == NULL) || !(tp->t_state & TS_ISOPEN)) {
if (!ISTTYOPEN(tp)) {
*(int *)data = i + 1;
return 0;
}
@ -1456,7 +1461,7 @@ sccnputc(dev_t dev, int c)
sc_draw_cursor_image(scp);
}
tp = VIRTUAL_TTY(scp->sc, scp->index);
if (tp->t_state & TS_ISOPEN)
if (ISTTYOPEN(tp))
scstart(tp);
}
#endif /* !SC_NO_HISTORY */
@ -1611,7 +1616,7 @@ sccnupdate(scr_stat *scp)
* when write_in_progress is non-zero. XXX
*/
if (!ISGRAPHSC(scp) && !(scp->status & SAVER_RUNNING))
if (!ISGRAPHSC(scp) && !(scp->sc->flags & SC_SCRN_BLANKED))
scrn_update(scp, TRUE);
}
@ -1692,7 +1697,7 @@ scrn_timer(void *arg)
/* Update the screen */
scp = sc->cur_scp; /* cur_scp may have changed... */
if (!ISGRAPHSC(scp) && !(scp->status & SAVER_RUNNING))
if (!ISGRAPHSC(scp) && !(sc->flags & SC_SCRN_BLANKED))
scrn_update(scp, TRUE);
#if NSPLASH > 0
@ -2208,7 +2213,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
*/
tp = VIRTUAL_TTY(sc, sc->cur_scp->index);
if ((sc->cur_scp->index != next_scr)
&& (tp->t_state & TS_ISOPEN)
&& ISTTYOPEN(tp)
&& (sc->cur_scp->smode.mode == VT_AUTO)
&& ISGRAPHSC(sc->cur_scp)) {
splx(s);
@ -2225,7 +2230,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
*/
if ((sc_console == NULL) || (next_scr != sc_console->index)) {
tp = VIRTUAL_TTY(sc, next_scr);
if ((tp == NULL) || !(tp->t_state & TS_ISOPEN)) {
if (!ISTTYOPEN(tp)) {
splx(s);
sc_bell(sc->cur_scp, bios_value.bell_pitch, BELL_DURATION);
DPRINTF(5, ("error 2, requested vty isn't open!\n"));
@ -2745,11 +2750,13 @@ sc_clean_up(scr_stat *scp)
int error;
#endif /* NSPLASH */
sc_touch_scrn_saver();
if (scp->sc->flags & SC_SCRN_BLANKED) {
sc_touch_scrn_saver();
#if NSPLASH > 0
if ((error = wait_scrn_saver_stop(scp->sc)))
return error;
if ((error = wait_scrn_saver_stop(scp->sc)))
return error;
#endif /* NSPLASH */
}
scp->status |= MOUSE_HIDDEN;
sc_remove_mouse_image(scp);
sc_remove_cutmarking(scp);
@ -3086,7 +3093,7 @@ scgetc(sc_softc_t *sc, u_int flags)
sc_draw_cursor_image(scp);
}
tp = VIRTUAL_TTY(sc, scp->index);
if (tp->t_state & TS_ISOPEN)
if (ISTTYOPEN(tp))
scstart(tp);
#endif
}
@ -3189,7 +3196,7 @@ scgetc(sc_softc_t *sc, u_int flags)
sc->first_vty + i != this_scr;
i = (i + 1)%sc->vtys) {
struct tty *tp = VIRTUAL_TTY(sc, sc->first_vty + i);
if (tp && tp->t_state & TS_ISOPEN) {
if (ISTTYOPEN(tp)) {
sc_switch_scr(scp->sc, sc->first_vty + i);
break;
}
@ -3202,7 +3209,7 @@ scgetc(sc_softc_t *sc, u_int flags)
sc->first_vty + i != this_scr;
i = (i + sc->vtys - 1)%sc->vtys) {
struct tty *tp = VIRTUAL_TTY(sc, sc->first_vty + i);
if (tp && tp->t_state & TS_ISOPEN) {
if (ISTTYOPEN(tp)) {
sc_switch_scr(scp->sc, sc->first_vty + i);
break;
}
@ -3390,7 +3397,7 @@ sc_paste(scr_stat *scp, u_char *p, int count)
u_char *rmap;
tp = VIRTUAL_TTY(scp->sc, scp->sc->cur_scp->index);
if (!(tp->t_state & TS_ISOPEN))
if (!ISTTYOPEN(tp))
return;
rmap = scp->sc->scr_rmap;
for (; count > 0; --count)
@ -3430,7 +3437,7 @@ blink_screen(void *arg)
scp->sc->blink_in_progress = 0;
mark_all(scp);
tp = VIRTUAL_TTY(scp->sc, scp->index);
if (tp->t_state & TS_ISOPEN)
if (ISTTYOPEN(tp))
scstart(tp);
if (scp->sc->delayed_next_scr)
sc_switch_scr(scp->sc, scp->sc->delayed_next_scr - 1);

View File

@ -167,6 +167,7 @@ typedef struct mouse_info mouse_info_t;
#define CONS_IDLE _IOR('c', 11, int)
/* set the screen saver mode */
#define CONS_NO_SAVER (-1)
#define CONS_LKM_SAVER 0
#define CONS_USR_SAVER 1
#define CONS_SAVERMODE _IOW('c', 12, int)