From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#50660: 28.0.50; Text artifacting when the cursor moves over text under mouse face that originally displayed a box Date: Mon, 20 Sep 2021 19:08:13 +0800 Message-ID: <87ee9j4i8y.fsf@yahoo.com> References: <87czp6ysw7.fsf.ref@yahoo.com> <87czp6ysw7.fsf@yahoo.com> <87y27uro4c.fsf@gnus.org> <877dfdz9ni.fsf@yahoo.com> <831r5l5d6d.fsf@gnu.org> <87h7egy8jo.fsf@yahoo.com> <838rzs4i09.fsf@gnu.org> <87fsu06oxi.fsf@yahoo.com> <83ee9j3ju3.fsf@gnu.org> <834kaf3ets.fsf@gnu.org> <8335pz3dli.fsf@gnu.org> <87r1dj4q4m.fsf@yahoo.com> <83zgs71su7.fsf@gnu.org> <87k0jb4k5l.fsf@yahoo.com> <83sfxz1pw0.fsf@gnu.org> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16858"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: larsi@gnus.org, 50660@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 20 13:09:15 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSHAh-00049P-95 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Sep 2021 13:09:15 +0200 Original-Received: from localhost ([::1]:49060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSHAf-0004qp-RB for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Sep 2021 07:09:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSHAU-0004nf-24 for bug-gnu-emacs@gnu.org; Mon, 20 Sep 2021 07:09:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mSHAT-0004qh-Qu for bug-gnu-emacs@gnu.org; Mon, 20 Sep 2021 07:09:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mSHAT-0000Cy-MH for bug-gnu-emacs@gnu.org; Mon, 20 Sep 2021 07:09:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Sep 2021 11:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50660 X-GNU-PR-Package: emacs Original-Received: via spool by 50660-submit@debbugs.gnu.org id=B50660.1632136108759 (code B ref 50660); Mon, 20 Sep 2021 11:09:01 +0000 Original-Received: (at 50660) by debbugs.gnu.org; 20 Sep 2021 11:08:28 +0000 Original-Received: from localhost ([127.0.0.1]:41086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSH9w-0000CA-Aw for submit@debbugs.gnu.org; Mon, 20 Sep 2021 07:08:28 -0400 Original-Received: from sonic307-56.consmr.mail.ne1.yahoo.com ([66.163.190.31]:37271) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSH9u-0000By-Mf for 50660@debbugs.gnu.org; Mon, 20 Sep 2021 07:08:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1632136100; bh=fXBfKDUaznoJcoeTweXn8iqO1VFoDepHuvGU+RWUev4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=AIGmjpawR14uA37WyhO9pqjO7U4iWcS2nH79wZvsAEd1jAh7t4mZJ2I9oAlih/UkpJm8cWqRERa2PHfTJXNwVatinN1qk7LgaRYsk3UHpR+rHfFhftS3dah+Eh8bwHN1wR3J4DrPK3Ni5jbEQWkigL/IPUIRz44JOQUgZPqaJjl8Tp42EjJS6ilUA6aztd0uvh140c2Mhp38LLu68mo0RrdP9xNBKn6VT7usTLXNuRgeT4u0JEBjz8zYsG7goVAsY359HQozaOL33G0hx1B2H0rGKwCCpLfL8WT70CimnmbPGSe7sIUkotQDGk0fGZVyGYjQ5SfxGmuH65tuURsJ9w== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1632136100; bh=mke+WXFj8nvhhn6nQMyE8h+gGSbSMrbI5B4d987+vuc=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=G5INof7SfeiAYwn33s15HpjX7x41Tu8Ipo8OAPS60sNkr7umE1e90wuJtmbQfP6aqvhCrM5jcebJ7WIG/r7DMoslXJ06zawXI/F4uRXcGfMgAWdnyWSwfuHD+5CiVa7Whvr9gmlXWg5BUaJWOsgYTHPp6eXsHDzrwpY4kD8QA0T+FVhxa6OIHsFi03u5sepNDL6tH1whD6pthekPyKMVrhr4b6AwsO0SqHu9w2vpKsTfoQ8dKYTEbGu+ZgP0cIdx4x0JyCB5gNK3Nf9SV1N5lUnFwb9mAimo+ahnYZw9nqmOPI9y0bj/2/zGzKBTAQv+5qnFnn3nipBA2OCh6UnM1g== X-YMail-OSG: RK_ILFAVM1nDpXcZBMCDjRTlLED.XmN0fRWgcAHNwya5fNItWkGluuepdeK72.A 8KzHgTO2lhxZs0oCdy2pGgSnb7QOtSXIkzJscf2Uri0C5tmdxcMeVsjBTofbAOs7KpaaAF3TOyv2 aw4YYNNs4d9.B7P_fj68_dFAJi1EjCOnHWQBNRpGcqSyvNEjqaRJ4DPfOMavtmiDad53mejlftA2 EpL2gavzW6h37Vw4djs72DqeUvCZ_JaduMkfGHUitW6TDx3cKgGc41u_mD6Kj16IYA0e8t4zD.Ra MNjvw74oK0qIb7DTCyj8uaoJKxtvBl6hTsOTmlfindfOUy1i8iAIf4qbeYCkz2vXCqhOnKfZCe5o ZyAcX11tMDY9qKXFkaIYUWXmQH2qIj79lJk8culOzbQ3vywySxJyaQEwTvhdmNhE5zRm3rS5mhj8 dZeqfZl1uXHrR8fk5ZuG85mtJjIpfPMxtmtczS82QfDo24_EDybIqhHqCfOuQ82HM5FAxE80Dp5m VP3opaoWO3WA5rvBnfTUSxaV0ZSrxNzI1UST9_SCfjLo.6DGxWAVq5d.F9gLhHC5RXvx6PQdrmXP 2GoYg73OB0nsiepjU7Iawhv4De0hQeLYTXGBRx5ztoiEuilU.AFlCz3g59ay3Ye5OIYQQbuWxVVJ fXsoEwIUOnOcqtlasf0gj3k5oieGfc6Gtt1r00myMH9XHbySBoWGnicburNTM5oU5v1wjIctWqtO xcErJN0EeitaAI4Sld77HtEnFfwKIXX83mDTbxGLazW8rzfikuG.34x2DzmwE5ZLa1wpYoeSg1o9 HSR.D8rdgdR8aGkTxsD95G9aLkIrmR_9jPXKFb7X9i X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Mon, 20 Sep 2021 11:08:20 +0000 Original-Received: by kubenode501.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID f1b0b0d53d8622f2f83fac77c1bd6a5d; Mon, 20 Sep 2021 11:08:16 +0000 (UTC) In-Reply-To: <83sfxz1pw0.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 Sep 2021 13:51:27 +0300") X-Mailer: WebService/1.1.19043 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214853 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Specifically, I now think the adjustment should happen in this > fragment from show_mouse_face, before we call display_and_set_cursor: Thanks, but I already cooked something up. The adjustment, in my case, is done in draw_phys_cursor_glyph, conditional on cursor_in_mouse_face_p. Is there anything wrong with this approach? Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=fix-cursor-position.patch diff --git a/src/xdisp.c b/src/xdisp.c index 2e72f6b591..ca6b98155a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -31696,7 +31696,69 @@ draw_phys_cursor_glyph (struct window *w, struct glyph_row *row, bool on_p = w->phys_cursor_on_p; int x1; int hpos = w->phys_cursor.hpos; + int mouse_off = 0; +#ifdef HAVE_WINDOW_SYSTEM + if (cursor_in_mouse_face_p (w)) + { + struct frame *f = WINDOW_XFRAME (w); + Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); + struct glyph *start, *end; + struct face *mouse_face = FACE_FROM_ID (f, hlinfo->mouse_face_face_id); + end = &row->glyphs[TEXT_AREA][hpos]; + + if (MATRIX_ROW_VPOS (row, w->current_matrix) == + hlinfo->mouse_face_beg_row) + start = &row->glyphs[TEXT_AREA][hlinfo->mouse_face_beg_col]; + else + start = row->glyphs[TEXT_AREA]; + + /* Calculate an offset to correct phys_cursor x if we are + drawing the cursor in the mouse face. */ + + for (; start <= end; ++start) + { + struct glyph *g = start; + struct face *mouse = mouse_face; + struct face *regular_face = FACE_FROM_ID (f, g->face_id); + + bool do_left_box_p = g->left_box_line_p; + bool do_right_box_p = g->right_box_line_p; + if (row->reversed_p && g->type == IMAGE_GLYPH) + { + struct image *img = IMAGE_FROM_ID (WINDOW_XFRAME (w), + g->u.img_id); + do_left_box_p = g->right_box_line_p && + g->slice.img.x + g->slice.img.width == img->width; + do_right_box_p = g->left_box_line_p && + g->slice.img.x == 0; + } + else if (g->type == IMAGE_GLYPH) + { + struct image *img = IMAGE_FROM_ID (WINDOW_XFRAME (w), + g->u.img_id); + do_left_box_p = g->left_box_line_p && + g->slice.img.x + g->slice.img.width == img->width; + do_right_box_p = g->right_box_line_p && + g->slice.img.x == 0; + } + + /* If the glyph has a left box line, subtract it the + offset. */ + if (do_left_box_p) + mouse_off -= max (0, regular_face->box_vertical_line_width); + /* Likewise with the right box line, as there may be a + box there as well. */ + if (do_right_box_p) + mouse_off -= max (0, regular_face->box_vertical_line_width); + /* Now we add the line widths from the new face. */ + if (g->left_box_line_p) + mouse_off += max (0, mouse->box_vertical_line_width); + if (g->right_box_line_p) + mouse_off += max (0, mouse->box_vertical_line_width); + } + } +#endif /* When the window is hscrolled, cursor hpos can legitimately be out of bounds, but we draw the cursor at the corresponding window margin in that case. */ @@ -31705,7 +31767,8 @@ draw_phys_cursor_glyph (struct window *w, struct glyph_row *row, if (row->reversed_p && hpos >= row->used[TEXT_AREA]) hpos = row->used[TEXT_AREA] - 1; - x1 = draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA, hpos, hpos + 1, + x1 = draw_glyphs (w, w->phys_cursor.x + mouse_off, + row, TEXT_AREA, hpos, hpos + 1, hl, 0); w->phys_cursor_on_p = on_p; --=-=-=--