Implement mouse support.
Also improve thread synchronization with regard to video.