Better handling of switching between touch and mouse events