How can I fix this problem?
This is happening because you are forwarding the X session over ssh. Make sure you have:
ForwardX11Trusted yes
in
~/.ssh/config
and
/etc/ssh_config