How to avoid borderless window losing focus?

Solution 1:

This happened to me too when the windows mouse sensitivity was set to 100%, the problem was solved by lowering it to 50%.

Go to Mouse & touchpad settings select Additional mouse options then select Pointer Options and under Motion you slide it down to half or even lower.