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: Thu, 14 Oct 2021 18:52:48 +0800 Message-ID: <878ryvnain.fsf@yahoo.com> References: <87czp6ysw7.fsf.ref@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> <87o88m14g0.fsf@yahoo.com> <83sfxyxeer.fsf@gnu.org> <87h7ee1252.fsf@yahoo.com> <83pmt2xcox.fsf@gnu.org> <87lf3myhlb.fsf@yahoo.com> <87a6jzvnpq.fsf@yahoo.com> <83o88fom1k.fsf@gnu.org> <871r5bvex8.fsf@yahoo.com> <83v92mkzft.fsf@gnu.org> <87k0j0rwo3.fsf@yahoo.com> <838rzbddfa.fsf@gnu.org> <878rzbd1w5.fsf@yahoo.com> <83wnmgkmok.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="21033"; 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 Thu Oct 14 12:54:13 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 1mayNJ-0005G2-Kb for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Oct 2021 12:54:13 +0200 Original-Received: from localhost ([::1]:55734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mayNI-0001kj-DS for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Oct 2021 06:54:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mayN9-0001kI-6R for bug-gnu-emacs@gnu.org; Thu, 14 Oct 2021 06:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mayN8-0002wa-Hv for bug-gnu-emacs@gnu.org; Thu, 14 Oct 2021 06:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mayN8-0003qP-Gv for bug-gnu-emacs@gnu.org; Thu, 14 Oct 2021 06:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Oct 2021 10:54:02 +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.163420878414711 (code B ref 50660); Thu, 14 Oct 2021 10:54:02 +0000 Original-Received: (at 50660) by debbugs.gnu.org; 14 Oct 2021 10:53:04 +0000 Original-Received: from localhost ([127.0.0.1]:34742 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mayMC-0003pC-88 for submit@debbugs.gnu.org; Thu, 14 Oct 2021 06:53:04 -0400 Original-Received: from sonic304-20.consmr.mail.ne1.yahoo.com ([66.163.191.146]:46443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mayM9-0003oh-Ty for 50660@debbugs.gnu.org; Thu, 14 Oct 2021 06:53:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1634208776; bh=QV2LLEVfjUrWtfpu2VywMaoafDHhlIwBbFewiuTkfXA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=SFNDyIyKE9XL8Cj8kNDLQgv9tlSJq1aHb3NE0Mci41xWPaBNZDPDbl3I+mq7YcT38SCDVoxWddwP6mjLNeV8Tg2iV9+UNCBvBBv5tXXtbjGf7s2a3fiEtFjeX2Jqio/ko2K5LTad2gEUNz57pauOHU55CZqceoN/lFxedmxvHHih92G7jwF6A789GdLPIqplvC0DScH+umRl2lV+vNVNratsottQjgt6szxgAfb9ghg9HSQblf0+VwzSAq5UBujrIb+x/M4qaV68PpvtMII2+Ab7/k7WerpFft1meZD7BXgUPKgJLFwW4Si7Z13D/fWJ3PTEzNLo8vFkSg1WSqErVw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1634208776; bh=uOuCR1WoFSp5j7zpyVM+x1HhfCu1zlg171ucqDdbWzs=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=LQVIe2LZAUy6Gk/e5CbmP/szB/MZYylT2nUAUi4tY/eCW750BlfJ0pXLD0iNTMfxG4fZUA6YVe3TxpbrDldwlSthz6mxWZDr+mTkAxVh5XaMt1CthRewCB6z7zl7D6KMyW7wGA/hNl/RHpJitAai0h38leDuZ0+rC6H0A3187cUopz4xTgunIsDmCHe+7Ni0/Xa6dXR7cNNBL9Mv9QZKNlmil/ZVm13LhsZrpXeg7Bw9I2857mPiBqUP97QcaHtTFvWzEIWA+ilcUWY2N9p+CekU4gk3YlByr8tKWtScy1aT+siA61ExRoPY3SOj6Szb8Dg7OxUcp+NS+0G5nWHLkw== X-YMail-OSG: Z1DiWOAVM1kuZyfh2lwJJIuYrOA_vfx4VCvfApJEKabN8l3mzxLnuQH8Arj5.sv 57o2VhKM5XBYDW4uMji1uAep7qtUkEZ5H2GwmjDuUIzELBPaRlYNF8C42H4f1o6RiObe1F7e0OzK y8238jL0gYKBL1K20bIq1TniyB3worvAwk.qjemMJoxflvWTXWwQkXAiDeNe3z3XOCFUFmvii6m8 3_Gq4GY65kR.QsjKkNmAmqSfRMfZuV8qg4iXeXFYJpsXgQEZBAbCBJYuQQZ8KXcFAfOMYGC7Ic6J jRp4TDSHBzdq4nHXrZDINMQv0OdbXOljHMwnnzATtNKXTI3ZIQ4vZuRWBjhrS2piG_DljkUt9b4j LC7faNzhgpg.Q.iPVzCfW0Lh4sKrtOHOtL.iIdCGvYNL6aY_cNvaKh8RZCdyUvuGS6VYQNONWwnu ZdwQMFHJBxP8Fk_vN_38pyP2o88f9ZWNyRYO3rW7XNA.WbRNJvQtwEmY3zGrlfmAg1CB8W_yJ7pZ KCkCn31E.5niemQ3tSNWqsg1GGGWESHVyaWXx3rR5LCrEyUa_Iv8p9L2mNSYyp08JjDGAjk7mlR6 eugr9wZGb0FDm2Hz35WmFvdl0L2f7ewqAo9X47kHMHgt5mB4KJ1K1t0lfaw4nE0RHLg9jmHIqGQa EAHUkT20vjmnCdSMuZNX1n.5WNWklG68OBnNoJZcplwjzXPBuRTuzEoCWgDdSkh6.BWJraJeFc1C TW.fTJHzq.LIY47DRr5p.FIYTSqfjqRn6RJbXBr.VaoPS8ftg5kwIgvZlHqHrNEhsHSyavRxTyAe 2B2CEEWGSheB7f3IcGQKPyaeScxwFOt_RSGJocLKlO X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Thu, 14 Oct 2021 10:52:56 +0000 Original-Received: by kubenode515.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID d78cd6ddf5ec180f5513d04446c23506; Thu, 14 Oct 2021 10:52:51 +0000 (UTC) In-Reply-To: <83wnmgkmok.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Oct 2021 11:58:19 +0300") X-Mailer: WebService/1.1.19116 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:217210 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > It looks like something is still amiss: the cursor blinking display is > incorrect in some cases. For example, evaluate this in a buffer under > Fundamental mode: > > (insert (propertize "some sample text" 'face '(:box 10) 'mouse-face 'highlight)) > > and then put the mouse pointer above the text, so it's highlighted, > and move the text cursor to the first 's' or the last 't'. As long as > the cursor blinks, you will see two characters drawn in the cursor > face, not one as expected. Thanks, here's a patch that should fix the issues, formatted with "git format-patch", but with one caveat: in your example above, the background of the character "s" at the beginning of the string "some sample text" is drawn too wide, but I wasn't able to find the problem. Could you please take a look at it? Thanks. I don't know how to apply the fixes to xterm.c to the other window systems, so someone who can needs to apply them to the NS and MS-Windows ports. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-minor-issues-with-text-display-when-cursor-is-in.patch >From 6d277be789bf30e0db5b27780bff86151e48f622 Mon Sep 17 00:00:00 2001 From: oldosfan Date: Thu, 14 Oct 2021 18:38:26 +0800 Subject: [PATCH] Fix minor issues with text display when cursor is in mouse face * src/xdisp.c (get_cursor_offset_for_mouse_face): Don't calculate offsets for the glyph the cursor is on. * src/xterm.c (x_draw_glyph_string_foreground, x_draw_composite_glyph_string_foreground, x_draw_glyphless_glyph_string_foreground, x_draw_image_foreground, x_draw_image_foreground_1): Take mouse face into account when offsetting X coordinate by the vertical line width. --- src/xdisp.c | 2 +- src/xterm.c | 107 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 93 insertions(+), 16 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 012c2ad8bf..0d964b1236 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -36042,7 +36042,7 @@ get_cursor_offset_for_mouse_face (struct window *w, struct glyph_row *row, /* Calculate the offset to correct phys_cursor x if we are drawing the cursor inside mouse-face highlighted text. */ - for (; row->reversed_p ? start >= end : start <= end; + for (; row->reversed_p ? start > end : start < end; row->reversed_p ? --start : ++start) { struct glyph *g = start; diff --git a/src/xterm.c b/src/xterm.c index 89885e0d88..d19f214019 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1799,11 +1799,24 @@ x_draw_glyph_string_foreground (struct glyph_string *s) { int i, x; + struct face *face_for_box_line = s->face; + + if (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)) + { + /* In this situation, the cursor is in the mouse face, but + s->face hasn't been updated with the mouse face yet. */ + face_for_box_line = + FACE_FROM_ID_OR_NULL (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); + + if (!face_for_box_line) + face_for_box_line = FACE_FROM_ID (s->f, MOUSE_FACE_ID); + } + /* If first glyph of S has a left box line, start drawing the text of S to the right of that box line. */ - if (s->face->box != FACE_NO_BOX + if (face_for_box_line->box != FACE_NO_BOX && s->first_glyph->left_box_line_p) - x = s->x + max (s->face->box_vertical_line_width, 0); + x = s->x + max (face_for_box_line->box_vertical_line_width, 0); else x = s->x; @@ -1893,11 +1906,24 @@ x_draw_composite_glyph_string_foreground (struct glyph_string *s) int i, j, x; struct font *font = s->font; + struct face *face_for_box_line = s->face; + + if (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)) + { + /* In this situation, the cursor is in the mouse face, but + s->face hasn't been updated with the mouse face yet. */ + face_for_box_line = + FACE_FROM_ID_OR_NULL (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); + + if (!face_for_box_line) + face_for_box_line = FACE_FROM_ID (s->f, MOUSE_FACE_ID); + } + /* If first glyph of S has a left box line, start drawing the text of S to the right of that box line. */ - if (s->face && s->face->box != FACE_NO_BOX + if (face_for_box_line->box != FACE_NO_BOX && s->first_glyph->left_box_line_p) - x = s->x + max (s->face->box_vertical_line_width, 0); + x = s->x + max (face_for_box_line->box_vertical_line_width, 0); else x = s->x; @@ -2004,11 +2030,24 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s) unsigned char2b[8]; int x, i, j; + struct face *face_for_box_line = s->face; + + if (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)) + { + /* In this situation, the cursor is in the mouse face, but + s->face hasn't been updated with the mouse face yet. */ + face_for_box_line = + FACE_FROM_ID_OR_NULL (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); + + if (!face_for_box_line) + face_for_box_line = FACE_FROM_ID (s->f, MOUSE_FACE_ID); + } + /* If first glyph of S has a left box line, start drawing the text of S to the right of that box line. */ - if (s->face && s->face->box != FACE_NO_BOX + if (face_for_box_line->box != FACE_NO_BOX && s->first_glyph->left_box_line_p) - x = s->x + max (s->face->box_vertical_line_width, 0); + x = s->x + max (face_for_box_line->box_vertical_line_width, 0); else x = s->x; @@ -3073,12 +3112,25 @@ x_draw_image_foreground (struct glyph_string *s) int x = s->x; int y = s->ybase - image_ascent (s->img, s->face, &s->slice); + struct face *face_for_box_line = s->face; + + if (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)) + { + /* In this situation, the cursor is in the mouse face, but + s->face hasn't been updated with the mouse face yet. */ + face_for_box_line = + FACE_FROM_ID_OR_NULL (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); + + if (!face_for_box_line) + face_for_box_line = FACE_FROM_ID (s->f, MOUSE_FACE_ID); + } + /* If first glyph of S has a left box line, start drawing it to the - right of that line. */ - if (s->face->box != FACE_NO_BOX + right of that box line. */ + if (face_for_box_line->box != FACE_NO_BOX && s->first_glyph->left_box_line_p && s->slice.x == 0) - x += max (s->face->box_vertical_line_width, 0); + x += max (face_for_box_line->box_vertical_line_width, 0); /* If there is a margin around the image, adjust x- and y-position by that margin. */ @@ -3191,13 +3243,25 @@ x_draw_image_relief (struct glyph_string *s) XRectangle r; int x = s->x; int y = s->ybase - image_ascent (s->img, s->face, &s->slice); + struct face *face_for_box_line = s->face; + + if (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)) + { + /* In this situation, the cursor is in the mouse face, but + s->face hasn't been updated with the mouse face yet. */ + face_for_box_line = + FACE_FROM_ID_OR_NULL (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); + + if (!face_for_box_line) + face_for_box_line = FACE_FROM_ID (s->f, MOUSE_FACE_ID); + } /* If first glyph of S has a left box line, start drawing it to the - right of that line. */ - if (s->face->box != FACE_NO_BOX + right of that box line. */ + if (face_for_box_line->box != FACE_NO_BOX && s->first_glyph->left_box_line_p && s->slice.x == 0) - x += max (s->face->box_vertical_line_width, 0); + x += max (face_for_box_line->box_vertical_line_width, 0); /* If there is a margin around the image, adjust x- and y-position by that margin. */ @@ -3282,12 +3346,25 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap) int x = 0; int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice); + struct face *face_for_box_line = s->face; + + if (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)) + { + /* In this situation, the cursor is in the mouse face, but + s->face hasn't been updated with the mouse face yet. */ + face_for_box_line = + FACE_FROM_ID_OR_NULL (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id); + + if (!face_for_box_line) + face_for_box_line = FACE_FROM_ID (s->f, MOUSE_FACE_ID); + } + /* If first glyph of S has a left box line, start drawing it to the - right of that line. */ - if (s->face->box != FACE_NO_BOX + right of that box line. */ + if (face_for_box_line->box != FACE_NO_BOX && s->first_glyph->left_box_line_p && s->slice.x == 0) - x += max (s->face->box_vertical_line_width, 0); + x += max (face_for_box_line->box_vertical_line_width, 0); /* If there is a margin around the image, adjust x- and y-position by that margin. */ -- 2.31.1 --=-=-=--