Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Aug 2014 15:36:58 +0000 (UTC)
From:      Jean-Sebastien Pedron <dumbbell@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r270338 - in head/sys/dev/vt: . hw/vga
Message-ID:  <201408221536.s7MFawui006620@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dumbbell
Date: Fri Aug 22 15:36:57 2014
New Revision: 270338
URL: http://svnweb.freebsd.org/changeset/base/270338

Log:
  vt(4): The offset to center the text area is per-window now
  
  The previous global offset, based on the last loaded font, had no
  meaning for other windows. This caused a shifted text area, often partly
  out-of-screen.
  
  MFC after:	1 week

Modified:
  head/sys/dev/vt/hw/vga/vt_vga.c
  head/sys/dev/vt/vt.h
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/hw/vga/vt_vga.c
==============================================================================
--- head/sys/dev/vt/hw/vga/vt_vga.c	Fri Aug 22 15:34:56 2014	(r270337)
+++ head/sys/dev/vt/hw/vga/vt_vga.c	Fri Aug 22 15:36:57 2014	(r270338)
@@ -556,13 +556,13 @@ vga_bitblt_one_text_pixels_block(struct 
 	memset(pattern_2colors, 0, sizeof(pattern_2colors));
 	memset(pattern_ncolors, 0, sizeof(pattern_ncolors));
 
-	if (i < vd->vd_offset.tp_col) {
+	if (i < vw->vw_offset.tp_col) {
 		/*
 		 * i is in the margin used to center the text area on
 		 * the screen.
 		 */
 
-		i = vd->vd_offset.tp_col;
+		i = vw->vw_offset.tp_col;
 	}
 
 	while (i < x + VT_VGA_PIXELS_BLOCK) {
@@ -573,8 +573,8 @@ vga_bitblt_one_text_pixels_block(struct 
 		 * While here, record what colors it uses.
 		 */
 
-		col = (i - vd->vd_offset.tp_col) / vf->vf_width;
-		row = (y - vd->vd_offset.tp_row) / vf->vf_height;
+		col = (i - vw->vw_offset.tp_col) / vf->vf_width;
+		row = (y - vw->vw_offset.tp_row) / vf->vf_height;
 
 		c = VTBUF_GET_FIELD(vb, row, col);
 		src = vtfont_lookup(vf, c);
@@ -605,11 +605,11 @@ vga_bitblt_one_text_pixels_block(struct 
 		 * character.
 		 */
 
-		src_x = i - (col * vf->vf_width + vd->vd_offset.tp_col);
+		src_x = i - (col * vf->vf_width + vw->vw_offset.tp_col);
 		x_count = min(
-		    (col + 1) * vf->vf_width + vd->vd_offset.tp_col,
+		    (col + 1) * vf->vf_width + vw->vw_offset.tp_col,
 		    x + VT_VGA_PIXELS_BLOCK);
-		x_count -= col * vf->vf_width + vd->vd_offset.tp_col;
+		x_count -= col * vf->vf_width + vw->vw_offset.tp_col;
 		x_count -= src_x;
 
 		/* Copy a portion of the character. */
@@ -632,8 +632,8 @@ vga_bitblt_one_text_pixels_block(struct 
 	 * to mark the area dirty.
 	 */
 	cursor = vd->vd_mcursor;
-	mx = vd->vd_moldx + vd->vd_offset.tp_col;
-	my = vd->vd_moldy + vd->vd_offset.tp_row;
+	mx = vd->vd_moldx + vw->vw_offset.tp_col;
+	my = vd->vd_moldy + vw->vw_offset.tp_row;
 	if (cursor_displayed &&
 	    ((mx >= x && x + VT_VGA_PIXELS_BLOCK - 1 >= mx) ||
 	     (mx < x && mx + cursor->width >= x)) &&
@@ -720,10 +720,10 @@ vga_bitblt_text_gfxmode(struct vt_device
 
 	col = area->tr_begin.tp_col;
 	row = area->tr_begin.tp_row;
-	x1 = (int)((col * vf->vf_width + vd->vd_offset.tp_col)
+	x1 = (int)((col * vf->vf_width + vw->vw_offset.tp_col)
 	     / VT_VGA_PIXELS_BLOCK)
 	    * VT_VGA_PIXELS_BLOCK;
-	y1 = row * vf->vf_height + vd->vd_offset.tp_row;
+	y1 = row * vf->vf_height + vw->vw_offset.tp_row;
 
 	/*
 	 * Compute the bottom right pixel position, again, aligned with
@@ -735,11 +735,11 @@ vga_bitblt_text_gfxmode(struct vt_device
 
 	col = area->tr_end.tp_col;
 	row = area->tr_end.tp_row;
-	x2 = (int)((col * vf->vf_width + vd->vd_offset.tp_col
+	x2 = (int)((col * vf->vf_width + vw->vw_offset.tp_col
 	      + VT_VGA_PIXELS_BLOCK - 1)
 	     / VT_VGA_PIXELS_BLOCK)
 	    * VT_VGA_PIXELS_BLOCK;
-	y2 = row * vf->vf_height + vd->vd_offset.tp_row;
+	y2 = row * vf->vf_height + vw->vw_offset.tp_row;
 
 	/*
 	 * Clip the area to the screen size.

Modified: head/sys/dev/vt/vt.h
==============================================================================
--- head/sys/dev/vt/vt.h	Fri Aug 22 15:34:56 2014	(r270337)
+++ head/sys/dev/vt/vt.h	Fri Aug 22 15:36:57 2014	(r270338)
@@ -136,7 +136,6 @@ struct vt_device {
 	vt_axis_t		 vd_moldx;	/* (?) Mouse X as of last redraw. */
 	vt_axis_t		 vd_moldy;	/* (?) Mouse Y as of last redraw. */
 	uint32_t		 vd_mstate;	/* (?) Mouse state. */
-	term_pos_t		 vd_offset;	/* (?) Pixel offset. */
 	vt_axis_t		 vd_width;	/* (?) Screen width. */
 	vt_axis_t		 vd_height;	/* (?) Screen height. */
 	struct mtx		 vd_lock;	/* Per-device lock. */
@@ -258,6 +257,7 @@ struct vt_window {
 	struct terminal		*vw_terminal;	/* (c) Terminal. */
 	struct vt_buf		 vw_buf;	/* (u) Screen buffer. */
 	struct vt_font		*vw_font;	/* (d) Graphical font. */
+	term_pos_t		 vw_offset;	/* (?) Pixel offset. */
 	unsigned int		 vw_number;	/* (c) Window number. */
 	int			 vw_kbdmode;	/* (?) Keyboard mode. */
 	char			*vw_kbdsq;	/* Escape sequence queue*/

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Fri Aug 22 15:34:56 2014	(r270337)
+++ head/sys/dev/vt/vt_core.c	Fri Aug 22 15:36:57 2014	(r270338)
@@ -837,8 +837,8 @@ vt_bitblt_char(struct vt_device *vd, str
 		 * Fonts may not always be able to fill the entire
 		 * screen.
 		 */
-		top = row * vf->vf_height + vd->vd_offset.tp_row;
-		left = col * vf->vf_width + vd->vd_offset.tp_col;
+		top = row * vf->vf_height + vd->vd_curwindow->vw_offset.tp_row;
+		left = col * vf->vf_width + vd->vd_curwindow->vw_offset.tp_col;
 
 		vd->vd_driver->vd_bitbltchr(vd, src, NULL, 0, top, left,
 		    vf->vf_width, vf->vf_height, fg, bg);
@@ -973,8 +973,8 @@ vt_flush(struct vt_device *vd)
 
 			vd->vd_driver->vd_bitbltchr(vd,
 			    vd->vd_mcursor->map, vd->vd_mcursor->mask, bpl,
-			    vd->vd_offset.tp_row + vd->vd_my,
-			    vd->vd_offset.tp_col + vd->vd_mx,
+			    vw->vw_offset.tp_row + vd->vd_my,
+			    vw->vw_offset.tp_col + vd->vd_mx,
 			    w, h, vd->vd_mcursor_fg, vd->vd_mcursor_bg);
 		}
 #endif
@@ -1248,8 +1248,8 @@ vt_change_font(struct vt_window *vw, str
 	vt_termsize(vd, vf, &size);
 	vt_winsize(vd, vf, &wsz);
 	/* Save offset to font aligned area. */
-	vd->vd_offset.tp_col = (vd->vd_width % vf->vf_width) / 2;
-	vd->vd_offset.tp_row = (vd->vd_height % vf->vf_height) / 2;
+	vw->vw_offset.tp_col = (vd->vd_width % vf->vf_width) / 2;
+	vw->vw_offset.tp_row = (vd->vd_height % vf->vf_height) / 2;
 
 	/* Grow the screen buffer and terminal. */
 	terminal_mute(tm, 1);
@@ -1287,8 +1287,8 @@ vt_set_border(struct vt_window *vw, stru
 
 	x = vd->vd_width - 1;
 	y = vd->vd_height - 1;
-	off_x = vd->vd_offset.tp_col;
-	off_y = vd->vd_offset.tp_row;
+	off_x = vw->vw_offset.tp_col;
+	off_y = vw->vw_offset.tp_row;
 
 	/* Top bar. */
 	if (off_y > 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408221536.s7MFawui006620>