From owner-svn-src-head@FreeBSD.ORG Fri Aug 22 17:09:33 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 07C6847F; Fri, 22 Aug 2014 17:09:33 +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 DBD843BD8; Fri, 22 Aug 2014 17:09:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7MH9WDb049326; Fri, 22 Aug 2014 17:09:32 GMT (envelope-from dumbbell@FreeBSD.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7MH9W3Y049318; Fri, 22 Aug 2014 17:09:32 GMT (envelope-from dumbbell@FreeBSD.org) Message-Id: <201408221709.s7MH9W3Y049318@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dumbbell set sender to dumbbell@FreeBSD.org using -f From: Jean-Sebastien Pedron Date: Fri, 22 Aug 2014 17:09:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270342 - 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-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2014 17:09:33 -0000 Author: dumbbell Date: Fri Aug 22 17:09:31 2014 New Revision: 270342 URL: http://svnweb.freebsd.org/changeset/base/270342 Log: vt(4): Use the actual size of the mouse when marking its position as dirty This fixes a bug where part of the cursor was not erased. MFC after: 1 week Modified: head/sys/dev/vt/vt.h head/sys/dev/vt/vt_buf.c head/sys/dev/vt/vt_core.c Modified: head/sys/dev/vt/vt.h ============================================================================== --- head/sys/dev/vt/vt.h Fri Aug 22 17:05:41 2014 (r270341) +++ head/sys/dev/vt/vt.h Fri Aug 22 17:09:31 2014 (r270342) @@ -203,12 +203,12 @@ void vtbuf_grow(struct vt_buf *, const t void vtbuf_putchar(struct vt_buf *, const term_pos_t *, term_char_t); void vtbuf_cursor_position(struct vt_buf *, const term_pos_t *); void vtbuf_scroll_mode(struct vt_buf *vb, int yes); +void vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area); void vtbuf_undirty(struct vt_buf *, term_rect_t *, struct vt_bufmask *); void vtbuf_sethistory_size(struct vt_buf *, int); int vtbuf_iscursor(const struct vt_buf *vb, int row, int col); void vtbuf_cursor_visibility(struct vt_buf *, int); #ifndef SC_NO_CUTPASTE -void vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row); int vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row); int vtbuf_get_marked_len(struct vt_buf *vb); void vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz); Modified: head/sys/dev/vt/vt_buf.c ============================================================================== --- head/sys/dev/vt/vt_buf.c Fri Aug 22 17:05:41 2014 (r270341) +++ head/sys/dev/vt/vt_buf.c Fri Aug 22 17:09:31 2014 (r270342) @@ -246,7 +246,7 @@ vtbuf_dirty_locked(struct vt_buf *vb, co vtbuf_dirty_axis(area->tr_begin.tp_col, area->tr_end.tp_col); } -static inline void +void vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area) { @@ -558,18 +558,6 @@ vtbuf_cursor_position(struct vt_buf *vb, } #ifndef SC_NO_CUTPASTE -void -vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row) -{ - term_rect_t area; - - area.tr_begin.tp_row = MAX(row - 1, 0); - area.tr_begin.tp_col = MAX(col - 1, 0); - area.tr_end.tp_row = MIN(row + 2, vb->vb_scr_size.tp_row); - area.tr_end.tp_col = MIN(col + 2, vb->vb_scr_size.tp_col); - vtbuf_dirty(vb, &area); -} - static void vtbuf_flush_mark(struct vt_buf *vb) { Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Fri Aug 22 17:05:41 2014 (r270341) +++ head/sys/dev/vt/vt_core.c Fri Aug 22 17:09:31 2014 (r270342) @@ -819,6 +819,28 @@ vt_determine_colors(term_char_t c, int c } static void +vt_mark_mouse_position_as_dirty(struct vt_device *vd, int x, int y) +{ + term_rect_t area; + struct vt_window *vw; + struct vt_font *vf; + + vw = vd->vd_curwindow; + vf = vw->vw_font; + + area.tr_begin.tp_col = (x - vw->vw_offset.tp_col) / vf->vf_width; + area.tr_begin.tp_row = (y - vw->vw_offset.tp_row) / vf->vf_height; + area.tr_end.tp_col = + ((x + vd->vd_mcursor->width - vw->vw_offset.tp_col) / + vf->vf_width) + 1; + area.tr_end.tp_row = + ((y + vd->vd_mcursor->height - vw->vw_offset.tp_row) / + vf->vf_height) + 1; + + vtbuf_dirty(&vw->vw_buf, &area); +} + +static void vt_bitblt_char(struct vt_device *vd, struct vt_font *vf, term_char_t c, int iscursor, unsigned int row, unsigned int col) { @@ -884,23 +906,11 @@ vt_flush(struct vt_device *vd) /* * Mark last mouse position as dirty to erase. * - * FIXME: The font size could be different among - * all windows, so the column/row calculation - * below isn't correct for all windows. - * - * FIXME: The cursor can span more than one - * character cell. vtbuf_mouse_cursor_position - * marks surrounding cells as dirty. But due - * to font size possibly inconsistent across - * windows, this may not be sufficient. This - * causes part of the cursor to not be erased. - * * FIXME: The vt_buf lock is acquired twice in a * row. */ - vtbuf_mouse_cursor_position(&vw->vw_buf, - vd->vd_moldx / vf->vf_width, - vd->vd_moldy / vf->vf_height); + vt_mark_mouse_position_as_dirty(vd, + vd->vd_moldx, vd->vd_moldy); /* * Save point of last mouse cursor to erase it @@ -915,9 +925,8 @@ vt_flush(struct vt_device *vd) cursor_displayed = 1; /* Mark new mouse position as dirty. */ - vtbuf_mouse_cursor_position(&vw->vw_buf, - vd->vd_mx / vf->vf_width, - vd->vd_my / vf->vf_height); + vt_mark_mouse_position_as_dirty(vd, + vd->vd_mx, vd->vd_my); } } #endif @@ -1618,14 +1627,8 @@ vt_mouse_state(int show) break; } - /* - * Mark mouse position as dirty. - * - * FIXME: See comments in vt_flush(). - */ - vtbuf_mouse_cursor_position(&vw->vw_buf, - vd->vd_mx / vw->vw_font->vf_width, - vd->vd_my / vw->vw_font->vf_height); + /* Mark mouse position as dirty. */ + vt_mark_mouse_position_as_dirty(vd, vd->vd_mx, vd->vd_my); } #endif