Fixed starvation problem that could occur when previewing at a high frame rate.

The previewer uses a lot of CPU time to scale the image, and as a result the lock in X11Input would be held almost all the time. This blocks the GUI thread when it tries to read the frame counter.

With this patch, the previewer doesn't hold the lock anymore while scaling, and X11Input doesn't hold the lock while pushing out a frame. The frame counter is now a separate atomic variable.