https://bugs.winehq.org/show_bug.cgi?id=48121
--- Comment #12 from RĂ©mi Bernon rbernon@codeweavers.com --- Well sure it's old but it's also been there for a while, not breaking other apps, and probably serves a purpose. I personally don't clearly remember, and perhaps nobody does, but that doesn't mean the code is useless.
Maybe Windows doesn't let the application decide if it should be activated or not when Alt-Tab is used, but maybe it does when clicking on it. The code covers the former too, maybe incorrectly, but the latter may be important to support. Also, I don't know if it's possible, but maybe it is possible for some windows to not appear in the Alt-Tab list, and so only the former case applies for them.
Also FWIW, the WM_TAKE_FOCUS X11 message is only used to conditionally give focus with this check. If the check is removed, then we can remove all WM_TAKE_FOCUS related code altogether, which is essentially the same as using UseTakeFocus=No. Using that option should be doing exactly the same thing as removing the check.
UseTakeFocus makes Unity not lose focus in the first place, so is not a perfect solution, but does make most games playable.
Then this may require some investigation, UseTakeFocus=No should not change the focus loss behavior, only the focus gain on Wine windows.