http://bugs.winehq.org/show_bug.cgi?id=22532
--- Comment #5 from Vincent Povirk madewokherd@gmail.com 2010-05-03 15:14:42 --- I think I understand what's going on. Most of what follows is based on logs, but I can only guess at the motivations of Kwin.
In terms of window focus, the process looks like this: 1. Lemmix creates, shows, and focuses its "Parent Window" (my own made up name for it). This is a visible window, but it does not seem capable of any user interaction. 2. Lemmix _disables_ its Parent Window. 3. Lemmix creates, shows, and focuses a "Menu Window", which shows the menu. (Somehow during this process, we get a take focus message for the Parent Window, and we respond by focusing the the Menu Window.) 4. User presses F1. 5. Lemmix hides its "Menu Window". 6. Lemmix enables its "Parent Window". 7. Lemmix focuses the "Parent Window" and destroys the "Menu Window". 8. Lemmix disables the "Parent Window". 9. Lemmix creates, shows, and focuses the "Game Window".
Somehow, at step 9, the "Game Window" doesn't end up with the focus. The "Parent Window" is on top, but it isn't focused either. Instead, whatever was open originally now has the focus.
Now, the important difference between Locally Active (what Wine used before) and Globally Active (what it uses now) is in step 2. A disabled window cannot have the focus. With the Locally Active model, the window manager will insist on focusing it for us anyway. With the Globally Active model, however, the window manager only asks the window to "take focus", and the window will refuse in this case.
However, disabling the window doesn't mean we give up the focus. On Windows it would, but X doesn't really provide a way to do that. Instead, we simulate giving up the focus by ignoring keystrokes from then on, as I believe the ICCCM recommends.
So after step 2, the Parent Window still has the focus, and there's a smooth transition from Parent to Menu. They both belong to the same program, and thus Kwin is happy.
The problem comes when Lemmix hides the Menu Window (step 5). Naturally, a window loses focus when it is hidden, and the window manager has to focus something else. So Kwin tries to focus the "Parent Window". The Parent Window is disabled at this point, so it refuses to accept the focus (remember it can do that now, and it couldn't before). So instead, KWin focuses the next thing in the stacking order, which belongs to some other app.
Now, when we get to step 9 and we try to focus the Game Window, some other app's window has the focus. So we're asking for a transition from that other app to Lemmix. Kwin is not happy.