Avoid concorrency problems handling mouse events