While playing Civilization 2, I noticed that Wine crashes if I click menu bar twice while the game is thinking.
The reason for this is that raw hardware messages get processed before menu event loop starts. Raw event processing turns raw events into cooked events and because menu event loop has not started yet, game window is not capturing events and thus clicks on menu bar are turned into nonclient messages. These cooked messages are put back into message queue. When menu event loop starts, it receives the second nonclient button press event and passes it to DispatchMessage. Default window procedure creates a new menu event loop and since the nonclient message was still in the event queue (it would have been removed if DispatchMessage had returned), we get a nice stack overflow.
The real problem is not in menu event loop but in the fact that Wine event handling forgets that we can't determine whether a mouse event is nonclient event or not unless we have already called window procedure for all previous mouse events. This is because one of those calls might have for example captured mouse input after which we no longer report nonclient events.
Since event handling is quite complicated and this flaw looks more like a design error than coding bug, I would like to get some discussion about what should be done to fix this problem.