Subject: bug#68927: CapsLock gets toggled by a frozen Emacs even if that's supposed to be prevented by a third party app

From: Eli Zaretskii <[email-masked]>
Date: Mon, 05 Feb 2024 14:10:13 +0200

> From: Nikolay Kudryavtsev <[email-masked]>
> Date: Sun, 4 Feb 2024 22:11:55 +0300
> 
> 5. Freeze Emacs by forcing it to run some code for a few seconds. I've used:
> 
> (let ((x 0))
>    (dotimes (i 10000000)
>      (setq x (1+ x))))
> 
> 6. While the above is running, start tapping CapsLock. You'd see that 
> CapsLock toggles even though it shouldn't and this only happens when 
> Emacs is frozen.

Why are you saying that CapsLock should not toggle in this case?  What
prevents it from toggling in this scenario?

If I just run the above loop, and during its run quickly press and
release CapsLock, then type some letter key, then press and release
CapsLock again, I see an upper-case letter inserted after the loop
finishes.  Which means Emacs at least by default does pay attention to
CapsLock state even if it is busy with some calculation in its Lisp
thread.  Why should that behave differently with Mahou installed?

> I was wrong about Emacs 25 not suffering from this problem. I could 
> reproduce it there too.

So this is unlikely to be related to the low-level keyboard hook we
install on Windows since Emacs 26.

Thanks.