Subject: bug#73559: [PATCH] fix NS build focus-in event processing

From: Daniel Colascione <[email-masked]>
Date: Mon, 30 Sep 2024 10:50:31 -0700

On September 30, 2024 10:40:57 AM PDT, Eli Zaretskii <[email-masked]> wrote:
>> Date: Mon, 30 Sep 2024 10:05:09 -0700
>> From: Daniel Colascione <[email-masked]>
>> CC: [email-masked], [email-masked]
>> 
>> It's not that the NS pselect waits too long. It's that it doesn't know to wake up. The focus event is delivered to Emacs by NS as a callback. Unless that callback, one way or another, takes some action to wake up the event loop, nothing gets processed. On Windows, we drain the event queue as a side effect of the message pump, whereas on NS there doesn't seem to be a separate pump that works this way -- just a callback.
>
>What about making pselect wait on one more descriptor, to which the
>callback could then write?

That's the moral equivalent of what my patch does. My patch just uses the existing machinery for waking the main thread instead of adding a new FD.