When keyboard focus shifts from an X window to a Windows 10 window, the X window does not get told about the defocus until focus shifts to another X window.
Simple way to recreate:
When the emacs window loses focus, the cursor is supposed to turn hollow. When it loses focus to the xterm window, everything is fine. When it loses focus to the browser window, however, the cursor continues to show solid. If you then click on the xterm, the emacs cursor goes hollow.
The situation is a bit complicated by the fact that if you shift focus from the xterm to the browser the xterm's cursor does go hollow.
But he fact that the emacs window is told about the focus moving from the browser to the xterm points strongly at the xserver to me. Whatever action the server is taking on defocus ought to have been done when the emacs window lost focus.
I am having the same issue.
I've stumbled across the same problem with IntelliJ IDEA, and other java apps.
I believe the problem is caused by applications facilitating what Java calls a "Focus Proxy" window.
Both IntellIiJ and Emacs-gtk windows each have two children, one with the actual dimensions of the application, and one with geometry "1x1+-1+-1". In java apps, this latter window is called "FocusProxy".
According to 'xdotool getwindowfocus', the focus is on the parent window. Perhaps xvcsrv checks against the content window, which does not have the focus (its parent has), and thus does not change the focus to the root window on deactivation?
If you can point me in the right direction where to look for in the source code, I would be more than happy to try and provide a pull request.
Last edit: Bernhard Frauendienst 2021-02-05
I'm having the same issue.
I see the same behavior. I work with PyCharm (starting from WSL2 env). When I switch to another windows application, PyCharm does not understand that the application lost focus. Many bad things happens because of that:
Any ideas how to fix it?
Upstream ticket - https://gitlab.freedesktop.org/xorg/xserver/-/issues/1215
Fixed in commit 908ae868dd5dfde80509918683919e6c44c0f1c6
Confirm it's fixed in the 1.20.14 version. Thank you!
I can also confirm - it works in 1.20.14. The newest version is already available from https://sourceforge.net/projects/vcxsrv/files/latest/download
(De-)focus events are fired correctly on window switch, causing PyCharm saving and loading file correctly.
I can confirm that 1.20.14 only partially fixes the issue. With the latest update, when a window is minimized then mousemove events are no longer recorded in the window, but I am still getting them when a Windows (non-X) window is selected and on-top of the X-window (that lost focus). Or, have I coded my app incorrectly? How can the app determine that it has lost focus?