summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-11-03 22:21:37 +0000
committered <ed@FreeBSD.org>2012-11-03 22:21:37 +0000
commite77bf633a0b379566f2c9ad79dc776ed4c716f54 (patch)
treecf775c9d71eb160c1590d5834065535cef959157
parenta842b8978aefab172b0bcf05a00fd85ef09ad4e1 (diff)
downloadFreeBSD-src-e77bf633a0b379566f2c9ad79dc776ed4c716f54.zip
FreeBSD-src-e77bf633a0b379566f2c9ad79dc776ed4c716f54.tar.gz
Add tty_set_winsize().
This removes some of the signalling magic from the Syscons driver and puts it in the TTY layer, where it belongs.
-rw-r--r--sys/dev/syscons/scvidctl.c45
-rw-r--r--sys/kern/tty.c15
-rw-r--r--sys/sys/tty.h1
3 files changed, 24 insertions, 37 deletions
diff --git a/sys/dev/syscons/scvidctl.c b/sys/dev/syscons/scvidctl.c
index 7e26fcf..6ae923d 100644
--- a/sys/dev/syscons/scvidctl.c
+++ b/sys/dev/syscons/scvidctl.c
@@ -137,6 +137,7 @@ sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
int fontsize, int fontwidth)
{
video_info_t info;
+ struct winsize wsz;
u_char *font;
int prev_ysize;
int error;
@@ -234,16 +235,9 @@ sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
if (tp == NULL)
return 0;
- DPRINTF(5, ("ws_*size (%d,%d), size (%d,%d)\n",
- tp->t_winsize.ws_col, tp->t_winsize.ws_row, scp->xsize, scp->ysize));
- if (tp->t_winsize.ws_col != scp->xsize
- || tp->t_winsize.ws_row != scp->ysize) {
- tp->t_winsize.ws_col = scp->xsize;
- tp->t_winsize.ws_row = scp->ysize;
-
- tty_signal_pgrp(tp, SIGWINCH);
- }
-
+ wsz.ws_col = scp->xsize;
+ wsz.ws_row = scp->ysize;
+ tty_set_winsize(tp, &wsz);
return 0;
}
@@ -254,6 +248,7 @@ sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
return ENODEV;
#else
video_info_t info;
+ struct winsize wsz;
int error;
int s;
@@ -300,14 +295,9 @@ sc_set_graphics_mode(scr_stat *scp, struct tty *tp, int mode)
if (tp == NULL)
return 0;
- if (tp->t_winsize.ws_xpixel != scp->xpixel
- || tp->t_winsize.ws_ypixel != scp->ypixel) {
- tp->t_winsize.ws_xpixel = scp->xpixel;
- tp->t_winsize.ws_ypixel = scp->ypixel;
-
- tty_signal_pgrp(tp, SIGWINCH);
- }
-
+ wsz.ws_col = scp->xsize;
+ wsz.ws_row = scp->ysize;
+ tty_set_winsize(tp, &wsz);
return 0;
#endif /* SC_NO_MODE_CHANGE */
}
@@ -320,7 +310,7 @@ sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
return ENODEV;
#else
video_info_t info;
- ksiginfo_t ksi;
+ struct winsize wsz;
u_char *font;
int prev_ysize;
int error;
@@ -425,20 +415,9 @@ sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
if (tp == NULL)
return 0;
- if (tp->t_winsize.ws_col != scp->xsize
- || tp->t_winsize.ws_row != scp->ysize) {
- tp->t_winsize.ws_col = scp->xsize;
- tp->t_winsize.ws_row = scp->ysize;
- if (tp->t_pgrp != NULL) {
- ksiginfo_init(&ksi);
- ksi.ksi_signo = SIGWINCH;
- ksi.ksi_code = SI_KERNEL;
- PGRP_LOCK(tp->t_pgrp);
- pgsignal(tp->t_pgrp, SIGWINCH, 1, &ksi);
- PGRP_UNLOCK(tp->t_pgrp);
- }
- }
-
+ wsz.ws_col = scp->xsize;
+ wsz.ws_row = scp->ysize;
+ tty_set_winsize(tp, &wsz);
return 0;
#endif /* SC_PIXEL_MODE */
}
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 4da8d38..e6d0d80 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1381,6 +1381,16 @@ tty_flush(struct tty *tp, int flags)
}
}
+void
+tty_set_winsize(struct tty *tp, const struct winsize *wsz)
+{
+
+ if (memcmp(&tp->t_winsize, wsz, sizeof(*wsz)) == 0)
+ return;
+ tp->t_winsize = *wsz;
+ tty_signal_pgrp(tp, SIGWINCH);
+}
+
static int
tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
struct thread *td)
@@ -1689,10 +1699,7 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
return (0);
case TIOCSWINSZ:
/* Set window size. */
- if (bcmp(&tp->t_winsize, data, sizeof(struct winsize)) == 0)
- return (0);
- tp->t_winsize = *(struct winsize*)data;
- tty_signal_pgrp(tp, SIGWINCH);
+ tty_set_winsize(tp, data);
return (0);
case TIOCEXCL:
tp->t_flags |= TF_EXCLUDE;
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 96b8821..c4d4d41 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -192,6 +192,7 @@ int tty_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
struct thread *td);
int tty_ioctl_compat(struct tty *tp, u_long cmd, caddr_t data,
int fflag, struct thread *td);
+void tty_set_winsize(struct tty *tp, const struct winsize *wsz);
void tty_init_console(struct tty *tp, speed_t speed);
void tty_flush(struct tty *tp, int flags);
void tty_hiwat_in_block(struct tty *tp);
OpenPOWER on IntegriCloud