GNU bug report logs - #72230
29.4; Cursor Disappears with Hebrew Text

Previous Next

Package: emacs;

Reported by: hermann sorgel <hermannsorgel <at> gmail.com>

Date: Sun, 21 Jul 2024 15:30:02 UTC

Severity: normal

Found in version 29.4

Fixed in version 30.1

Done: Gerd Möllmann <gerd.moellmann <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72230 in the body.
You can then email your comments to 72230 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 15:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to hermann sorgel <hermannsorgel <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 21 Jul 2024 15:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: hermann sorgel <hermannsorgel <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 17:20:50 +0300
[Message part 1 (text/plain, inline)]
I'm encountering an issue with cursor behavior in Emacs, and I'm hoping
someone can help me resolve it.

When the cursor hovers over Hebrew text, it becomes invisible. Here are a
few facts I've observed:
- This only occurs with the cursor type set to 'bar'.
- The "box" and other cursor types work without issues.
- The "bar" cursor becomes visible if I make its size huge, like '(bar .
10).
- There's a similar, but slightly different issue with Arabic text.

The issue was reproduced with Emacs 29.3 for Mac and emacs-plus 29.4, on
macOS Sonoma 14.5 (23F79). Changing font and bidi settings haven't affected
the issue. Neither has --no-init-file.

Short video with demonstration
<https://e.pcloud.link/publink/show?code=XZIDjgZ3QLO9BNemLm4rGJp1Venlhq0PeI7>

Text file from video
<https://gist.github.com/hermannsorgel/a2a7de12dab858bb17da35b822721702>

Please let me know if I'm missing something.

In GNU Emacs 29.4 (build 1, aarch64-apple-darwin23.5.0, NS
 appkit-2487.60 Version 14.5 (Build 23F79)) of 2024-07-21 built on
 Sorgel-MBP
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.5

Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
 --infodir=/opt/homebrew/Cellar/emacs-plus <at> 29/29.4/share/info/emacs
 --prefix=/opt/homebrew/Cellar/emacs-plus <at> 29/29.4 --with-xml2
 --with-gnutls --without-compress-install --without-dbus
 --without-imagemagick --with-modules --with-rsvg --with-ns
 --disable-ns-self-contained 'CFLAGS=-Os -w -pipe
 -mmacosx-version-min=14
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -O2
 -DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT'
 'CPPFLAGS=-I/opt/homebrew/opt/icu4c/include
 -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/readline/include
 -isystem/opt/homebrew/include -F/opt/homebrew/Frameworks
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk'
 'LDFLAGS=-L/opt/homebrew/opt/icu4c/lib -L/opt/homebrew/opt/sqlite/lib
 -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/lib
 -F/opt/homebrew/Frameworks -Wl,-headerpad_max_install_names
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
XIM ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
thingatpt vc-git diff-mode easy-mmode vc-dispatcher cl-loaddefs cl-lib
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 43275 6299)
 (symbols 48 5649 0)
 (strings 32 15396 2057)
 (string-bytes 1 443058)
 (vectors 16 11570)
 (vector-slots 8 175067 6803)
 (floats 8 23 53)
 (intervals 56 298 0)
 (buffers 984 12))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 15:50:01 GMT) Full text and rfc822 format available.

Message #8 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: hermann sorgel <hermannsorgel <at> gmail.com>
Cc: 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 18:46:58 +0300
> From: hermann sorgel <hermannsorgel <at> gmail.com>
> Date: Sun, 21 Jul 2024 17:20:50 +0300
> 
> I'm encountering an issue with cursor behavior in Emacs, and I'm hoping someone can help me resolve it.
> 
> When the cursor hovers over Hebrew text, it becomes invisible. Here are a few facts I've observed:
> - This only occurs with the cursor type set to 'bar'.
> - The "box" and other cursor types work without issues.
> - The "bar" cursor becomes visible if I make its size huge, like '(bar . 10).
> - There's a similar, but slightly different issue with Arabic text.
> 
> The issue was reproduced with Emacs 29.3 for Mac and emacs-plus 29.4, on macOS Sonoma 14.5 (23F79).
> Changing font and bidi settings haven't affected the issue. Neither has --no-init-file.

Thanks.  I cannot reproduce this on my system, but I'm not on macOS.
Maybe this is specific to macOS?  Can a macOS user please try
reproducing this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 16:02:01 GMT) Full text and rfc822 format available.

Message #11 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: hermannsorgel <at> gmail.com
Cc: 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 19:01:41 +0300
> Cc: 72230 <at> debbugs.gnu.org
> Date: Sun, 21 Jul 2024 18:46:58 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> Thanks.  I cannot reproduce this on my system, but I'm not on macOS.
> Maybe this is specific to macOS?  Can a macOS user please try
> reproducing this?

And I think I see the problem.  This fragment of nsterm.m:

    case BAR_CURSOR:
      s = r;
      /* If the character under cursor is R2L, draw the bar cursor
         on the right of its glyph, rather than on the left.  */
      cursor_glyph = get_phys_cursor_glyph (w);
      if ((cursor_glyph->resolved_level & 1) != 0)
        s.origin.x += cursor_glyph->pixel_width - s.size.width;

is incorrect: it should use the value of the cursor_width argument,
not s.size.width.  Can someone who is capable of building Emacs on
macOS please try copying more closely the code from xterm.c or
w32term.c that draws the bar cursor, and see if that solves the
problem?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 17:38:01 GMT) Full text and rfc822 format available.

Message #14 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: hermann sorgel <hermannsorgel <at> gmail.com>
Cc: 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 20:37:31 +0300
> From: hermann sorgel <hermannsorgel <at> gmail.com>
> Date: Sun, 21 Jul 2024 20:31:54 +0300
> Cc: 72230 <at> debbugs.gnu.org
> 
> Here is the same code  with s.size.width in the working fork. It does not look that anything has changed in
> 29.4.

So maybe the problem is elsewhere.  One thing is almost certain: it's
a problem specific to the macOS build of Emacs.  People who can debug
on that platform are encouraged to suggest insights and changes.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 17:41:02 GMT) Full text and rfc822 format available.

Message #17 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: hermann sorgel <hermannsorgel <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 20:15:04 +0300
[Message part 1 (text/plain, inline)]
Thank you, Eli!

Sadly, I'm not actually into coding, but I'm able to run make. So, the only
thing I've changed was:

s.origin.x += cursor_glyph->pixel_width - *cursor_width*;

Such a build kind of works, but does not fix the described behavior.

Also, with the help of redditors, I've found that Mitsuharu's fork of 29.1
does not have this issue. Hope this will help us find the root of the
problem.

On Sun, Jul 21, 2024 at 7:01 PM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Cc: 72230 <at> debbugs.gnu.org
> > Date: Sun, 21 Jul 2024 18:46:58 +0300
> > From: Eli Zaretskii <eliz <at> gnu.org>
> >
> > Thanks.  I cannot reproduce this on my system, but I'm not on macOS.
> > Maybe this is specific to macOS?  Can a macOS user please try
> > reproducing this?
>
> And I think I see the problem.  This fragment of nsterm.m:
>
>     case BAR_CURSOR:
>       s = r;
>       /* If the character under cursor is R2L, draw the bar cursor
>          on the right of its glyph, rather than on the left.  */
>       cursor_glyph = get_phys_cursor_glyph (w);
>       if ((cursor_glyph->resolved_level & 1) != 0)
>         s.origin.x += cursor_glyph->pixel_width - s.size.width;
>
> is incorrect: it should use the value of the cursor_width argument,
> not s.size.width.  Can someone who is capable of building Emacs on
> macOS please try copying more closely the code from xterm.c or
> w32term.c that draws the bar cursor, and see if that solves the
> problem?
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 17:41:02 GMT) Full text and rfc822 format available.

Message #20 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: hermann sorgel <hermannsorgel <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 20:31:54 +0300
[Message part 1 (text/plain, inline)]
Here is the same code
<https://bitbucket.org/mituharu/emacs-mac/src/master/src/nsterm.m#lines-3119>
 with s.size.width in the working fork. It does not look that anything has
changed in 29.4.

On Sun, Jul 21, 2024 at 7:01 PM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Cc: 72230 <at> debbugs.gnu.org
> > Date: Sun, 21 Jul 2024 18:46:58 +0300
> > From: Eli Zaretskii <eliz <at> gnu.org>
> >
> > Thanks.  I cannot reproduce this on my system, but I'm not on macOS.
> > Maybe this is specific to macOS?  Can a macOS user please try
> > reproducing this?
>
> And I think I see the problem.  This fragment of nsterm.m:
>
>     case BAR_CURSOR:
>       s = r;
>       /* If the character under cursor is R2L, draw the bar cursor
>          on the right of its glyph, rather than on the left.  */
>       cursor_glyph = get_phys_cursor_glyph (w);
>       if ((cursor_glyph->resolved_level & 1) != 0)
>         s.origin.x += cursor_glyph->pixel_width - s.size.width;
>
> is incorrect: it should use the value of the cursor_width argument,
> not s.size.width.  Can someone who is capable of building Emacs on
> macOS please try copying more closely the code from xterm.c or
> w32term.c that draws the bar cursor, and see if that solves the
> problem?
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 18:08:02 GMT) Full text and rfc822 format available.

Message #23 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, hermann sorgel <hermannsorgel <at> gmail.com>
Cc: Po Lu <luangruo <at> yahoo.com>, 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 11:05:57 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

> So maybe the problem is elsewhere.  One thing is almost certain: it's
> a problem specific to the macOS build of Emacs.  People who can debug
> on that platform are encouraged to suggest insights and changes.

This seems to have something to with the clipping path, and is fixed
here by the below patch. I don't think it's suitable for installing
though.

Po Lu, since you added the below NSRectClip call, do you have any
thoughts here?

diff --git a/src/nsterm.m b/src/nsterm.m
index 794630de1c1..54b15bc851d 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3102,7 +3102,7 @@ Note that CURSOR_WIDTH is meaningful only for
(h)bar cursors.
 #ifdef NS_IMPL_GNUSTEP
   GSRectClipList (ctx, &r, 1);
 #else
-  NSRectClip (r);
+  // NSRectClip (r);
 #endif

   [FRAME_CURSOR_COLOR (f) set];
@@ -3135,7 +3135,7 @@ Note that CURSOR_WIDTH is meaningful only for
(h)bar cursors.
          on the right of its glyph, rather than on the left.  */
       cursor_glyph = get_phys_cursor_glyph (w);
       if ((cursor_glyph->resolved_level & 1) != 0)
-        s.origin.x += cursor_glyph->pixel_width - s.size.width;
+        s.origin.x += cursor_glyph->pixel_width - cursor_width;

       NSRectFill (s);
       [ctx restoreGraphicsState];




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 18:45:01 GMT) Full text and rfc822 format available.

Message #26 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Po Lu <luangruo <at> yahoo.com>, Eli Zaretskii <eliz <at> gnu.org>,
 hermann sorgel <hermannsorgel <at> gmail.com>, 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 20:42:57 +0200
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> So maybe the problem is elsewhere.  One thing is almost certain: it's
>> a problem specific to the macOS build of Emacs.  People who can debug
>> on that platform are encouraged to suggest insights and changes.
>
> This seems to have something to with the clipping path, and is fixed
> here by the below patch. I don't think it's suitable for installing
> though.
>
> Po Lu, since you added the below NSRectClip call, do you have any
> thoughts here?
>
> diff --git a/src/nsterm.m b/src/nsterm.m
> index 794630de1c1..54b15bc851d 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -3102,7 +3102,7 @@ Note that CURSOR_WIDTH is meaningful only for
> (h)bar cursors.
>  #ifdef NS_IMPL_GNUSTEP
>    GSRectClipList (ctx, &r, 1);
>  #else
> -  NSRectClip (r);
> +  // NSRectClip (r);
>  #endif
>
>    [FRAME_CURSOR_COLOR (f) set];
> @@ -3135,7 +3135,7 @@ Note that CURSOR_WIDTH is meaningful only for
> (h)bar cursors.
>           on the right of its glyph, rather than on the left.  */
>        cursor_glyph = get_phys_cursor_glyph (w);
>        if ((cursor_glyph->resolved_level & 1) != 0)
> -        s.origin.x += cursor_glyph->pixel_width - s.size.width;
> +        s.origin.x += cursor_glyph->pixel_width - cursor_width;
>
>        NSRectFill (s);
>        [ctx restoreGraphicsState];

A clipping path set with NSRectClip is permanent, and the only way to
get rid it is to restore the graphics state. This seems to work:

modified   src/nsterm.m
@@ -3130,6 +3130,8 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
       [ctx restoreGraphicsState];
       break;
     case BAR_CURSOR:
+      [ctx restoreGraphicsState];
+      [ctx saveGraphicsState];
       s = r;
       /* If the character under cursor is R2L, draw the bar cursor
          on the right of its glyph, rather than on the left.  */
@@ -3137,6 +3139,10 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
       if ((cursor_glyph->resolved_level & 1) != 0)
         s.origin.x += cursor_glyph->pixel_width - s.size.width;
 
+      /* Get rid of the clipping set previously. */
+      [ctx restoreGraphicsState];
+      [ctx saveGraphicsState];
+      NSRectClip (s);
       NSRectFill (s);
       [ctx restoreGraphicsState];
       break;





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 18:47:02 GMT) Full text and rfc822 format available.

Message #29 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Po Lu <luangruo <at> yahoo.com>, Eli Zaretskii <eliz <at> gnu.org>,
 hermann sorgel <hermannsorgel <at> gmail.com>, 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 20:45:32 +0200
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> So maybe the problem is elsewhere.  One thing is almost certain: it's
>> a problem specific to the macOS build of Emacs.  People who can debug
>> on that platform are encouraged to suggest insights and changes.
>
> This seems to have something to with the clipping path, and is fixed
> here by the below patch. I don't think it's suitable for installing
> though.
>
> Po Lu, since you added the below NSRectClip call, do you have any
> thoughts here?
>
> diff --git a/src/nsterm.m b/src/nsterm.m
> index 794630de1c1..54b15bc851d 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -3102,7 +3102,7 @@ Note that CURSOR_WIDTH is meaningful only for
> (h)bar cursors.
>  #ifdef NS_IMPL_GNUSTEP
>    GSRectClipList (ctx, &r, 1);
>  #else
> -  NSRectClip (r);
> +  // NSRectClip (r);
>  #endif
>
>    [FRAME_CURSOR_COLOR (f) set];
> @@ -3135,7 +3135,7 @@ Note that CURSOR_WIDTH is meaningful only for
> (h)bar cursors.
>           on the right of its glyph, rather than on the left.  */
>        cursor_glyph = get_phys_cursor_glyph (w);
>        if ((cursor_glyph->resolved_level & 1) != 0)
> -        s.origin.x += cursor_glyph->pixel_width - s.size.width;
> +        s.origin.x += cursor_glyph->pixel_width - cursor_width;
>
>        NSRectFill (s);
>        [ctx restoreGraphicsState];

Erm, once is enough :-)

1 file changed, 4 insertions(+)
src/nsterm.m | 4 ++++

modified   src/nsterm.m
@@ -3137,6 +3137,10 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
       if ((cursor_glyph->resolved_level & 1) != 0)
         s.origin.x += cursor_glyph->pixel_width - s.size.width;
 
+      /* Get rid of the clipping set previously. */
+      [ctx restoreGraphicsState];
+      [ctx saveGraphicsState];
+      NSRectClip (s);
       NSRectFill (s);
       [ctx restoreGraphicsState];
       break;





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Sun, 21 Jul 2024 19:28:02 GMT) Full text and rfc822 format available.

Message #32 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Cc: Po Lu <luangruo <at> yahoo.com>, Eli Zaretskii <eliz <at> gnu.org>,
 hermann sorgel <hermannsorgel <at> gmail.com>, 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Sun, 21 Jul 2024 12:26:48 -0700
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> 1 file changed, 4 insertions(+)
> src/nsterm.m | 4 ++++
>
> modified   src/nsterm.m
> @@ -3137,6 +3137,10 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
>        if ((cursor_glyph->resolved_level & 1) != 0)
>          s.origin.x += cursor_glyph->pixel_width - s.size.width;
>
> +      /* Get rid of the clipping set previously. */
> +      [ctx restoreGraphicsState];
> +      [ctx saveGraphicsState];
> +      NSRectClip (s);
>        NSRectFill (s);
>        [ctx restoreGraphicsState];
>        break;
>

This fixes the bug for me.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Mon, 22 Jul 2024 02:06:01 GMT) Full text and rfc822 format available.

Message #35 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, hermann sorgel <hermannsorgel <at> gmail.com>,
 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Mon, 22 Jul 2024 10:05:05 +0800
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> So maybe the problem is elsewhere.  One thing is almost certain: it's
>> a problem specific to the macOS build of Emacs.  People who can debug
>> on that platform are encouraged to suggest insights and changes.
>
> This seems to have something to with the clipping path, and is fixed
> here by the below patch. I don't think it's suitable for installing
> though.
>
> Po Lu, since you added the below NSRectClip call, do you have any
> thoughts here?

Yes, this will cause the overhangs of a cursor glyph to overwrite its
surroundings.  There is certain to be some other factor that has not
been accounted for, while mindlessly removing clipping operations is not
the solution.

> diff --git a/src/nsterm.m b/src/nsterm.m
> index 794630de1c1..54b15bc851d 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -3102,7 +3102,7 @@ Note that CURSOR_WIDTH is meaningful only for
> (h)bar cursors.
>  #ifdef NS_IMPL_GNUSTEP
>    GSRectClipList (ctx, &r, 1);
>  #else
> -  NSRectClip (r);
> +  // NSRectClip (r);
>  #endif
>
>    [FRAME_CURSOR_COLOR (f) set];
> @@ -3135,7 +3135,7 @@ Note that CURSOR_WIDTH is meaningful only for
> (h)bar cursors.
>           on the right of its glyph, rather than on the left.  */
>        cursor_glyph = get_phys_cursor_glyph (w);
>        if ((cursor_glyph->resolved_level & 1) != 0)
> -        s.origin.x += cursor_glyph->pixel_width - s.size.width;
> +        s.origin.x += cursor_glyph->pixel_width - cursor_width;

I don't recollect what `s' is supposed to represent.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Mon, 22 Jul 2024 06:49:02 GMT) Full text and rfc822 format available.

Message #38 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, hermann sorgel <hermannsorgel <at> gmail.com>,
 Stefan Kangas <stefankangas <at> gmail.com>, 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Mon, 22 Jul 2024 08:47:30 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>> So maybe the problem is elsewhere.  One thing is almost certain: it's
>>> a problem specific to the macOS build of Emacs.  People who can debug
>>> on that platform are encouraged to suggest insights and changes.
>>
>> This seems to have something to with the clipping path, and is fixed
>> here by the below patch. I don't think it's suitable for installing
>> though.
>>
>> Po Lu, since you added the below NSRectClip call, do you have any
>> thoughts here?
>
> Yes, this will cause the overhangs of a cursor glyph to overwrite its
> surroundings.  There is certain to be some other factor that has not
> been accounted for, while mindlessly removing clipping operations is not
> the solution.
>
>> diff --git a/src/nsterm.m b/src/nsterm.m
>> index 794630de1c1..54b15bc851d 100644
>> --- a/src/nsterm.m
>> +++ b/src/nsterm.m
>> @@ -3102,7 +3102,7 @@ Note that CURSOR_WIDTH is meaningful only for
>> (h)bar cursors.
>>  #ifdef NS_IMPL_GNUSTEP
>>    GSRectClipList (ctx, &r, 1);
>>  #else
>> -  NSRectClip (r);
>> +  // NSRectClip (r);
>>  #endif
>>
>>    [FRAME_CURSOR_COLOR (f) set];
>> @@ -3135,7 +3135,7 @@ Note that CURSOR_WIDTH is meaningful only for
>> (h)bar cursors.
>>           on the right of its glyph, rather than on the left.  */
>>        cursor_glyph = get_phys_cursor_glyph (w);
>>        if ((cursor_glyph->resolved_level & 1) != 0)
>> -        s.origin.x += cursor_glyph->pixel_width - s.size.width;
>> +        s.origin.x += cursor_glyph->pixel_width - cursor_width;
>
> I don't recollect what `s' is supposed to represent.

I propose the following as a fix. This computes the right rectangle to
draw before that rectangle is set via NSClipRect.

1 file changed, 8 insertions(+), 12 deletions(-)
src/nsterm.m | 20 ++++++++------------

modified   src/nsterm.m
@@ -3026,7 +3026,7 @@ External call (RIF): draw cursor.
      Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
    -------------------------------------------------------------------------- */
 {
-  NSRect r, s;
+  NSRect r;
   int fx, fy, h, cursor_height;
   struct frame *f = WINDOW_XFRAME (w);
   struct glyph *phys_cursor_glyph;
@@ -3076,6 +3076,12 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
       /* The bar cursor should never be wider than the glyph.  */
       if (cursor_width < w->phys_cursor_width)
         w->phys_cursor_width = cursor_width;
+
+      /* If the character under cursor is R2L, draw the bar cursor
+         on the right of its glyph, rather than on the left.  */
+      cursor_glyph = get_phys_cursor_glyph (w);
+      if ((cursor_glyph->resolved_level & 1) != 0)
+        fx += cursor_glyph->pixel_width - w->phys_cursor_width;
     }
   /* If we have an HBAR, "cursor_width" MAY specify height.  */
   else if (cursor_type == HBAR_CURSOR)
@@ -3126,18 +3132,8 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
       [ctx restoreGraphicsState];
       break;
     case HBAR_CURSOR:
-      NSRectFill (r);
-      [ctx restoreGraphicsState];
-      break;
     case BAR_CURSOR:
-      s = r;
-      /* If the character under cursor is R2L, draw the bar cursor
-         on the right of its glyph, rather than on the left.  */
-      cursor_glyph = get_phys_cursor_glyph (w);
-      if ((cursor_glyph->resolved_level & 1) != 0)
-        s.origin.x += cursor_glyph->pixel_width - s.size.width;
-
-      NSRectFill (s);
+      NSRectFill (r);
       [ctx restoreGraphicsState];
       break;
     }





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Mon, 22 Jul 2024 07:07:01 GMT) Full text and rfc822 format available.

Message #41 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: hermann sorgel <hermannsorgel <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Gerd Möllmann <gerd.moellmann <at> gmail.com>,
 Po Lu <luangruo <at> yahoo.com>, Eli Zaretskii <eliz <at> gnu.org>,
 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Mon, 22 Jul 2024 00:35:17 +0300
[Message part 1 (text/plain, inline)]
Yes, thank you so much. This works for me too.


On Sun, Jul 21, 2024 at 10:26 PM Stefan Kangas <stefankangas <at> gmail.com>
wrote:

> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
> > 1 file changed, 4 insertions(+)
> > src/nsterm.m | 4 ++++
> >
> > modified   src/nsterm.m
> > @@ -3137,6 +3137,10 @@ Note that CURSOR_WIDTH is meaningful only for
> (h)bar cursors.
> >        if ((cursor_glyph->resolved_level & 1) != 0)
> >          s.origin.x += cursor_glyph->pixel_width - s.size.width;
> >
> > +      /* Get rid of the clipping set previously. */
> > +      [ctx restoreGraphicsState];
> > +      [ctx saveGraphicsState];
> > +      NSRectClip (s);
> >        NSRectFill (s);
> >        [ctx restoreGraphicsState];
> >        break;
> >
>
> This fixes the bug for me.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Tue, 23 Jul 2024 06:20:02 GMT) Full text and rfc822 format available.

Message #44 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, hermann sorgel <hermannsorgel <at> gmail.com>,
 Stefan Kangas <stefankangas <at> gmail.com>, 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Tue, 23 Jul 2024 08:17:52 +0200
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> I propose the following as a fix. This computes the right rectangle to
> draw before that rectangle is set via NSClipRect.

I've pushed this to emacs-30. Closing.




bug marked as fixed in version 30.1, send any further explanations to 72230 <at> debbugs.gnu.org and hermann sorgel <hermannsorgel <at> gmail.com> Request was from Gerd Möllmann <gerd.moellmann <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Jul 2024 06:20:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72230; Package emacs. (Tue, 23 Jul 2024 07:16:02 GMT) Full text and rfc822 format available.

Message #49 received at 72230 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>, 
 Po Lu <luangruo <at> yahoo.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, hermann sorgel <hermannsorgel <at> gmail.com>,
 72230 <at> debbugs.gnu.org
Subject: Re: bug#72230: 29.4; Cursor Disappears with Hebrew Text
Date: Tue, 23 Jul 2024 00:14:34 -0700
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> I've pushed this to emacs-30. Closing.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Aug 2024 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 205 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.