Left mouse click inverted when refocusing window

I’m testing my multiplayer game with a dedicated server and two clients. When using Alt+Tab to switch between clients, everything works fine. But if I use something, for example windows key and try to refocus a client with left mouse click, my gun keeps firing as if i was holding left mouse button, which i am not. holding the left mouse button stops the gun from firing, as if the left mouse button is not pressed.

How do i keep this from happening when switching between anything and a client?