From owner-svn-src-all@FreeBSD.ORG Thu May 29 21:52:43 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2FE32C4D; Thu, 29 May 2014 21:52:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 03EDA2C06; Thu, 29 May 2014 21:52:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4TLqgew041301; Thu, 29 May 2014 21:52:42 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4TLqgwF041300; Thu, 29 May 2014 21:52:42 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201405292152.s4TLqgwF041300@svn.freebsd.org> From: Ed Maste Date: Thu, 29 May 2014 21:52:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266862 - head/sys/dev/vt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 May 2014 21:52:43 -0000 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); }