My issue is slightly different.
I have the mouse cursor being activated when I hold down the right mouse button, and being hidden again when I let go.
When I let go, the game window loses focus, and I have to click on it to regain mouselook.
If I use a key instead of a mouse button for this action, it works as expected.
I’ve worked around the problem by drawing the mouse cursor manually as part of the HUD, which also has the added advantage of allowing custom cursor art. The movement is not as smooth as a real cursor, though.