Add event handling and FPS limiter.

This event handler deals with closing the window, reshapes, and window manager
induced redraws.