Moved the mouse handling code of tools to their respective classes.

Doesn't seem to have introduced any regressions.