Could you, with m-a-w 1.0 and f-f-m t and focus follows mouse in the
window manager confirm that the following DTRT: You have two frames
A and B. A has two windows 1 and 2, where 1 is active and has the
mouse cursor in it. Move the mouse to frame B to select it. Now move
the mouse to window 2 on frame A. Does it get selected?
Yes.
Before, Emacs consumed 99% CPU here because it got trapped in the
for (;;) loop of kbd_buffer_get_event with an unread select-window
event (you should be able to reproduce this with the scenario above
and without my patch applied).
Yes, I could reproduce that (but not 100% of the time).