Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 May 2014 21:52:42 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266862 - head/sys/dev/vt
Message-ID:  <201405292152.s4TLqgwF041300@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Thu May 29 21:52:42 2014
New Revision: 266862
URL: http://svnweb.freebsd.org/changeset/base/266862

Log:
  Correct vt(4) border calculations on font switch
  
  If a vt(4) font does not exactly fit the screen dimensions, the console
  window is offset so that it is centered.  A rectangle is drawn at the
  top, left, right, and bottom of the screen, to erase any leftovers that
  are outside of the new usable console area.
  
  If the x offset or y offset is 0 then the left border or top border
  respectively is not drawn.  The right and bottom borders may be one
  pixel larger than necessary due to rounding, and are always drawn.
  
  Prior to this change a 0 offset would result in a panic when calling
  vt_drawrect with an x or y coordinate of -1.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Thu May 29 21:10:33 2014	(r266861)
+++ head/sys/dev/vt/vt_core.c	Thu May 29 21:52:42 2014	(r266862)
@@ -1171,22 +1171,27 @@ static int
 vt_set_border(struct vt_window *vw, struct vt_font *vf, term_color_t c)
 {
 	struct vt_device *vd = vw->vw_device;
-	int l, r, t, b, w, h;
+	int x, y, off_x, off_y;
 
 	if (vd->vd_driver->vd_drawrect == NULL)
 		return (ENOTSUP);
 
-	w = vd->vd_width - 1;
-	h = vd->vd_height - 1;
-	l = vd->vd_offset.tp_col - 1;
-	r = w - l;
-	t = vd->vd_offset.tp_row - 1;
-	b = h - t;
-
-	vd->vd_driver->vd_drawrect(vd, 0, 0, w, t, 1, c); /* Top bar. */
-	vd->vd_driver->vd_drawrect(vd, 0, t, l, b, 1, c); /* Left bar. */
-	vd->vd_driver->vd_drawrect(vd, r, t, w, b, 1, c); /* Right bar. */
-	vd->vd_driver->vd_drawrect(vd, 0, b, w, h, 1, c); /* Bottom bar. */
+	x = vd->vd_width - 1;
+	y = vd->vd_height - 1;
+	off_x = vd->vd_offset.tp_col;
+	off_y = vd->vd_offset.tp_row;
+
+	/* Top bar. */
+	if (off_y > 0)
+		vd->vd_driver->vd_drawrect(vd, 0, 0, x, off_y - 1, 1, c);
+	/* Left bar. */
+	if (off_x > 0)
+		vd->vd_driver->vd_drawrect(vd, 0, off_y, off_x - 1, y - off_y,
+		    1, c);
+	/* Right bar.  May be 1 pixel wider than necessary due to rounding. */
+	vd->vd_driver->vd_drawrect(vd, x - off_x, off_y, x, y - off_y, 1, c);
+	/* Bottom bar.  May be 1 mixel taller than necessary due to rounding. */
+	vd->vd_driver->vd_drawrect(vd, 0, y - off_y, x, y, 1, c);
 
 	return (0);
 }



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