emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] On the nasty "ghost key" problem on NS


From: Kai Ma
Subject: [PATCH] On the nasty "ghost key" problem on NS
Date: Fri, 4 Nov 2022 02:07:39 +0800

Hi all,

Attached is a one-liner patch to the “ghost key” problem on NS. (The name is 
made up by me.) I didn’t have luck finding a bug report (but it did happen to 
many to-be-liberated Mac users [1-3]), so I decided to directly send it here.

On certain occasions (*), the key event buffer is not cleared to be empty even 
if the events have been processed. This results in a nasty problem: when you 
press a key, say “y”, a key that is pressed earlier will be prepended to the 
current key. There’s no way to reset the event buffer.

This problem is highly unpredictable, making it very hard to reproduce. A 
probably quicker way: hack Emacs’ C codebase with corfu-auto and citre-mode.

(*) The root cause is still not clear to me. It’s observed that sometimes, the 
[interpretKeyEvents] call seems not to return. (Blocked inside Cocoa?) And the 
supposedly matched “remove” is never called. Now “nsEvArray” is left with an 
earlier keyDown event, and since “nsEvArray” is static, you have the problem as 
described above. I guess it may be some Cocoa internal changes that caused this.

This patch is just a workaround, but it improves the current user experience a 
bit.

Regards
Kai

[1] https://emacs-china.org/t/emacs-rime-e/20286
[2] https://emacs-china.org/t/emacs/15430
[3] https://emacs-china.org/t/topic/13207

Attachment: trace.org
Description: Binary data

Attachment: fix-ghost-key.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]