Subject: Re: bug#39188: 28.0.50; w32 cursor redisplay problem
From: Eli Zaretskii <[email-masked]>
To: Fabrice Popineau <[email-masked]>
Cc: [email-masked]
Date: Tue, 21 Jan 2020 18:32:54 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Fabrice Popineau <[email-masked]>
> Date: Mon, 20 Jan 2020 19:41:48 +0100
> Cc: [email-masked]
> 
> Maybe it is not the most important bug (except if Windows start to tell
> emacs that there are screen readers everywhere)

I found the problem.  As part of redisplay, we sometimes scroll
rectangular portions of the window, as pixels, up and down.  When we
do so, we first turn off the cursor, but when the system caret is used
instead of the cursor, we hide and unhide the caret in a separate UI
thread.  So there's a race between the main thread which scrolls the
pixels and the UI thread that draws the caret, and that race causes
the pixels of the caret to sometimes be copied with the rectangular
area that is scrolled.

The solution is to disable the scrolling in w32_scroll_run when the
system caret is in use.  This slows down redisplay to some extent
(because w32_scroll_run is a redisplay optimization), but I don't see
any easy way around that.

Should be fixed now on the emacs-27 branch.